Start release from MTH Export...

This commit is contained in:
Samuele E. Locatelli
2020-07-02 10:06:04 +02:00
parent f94d8cf554
commit da5f28926b
27 changed files with 10283 additions and 0 deletions
+329
View File
@@ -0,0 +1,329 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# ---> C Sharp
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/
# mstest test results
TestResults
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.log
*.vspscc
*.vssscc
.builds
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish
# Publish Web Output
*.Publish.xml
# NuGet Packages Directory
packages
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
[Bb]in
[Oo]bj
sql
TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
+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}") = "IOB-WIN-FILE-EXP", "IOB-WIN-FILE-EXP\IOB-WIN-FILE-EXP.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
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</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>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib;libs"/>
</assemblyBinding>
</runtime>
</configuration>
+129
View File
@@ -0,0 +1,129 @@
<?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.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</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=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.6.0\lib\net40-client\NLog.dll</HintPath>
</Reference>
<Reference Include="S7.Net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d5812d469e84c693, processorArchitecture=MSIL">
<HintPath>..\packages\S7netplus.0.1.9\lib\net40\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">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<ItemGroup>
<MoveToLibFolder Include="$(OutputPath)*.dll ; $(OutputPath)*.pdb ; $(OutputPath)*.xml" />
</ItemGroup>
<Move SourceFiles="@(MoveToLibFolder)" DestinationFolder="$(OutputPath)lib" OverwriteReadOnlyFiles="true" />
</Target>
</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>
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());
}
}
}
@@ -0,0 +1,35 @@
using System.Reflection;
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.1.2005.28")]
[assembly: AssemblyFileVersion("1.1.2005.28")]
+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;
}
}
}
}
@@ -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

