Init progetto

This commit is contained in:
Samuele E. Locatelli
2020-05-11 13:55:54 +02:00
commit 9cdaa24096
79 changed files with 437103 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30002.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MHT-Siemens", "MTH-Siemens\MHT-Siemens.csproj", "{958CB938-3860-49D3-8B16-15ED0E9FE2FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{958CB938-3860-49D3-8B16-15ED0E9FE2FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{958CB938-3860-49D3-8B16-15ED0E9FE2FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{958CB938-3860-49D3-8B16-15ED0E9FE2FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{958CB938-3860-49D3-8B16-15ED0E9FE2FB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5526017D-C2F7-42FD-9BB0-7D8ECF5EB82B}
EndGlobalSection
EndGlobal
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<appSettings>
<add key="appName" value="MHT-Proxy"/>
<add key="verbose" value="false"/>
<!--conf file-->
<add key="memConfPath" value="setupData.json"/>
<add key="sampleTimerMs" value="1000"/>
</appSettings>
</configuration>
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{958CB938-3860-49D3-8B16-15ED0E9FE2FB}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>MHT_Siemens</RootNamespace>
<AssemblyName>MHT-Siemens</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>SteamWare.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.0\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="S7.Net, Version=0.4.0.0, Culture=neutral, PublicKeyToken=d5812d469e84c693, processorArchitecture=MSIL">
<HintPath>..\packages\S7netplus.0.4.0\lib\net452\S7.Net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="connParam.cs" />
<Compile Include="dataProxy.cs" />
<Compile Include="memAddress.cs" />
<Compile Include="SiemensProxy.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SiemensProxy.Designer.cs">
<DependentUpon>SiemensProxy.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="utils.cs" />
<Content Include="logs\.placeholder.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\logoSteamware.png" />
<Content Include="Resources\SteamWare.ico" />
<Content Include="SteamWare.ico" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="SiemensProxy.resx">
<DependentUpon>SiemensProxy.cs</DependentUpon>
</EmbeddedResource>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="setup.json" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="logDir" value="${basedir}/logs"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<target xsi:type="File"
name="f_base"
fileName="${logDir}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}"
archiveFileName="${logDir}/${shortdate}.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="60"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
<target xsi:type="File"
name="f_error"
fileName="${logDir}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}${newline}${exception:format=tostring}"
archiveFileName="${logDir}/${shortdate}.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="60"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="*" minlevel="Debug" maxlevel="Warn" final="true" writeTo="f_base" />
<logger name="*" minlevel="Error" writeTo="f_error" />
</rules>
</nlog>
+3627
View File
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MHT_Siemens
{
static class Program
{
/// <summary>
/// Punto di ingresso principale dell'applicazione.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SiemensProxy());
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("MTH-Siemens")]
[assembly: AssemblyDescription("MTH Siemens proxy")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Steamware")]
[assembly: AssemblyProduct("MTH-Siemens")]
[assembly: AssemblyCopyright("Steamware © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("958cb938-3860-49d3-8b16-15ed0e9fe2fb")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+63
View File
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MHT_Siemens.Properties {
using System;
/// <summary>
/// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
/// </summary>
// Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder.
// tramite uno strumento quale ResGen o Visual Studio.
// Per aggiungere o rimuovere un membro, modificare il file con estensione ResX ed eseguire nuovamente ResGen
// con l'opzione /str oppure ricompilare il progetto VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MHT_Siemens.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte le
/// ricerche di risorse eseguite utilizzando questa classe di risorse fortemente tipizzata.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+26
View File
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MHT_Siemens.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
+7
View File
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

+215
View File
@@ -0,0 +1,215 @@
namespace MHT_Siemens
{
partial class SiemensProxy
{
/// <summary>
/// Variabile di progettazione necessaria.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Pulire le risorse in uso.
/// </summary>
/// <param name="disposing">ha valore true se le risorse gestite devono essere eliminate, false in caso contrario.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Codice generato da Progettazione Windows Form
/// <summary>
/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
/// il contenuto del metodo con l'editor di codice.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SiemensProxy));
this.txtCsvPath = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtIP = new System.Windows.Forms.TextBox();
this.txtSlot = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtRack = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.cbCpuType = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.tsslApp = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// txtCsvPath
//
this.txtCsvPath.Location = new System.Drawing.Point(28, 40);
this.txtCsvPath.Name = "txtCsvPath";
this.txtCsvPath.Size = new System.Drawing.Size(172, 20);
this.txtCsvPath.TabIndex = 0;
this.txtCsvPath.Text = "c:\\zz\\prova1.csv";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(25, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 1;
this.label1.Text = "CSV File";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(279, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(42, 13);
this.label2.TabIndex = 2;
this.label2.Text = "IP Addr";
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// txtIP
//
this.txtIP.Location = new System.Drawing.Point(327, 21);
this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(109, 20);
this.txtIP.TabIndex = 3;
this.txtIP.Text = "192.168.0.102";
this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtSlot
//
this.txtSlot.Location = new System.Drawing.Point(496, 47);
this.txtSlot.Margin = new System.Windows.Forms.Padding(2);
this.txtSlot.Name = "txtSlot";
this.txtSlot.Size = new System.Drawing.Size(32, 20);
this.txtSlot.TabIndex = 10;
this.txtSlot.Text = "1";
this.txtSlot.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(462, 49);
this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(25, 13);
this.label5.TabIndex = 8;
this.label5.Text = "Slot";
//
// txtRack
//
this.txtRack.Location = new System.Drawing.Point(496, 21);
this.txtRack.Margin = new System.Windows.Forms.Padding(2);
this.txtRack.Name = "txtRack";
this.txtRack.Size = new System.Drawing.Size(32, 20);
this.txtRack.TabIndex = 11;
this.txtRack.Text = "0";
this.txtRack.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(462, 23);
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(33, 13);
this.label4.TabIndex = 9;
this.label4.Text = "Rack";
//
// cbCpuType
//
this.cbCpuType.FormattingEnabled = true;
this.cbCpuType.Items.AddRange(new object[] {
"S7200",
"S7300",
"S7400",
"S71200",
"S71500"});
this.cbCpuType.Location = new System.Drawing.Point(353, 46);
this.cbCpuType.Margin = new System.Windows.Forms.Padding(2);
this.cbCpuType.Name = "cbCpuType";
this.cbCpuType.Size = new System.Drawing.Size(83, 21);
this.cbCpuType.TabIndex = 6;
this.cbCpuType.Text = "S71500";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(279, 49);
this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 13);
this.label3.TabIndex = 7;
this.label3.Text = "CPU Type";
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsslApp,
this.toolStripProgressBar1});
this.statusStrip1.Location = new System.Drawing.Point(0, 118);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(554, 22);
this.statusStrip1.TabIndex = 12;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripProgressBar1
//
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16);
//
// tsslApp
//
this.tsslApp.Name = "tsslApp";
this.tsslApp.Size = new System.Drawing.Size(16, 17);
this.tsslApp.Text = "...";
//
// SiemensProxy
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(554, 140);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.txtSlot);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtRack);
this.Controls.Add(this.label4);
this.Controls.Add(this.cbCpuType);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtIP);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtCsvPath);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "SiemensProxy";
this.Text = "SiemensProxy";
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtCsvPath;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtIP;
private System.Windows.Forms.TextBox txtSlot;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtRack;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox cbCpuType;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel tsslApp;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
}
}
+236
View File
@@ -0,0 +1,236 @@
using Newtonsoft.Json;
using NLog;
using S7.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MHT_Siemens
{
public partial class SiemensProxy : Form
{
/// <summary>
/// configurazioen principale proxy
/// </summary>
protected dataProxy currDataProxy;
/// <summary>
/// Oggetto PLC da ri-utilizzare...
/// </summary>
protected Plc currPLC;
/// <summary>
/// parametri di connessione
/// </summary>
protected connParam parametri;
/// <summary>
/// oggetto logging
/// </summary>
public static Logger lg;
/// <summary>
/// oggetto uiTimer x gestioen refresh UI
/// </summary>
protected Timer uiTimer = new Timer();
/// <summary>
/// oggetto uiTimer x sampling file testuale
/// </summary>
protected Timer sampleTimer = new Timer();
/// <summary>
/// oggetto uiTimer x verifiche
/// </summary>
protected Timer checkTimer = new Timer();
public SiemensProxy()
{
InitializeComponent();
myInit();
}
private void myInit()
{
lg = LogManager.GetCurrentClassLogger();
tsslApp.Text = $"{utils.CRS("appName")}";
loadPlc();
loadMemConf();
startUiTimer();
startSampleTimer();
startCheckTimer();
}
private void startUiTimer()
{
uiTimer.Interval = 20;
uiTimer.Tick += UiTimer_Tick;
uiTimer.Start();
}
private void UiTimer_Tick(object sender, EventArgs e)
{
toolStripProgressBar1.ProgressBar.Value += 5;
if (toolStripProgressBar1.ProgressBar.Value >= toolStripProgressBar1.ProgressBar.Maximum)
{
toolStripProgressBar1.ProgressBar.Value = 0;
}
}
private void startSampleTimer()
{
int sampleTimerMs = utils.CRI("sampleTimerMs");
sampleTimerMs = sampleTimerMs < 100 ? 100 : sampleTimerMs;
sampleTimer.Interval = sampleTimerMs;
sampleTimer.Tick += SampleTimer_Tick;
sampleTimer.Start();
}
private void SampleTimer_Tick(object sender, EventArgs e)
{
// rileggo il file
// verifico valore...
// loggo!
lg.Info("New Value read...");
// invio a PLA
}
private void startCheckTimer()
{
checkTimer.Interval = sampleTimer.Interval*10;
checkTimer.Tick += CheckTimer_Tick;
checkTimer.Start();
}
private void CheckTimer_Tick(object sender, EventArgs e)
{
// rileggo il file
// verifico valore...
// loggo!
lg.Info("Program Alive control...");
// invio a PLA
}
/// <summary>
/// init PLC
/// </summary>
private void loadPlc()
{
parametri = new connParam()
{
ipAdrr = "127.0.0.1",
tipoCpu = CpuType.S7200,
slot = 0,
rack = 0
};
lg.Info("Refreshing connection...");
try
{
short.TryParse(txtSlot.Text, out parametri.slot);
short.TryParse(txtRack.Text, out parametri.rack);
parametri.tipoCpu = (CpuType)Enum.Parse(typeof(CpuType), cbCpuType.SelectedItem.ToString());
parametri.ipAdrr = txtIP.Text.Trim();
}
catch (Exception exc)
{
lg.Error(exc, "Errore in parse parametri");
}
// ora tento avvio PLC... SE PING OK...
if (testPing() == IPStatus.Success)
{
try
{
currPLC = new Plc(parametri.tipoCpu, parametri.ipAdrr, parametri.rack, parametri.slot);
currPLC.Open();
lg.Info($"PLC opened: CPU {parametri.tipoCpu} | IP: {parametri.ipAdrr} | R/S: {parametri.rack}/{parametri.slot}");
}
catch (Exception exc)
{
lg.Error(exc, "Errore in INIT PLC");
}
}
}
/// <summary>
/// test ping all'indirizzo impostato nei parametri
/// </summary>
/// <returns></returns>
private IPStatus testPing()
{
IPStatus answ = IPStatus.Unknown; ;
IPAddress address;
PingReply reply;
Ping pingSender = new Ping();
address = IPAddress.Loopback;
IPAddress.TryParse(parametri.ipAdrr, out address);
reply = pingSender.Send(address, 100);
answ = reply.Status;
return answ;
}
protected string csvFilePath
{
get
{
return txtCsvPath.Text.Trim();
}
}
protected string setupFile = "setup.json";
/// <summary>
/// Init conf memoria
/// </summary>
protected void loadMemConf()
{
if (File.Exists(setupFile))
{
try
{
StreamReader reader = new StreamReader(setupFile);
string jsonData = reader.ReadToEnd();
if (!string.IsNullOrEmpty(jsonData))
{
currDataProxy = JsonConvert.DeserializeObject<dataProxy>(jsonData);
}
}
catch
{
currDataProxy = null;
}
}
// se non esistesse creo un nuovo file default
if (currDataProxy == null)
{
dataConf newParam = new dataConf()
{
Column = "Valore assoluto",
Index = 8,
MemConf = "DB701.DBD142",
DataType = "real"
};
Dictionary<string, dataConf> paramList = new Dictionary<string, dataConf>();
paramList.Add(newParam.MemConf, newParam);
// creo nuovo obj...
currDataProxy = new dataProxy()
{
parametersList = paramList
};
// salvo!
string json = JsonConvert.SerializeObject(currDataProxy);
//write string to file
File.WriteAllText(setupFile, json);
}
}
private void label2_Click(object sender, EventArgs e)
{
}
}
}
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<appSettings>
<add key="appName" value="MHT-Proxy"/>
<add key="verbose" value="false"/>
<!--conf file-->
<add key="memConfPath" value="setupData.json"/>
<add key="sampleTimerMs" value="1000"/>
</appSettings>
</configuration>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<appSettings>
<add key="appName" value="MHT-Proxy"/>
<add key="verbose" value="false"/>
<!--conf file-->
<add key="memConfPath" value="setupData.json"/>
<add key="sampleTimerMs" value="1000"/>
</appSettings>
</configuration>
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="logDir" value="${basedir}/logs"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<target xsi:type="File"
name="f_base"
fileName="${logDir}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}"
archiveFileName="${logDir}/${shortdate}.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="60"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
<target xsi:type="File"
name="f_error"
fileName="${logDir}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}${newline}${exception:format=tostring}"
archiveFileName="${logDir}/${shortdate}.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="60"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="*" minlevel="Debug" maxlevel="Warn" final="true" writeTo="f_base" />
<logger name="*" minlevel="Error" writeTo="f_error" />
</rules>
</nlog>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1 @@

+1
View File
@@ -0,0 +1 @@
{"parametersList":{"DB701.DBD142":{"Column":"Valore assoluto","Index":8,"MemConf":"DB701.DBD142","DataType":"real"}}}
+18
View File
@@ -0,0 +1,18 @@
using S7.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MHT_Siemens
{
public class connParam
{
public string ipAdrr = "";
public CpuType tipoCpu = CpuType.S7300;
public short slot = 0;
public short rack = 0;
}
}
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MHT_Siemens
{
/// <summary>
/// classe costruzione dataproxy
/// </summary>
public class dataProxy
{
/// <summary>
/// Elenco parametri
/// </summary>
public Dictionary<string, dataConf> parametersList { get; set; } = new Dictionary<string, dataConf>();
}
/// <summary>
/// Configurazione item memoria gestito
/// </summary>
public class dataConf
{
/// <summary>
/// Colonna (intestazione) se non presente indice
/// </summary>
public string Column { get; set; } = "";
/// <summary>
/// Indice colonna (se presente usa questo)
/// </summary>
public int Index { get; set; } = -1;
/// <summary>
/// Area memoria in cui inserire i dati
/// </summary>
public string MemConf { get; set; } = "";
/// <summary>
/// Tipo di dati
/// </summary>
public string DataType { get; set; } = "";
}
}
+1
View File
@@ -0,0 +1 @@

+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MHT_Siemens
{
public class memAddress
{
/// <summary>
/// Indice DB
/// </summary>
public int DbNum = 0;
/// <summary>
/// Tipo Memoria (DBD, DBW...)
/// </summary>
public string tipoMem = "";
/// <summary>
/// Indice partenza memoria (es DBD0 --> 0)
/// </summary>
public int indiceMem = 0;
/// <summary>
/// Inizializza da un formato stringa
/// </summary>
/// <param name="strFormat"></param>
public memAddress(string strFormat)
{
string[] memComp = strFormat.Split('.');
int.TryParse(memComp[0].Replace("DB", ""), out DbNum);
tipoMem = memComp[1].Substring(2, 1);
int.TryParse(memComp[1].Replace("DB", "").Replace(tipoMem, ""), out indiceMem);
}
}
}
@@ -0,0 +1,18 @@
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\NLog.config
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\logs\.placeholder.txt
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\MHT-Siemens.exe.config
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\MHT-Siemens.exe
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\MHT-Siemens.pdb
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\Newtonsoft.Json.dll
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\NLog.dll
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\S7.Net.dll
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\Newtonsoft.Json.xml
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\NLog.xml
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\S7.Net.pdb
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT_Siemens.Properties.Resources.resources
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT_Siemens.SiemensProxy.resources
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT-Siemens.csproj.GenerateResource.cache
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT-Siemens.csproj.CoreCompileInputs.cache
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT-Siemens.csproj.CopyComplete
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT-Siemens.exe
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MHT-Siemens.pdb
@@ -0,0 +1,19 @@
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\NLog.config
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\MTH-Siemens.exe.config
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\MTH-Siemens.exe
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\MTH-Siemens.pdb
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\NLog.dll
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\S7.Net.dll
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\NLog.xml
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\S7.Net.pdb
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH-Siemens.csprojAssemblyReference.cache
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH_Siemens.Properties.Resources.resources
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH-Siemens.csproj.GenerateResource.cache
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH-Siemens.csproj.CoreCompileInputs.cache
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH-Siemens.csproj.CopyComplete
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH-Siemens.exe
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH-Siemens.pdb
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\Newtonsoft.Json.dll
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\Newtonsoft.Json.xml
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\obj\Debug\MTH_Siemens.SiemensProxy.resources
C:\Users\samuele.steamw\Documents\VisualStudioProject\MTH-Siemens\MTH-Siemens\bin\Debug\logs\.placeholder.txt
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net462" />
<package id="NLog" version="4.7.0" targetFramework="net462" />
<package id="NLog.Config" version="4.7.0" targetFramework="net462" />
<package id="NLog.Schema" version="4.7.0" targetFramework="net462" />
<package id="S7netplus" version="0.4.0" targetFramework="net462" />
</packages>
+10
View File
@@ -0,0 +1,10 @@
{
"parametersList": {
"DB701.DBD142": {
"Column": "Valore assoluto",
"Index": 8,
"MemConf": "DB701.DBD142",
"DataType": "real"
}
}
}
+265
View File
@@ -0,0 +1,265 @@
using NLog;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MHT_Siemens
{
public class utils
{
/// <summary>
/// wrapper di log
/// </summary>
public static Logger lg;
/// <summary>
/// folder archiviazione dati configurazione (DATA\CONF)
/// </summary>
public static string confDir
{
get
{
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath"));
}
}
/// <summary>
/// legge conf in formato char
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static char CRC(string key)
{
char answ = '-';
try
{
answ = ConfigurationManager.AppSettings[key].ToCharArray()[0];
}
catch
{ }
return answ;
}
/// <summary>
/// legge conf in formato stringa
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string CRS(string key)
{
string answ = "";
try
{
answ = ConfigurationManager.AppSettings[key].ToString();
}
catch
{ }
return answ;
}
/// <summary>
/// legge conf in formato INT
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static Int32 CRI(string key)
{
int answ = 0;
try
{
answ = Convert.ToInt32(CRS(key));
}
catch
{ }
return answ;
}
/// <summary>
/// legge conf in formato BOOLean
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static bool CRB(string key)
{
bool answ = false;
try
{
answ = Convert.ToBoolean(CRS(key));
}
catch
{ }
return answ;
}
/// <summary>
/// Decodifica file allarme
/// </summary>
/// <param name="linea"></param>
/// <param name="separator"></param>
/// <param name="memPre">tipo memoria (R/D/...)</param>
/// <param name="baseAddr">indirizzo di partenza memoria</param>
/// <param name="memSize">dimensione singolo slot in byte</param>
/// <returns></returns>
protected static otherData decodeOtherData(string linea, char separator, string memPre, int baseAddr, int memSize)
{
string[] valori = linea.Split(separator);
int shift = 0;
try
{
shift = Convert.ToInt32(valori[0]) - 1;
}
catch
{ }
string memAddr = string.Format("{0}{1}", memPre, baseAddr + shift * memSize);
return new otherData(valori[0], memAddr, valori[1].Trim(), valori[2].Trim());
}
/// <summary>
/// Decodifica file MAP (caso ESA/IOT)
/// </summary>
/// <param name="linea"></param>
/// <param name="separator"></param>
/// <param name="ByteNum">indirizzo Byte: indirizzo di partenza memoria</param>
/// <param name="memSize">dimensione singolo slot in byte</param>
/// <param name="BitNum">indirizzo bit: numero riga x calcolo indice bit</param>
/// <returns></returns>
protected static otherData decodeBitData(string linea, char separator, int ByteNum, int memSize, int BitNum)
{
string[] valori = linea.Split(separator);
int shift = 0;
try
{
shift = Convert.ToInt32(valori[0]) - 1;
}
catch
{ }
int resto = 0;
Math.DivRem(BitNum, 8, out resto);
string memAddr = string.Format("{0}.{1}", ByteNum + shift * memSize, resto);
return new otherData(valori[0], memAddr, valori[1].Trim(), valori[2].Trim());
}
/// <summary>
/// Decodifica file MAP (caso FANUC/OSAI/...)
/// </summary>
/// <param name="linea"></param>
/// <param name="separator"></param>
/// <param name="memPre">tipo memoria (R/D/...)</param>
/// <param name="baseAddr">indirizzo Byte: indirizzo di partenza memoria</param>
/// <param name="memSize">dimensione singolo slot in byte</param>
/// <param name="numRiga">indirizzo bit: numero riga x calcolo indice bit</param>
/// <returns></returns>
protected static otherData decodeBitData(string linea, char separator, string memPre, int baseAddr, int memSize, int numRiga)
{
string[] valori = linea.Split(separator);
int shift = 0;
try
{
shift = (Convert.ToInt32(valori[0]) - 1) / (8 * memSize);
}
catch
{ }
int resto = 0;
Math.DivRem(numRiga, 8 * memSize, out resto);
string memAddr = string.Format("{0}{1}.{2}", memPre, baseAddr + shift, resto);
return new otherData(valori[0], memAddr, valori[1].Trim(), valori[2].Trim());
}
/// <summary>
/// Legge il file di conf di una MAP di informazioni da gestire con lettura set memoria
/// </summary>
/// <param name="vettoreConf">nome vettore memoria</param>
/// <param name="nomeFile">file origine</param>
/// <param name="memSize">dimensione (in byte) della memoria</param>
/// <param name="numVett">dimensione (in byte) della memoria</param>
public static void loadConfFile(ref otherData[] vettoreConf, string nomeFile, int memSize, ref int numVett)
{
otherData lastData = new otherData();
int totRighe = 0;
string linea;
totRighe = File.ReadLines(nomeFile).Count();
// creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
vettoreConf = new otherData[File.ReadLines(nomeFile).Count()];
// carica da file...
StreamReader file = new StreamReader(nomeFile);
// leggo 1 linea alla volta...
int numRiga = 0;
int bitNum = 0;
int byteNum = 0;
while ((linea = file.ReadLine()) != null)
{
// SE non è un commento...
if (linea.Substring(0, 1) != "#")
{
// se finisce per BIT allora processo bit-a-bit...
if (linea.EndsWith("BOOL"))
{
try
{
string[] memIdx = linea.Split(utils.CRC("charSep"))[0].Split('.');
// calcolo bit e byte number...
int.TryParse(memIdx[0], out byteNum);
if (memIdx.Length > 1)
{
int.TryParse(memIdx[1], out bitNum);
}
else
{
bitNum = 0;
}
}
catch
{
byteNum = 0;
bitNum = 0;
}
lastData = decodeBitData(linea, utils.CRC("charSep"), byteNum, 1, bitNum);
vettoreConf[numRiga] = lastData;
}
else
{
lastData = decodeOtherData(linea, utils.CRC("charSep"), "", 1, memSize);
vettoreConf[numRiga] = lastData;
}
numRiga++;
}
}
// salvo lunghezza file...
try
{
numVett = Convert.ToInt32(lastData.memAddr) + 1;
}
catch
{
numVett = numRiga + 1;
}
// chiudo file
file.Close();
// ora trimmo vettore al solo numero VERO dei valori caricati...
Array.Resize<otherData>(ref vettoreConf, numRiga);
if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili per file {1}", numRiga, nomeFile));
}
}
/// <summary>
/// Dato generico (per decodifica)
/// </summary>
public class otherData
{
public string codNum;
public string memAddr;
public string varName;
public string dataType;
public otherData()
{
codNum = "";
memAddr = "";
varName = "";
dataType = "";
}
public otherData(string _codNum, string _memAddr, string _varName, string _dataType)
{
codNum = _codNum;
memAddr = _memAddr;
varName = _varName;
dataType = _dataType;
}
}
}
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
</rules>
</nlog>
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
</rules>
</nlog>
+12
View File
@@ -0,0 +1,12 @@
param($installPath, $toolsPath, $package, $project)
$configItem = $project.ProjectItems.Item("NLog.config")
# set 'Copy To Output Directory' to 'Copy if newer'
$copyToOutput = $configItem.Properties.Item("CopyToOutputDirectory")
$copyToOutput.Value = 2
# set 'Build Action' to 'Content'
$buildAction = $configItem.Properties.Item("BuildAction")
$buildAction.Value = 2
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2007 James Newton-King
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.
Binary file not shown.