+235
View File
@@ -0,0 +1,235 @@
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.label3 = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.tsslApp = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.txtCpuType = new System.Windows.Forms.TextBox();
this.txtLog = new System.Windows.Forms.TextBox();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// txtCsvPath
//
this.txtCsvPath.Enabled = false;
this.txtCsvPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
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";
//
// txtIP
//
this.txtIP.Enabled = false;
this.txtIP.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtIP.Location = new System.Drawing.Point(340, 21);
this.txtIP.Name = "txtIP";
this.txtIP.Size = new System.Drawing.Size(106, 20);
this.txtIP.TabIndex = 3;
this.txtIP.Text = "192.168.0.102";
this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtSlot
//
this.txtSlot.Enabled = false;
this.txtSlot.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtSlot.Location = new System.Drawing.Point(499, 47);
this.txtSlot.Margin = new System.Windows.Forms.Padding(2);
this.txtSlot.Name = "txtSlot";
this.txtSlot.Size = new System.Drawing.Size(29, 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.Enabled = false;
this.txtRack.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtRack.Location = new System.Drawing.Point(499, 21);
this.txtRack.Margin = new System.Windows.Forms.Padding(2);
this.txtRack.Name = "txtRack";
this.txtRack.Size = new System.Drawing.Size(29, 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";
//
// 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, 236);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(555, 22);
this.statusStrip1.TabIndex = 12;
this.statusStrip1.Text = "statusStrip1";
//
// tsslApp
//
this.tsslApp.Name = "tsslApp";
this.tsslApp.Size = new System.Drawing.Size(16, 17);
this.tsslApp.Text = "...";
//
// toolStripProgressBar1
//
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16);
//
// txtCpuType
//
this.txtCpuType.Enabled = false;
this.txtCpuType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCpuType.Location = new System.Drawing.Point(340, 47);
this.txtCpuType.Name = "txtCpuType";
this.txtCpuType.Size = new System.Drawing.Size(106, 20);
this.txtCpuType.TabIndex = 13;
this.txtCpuType.Text = "S71200";
this.txtCpuType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtLog
//
this.txtLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtLog.BackColor = System.Drawing.Color.Black;
this.txtLog.Enabled = false;
this.txtLog.ForeColor = System.Drawing.SystemColors.MenuHighlight;
this.txtLog.Location = new System.Drawing.Point(13, 82);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.Size = new System.Drawing.Size(530, 151);
this.txtLog.TabIndex = 14;
this.txtLog.Text = "...";
//
// SiemensProxy
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(555, 258);
this.Controls.Add(this.txtLog);
this.Controls.Add(this.txtCpuType);
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.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.Label label3;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel tsslApp;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
private System.Windows.Forms.TextBox txtCpuType;
private System.Windows.Forms.TextBox txtLog;
}
}
+511
View File
@@ -0,0 +1,511 @@
using Newtonsoft.Json;
using NLog;
using S7.Net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows.Forms;
namespace MHT_Siemens
{
public partial class SiemensProxy : Form
{
#region oggetti di base
/// <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 gestione 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();
/// <summary>
/// Contatore per decidere quando loggare la lettura del file
/// </summary>
protected int loaderLogCounter = 30;
/// <summary>
/// file delle conf attivo
/// </summary>
protected string setupFile = "setup.json";
/// <summary>
/// Ultimi valori registrati da file
/// </summary>
protected Dictionary<string, string> prevValues;
/// <summary>
/// valori correntemente letti dal file
/// </summary>
protected Dictionary<string, string> currValues;
#endregion
#region inizializazione
public SiemensProxy()
{
InitializeComponent();
myInit();
}
private void myInit()
{
lg = LogManager.GetCurrentClassLogger();
tsslApp.Text = $"{utils.CRS("appName")}";
prevValues = new Dictionary<string, string>();
currValues = new Dictionary<string, string>();
loadMemConf();
loadPlc();
startUiTimer();
startSampleTimer();
startCheckTimer();
}
private void startUiTimer()
{
uiTimer.Interval = 20;
uiTimer.Tick += UiTimer_Tick;
uiTimer.Start();
}
private void startSampleTimer()
{
int sampleTimerMs = utils.CRI("sampleTimerMs");
sampleTimerMs = sampleTimerMs < 100 ? 100 : sampleTimerMs;
sampleTimer.Interval = sampleTimerMs;
sampleTimer.Tick += SampleTimer_Tick;
sampleTimer.Start();
}
private void startCheckTimer()
{
// ogni 5 minuti watchdog
checkTimer.Interval = sampleTimer.Interval * 60;
checkTimer.Tick += CheckTimer_Tick;
checkTimer.Start();
}
/// <summary>
/// init PLC
/// </summary>
private void loadPlc()
{
lgInfo("Refreshing connection...");
parametri = currDataProxy.confPLC;
// ora tento avvio PLC... SE PING OK...
if (testPing() == IPStatus.Success)
{
try
{
lgInfo($"PLC parameters: CPU {parametri.tipoCpu} | IP: {parametri.ipAdrr} | R/S: {parametri.rack}/{parametri.slot}");
currPLC = new Plc(parametri.tipoCpu, parametri.ipAdrr, parametri.rack, parametri.slot);
currPLC.Open();
if (currPLC.IsConnected)
{
lgInfo("PLC Connected!");
}
else
{
lgInfo("Connection error!");
}
}
catch (Exception exc)
{
lgError(exc, "Errore in INIT PLC");
}
}
}
/// <summary>
/// Init conf memoria
/// </summary>
protected void loadMemConf()
{
lgInfo("Starting loadMemConf");
if (File.Exists(setupFile))
{
lgInfo("Setup File found!");
try
{
StreamReader reader = new StreamReader(setupFile);
string jsonData = reader.ReadToEnd();
if (!string.IsNullOrEmpty(jsonData))
{
currDataProxy = JsonConvert.DeserializeObject<dataProxy>(jsonData);
lgInfo("Completed data deserialization");
}
reader.Close();
}
catch
{
currDataProxy = null;
}
}
// se non esistesse creo un nuovo file default
if (currDataProxy == null)
{
lgInfo($"File NOT found: {setupFile} - creating new");
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()
{
csvFilePath = @"c:\zz\prova1.csv",
csvHasHeader = true,
csvSeparator = ';',
confPLC = new connParam()
{
ipAdrr = "192.168.0.102",
tipoCpu = CpuType.S71500,
rack = 0,
slot = 1
},
parametersList = paramList
};
// salvo!
string json = JsonConvert.SerializeObject(currDataProxy);
//write string to file
File.WriteAllText(setupFile, json);
lgInfo($"Setup File saved: {setupFile}");
}
// adesso valorizzo tutti i parametri
txtCsvPath.Text = currDataProxy.csvFilePath;
txtIP.Text = currDataProxy.confPLC.ipAdrr;
txtCpuType.Text = $"{currDataProxy.confPLC.tipoCpu}";
txtRack.Text = $"{currDataProxy.confPLC.rack}";
txtSlot.Text = $"{currDataProxy.confPLC.slot}";
}
#endregion
#region metodi ricorrenti
private void UiTimer_Tick(object sender, EventArgs e)
{
toolStripProgressBar1.ProgressBar.Value++;
if (toolStripProgressBar1.ProgressBar.Value >= toolStripProgressBar1.ProgressBar.Maximum)
{
toolStripProgressBar1.ProgressBar.Value = 0;
}
}
private void CheckTimer_Tick(object sender, EventArgs e)
{
// loggo!
lgInfo("Program Alive control...");
//verifico PLC
if (currPLC.IsConnected)
{
lgInfo("PLC Connected!");
}
else
{
lgInfo("Connection error!");
}
// loggo che COMUNQUE forzo scrittura su PLC!
lgInfo("Forced PLC write");
// invio a PLC
saveToPLC();
}
private void SampleTimer_Tick(object sender, EventArgs e)
{
// rileggo il file
reloadFromFile();
// verifico valore confrontando con i precedenti...
if (dataChanged())
{
// loggo!
lgInfo("Data Change on File");
// invio a PLC
saveToPLC();
}
}
#endregion
#region helper methods
/// <summary>
/// salva i dati sul PLC
/// </summary>
private void saveToPLC()
{
// invio TUTTI i dati al PLC secondo configurazione...
if (testCncConn())
{
// decodifico memoria...
memAddress memoria = null;
double valore = -999;
foreach (var item in currValues)
{
memoria = new memAddress(item.Key);
double.TryParse(item.Value, out valore);
// hard coded REAL!!!
byte[] DB_Byte = new byte[4];
S7.Net.Types.Double.ToByteArray(valore).CopyTo(DB_Byte, 0);
currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte);
// loggo invio al PLC!
lgInfo($"Value sent to PLC: {item.Key} | {valore}");
}
}
}
/// <summary>
/// Effettua comparazioen dati vecchi/nuovi
/// </summary>
/// <returns></returns>
private bool dataChanged()
{
bool answ = false;
// se i 2 vettori sono diversi
if (currValues.Count != prevValues.Count)
{
resetPrevVal();
return true;
}
// verifico ogni singolo valore...
foreach (var item in currValues)
{
// cerco...
if (prevValues.ContainsKey(item.Key))
{
// verifico se diversi --> trovato cambio!
answ = currValues[item.Key] != prevValues[item.Key];
}
else
{
answ = true;
}
// se ho cambiamenti --> esco!
if (answ)
{
// salvo ed esco subito
resetPrevVal();
return true;
}
}
return answ;
}
/// <summary>
/// Refresh oggetto valori precedenti
/// </summary>
private void resetPrevVal()
{
// salvo ed esco subito
prevValues = new Dictionary<string, string>();
foreach (var item in currValues)
{
prevValues.Add(item.Key, item.Value);
}
}
/// <summary>
/// Effettua rilettura da file
/// </summary>
protected void reloadFromFile()
{
if (File.Exists(currDataProxy.csvFilePath))
{
// leggo...
using (StreamReader sr = new StreamReader(currDataProxy.csvFilePath))
{
string currentLine;
//se ha header salto la prima riga...
if (currDataProxy.csvHasHeader)
{
if ((currentLine = sr.ReadLine()) == null)
{
// vuoto: loggo ed esco!
lgError("Errore intestazione vuota!");
return;
}
}
// ora leggo la riga successiva... SE !=null
if ((currentLine = sr.ReadLine()) != null)
{
// splitto riga e cerco valore...
var valori = currentLine.Split(currDataProxy.csvSeparator);
// cerco parametri!
try
{
foreach (var item in currDataProxy.parametersList)
{
// cerco!
if (valori.Count() >= item.Value.Index)
{
upsertValue(item.Key, valori[item.Value.Index]);
}
}
}
catch (Exception exc)
{
lgError($"Eccezione i decodifica riga misura: {Environment.NewLine}{exc}");
}
loaderLogCounter--;
if (loaderLogCounter < 0)
{
// loggo che ho letto file e che contiene una certa riga...
lgInfo($"Verifica periodica riga file, contenuto:{Environment.NewLine}{currentLine}");
loaderLogCounter = 30;
}
}
else
{
// vuoto: loggo ed esco!
lgError("Errore riga vuota!");
return;
}
loaderLogCounter--;
if (loaderLogCounter < 0)
{
// loggo che ho letto file e che contiene una certa riga...
lgInfo("Check periodico file presente OK");
loaderLogCounter = 30;
}
}
}
else
{
lgError($"Errore! file non trovato: {currDataProxy.csvFilePath}");
}
}
protected void upsertValue(string key, string value)
{
// cerco se ci sia... aggiorno!
if (currValues.ContainsKey(key))
{
currValues[key] = value;
}
// altrimenti aggiungo
else
{
currValues.Add(key, value);
}
}
/// <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;
}
/// <summary>
/// Test connessione CNC
/// </summary>
/// <returns></returns>
private bool testCncConn()
{
bool answ = false;
IPStatus pingStatus = testPing();
// se passa il ping faccio il resto...
if (pingStatus != IPStatus.Success)
{
lgError("Errore ping");
}
else
{
if (!currPLC.IsConnected)
{
currPLC.Open();
}
if (!currPLC.IsConnected)
{
lgError("Errore connessione");
}
else
{
answ = true;
}
}
return answ;
}
private void appenRTLog(string contenuto)
{
// se troppe righe trimmo...
string fullLog = limitLine2show($"{contenuto}{Environment.NewLine}{txtLog.Text}");
// update
txtLog.Text = fullLog;
}
/// <summary>
/// Effettua un trim della stringa al numero max di linee da mostrare a video
/// </summary>
/// <param name="newString"></param>
/// <returns></returns>
public string limitLine2show(string newString)
{
if (!string.IsNullOrEmpty(newString))
{
// se num righe superiore a limite trimmo...
if (newString.Split('\n').Length > 50)
{
//int idx = newString.LastIndexOf('\r');
int idx = newString.LastIndexOf(Environment.NewLine);
newString = newString.Substring(0, idx);
}
}
return newString;
}
protected void lgInfo(string contenuto)
{
lg.Info(contenuto);
appenRTLog(contenuto);
}
protected void lgError(string contenuto)
{
lg.Error(contenuto);
appenRTLog(contenuto);
}
protected void lgError(Exception exc, string contenuto)
{
lg.Error(exc, contenuto);
appenRTLog(contenuto);
}
#endregion
}
}
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

+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 rack = 0;
public short slot = 0;
}
}
+58
View File
@@ -0,0 +1,58 @@
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>
/// Nome file da osservare
/// </summary>
public string csvFilePath { get; set; } = "";
/// <summary>
/// Indica se il CSV abbia intestazione
/// </summary>
public bool csvHasHeader { get; set; } = true;
/// <summary>
/// Indica se il CSV abbia intestazione
/// </summary>
public char csvSeparator { get; set; } = ';';
/// <summary>
/// Configurazione PLC
/// </summary>
public connParam confPLC { get; set; }
/// <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);
}
}
}
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net40" />
<package id="NLog" version="4.6.0" targetFramework="net40" />
<package id="NLog.Config" version="4.6.0" targetFramework="net40" />
<package id="NLog.Schema" version="4.6.0" targetFramework="net40" />
<package id="PrettyBin" version="1.1.0" targetFramework="net462" />
<package id="S7netplus" version="0.1.9" targetFramework="net40" />
</packages>
+19
View File
@@ -0,0 +1,19 @@
{
"csvFilePath": "c:\\zz\\prova1.csv",
"csvHasHeader": true,
"csvSeparator": ";",
"confPLC": {
"ipAdrr": "192.168.214.1",
"tipoCpu": "S7300",
"rack": 0,
"slot": 2
},
"parametersList": {
"DB701.DBD142": {
"Column": "Valore assoluto",
"Index": 7,
"MemConf": "DB701.DBD142",
"DataType": "real"
}
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"csvFilePath": "c:\\zz\\prova1.csv",
"csvHasHeader": true,
"csvSeparator": ";",
"confPLC": {
"ipAdrr": "192.168.0.102",
"tipoCpu": "S71500",
"rack": 0,
"slot": 1
},
"parametersList": {
"DB999.DBD32": {
"Column": "Valore assoluto",
"Index": 7,
"MemConf": "DB999.DBD32",
"DataType": "real"
}
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"csvFilePath": "c:\\zz\\prova1.csv",
"csvHasHeader": true,
"csvSeparator": ";",
"confPLC": {
"ipAdrr": "192.168.0.102",
"tipoCpu": "S71500",
"rack": 0,
"slot": 1
},
"parametersList": {
"DB999.DBD32": {
"Column": "Valore assoluto",
"Index": 7,
"MemConf": "DB999.DBD32",
"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;
}
}
}