diff --git a/SiemensS7/Siemens-S7-Test.sln b/SiemensS7/Siemens-S7-Test.sln
new file mode 100644
index 0000000..16c1820
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Siemens-S7-Test", "Siemens-S7-Test\Siemens-S7-Test.csproj", "{A0168CBE-9DA5-4E41-82FF-AFD39C982717}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A0168CBE-9DA5-4E41-82FF-AFD39C982717}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A0168CBE-9DA5-4E41-82FF-AFD39C982717}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A0168CBE-9DA5-4E41-82FF-AFD39C982717}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A0168CBE-9DA5-4E41-82FF-AFD39C982717}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {C43DB985-D122-49F0-AE6E-DADEFFC1AD3D}
+ EndGlobalSection
+EndGlobal
diff --git a/SiemensS7/Siemens-S7-Test/App.config b/SiemensS7/Siemens-S7-Test/App.config
new file mode 100644
index 0000000..8c97693
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/App.config
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SiemensS7/Siemens-S7-Test/BinaryFormatter.cs b/SiemensS7/Siemens-S7-Test/BinaryFormatter.cs
new file mode 100644
index 0000000..1a878e2
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/BinaryFormatter.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Globalization;
+using System.Numerics;
+
+namespace Siemens_S7_Test
+{
+
+ public class BinaryFormatter : IFormatProvider, ICustomFormatter
+ {
+ // IFormatProvider.GetFormat implementation.
+ public object GetFormat(Type formatType)
+ {
+ // Determine whether custom formatting object is requested.
+ if (formatType == typeof(ICustomFormatter))
+ return this;
+ else
+ return null;
+ }
+
+ // Format number in binary (B), octal (O), or hexadecimal (H).
+ public string Format(string format, object arg, IFormatProvider formatProvider)
+ {
+ // Handle format string.
+ int baseNumber;
+ // Handle null or empty format string, string with precision specifier.
+ string thisFmt = String.Empty;
+ // Extract first character of format string (precision specifiers
+ // are not supported).
+ if (!String.IsNullOrEmpty(format))
+ thisFmt = format.Length > 1 ? format.Substring(0, 1) : format;
+
+
+ // Get a byte array representing the numeric value.
+ byte[] bytes;
+ if (arg is sbyte)
+ {
+ string byteString = ((sbyte)arg).ToString("X2");
+ bytes = new byte[1] { Byte.Parse(byteString, System.Globalization.NumberStyles.HexNumber) };
+ }
+ else if (arg is byte)
+ {
+ bytes = new byte[1] { (byte)arg };
+ }
+ else if (arg is short)
+ {
+ bytes = BitConverter.GetBytes((short)arg);
+ }
+ else if (arg is int)
+ {
+ bytes = BitConverter.GetBytes((int)arg);
+ }
+ else if (arg is long)
+ {
+ bytes = BitConverter.GetBytes((long)arg);
+ }
+ else if (arg is ushort)
+ {
+ bytes = BitConverter.GetBytes((ushort)arg);
+ }
+ else if (arg is uint)
+ {
+ bytes = BitConverter.GetBytes((uint)arg);
+ }
+ else if (arg is ulong)
+ {
+ bytes = BitConverter.GetBytes((ulong)arg);
+ }
+ else if (arg is BigInteger)
+ {
+ bytes = ((BigInteger)arg).ToByteArray();
+ }
+ else
+ {
+ try
+ {
+ return HandleOtherFormats(format, arg);
+ }
+ catch (FormatException e)
+ {
+ throw new FormatException(String.Format("The format of '{0}' is invalid.", format), e);
+ }
+ }
+
+ switch (thisFmt.ToUpper())
+ {
+ // Binary formatting.
+ case "B":
+ baseNumber = 2;
+ break;
+ case "O":
+ baseNumber = 8;
+ break;
+ case "H":
+ baseNumber = 16;
+ break;
+ // Handle unsupported format strings.
+ default:
+ try
+ {
+ return HandleOtherFormats(format, arg);
+ }
+ catch (FormatException e)
+ {
+ throw new FormatException(String.Format("The format of '{0}' is invalid.", format), e);
+ }
+ }
+
+ // Return a formatted string.
+ string numericString = String.Empty;
+ for (int ctr = bytes.GetUpperBound(0); ctr >= bytes.GetLowerBound(0); ctr--)
+ {
+ string byteString = Convert.ToString(bytes[ctr], baseNumber);
+ if (baseNumber == 2)
+ byteString = new String('0', 8 - byteString.Length) + byteString;
+ else if (baseNumber == 8)
+ byteString = new String('0', 4 - byteString.Length) + byteString;
+ // Base is 16.
+ else
+ byteString = new String('0', 2 - byteString.Length) + byteString;
+
+ numericString += byteString + " ";
+ }
+ return numericString.Trim();
+ }
+
+ private string HandleOtherFormats(string format, object arg)
+ {
+ if (arg is IFormattable)
+ return ((IFormattable)arg).ToString(format, CultureInfo.CurrentCulture);
+ else if (arg != null)
+ return arg.ToString();
+ else
+ return String.Empty;
+ }
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/DATA/CONF/MMapR.map b/SiemensS7/Siemens-S7-Test/DATA/CONF/MMapR.map
new file mode 100644
index 0000000..d6013e4
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/DATA/CONF/MMapR.map
@@ -0,0 +1,14 @@
+# Commenti con cancelletto, struttura un variabile per riga, tipo chiave|valore (occhio che il separatore è configurato da .cofig come "charSep"); spazi e tabulazioni dovrei trimmarli in acquisizione (qui inseriti per comodità di lettura)
+# PARAMETRI della DB600
+000|P0_ID |WORD
+002|P0_SET_HMI |4BYTE
+006|P0_SET_PLC |4BYTE
+010|P0_VAL_MAX |4BYTE
+014|P0_VAL_MIN |4BYTE
+018|P0_UN_MEAS |WORD
+020|P1_ID |WORD
+022|P1_SET_HMI |4BYTE
+026|P1_SET_PLC |4BYTE
+030|P1_VAL_MAX |4BYTE
+034|P1_VAL_MIN |4BYTE
+038|P1_UN_MEAS |WORD
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/DATA/CONF/MMapW.map b/SiemensS7/Siemens-S7-Test/DATA/CONF/MMapW.map
new file mode 100644
index 0000000..28d1ef3
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/DATA/CONF/MMapW.map
@@ -0,0 +1,14 @@
+# Commenti con cancelletto, struttura un variabile per riga, tipo chiave|valore (occhio che il separatore è configurato da .cofig come "charSep"); spazi e tabulazioni dovrei trimmarli in acquisizione (qui inseriti per comodità di lettura)
+# PARAMETRI della DB600
+000|P0_ID |WORD
+002|P0_SET_HMI |4BYTE
+006|P0_SET_PLC |4BYTE
+010|P0_VAL_MAX |4BYTE
+014|P0_VAL_MIN |4BYTE
+018|P0_UN_MEAS |WORD
+020|P1_ID |WORD
+022|P1_SET_HMI |4BYTE
+026|P1_SET_PLC |4BYTE
+030|P1_VAL_MAX |4BYTE
+034|P1_VAL_MIN |4BYTE
+038|P1_UN_MEAS |WORD
diff --git a/SiemensS7/Siemens-S7-Test/Interfaccia.txt b/SiemensS7/Siemens-S7-Test/Interfaccia.txt
new file mode 100644
index 0000000..e77e296
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Interfaccia.txt
@@ -0,0 +1,53 @@
+Interfaccia con TORRI
+
+DA PLC
+- un set di 8 bit di stato macchina
+ - power on (oppure se vedo spenta...)
+ - RUN (in lavorazione, semaforo verde)
+ - contapezzi
+ - allarme
+ - in manuale
+- un set di 16 byte - 128 allarmi (da confermare)
+ - ogni bit corrisponde ad un allarme, secondo tabella codificata
+- contatori pezzi
+ - num pz totali
+ - TempoCiclo ULTIMO pezzo
+ - bit pezzo buono
+ - bit pezzo scarto
+ - bit pezzo da riprendere
+- misure
+ - misura H1
+ - misura H2
+- dati macchina
+ - override speed
+ - override feed
+ - giri mandrino pezzo
+ - giri mandrino mola
+- autospegnimento attivo (0=spento, 1 = contapezzi, 2 = fine pallet 1, 3=finepallet 2, 4 = fine pallet 1 & 2)
+- num pezzi a spegnimento (SE condizione 1 con contapezzi)
+- tempo teorico allo spegnimento
+
+- bit conferma lettura stringa
+- bit conferma lettura inizio commessa
+- bit conferma lettura fine commessa
+
+
+VERSO PLC
+bit
+- bit che indica "nuovi dati stringa da leggere"
+- bit inizio commessa
+- bit fuine commessa
+
+stringhe
+- codice commessa
+- codice articolo
+- codice programma
+- codice macchina (x controllo coerenza)
+- dir programma Fissa su macchcina o parametro
+num int
+- quantità lotto
+
+
+
+ATTENZIONE: letture real devono essere tenute arrotondando alla 4° cifra decimale (NON OLTRE CHE INVENTA)
+Avremo 2 DB: 700 scrive PLC, 701 scrive sw esterno
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/NLog.config b/SiemensS7/Siemens-S7-Test/NLog.config
new file mode 100644
index 0000000..7a0f3aa
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/NLog.config
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SiemensS7/Siemens-S7-Test/NLog.xsd b/SiemensS7/Siemens-S7-Test/NLog.xsd
new file mode 100644
index 0000000..2ca3ba8
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/NLog.xsd
@@ -0,0 +1,3627 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Watch config file for changes and reload automatically.
+
+
+
+
+ Print internal NLog messages to the console. Default value is: false
+
+
+
+
+ Print internal NLog messages to the console error output. Default value is: false
+
+
+
+
+ Write internal NLog messages to the specified file.
+
+
+
+
+ Log level threshold for internal log messages. Default value is: Info.
+
+
+
+
+ Global log level threshold for application log messages. Messages below this level won't be logged.
+
+
+
+
+ Throw an exception when there is an internal error. Default value is: false. Not recommend to set to true in production!
+
+
+
+
+ Throw an exception when there is a configuration error. If not set, determined by throwExceptions.
+
+
+
+
+ Gets or sets a value indicating whether Variables should be kept on configuration reload. Default value is: false.
+
+
+
+
+ Write internal NLog messages to the System.Diagnostics.Trace. Default value is: false.
+
+
+
+
+ Write timestamps for internal NLog messages. Default value is: true.
+
+
+
+
+ Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false.
+
+
+
+
+ Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Prefix for targets/layout renderers/filters/conditions loaded from this assembly.
+
+
+
+
+ Load NLog extensions from the specified file (*.dll)
+
+
+
+
+ Load NLog extensions from the specified assembly. Assembly name should be fully qualified.
+
+
+
+
+
+
+
+
+
+ Name of the logger. May include wildcard characters ('*' or '?').
+
+
+
+
+ Comma separated list of levels that this rule matches.
+
+
+
+
+ Minimum level that this rule matches.
+
+
+
+
+ Maximum level that this rule matches.
+
+
+
+
+ Level that this rule matches.
+
+
+
+
+ Comma separated list of target names.
+
+
+
+
+ Ignore further rules if this one matches.
+
+
+
+
+ Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Default action if none of the filters match.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the file to be included. You could use * wildcard. The name is relative to the name of the current config file.
+
+
+
+
+ Ignore any errors in the include file.
+
+
+
+
+
+
+
+ Variable value. Note, the 'value' attribute has precedence over this one.
+
+
+
+
+
+ Variable name.
+
+
+
+
+ Variable value.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Number of log events that should be processed in a batch by the lazy writer thread.
+
+
+
+
+ Whether to use the locking queue, instead of a lock-free concurrent queue The locking queue is less concurrent when many logger threads, but reduces memory allocation
+
+
+
+
+ Limit of full s to write before yielding into Performance is better when writing many small batches, than writing a single large batch
+
+
+
+
+ Action to be taken when the lazy writer thread request queue count exceeds the set limit.
+
+
+
+
+ Limit on the number of requests in the lazy writer thread request queue.
+
+
+
+
+ Time in milliseconds to sleep between batches. (1 or less means trigger on new activity)
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Delay the flush until the LogEvent has been confirmed as written
+
+
+
+
+ Condition expression. Log events who meet this condition will cause a flush on the wrapped target.
+
+
+
+
+ Only flush when LogEvent matches condition. Ignore explicit-flush, config-reload-flush and shutdown-flush
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Number of log events to be buffered.
+
+
+
+
+ Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes.
+
+
+
+
+ Action to take if the buffer overflows.
+
+
+
+
+ Indicates whether to use sliding timeout.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Encoding to be used.
+
+
+
+
+ Instance of that is used to format log messages.
+
+
+
+
+ End of line value if a newline is appended at the end of log message .
+
+
+
+
+ Maximum message size in bytes.
+
+
+
+
+ Indicates whether to append newline at the end of log message.
+
+
+
+
+ Get or set the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP.
+
+
+
+
+ Network address.
+
+
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ The number of seconds a connection will remain idle before the first keep-alive probe is sent
+
+
+
+
+ Maximum queue size.
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Action that should be taken if the will be more connections than .
+
+
+
+
+ Action that should be taken if the message is larger than maxMessageSize.
+
+
+
+
+ Indicates whether to keep connection open whenever possible.
+
+
+
+
+ NDLC item separator.
+
+
+
+
+ Indicates whether to include source info (file name and line number) in the information sent over the network.
+
+
+
+
+ Renderer for log4j:event logger-xml-attribute (Default ${logger})
+
+
+
+
+ Indicates whether to include NLog-specific extensions to log4j schema.
+
+
+
+
+ Indicates whether to include contents of the stack.
+
+
+
+
+ Indicates whether to include stack contents.
+
+
+
+
+ Indicates whether to include dictionary contents.
+
+
+
+
+ Indicates whether to include dictionary contents.
+
+
+
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
+
+
+
+
+ Option to include all properties from the log events
+
+
+
+
+ AppInfo field. By default it's the friendly name of the current AppDomain.
+
+
+
+
+ NDC item separator.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that should be use to calculate the value for the parameter.
+
+
+
+
+ Viewer parameter name.
+
+
+
+
+ Whether an attribute with empty value should be included in the output
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App)
+
+
+
+
+ Enables output using ANSI Color Codes
+
+
+
+
+ The encoding for writing messages to the .
+
+
+
+
+ Indicates whether the error stream (stderr) should be used instead of the output stream (stdout).
+
+
+
+
+ Indicates whether to auto-flush after
+
+
+
+
+ Indicates whether to auto-check if the console has been redirected to file - Disables coloring logic when System.Console.IsOutputRedirected = true
+
+
+
+
+ Indicates whether to use default row highlighting rules.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Condition that must be met in order to set the specified foreground and background color.
+
+
+
+
+ Background color.
+
+
+
+
+ Foreground color.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used.
+
+
+
+
+ Indicates whether to ignore case when comparing texts.
+
+
+
+
+ Regular expression to be matched. You must specify either text or regex.
+
+
+
+
+ Text to be matched. You must specify either text or regex.
+
+
+
+
+ Indicates whether to match whole words only.
+
+
+
+
+ Background color.
+
+
+
+
+ Foreground color.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Indicates whether to auto-flush after
+
+
+
+
+ Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App)
+
+
+
+
+ The encoding for writing messages to the .
+
+
+
+
+ Indicates whether to send the log messages to the standard error instead of the standard output.
+
+
+
+
+ Whether to enable batch writing using char[]-buffers, instead of using
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this.
+
+
+
+
+ Indicates whether to keep the database connection open between the log events.
+
+
+
+
+ Name of the database provider.
+
+
+
+
+ Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string.
+
+
+
+
+ Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string.
+
+
+
+
+ Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string.
+
+
+
+
+ Name of the connection string (as specified in <connectionStrings> configuration section.
+
+
+
+
+ Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase.
+
+
+
+
+ Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string.
+
+
+
+
+ Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used.
+
+
+
+
+ Configures isolated transaction batch writing. If supported by the database, then it will improve insert performance.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+ Text of the SQL command to be run on each log level.
+
+
+
+
+ Type of the SQL command to be run on each log level.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Convert format of the property value
+
+
+
+
+ Culture used for parsing property string-value for type-conversion
+
+
+
+
+ Value to assign on the object-property
+
+
+
+
+ Name for the object-property
+
+
+
+
+ Type of the object-property
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Type of the command.
+
+
+
+
+ Connection string to run the command against. If not provided, connection string from the target is used.
+
+
+
+
+ Indicates whether to ignore failures.
+
+
+
+
+ Command text.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Database parameter name.
+
+
+
+
+ Layout that should be use to calculate the value for the parameter.
+
+
+
+
+ Database parameter DbType.
+
+
+
+
+ Database parameter size.
+
+
+
+
+ Database parameter precision.
+
+
+
+
+ Database parameter scale.
+
+
+
+
+ Type of the parameter.
+
+
+
+
+ Convert format of the database parameter value.
+
+
+
+
+ Culture used for parsing parameter string-value for type-conversion
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Layout that renders event Category.
+
+
+
+
+ Optional entry type. When not set, or when not convertible to then determined by
+
+
+
+
+ Layout that renders event ID.
+
+
+
+
+ Name of the Event Log to write to. This can be System, Application or any user-defined name.
+
+
+
+
+ Name of the machine on which Event Log service is running.
+
+
+
+
+ Maximum Event log size in kilobytes.
+
+
+
+
+ Message length limit to write to the Event Log.
+
+
+
+
+ Value to be used as the event Source.
+
+
+
+
+ Action to take if the message is larger than the option.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Indicates whether to return to the first target after any successful write.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ File encoding.
+
+
+
+
+ Line ending mode.
+
+
+
+
+ Maximum days of archive files that should be kept.
+
+
+
+
+ Indicates whether to compress archive files into the zip archive format.
+
+
+
+
+ Way file archives are numbered.
+
+
+
+
+ Name of the file to be used for an archive.
+
+
+
+
+ Is the an absolute or relative path?
+
+
+
+
+ Indicates whether to automatically archive log files every time the specified time passes.
+
+
+
+
+ Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose:
+
+
+
+
+ Maximum number of archive files that should be kept.
+
+
+
+
+ Indicates whether the footer should be written only when the file is archived.
+
+
+
+
+ Maximum number of log file names that should be stored as existing.
+
+
+
+
+ Indicates whether to delete old log file on startup.
+
+
+
+
+ File attributes (Windows only).
+
+
+
+
+ Indicates whether to create directories if they do not exist.
+
+
+
+
+ Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong.
+
+
+
+
+ Value of the file size threshold to archive old log file on startup.
+
+
+
+
+ Indicates whether to archive old log file on startup.
+
+
+
+
+ Value specifying the date format to use when archiving files.
+
+
+
+
+ Indicates whether to enable log file(s) to be deleted.
+
+
+
+
+ Indicates whether to write BOM (byte order mark) in created files
+
+
+
+
+ Indicates whether to replace file contents on each write instead of appending log message at the end.
+
+
+
+
+ Indicates whether file creation calls should be synchronized by a system global mutex.
+
+
+
+
+ Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation.
+
+
+
+
+ Is the an absolute or relative path?
+
+
+
+
+ Name of the file to write to.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+ Indicates whether concurrent writes to the log file by multiple processes on different network hosts.
+
+
+
+
+ Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity.
+
+
+
+
+ Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger).
+
+
+
+
+ Indicates whether to keep log file open instead of opening and closing it on each logging event.
+
+
+
+
+ Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write
+
+
+
+
+ Indicates whether concurrent writes to the log file by multiple processes on the same host.
+
+
+
+
+ Number of times the write is appended on the file before NLog discards the log message.
+
+
+
+
+ Delay in milliseconds to wait before attempting to write to the file again.
+
+
+
+
+ Log file buffer size in bytes.
+
+
+
+
+ Maximum number of seconds before open files are flushed. If this number is negative or zero the files are not flushed by timer.
+
+
+
+
+ Indicates whether to automatically flush the file buffers after each log message.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Condition expression. Log events who meet this condition will be forwarded to the wrapped target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Windows domain name to change context to.
+
+
+
+
+ Required impersonation level.
+
+
+
+
+ Type of the logon provider.
+
+
+
+
+ Logon Type.
+
+
+
+
+ User account password.
+
+
+
+
+ Indicates whether to revert to the credentials of the process instead of impersonating another user.
+
+
+
+
+ Username to change context to.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Interval in which messages will be written up to the number of messages.
+
+
+
+
+ Maximum allowed number of messages written per .
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Endpoint address.
+
+
+
+
+ Name of the endpoint configuration in WCF configuration file.
+
+
+
+
+ Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply)
+
+
+
+
+ Client ID.
+
+
+
+
+ Indicates whether to include per-event properties in the payload sent to the server.
+
+
+
+
+ Indicates whether to use binary message encoding.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that should be use to calculate the value for the parameter.
+
+
+
+
+ Name of the parameter.
+
+
+
+
+ Type of the parameter.
+
+
+
+
+ Type of the parameter. Obsolete alias for
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Text to be rendered.
+
+
+
+
+ Header.
+
+
+
+
+ Footer.
+
+
+
+
+ Indicates whether NewLine characters in the body should be replaced with tags.
+
+
+
+
+ Priority used for sending mails.
+
+
+
+
+ Encoding to be used for sending e-mail.
+
+
+
+
+ BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+
+
+
+
+ CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+
+
+
+
+ Indicates whether to add new lines between log entries.
+
+
+
+
+ Indicates whether to send message as HTML instead of plain text.
+
+
+
+
+ Sender's email address (e.g. joe@domain.com).
+
+
+
+
+ Mail message body (repeated for each log message send in one mail).
+
+
+
+
+ Mail subject.
+
+
+
+
+ Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+ Indicates the SMTP client timeout.
+
+
+
+
+ SMTP Server to be used for sending.
+
+
+
+
+ SMTP Authentication mode.
+
+
+
+
+ Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic").
+
+
+
+
+ Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic").
+
+
+
+
+ Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server.
+
+
+
+
+ Port number that SMTP Server is listening on.
+
+
+
+
+ Indicates whether the default Settings from System.Net.MailSettings should be used.
+
+
+
+
+ Folder where applications save mail messages to be processed by the local SMTP server.
+
+
+
+
+ Specifies how outgoing email messages will be handled.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Max number of items to have in memory
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Class name.
+
+
+
+
+ Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Encoding to be used.
+
+
+
+
+ End of line value if a newline is appended at the end of log message .
+
+
+
+
+ Maximum message size in bytes.
+
+
+
+
+ Indicates whether to append newline at the end of log message.
+
+
+
+
+ Network address.
+
+
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ The number of seconds a connection will remain idle before the first keep-alive probe is sent
+
+
+
+
+ Indicates whether to keep connection open whenever possible.
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Maximum queue size.
+
+
+
+
+ Action that should be taken if the will be more connections than .
+
+
+
+
+ Action that should be taken if the message is larger than maxMessageSize.
+
+
+
+
+ Get or set the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Encoding to be used.
+
+
+
+
+ Instance of that is used to format log messages.
+
+
+
+
+ End of line value if a newline is appended at the end of log message .
+
+
+
+
+ Maximum message size in bytes.
+
+
+
+
+ Indicates whether to append newline at the end of log message.
+
+
+
+
+ Get or set the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP.
+
+
+
+
+ Network address.
+
+
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ The number of seconds a connection will remain idle before the first keep-alive probe is sent
+
+
+
+
+ Maximum queue size.
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Action that should be taken if the will be more connections than .
+
+
+
+
+ Action that should be taken if the message is larger than maxMessageSize.
+
+
+
+
+ Indicates whether to keep connection open whenever possible.
+
+
+
+
+ NDLC item separator.
+
+
+
+
+ Indicates whether to include source info (file name and line number) in the information sent over the network.
+
+
+
+
+ Renderer for log4j:event logger-xml-attribute (Default ${logger})
+
+
+
+
+ Indicates whether to include NLog-specific extensions to log4j schema.
+
+
+
+
+ Indicates whether to include contents of the stack.
+
+
+
+
+ Indicates whether to include stack contents.
+
+
+
+
+ Indicates whether to include dictionary contents.
+
+
+
+
+ Indicates whether to include dictionary contents.
+
+
+
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
+
+
+
+
+ Option to include all properties from the log events
+
+
+
+
+ AppInfo field. By default it's the friendly name of the current AppDomain.
+
+
+
+
+ NDC item separator.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Indicates whether to perform layout calculation.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Indicates whether performance counter should be automatically created.
+
+
+
+
+ Name of the performance counter category.
+
+
+
+
+ Counter help text.
+
+
+
+
+ Name of the performance counter.
+
+
+
+
+ Performance counter type.
+
+
+
+
+ The value by which to increment the counter.
+
+
+
+
+ Performance counter instance name.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Default filter to be applied when no specific rule matches.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+ Condition to be tested.
+
+
+
+
+ Resulting filter to be applied when the condition matches.
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+ Number of times to repeat each log message.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+ Number of retries that should be attempted on the wrapped target in case of a failure.
+
+
+
+
+ Time to wait between retries in milliseconds.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Layout used to format log messages.
+
+
+
+
+ Forward to (Instead of )
+
+
+
+
+ Always use independent of
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name of the target.
+
+
+
+
+ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit
+
+
+
+
+ Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8.
+
+
+
+
+ Web service method name. Only used with Soap.
+
+
+
+
+ Web service namespace. Only used with Soap.
+
+
+
+
+ Protocol to be used when calling web service.
+
+
+
+
+ Custom proxy address, include port separated by a colon
+
+
+
+
+ Encoding.
+
+
+
+
+ Web service URL.
+
+
+
+
+ Value whether escaping be done according to the old NLog style (Very non-standard)
+
+
+
+
+ Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs)
+
+
+
+
+ Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in parameters)
+
+
+
+
+ Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see and ).
+
+
+
+
+ (optional) root namespace of the XML document, if POST of XML document chosen. (see and ).
+
+
+
+
+ Proxy configuration when calling web service
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Footer layout.
+
+
+
+
+ Header layout.
+
+
+
+
+ Body layout (can be repeated multiple times).
+
+
+
+
+ Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom').
+
+
+
+
+ Column delimiter.
+
+
+
+
+ Quote Character.
+
+
+
+
+ Quoting mode.
+
+
+
+
+ Indicates whether CVS should include header.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout of the column.
+
+
+
+
+ Name of the column.
+
+
+
+
+ Override of Quoting mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Should forward slashes be escaped? If true, / will be converted to \/
+
+
+
+
+ Option to render the empty object value {}
+
+
+
+
+ Option to suppress the extra spaces in the output json
+
+
+
+
+ List of property names to exclude when is true
+
+
+
+
+ Option to include all properties from the log event (as JSON)
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ How far should the JSON serializer follow object references before backing off
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that will be rendered as the attribute's value.
+
+
+
+
+ Name of the attribute.
+
+
+
+
+ Determines whether or not this attribute will be Json encoded.
+
+
+
+
+ Should forward slashes be escaped? If true, / will be converted to \/
+
+
+
+
+ Indicates whether to escape non-ascii characters
+
+
+
+
+ Whether an attribute with empty value should be included in the output
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Footer layout.
+
+
+
+
+ Header layout.
+
+
+
+
+ Body layout (can be repeated multiple times).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Option to include all properties from the log events
+
+
+
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ Indicates whether to include contents of the stack.
+
+
+
+
+ Indicates whether to include contents of the stack.
+
+
+
+
+ Indicates whether to include source info (file name and line number) in the information sent over the network.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout text.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ List of property names to exclude when is true
+
+
+
+
+ Option to include all properties from the log event (as XML)
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ How far should the XML serializer follow object references before backing off
+
+
+
+
+ XML element name to use for rendering IList-collections items
+
+
+
+
+ XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included
+
+
+
+
+ XML element name to use when rendering properties
+
+
+
+
+ XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value
+
+
+
+
+ Name of the root XML element
+
+
+
+
+ Value inside the root XML element
+
+
+
+
+ Whether a ElementValue with empty value should be included in the output
+
+
+
+
+ Auto indent and create new lines
+
+
+
+
+ Determines whether or not this attribute will be Xml encoded.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Layout that will be rendered as the attribute's value.
+
+
+
+
+ Name of the attribute.
+
+
+
+
+ Determines whether or not this attribute will be Xml encoded.
+
+
+
+
+ Whether an attribute with empty value should be included in the output
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Determines whether or not this attribute will be Xml encoded.
+
+
+
+
+ Name of the element
+
+
+
+
+ Value inside the element
+
+
+
+
+ Whether a ElementValue with empty value should be included in the output
+
+
+
+
+ Auto indent and create new lines
+
+
+
+
+ List of property names to exclude when is true
+
+
+
+
+ Option to include all properties from the log event (as XML)
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ Indicates whether to include contents of the dictionary.
+
+
+
+
+ How far should the XML serializer follow object references before backing off
+
+
+
+
+ XML element name to use for rendering IList-collections items
+
+
+
+
+ XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included
+
+
+
+
+ XML element name to use when rendering properties
+
+
+
+
+ XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Condition expression.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+ Substring to be matched.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ String to compare the layout to.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+ Substring to be matched.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ String to compare the layout to.
+
+
+
+
+ Indicates whether to ignore case when comparing strings.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Action to be taken when filter matches.
+
+
+
+
+ Default number of unique filter values to expect, will automatically increase if needed
+
+
+
+
+ Applies the configured action to the initial logevent that starts the timeout period. Used to configure that it should ignore all events until timeout.
+
+
+
+
+ Layout to be used to filter log messages.
+
+
+
+
+ Max number of unique filter values to expect simultaneously
+
+
+
+
+ Max length of filter values, will truncate if above limit
+
+
+
+
+ How long before a filter expires, and logging is accepted again
+
+
+
+
+ Default buffer size for the internal buffers
+
+
+
+
+ Reuse internal buffers, and doesn't have to constantly allocate new buffers
+
+
+
+
+ Append FilterCount to the when an event is no longer filtered
+
+
+
+
+ Insert FilterCount value into when an event is no longer filtered
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/Program.cs b/SiemensS7/Siemens-S7-Test/Program.cs
new file mode 100644
index 0000000..b33b15f
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Siemens_S7_Test
+{
+ static class Program
+ {
+ ///
+ /// Punto di ingresso principale dell'applicazione.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new TestMainForm());
+ }
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/Properties/AssemblyInfo.cs b/SiemensS7/Siemens-S7-Test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3d8e5f2
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Properties/AssemblyInfo.cs
@@ -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("Test-S7")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Test-S7")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[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("a0168cbe-9da5-4e41-82ff-afd39c982717")]
+
+// 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")]
diff --git a/SiemensS7/Siemens-S7-Test/Properties/Resources.Designer.cs b/SiemensS7/Siemens-S7-Test/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..eeae1c8
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Siemens_S7_Test.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [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() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [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("Siemens_S7_Test.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/Properties/Resources.resx b/SiemensS7/Siemens-S7-Test/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/Properties/Settings.Designer.cs b/SiemensS7/Siemens-S7-Test/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..49be6d8
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Siemens_S7_Test.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;
+ }
+ }
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/Properties/Settings.settings b/SiemensS7/Siemens-S7-Test/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/SiemensS7/Siemens-S7-Test/Siemens-S7-Test.csproj b/SiemensS7/Siemens-S7-Test/Siemens-S7-Test.csproj
new file mode 100644
index 0000000..c39a92c
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Siemens-S7-Test.csproj
@@ -0,0 +1,127 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {A0168CBE-9DA5-4E41-82FF-AFD39C982717}
+ WinExe
+ Siemens_S7_Test
+ Siemens-S7-Test
+ v4.6.2
+ 512
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\NLog.4.7.0\lib\net45\NLog.dll
+
+
+ ..\packages\S7netplus.0.4.0\lib\net452\S7.Net.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ TestMainForm.cs
+
+
+
+
+
+
+ TestMainForm.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+ True
+
+
+
+ Always
+
+
+ PreserveNewest
+
+
+ Always
+
+
+ Always
+
+
+ Designer
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+ Always
+
+
+ Always
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/Siemens-S7-Test.csproj.user b/SiemensS7/Siemens-S7-Test/Siemens-S7-Test.csproj.user
new file mode 100644
index 0000000..944ec00
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/Siemens-S7-Test.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ ShowAllFiles
+
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/TestMainForm.Designer.cs b/SiemensS7/Siemens-S7-Test/TestMainForm.Designer.cs
new file mode 100644
index 0000000..0f5ebf0
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/TestMainForm.Designer.cs
@@ -0,0 +1,640 @@
+namespace Siemens_S7_Test
+{
+ partial class TestMainForm
+ {
+ ///
+ /// Variabile di progettazione necessaria.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Pulire le risorse in uso.
+ ///
+ /// ha valore true se le risorse gestite devono essere eliminate, false in caso contrario.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Codice generato da Progettazione Windows Form
+
+ ///
+ /// Metodo necessario per il supporto della finestra di progettazione. Non modificare
+ /// il contenuto del metodo con l'editor di codice.
+ ///
+ private void InitializeComponent()
+ {
+ this.txtIP = new System.Windows.Forms.TextBox();
+ this.lblIP = new System.Windows.Forms.Label();
+ this.cbCpuType = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.txtMemArea = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.txtMemSize = new System.Windows.Forms.TextBox();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.btnReadString = new System.Windows.Forms.Button();
+ this.btnReadDWord = new System.Windows.Forms.Button();
+ this.btnReadWord = new System.Windows.Forms.Button();
+ this.btnReadReal = new System.Windows.Forms.Button();
+ this.btnReadByte = new System.Windows.Forms.Button();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.txtOut = new System.Windows.Forms.TextBox();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.textBox2 = new System.Windows.Forms.TextBox();
+ this.label6 = new System.Windows.Forms.Label();
+ 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.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.tslConn = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
+ this.tslRTime = new System.Windows.Forms.ToolStripStatusLabel();
+ this.groupBox4 = new System.Windows.Forms.GroupBox();
+ this.btnStrWrite = new System.Windows.Forms.Button();
+ this.btnNumWriteB = new System.Windows.Forms.Button();
+ this.btnNumWriteDW = new System.Windows.Forms.Button();
+ this.btnNumWriteW = new System.Windows.Forms.Button();
+ this.txtWriteVal2 = new System.Windows.Forms.TextBox();
+ this.label9 = new System.Windows.Forms.Label();
+ this.txtWriteVal1 = new System.Windows.Forms.TextBox();
+ this.label8 = new System.Windows.Forms.Label();
+ this.txtWriteAddr2 = new System.Windows.Forms.TextBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.txtWriteAddr1 = new System.Windows.Forms.TextBox();
+ this.label7 = new System.Windows.Forms.Label();
+ this.btnReadStruct = new System.Windows.Forms.Button();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.groupBox3.SuspendLayout();
+ this.statusStrip1.SuspendLayout();
+ this.groupBox4.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // txtIP
+ //
+ this.txtIP.Location = new System.Drawing.Point(85, 23);
+ this.txtIP.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtIP.Name = "txtIP";
+ this.txtIP.Size = new System.Drawing.Size(109, 22);
+ this.txtIP.TabIndex = 0;
+ this.txtIP.Text = "192.168.0.102";
+ this.txtIP.TextChanged += new System.EventHandler(this.txtIP_TextChanged);
+ //
+ // lblIP
+ //
+ this.lblIP.AutoSize = true;
+ this.lblIP.Location = new System.Drawing.Point(16, 26);
+ this.lblIP.Name = "lblIP";
+ this.lblIP.Size = new System.Drawing.Size(63, 17);
+ this.lblIP.TabIndex = 1;
+ this.lblIP.Text = "IP ADDR";
+ //
+ // cbCpuType
+ //
+ this.cbCpuType.FormattingEnabled = true;
+ this.cbCpuType.Items.AddRange(new object[] {
+ "S7200",
+ "S7300",
+ "S7400",
+ "S71200",
+ "S71500"});
+ this.cbCpuType.Location = new System.Drawing.Point(85, 62);
+ this.cbCpuType.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.cbCpuType.Name = "cbCpuType";
+ this.cbCpuType.Size = new System.Drawing.Size(109, 24);
+ this.cbCpuType.TabIndex = 2;
+ this.cbCpuType.Text = "S71500";
+ this.cbCpuType.SelectedIndexChanged += new System.EventHandler(this.cbCpuType_SelectedIndexChanged);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(7, 64);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(72, 17);
+ this.label1.TabIndex = 3;
+ this.label1.Text = "CPU Type";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(9, 23);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(80, 17);
+ this.label2.TabIndex = 5;
+ this.label2.Text = "MEM AREA";
+ //
+ // txtMemArea
+ //
+ this.txtMemArea.Location = new System.Drawing.Point(156, 20);
+ this.txtMemArea.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtMemArea.Name = "txtMemArea";
+ this.txtMemArea.Size = new System.Drawing.Size(117, 22);
+ this.txtMemArea.TabIndex = 4;
+ this.txtMemArea.Text = "DB600.DBB0";
+ this.txtMemArea.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.txtMemArea.TextChanged += new System.EventHandler(this.txtMemArea_TextChanged);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(9, 80);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(113, 17);
+ this.label3.TabIndex = 7;
+ this.label3.Text = "MEM SIZE BYTE";
+ //
+ // txtMemSize
+ //
+ this.txtMemSize.Location = new System.Drawing.Point(156, 78);
+ this.txtMemSize.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtMemSize.Name = "txtMemSize";
+ this.txtMemSize.Size = new System.Drawing.Size(39, 22);
+ this.txtMemSize.TabIndex = 6;
+ this.txtMemSize.Text = "2";
+ this.txtMemSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ this.txtMemSize.TextChanged += new System.EventHandler(this.txtMemSize_TextChanged);
+ //
+ // groupBox1
+ //
+ this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.groupBox1.Controls.Add(this.btnReadStruct);
+ this.groupBox1.Controls.Add(this.btnReadString);
+ this.groupBox1.Controls.Add(this.btnReadDWord);
+ this.groupBox1.Controls.Add(this.btnReadWord);
+ this.groupBox1.Controls.Add(this.btnReadReal);
+ this.groupBox1.Controls.Add(this.btnReadByte);
+ this.groupBox1.Controls.Add(this.textBox1);
+ this.groupBox1.Controls.Add(this.txtMemArea);
+ this.groupBox1.Controls.Add(this.txtMemSize);
+ this.groupBox1.Controls.Add(this.label3);
+ this.groupBox1.Controls.Add(this.label2);
+ this.groupBox1.Location = new System.Drawing.Point(468, 12);
+ this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox1.Size = new System.Drawing.Size(387, 105);
+ this.groupBox1.TabIndex = 8;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Memoria: READ param";
+ //
+ // btnReadString
+ //
+ this.btnReadString.Location = new System.Drawing.Point(201, 75);
+ this.btnReadString.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnReadString.Name = "btnReadString";
+ this.btnReadString.Size = new System.Drawing.Size(101, 25);
+ this.btnReadString.TabIndex = 11;
+ this.btnReadString.Text = "R String";
+ this.btnReadString.UseVisualStyleBackColor = true;
+ this.btnReadString.Click += new System.EventHandler(this.btnReadString_Click);
+ //
+ // btnReadDWord
+ //
+ this.btnReadDWord.Location = new System.Drawing.Point(308, 47);
+ this.btnReadDWord.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnReadDWord.Name = "btnReadDWord";
+ this.btnReadDWord.Size = new System.Drawing.Size(72, 25);
+ this.btnReadDWord.TabIndex = 10;
+ this.btnReadDWord.Text = "R DW";
+ this.btnReadDWord.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
+ this.btnReadDWord.UseVisualStyleBackColor = true;
+ this.btnReadDWord.Click += new System.EventHandler(this.btnReadDWord_Click);
+ //
+ // btnReadWord
+ //
+ this.btnReadWord.Location = new System.Drawing.Point(308, 18);
+ this.btnReadWord.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnReadWord.Name = "btnReadWord";
+ this.btnReadWord.Size = new System.Drawing.Size(72, 25);
+ this.btnReadWord.TabIndex = 10;
+ this.btnReadWord.Text = "R W";
+ this.btnReadWord.UseVisualStyleBackColor = true;
+ this.btnReadWord.Click += new System.EventHandler(this.btnReadWord_Click);
+ //
+ // btnReadReal
+ //
+ this.btnReadReal.Location = new System.Drawing.Point(235, 48);
+ this.btnReadReal.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnReadReal.Name = "btnReadReal";
+ this.btnReadReal.Size = new System.Drawing.Size(67, 25);
+ this.btnReadReal.TabIndex = 9;
+ this.btnReadReal.Text = "R REAL";
+ this.btnReadReal.UseVisualStyleBackColor = true;
+ this.btnReadReal.Click += new System.EventHandler(this.btnReadReal_Click);
+ //
+ // btnReadByte
+ //
+ this.btnReadByte.Location = new System.Drawing.Point(156, 47);
+ this.btnReadByte.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnReadByte.Name = "btnReadByte";
+ this.btnReadByte.Size = new System.Drawing.Size(73, 25);
+ this.btnReadByte.TabIndex = 9;
+ this.btnReadByte.Text = "R Byte";
+ this.btnReadByte.UseVisualStyleBackColor = true;
+ this.btnReadByte.Click += new System.EventHandler(this.btnReadByte_Click);
+ //
+ // textBox1
+ //
+ this.textBox1.BackColor = System.Drawing.SystemColors.Menu;
+ this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.textBox1.Location = new System.Drawing.Point(12, 44);
+ this.textBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBox1.Multiline = true;
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(127, 33);
+ this.textBox1.TabIndex = 8;
+ this.textBox1.Text = "Indicare tipo memoria e size del tipo";
+ //
+ // groupBox2
+ //
+ this.groupBox2.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.groupBox2.AutoSize = true;
+ this.groupBox2.Controls.Add(this.txtOut);
+ this.groupBox2.Location = new System.Drawing.Point(12, 190);
+ this.groupBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox2.Size = new System.Drawing.Size(843, 402);
+ this.groupBox2.TabIndex = 9;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Risultati";
+ //
+ // txtOut
+ //
+ this.txtOut.BackColor = System.Drawing.SystemColors.Desktop;
+ this.txtOut.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.txtOut.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.txtOut.ForeColor = System.Drawing.Color.Yellow;
+ this.txtOut.Location = new System.Drawing.Point(3, 17);
+ this.txtOut.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtOut.Multiline = true;
+ this.txtOut.Name = "txtOut";
+ this.txtOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.txtOut.Size = new System.Drawing.Size(837, 383);
+ this.txtOut.TabIndex = 0;
+ this.txtOut.Text = "...";
+ //
+ // groupBox3
+ //
+ this.groupBox3.Controls.Add(this.textBox2);
+ this.groupBox3.Controls.Add(this.label6);
+ this.groupBox3.Controls.Add(this.txtSlot);
+ this.groupBox3.Controls.Add(this.label5);
+ this.groupBox3.Controls.Add(this.txtRack);
+ this.groupBox3.Controls.Add(this.label4);
+ this.groupBox3.Controls.Add(this.cbCpuType);
+ this.groupBox3.Controls.Add(this.txtIP);
+ this.groupBox3.Controls.Add(this.lblIP);
+ this.groupBox3.Controls.Add(this.label1);
+ this.groupBox3.Location = new System.Drawing.Point(12, 12);
+ this.groupBox3.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox3.Size = new System.Drawing.Size(448, 105);
+ this.groupBox3.TabIndex = 10;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "Parametri PLC";
+ //
+ // textBox2
+ //
+ this.textBox2.BackColor = System.Drawing.SystemColors.Menu;
+ this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.textBox2.Location = new System.Drawing.Point(301, 38);
+ this.textBox2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBox2.Multiline = true;
+ this.textBox2.Name = "textBox2";
+ this.textBox2.Size = new System.Drawing.Size(140, 48);
+ this.textBox2.TabIndex = 7;
+ this.textBox2.Text = "S7-1200/S7-1500: 0/1\r\nS7-300/S7-400: 0/2\r\nSlot > 0 se eth ext";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(301, 14);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(114, 17);
+ this.label6.TabIndex = 6;
+ this.label6.Text = "Note Rack / Slot:";
+ //
+ // txtSlot
+ //
+ this.txtSlot.Location = new System.Drawing.Point(253, 62);
+ this.txtSlot.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtSlot.Name = "txtSlot";
+ this.txtSlot.Size = new System.Drawing.Size(41, 22);
+ this.txtSlot.TabIndex = 5;
+ this.txtSlot.Text = "1";
+ this.txtSlot.TextChanged += new System.EventHandler(this.txtSlot_TextChanged);
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(208, 64);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(32, 17);
+ this.label5.TabIndex = 4;
+ this.label5.Text = "Slot";
+ //
+ // txtRack
+ //
+ this.txtRack.Location = new System.Drawing.Point(253, 23);
+ this.txtRack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtRack.Name = "txtRack";
+ this.txtRack.Size = new System.Drawing.Size(41, 22);
+ this.txtRack.TabIndex = 5;
+ this.txtRack.Text = "0";
+ this.txtRack.TextChanged += new System.EventHandler(this.txtRack_TextChanged);
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(208, 26);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(40, 17);
+ this.label4.TabIndex = 4;
+ this.label4.Text = "Rack";
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.tslConn,
+ this.toolStripStatusLabel1,
+ this.toolStripProgressBar1,
+ this.tslRTime});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 596);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 13, 0);
+ this.statusStrip1.Size = new System.Drawing.Size(869, 28);
+ this.statusStrip1.TabIndex = 11;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // tslConn
+ //
+ this.tslConn.Name = "tslConn";
+ this.tslConn.Size = new System.Drawing.Size(72, 22);
+ this.tslConn.Text = "Conn: ND";
+ //
+ // toolStripStatusLabel1
+ //
+ this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
+ this.toolStripStatusLabel1.Size = new System.Drawing.Size(13, 22);
+ this.toolStripStatusLabel1.Text = "|";
+ //
+ // toolStripProgressBar1
+ //
+ this.toolStripProgressBar1.Name = "toolStripProgressBar1";
+ this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 20);
+ //
+ // tslRTime
+ //
+ this.tslRTime.Name = "tslRTime";
+ this.tslRTime.Size = new System.Drawing.Size(37, 22);
+ this.tslRTime.Text = "...ms";
+ //
+ // groupBox4
+ //
+ this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.groupBox4.Controls.Add(this.btnStrWrite);
+ this.groupBox4.Controls.Add(this.btnNumWriteB);
+ this.groupBox4.Controls.Add(this.btnNumWriteDW);
+ this.groupBox4.Controls.Add(this.btnNumWriteW);
+ this.groupBox4.Controls.Add(this.txtWriteVal2);
+ this.groupBox4.Controls.Add(this.label9);
+ this.groupBox4.Controls.Add(this.txtWriteVal1);
+ this.groupBox4.Controls.Add(this.label8);
+ this.groupBox4.Controls.Add(this.txtWriteAddr2);
+ this.groupBox4.Controls.Add(this.label10);
+ this.groupBox4.Controls.Add(this.txtWriteAddr1);
+ this.groupBox4.Controls.Add(this.label7);
+ this.groupBox4.Location = new System.Drawing.Point(12, 117);
+ this.groupBox4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox4.Name = "groupBox4";
+ this.groupBox4.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.groupBox4.Size = new System.Drawing.Size(843, 71);
+ this.groupBox4.TabIndex = 12;
+ this.groupBox4.TabStop = false;
+ this.groupBox4.Text = "Memoria: WRITE param";
+ //
+ // btnStrWrite
+ //
+ this.btnStrWrite.Location = new System.Drawing.Point(799, 25);
+ this.btnStrWrite.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnStrWrite.Name = "btnStrWrite";
+ this.btnStrWrite.Size = new System.Drawing.Size(41, 23);
+ this.btnStrWrite.TabIndex = 10;
+ this.btnStrWrite.Text = "SW";
+ this.btnStrWrite.UseVisualStyleBackColor = true;
+ this.btnStrWrite.Click += new System.EventHandler(this.btnStrWrite_Click);
+ //
+ // btnNumWriteB
+ //
+ this.btnNumWriteB.Location = new System.Drawing.Point(329, 5);
+ this.btnNumWriteB.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnNumWriteB.Name = "btnNumWriteB";
+ this.btnNumWriteB.Size = new System.Drawing.Size(48, 23);
+ this.btnNumWriteB.TabIndex = 10;
+ this.btnNumWriteB.Text = "B";
+ this.btnNumWriteB.UseVisualStyleBackColor = true;
+ this.btnNumWriteB.Click += new System.EventHandler(this.btnNumWriteB_Click);
+ //
+ // btnNumWriteDW
+ //
+ this.btnNumWriteDW.Location = new System.Drawing.Point(329, 44);
+ this.btnNumWriteDW.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnNumWriteDW.Name = "btnNumWriteDW";
+ this.btnNumWriteDW.Size = new System.Drawing.Size(48, 23);
+ this.btnNumWriteDW.TabIndex = 10;
+ this.btnNumWriteDW.Text = "DW";
+ this.btnNumWriteDW.UseVisualStyleBackColor = true;
+ this.btnNumWriteDW.Click += new System.EventHandler(this.btnNumWriteDW_Click);
+ //
+ // btnNumWriteW
+ //
+ this.btnNumWriteW.Location = new System.Drawing.Point(329, 23);
+ this.btnNumWriteW.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnNumWriteW.Name = "btnNumWriteW";
+ this.btnNumWriteW.Size = new System.Drawing.Size(48, 23);
+ this.btnNumWriteW.TabIndex = 10;
+ this.btnNumWriteW.Text = "W";
+ this.btnNumWriteW.UseVisualStyleBackColor = true;
+ this.btnNumWriteW.Click += new System.EventHandler(this.btnNumWriteW_Click);
+ //
+ // txtWriteVal2
+ //
+ this.txtWriteVal2.Location = new System.Drawing.Point(612, 25);
+ this.txtWriteVal2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtWriteVal2.Name = "txtWriteVal2";
+ this.txtWriteVal2.Size = new System.Drawing.Size(187, 22);
+ this.txtWriteVal2.TabIndex = 8;
+ this.txtWriteVal2.Text = "SAMUELEL";
+ this.txtWriteVal2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Location = new System.Drawing.Point(571, 27);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(36, 17);
+ this.label9.TabIndex = 9;
+ this.label9.Text = "STR";
+ //
+ // txtWriteVal1
+ //
+ this.txtWriteVal1.Location = new System.Drawing.Point(237, 25);
+ this.txtWriteVal1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtWriteVal1.Name = "txtWriteVal1";
+ this.txtWriteVal1.Size = new System.Drawing.Size(85, 22);
+ this.txtWriteVal1.TabIndex = 8;
+ this.txtWriteVal1.Text = "987654321";
+ this.txtWriteVal1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(197, 27);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(39, 17);
+ this.label8.TabIndex = 9;
+ this.label8.Text = "NUM";
+ //
+ // txtWriteAddr2
+ //
+ this.txtWriteAddr2.Location = new System.Drawing.Point(448, 25);
+ this.txtWriteAddr2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtWriteAddr2.Name = "txtWriteAddr2";
+ this.txtWriteAddr2.Size = new System.Drawing.Size(116, 22);
+ this.txtWriteAddr2.TabIndex = 6;
+ this.txtWriteAddr2.Text = "DB600.DBB2";
+ this.txtWriteAddr2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ //
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Location = new System.Drawing.Point(389, 27);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(59, 17);
+ this.label10.TabIndex = 7;
+ this.label10.Text = "ADDR 2";
+ //
+ // txtWriteAddr1
+ //
+ this.txtWriteAddr1.Location = new System.Drawing.Point(71, 25);
+ this.txtWriteAddr1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.txtWriteAddr1.Name = "txtWriteAddr1";
+ this.txtWriteAddr1.Size = new System.Drawing.Size(123, 22);
+ this.txtWriteAddr1.TabIndex = 6;
+ this.txtWriteAddr1.Text = "DB600.DBB0";
+ this.txtWriteAddr1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Location = new System.Drawing.Point(5, 27);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(59, 17);
+ this.label7.TabIndex = 7;
+ this.label7.Text = "ADDR 1";
+ //
+ // btnReadStruct
+ //
+ this.btnReadStruct.Location = new System.Drawing.Point(308, 75);
+ this.btnReadStruct.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.btnReadStruct.Name = "btnReadStruct";
+ this.btnReadStruct.Size = new System.Drawing.Size(72, 25);
+ this.btnReadStruct.TabIndex = 12;
+ this.btnReadStruct.Text = "R Struc";
+ this.btnReadStruct.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
+ this.btnReadStruct.UseVisualStyleBackColor = true;
+ this.btnReadStruct.Click += new System.EventHandler(this.btnReadStruct_Click);
+ //
+ // TestMainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(869, 624);
+ this.Controls.Add(this.groupBox4);
+ this.Controls.Add(this.statusStrip1);
+ this.Controls.Add(this.groupBox3);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "TestMainForm";
+ this.Text = "SIEMENS S7 TEST";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
+ this.groupBox4.ResumeLayout(false);
+ this.groupBox4.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox txtIP;
+ private System.Windows.Forms.Label lblIP;
+ private System.Windows.Forms.ComboBox cbCpuType;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox txtMemArea;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.TextBox txtMemSize;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.TextBox txtOut;
+ private System.Windows.Forms.GroupBox groupBox3;
+ 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.TextBox textBox2;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.Button btnReadByte;
+ private System.Windows.Forms.StatusStrip statusStrip1;
+ private System.Windows.Forms.ToolStripStatusLabel tslConn;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
+ private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
+ private System.Windows.Forms.ToolStripStatusLabel tslRTime;
+ private System.Windows.Forms.GroupBox groupBox4;
+ private System.Windows.Forms.Button btnStrWrite;
+ private System.Windows.Forms.Button btnNumWriteW;
+ private System.Windows.Forms.TextBox txtWriteVal2;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.TextBox txtWriteVal1;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.TextBox txtWriteAddr1;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.TextBox txtWriteAddr2;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.Button btnReadString;
+ private System.Windows.Forms.Button btnReadWord;
+ private System.Windows.Forms.Button btnReadDWord;
+ private System.Windows.Forms.Button btnReadReal;
+ private System.Windows.Forms.Button btnNumWriteB;
+ private System.Windows.Forms.Button btnNumWriteDW;
+ private System.Windows.Forms.Button btnReadStruct;
+ }
+}
+
diff --git a/SiemensS7/Siemens-S7-Test/TestMainForm.cs b/SiemensS7/Siemens-S7-Test/TestMainForm.cs
new file mode 100644
index 0000000..2c42ad7
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/TestMainForm.cs
@@ -0,0 +1,727 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using S7.Net;
+using System.Net.NetworkInformation;
+using System.Net;
+using NLog;
+using System.Diagnostics;
+
+namespace Siemens_S7_Test
+{
+ public partial class TestMainForm : Form
+ {
+ ///
+ /// Configurazione valori da LEGGERE dal PLC
+ ///
+ public otherData[] memMapR;
+ ///
+ /// Configurazione valori da SCRIVERE nel PLC
+ ///
+ public otherData[] memMapW;
+ ///
+ /// Byte dimensione buffer dati memoria (da file map)
+ ///
+ public int numByte = 0;
+ ///
+ /// Lungh massima stringhe
+ ///
+ protected int maxStrChar = 20;
+ ///
+ /// Oggetto PLC da ri-utilizzare...
+ ///
+ protected Plc currPLC;
+ ///
+ /// indica se serva refresh parametri e quindi PLC...
+ ///
+ bool needRefresh = true;
+ ///
+ /// Oggetto cronometro x test vari...
+ ///
+ protected Stopwatch sw = new Stopwatch();
+ ///
+ /// parametri di connessione
+ ///
+ protected connParam parametri;
+ ///
+ /// titolo x log/debug
+ ///
+ protected string titolo = "";
+ ///
+ /// contenuto x log/debug
+ ///
+ protected string contenuto = "";
+ ///
+ /// oggetto logging
+ ///
+ public static Logger lg;
+
+ public TestMainForm()
+ {
+ InitializeComponent();
+
+ myInit();
+ }
+ ///
+ /// inizializzo
+ ///
+ private void myInit()
+ {
+ lg = LogManager.GetCurrentClassLogger();
+ // inizializzo parametri...
+ parametri = new connParam()
+ {
+ ipAdrr = "127.0.0.1",
+ tipoCpu = CpuType.S7200,
+ slot = 0,
+ rack = 0
+ };
+ setParamPlc();
+ }
+ ///
+ /// Imposto parametri PLC
+ ///
+ private void setParamPlc()
+ {
+ txtOut.Text = "";
+ // SE è necessario refresh...
+ if (needRefresh)
+ {
+ 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();
+ titolo = "PARAM PLC (pre connect)";
+ contenuto = string.Format("IP: {0}{1}", parametri.ipAdrr, Environment.NewLine);
+ contenuto += string.Format("CPU: {0}{1}", parametri.tipoCpu, Environment.NewLine);
+ contenuto += string.Format("RACK: {0}{1}", parametri.rack, Environment.NewLine);
+ contenuto += string.Format("SLOT: {0}", parametri.slot, Environment.NewLine);
+ }
+ 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();
+ if (currPLC.IsConnected) titolo = "CONNESSIONE AVVENUTA";
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in INIT PLC");
+ }
+ needRefresh = false;
+ }
+ // carico conf vettore memoria...
+ loadMemConf();
+ // mostra output
+ showOut(titolo, contenuto);
+ }
+ }
+ ///
+ /// Caricamento conf memoria DB del SIEMENS
+ ///
+ private void loadMemConf()
+ {
+ // carico conf memoria
+ utils.loadConfFile(ref memMapR, filePath("MMapR"), 1, ref numByte);
+ utils.loadConfFile(ref memMapW, filePath("MMapW"), 1, ref numByte);
+ }
+ ///
+ /// Restituisce path completo file da chaive configurazione
+ ///
+ /// chaive conf x file richiesto
+ ///
+ protected string filePath(string keyFile)
+ {
+ return string.Format(@"{0}\{1}", utils.confDir, utils.CRS(keyFile));
+ }
+ ///
+ /// Esecuzione lettura!
+ ///
+ private void eseguiLetturaByte()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtMemArea.Text);
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+
+ //var readVal = currPLC.Read("DB600.DBD0");
+
+ Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ titolo = string.Format("READ BLOCK MEM BYTE: {0} --> {1} byte", txtMemArea.Text, numByte);
+ contenuto = "";
+ string byteVal = "";
+ for (int i = 0; i < memByteRead.Length; i++)
+ {
+ byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0');
+ contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ }
+ ///
+ /// Esecuzione lettura WORD!
+ ///
+ private void eseguiLetturaWord()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtMemArea.Text);
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+ Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte);
+ contenuto = "";
+ ushort shortVal = 0;
+ string byteValA = "";
+ string byteValB = "";
+ for (int i = 0; i < memByteRead.Length / 2; i++)
+ {
+ byteValA = Convert.ToString(memByteRead[i * 2], 2).PadLeft(8, '0');
+ byteValB = Convert.ToString(memByteRead[i * 2 + 1], 2).PadLeft(8, '0');
+ shortVal = S7.Net.Types.Word.FromByteArray(memByteRead.Skip(2 * i).Take(2).ToArray());
+ contenuto += string.Format("W{0:000}: {1} | {2}-{3}{4}", i, shortVal, byteValA, byteValB, Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ }
+
+ ///
+ /// Esecuzione lettura come struct
+ ///
+ private void eseguiLetturaStruct()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+ titolo = string.Format("READ STRUCT: {0} --> {1} byte", txtMemArea.Text, numByte);
+
+ //leggo a ciclo una singola struct...
+
+ int numPar = 50;
+ ThermoParam objPar = new ThermoParam();
+ List ElencoParametri = new List();
+ for (int i = 0; i < numPar; i++)
+ {
+ objPar = (ThermoParam)currPLC.ReadStruct(600, i * 20);
+ ElencoParametri.Add(objPar);
+ }
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+
+ foreach (var item in ElencoParametri)
+ {
+ contenuto += $"Id: {item.Id}{Environment.NewLine}";
+ contenuto += $"SetpointHMI: {item.SetpointHMI}{Environment.NewLine}";
+ contenuto += $"SetpointPLC: {item.SetpointPLC}{Environment.NewLine}";
+ contenuto += $"ValMin: {item.ValMin}{Environment.NewLine}";
+ contenuto += $"ValMax: {item.ValMax}{Environment.NewLine}";
+ contenuto += $"UnitMeasure: {item.UnitMeasure}{Environment.NewLine}";
+ contenuto += $"---------{Environment.NewLine}";
+ }
+
+
+#if false
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtMemArea.Text);
+ Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ contenuto = "";
+ ushort shortVal = 0;
+ string byteValA = "";
+ string byteValB = "";
+ for (int i = 0; i < memByteRead.Length / 2; i++)
+ {
+ byteValA = Convert.ToString(memByteRead[i * 2], 2).PadLeft(8, '0');
+ byteValB = Convert.ToString(memByteRead[i * 2 + 1], 2).PadLeft(8, '0');
+ shortVal = S7.Net.Types.Word.FromByteArray(memByteRead.Skip(2 * i).Take(2).ToArray());
+ contenuto += string.Format("W{0:000}: {1} | {2}-{3}{4}", i, shortVal, byteValA, byteValB, Environment.NewLine);
+ }
+#endif
+
+
+ showOut(titolo, contenuto);
+ }
+ }
+
+
+
+ ///
+ /// Esecuzione lettura DWORD!
+ ///
+ private void eseguiLetturaDWord()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtMemArea.Text);
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+ Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte);
+ contenuto = "";
+ uint intVal = 0;
+ string byteValA = "";
+ string byteValB = "";
+ string byteValC = "";
+ string byteValD = "";
+ for (int i = 0; i < memByteRead.Length / 4; i++)
+ {
+ byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0');
+ byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0');
+ byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0');
+ byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0');
+ intVal = S7.Net.Types.DWord.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray());
+ contenuto += string.Format("W{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, intVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ }
+ ///
+ /// Esecuzione lettura Real!
+ ///
+ private void eseguiLetturaReal()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtMemArea.Text);
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+ Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ titolo = string.Format("READ BLOCK MEM WORD: {0} --> {1} byte", txtMemArea.Text, numByte);
+ contenuto = "";
+ double realVal = 0;
+ string byteValA = "";
+ string byteValB = "";
+ string byteValC = "";
+ string byteValD = "";
+ for (int i = 0; i < memByteRead.Length / 4; i++)
+ {
+ byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0');
+ byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0');
+ byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0');
+ byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0');
+ realVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray());
+ contenuto += string.Format("W{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, realVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ }
+ ///
+ /// Esecuzione lettura tipo STRING!
+ ///
+ private void eseguiLetturaString()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtMemArea.Text);
+ int numByte = 1;
+ int.TryParse(txtMemSize.Text, out numByte);
+ Byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ titolo = string.Format("READ BLOCK MEM STRING: {0} --> {1} byte", txtMemArea.Text, numByte);
+ contenuto = "";
+ string byteVal = "";
+ // i primi 2 byte sono LUNGHEZZA MAX e lungh effettiva quindi setto il NUM BYTE....
+ for (int i = 0; i < 2; i++)
+ {
+ byteVal = Convert.ToString(memByteRead[i], 2).PadLeft(8, '0');
+ contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, memByteRead[i], Environment.NewLine);
+ }
+ // prendo 2° valore (num max valori)
+ numByte = memByteRead[1];
+ // poi prendo la stringa...
+ string outVal = "";
+ for (int i = 2; i < numByte + 2; i++)
+ {
+ outVal += Char.ConvertFromUtf32(memByteRead[i]);
+ }
+ contenuto += string.Format("{0}{1}", outVal, Environment.NewLine);
+ showOut(titolo, contenuto);
+ }
+ }
+ ///
+ /// Test connessione CNC
+ ///
+ ///
+ private bool testCncConn()
+ {
+ bool answ = false;
+ IPStatus pingStatus = testPing();
+ // se passa il ping faccio il resto...
+ if (pingStatus != IPStatus.Success)
+ {
+ titolo = "Errore ping";
+ contenuto = string.Format("Reply Status per {0}: {1}", parametri.ipAdrr, pingStatus);
+ showOut(titolo, contenuto);
+ }
+ else
+ {
+ if (!currPLC.IsConnected) currPLC.Open();
+ bool excludeAvailable = true;
+ if (excludeAvailable)
+ {
+ if (!currPLC.IsConnected)
+ {
+ titolo = "Errore connessione";
+ //contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString);
+ //currPLC.ClearLastError();
+ contenuto = "!currPLC.IsConnected";
+ showOut(titolo, contenuto);
+ tslConn.Text = "NO Connection";
+ }
+ else
+ {
+ tslConn.Text = "Connection OK";
+ answ = true;
+ }
+ }
+ else
+ {
+ if (!currPLC.IsAvailable)
+ {
+ titolo = "Errore Disponibilità";
+ //contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString);
+ //currPLC.ClearLastError();
+ contenuto = "!currPLC.IsAvailable";
+ showOut(titolo, contenuto);
+ }
+ else
+ {
+ if (!currPLC.IsConnected)
+ {
+ titolo = "Errore connessione";
+ //contenuto = string.Format("{0} | {1}", currPLC.LastErrorCode, currPLC.LastErrorString);
+ //currPLC.ClearLastError();
+ contenuto = "!currPLC.IsConnected";
+ showOut(titolo, contenuto);
+ tslConn.Text = "NO Connection";
+ }
+ else
+ {
+ tslConn.Text = "Connection OK";
+ answ = true;
+ }
+ }
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// test ping all'indirizzo impostato nei parametri
+ ///
+ ///
+ 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;
+ }
+
+ ///
+ /// formatta un numero in forma binaria 0/1 a 32 bit (4 byte)
+ ///
+ ///
+ ///
+ public static string binaryForm(int valore)
+ {
+ string answ = "";
+ try
+ {
+ answ = string.Format(new BinaryFormatter(), "{0:B}", valore);
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ protected void showOut(string title, string content)
+ {
+ string outText = "";
+ // a video
+ outText += string.Format("{0}--------------------------------------------------------------------------------------{0}", Environment.NewLine);
+ outText += string.Format("- {0}{1}", title, Environment.NewLine);
+ outText += string.Format("--------------------------------------------------------------------------------------{0}", Environment.NewLine);
+ outText += string.Format("{0}{1}", content, Environment.NewLine);
+ outText += string.Format("--------------------------------------------------------------------------------------{0}{0}", Environment.NewLine);
+
+ // aggiorno visualizzazione
+ txtOut.Text += outText;
+ // loggo!
+ lg.Info(outText);
+ }
+
+ ///
+ /// Esecuzione SCRITTURA Byte!
+ ///
+ private void eseguiScritturaByte()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtWriteAddr1.Text);
+ byte num2write = 0;
+ string val2write = txtWriteVal2.Text;
+ byte.TryParse(txtWriteVal1.Text, out num2write);
+ byte[] DB_Byte = new byte[1];
+ DB_Byte[0] = num2write;
+ currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte);
+ titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text);
+ contenuto = "";
+ contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine);
+ string byteVal = "";
+ for (int i = 0; i < DB_Byte.Length; i++)
+ {
+ byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0');
+ contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ }
+ ///
+ /// Esecuzione SCRITTURA WORD!
+ ///
+ private void eseguiScritturaWord()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtWriteAddr1.Text);
+ UInt16 num2write = 0;
+ string val2write = txtWriteVal2.Text;
+ UInt16.TryParse(txtWriteVal1.Text, out num2write);
+ byte[] DB_Byte = new byte[2];
+ S7.Net.Types.Word.ToByteArray(num2write).CopyTo(DB_Byte, 0);
+ currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte);
+ titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text);
+ contenuto = "";
+ contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine);
+ string byteVal = "";
+ for (int i = 0; i < DB_Byte.Length; i++)
+ {
+ byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0');
+ contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ }
+ ///
+ /// Esecuzione SCRITTURA DWORD!
+ ///
+ private void eseguiScritturaDWord()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtWriteAddr1.Text);
+ uint num2write = 0;
+ string val2write = txtWriteVal2.Text;
+ uint.TryParse(txtWriteVal1.Text, out num2write);
+ byte[] DB_Byte = new byte[4];
+ S7.Net.Types.DWord.ToByteArray(num2write).CopyTo(DB_Byte, 0);
+ currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte);
+ titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text);
+ contenuto = "";
+ contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | num2write: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine);
+ string byteVal = "";
+ for (int i = 0; i < DB_Byte.Length; i++)
+ {
+ byteVal = Convert.ToString(DB_Byte[i], 2).PadLeft(8, '0');
+ contenuto += string.Format("B{0:000}: {1} | {2}{3}", i, byteVal, DB_Byte[i], Environment.NewLine);
+ }
+ showOut(titolo, contenuto);
+ }
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ }
+ ///
+ /// Esecuzione SCRITTURA String!
+ ///
+ private void eseguiScritturaString()
+ {
+ sw.Restart();
+ if (testCncConn())
+ {
+ // decodifico memoria...
+ memAddress memoria = new memAddress(txtWriteAddr2.Text);
+ int num2write = 0;
+ // verifico di no sforare con lunghezza
+ string val2write = txtWriteVal2.Text;
+ // se è maggiore di maxStrChar TRIMMA:::
+ if (val2write.Length > maxStrChar)
+ {
+ val2write = val2write.Substring(0, 20);
+ }
+ // scambio spazi con underscore... e MAIUSCOLO!!!
+ val2write = val2write.Replace(' ', '_').ToUpper();
+ num2write = val2write.Length;
+ byte[] DB_Byte = new byte[maxStrChar + 2];
+ // primi 2 byte sono 20 (fix) e lung effettiva...
+ DB_Byte[0] = 20;
+ DB_Byte[1] = (byte)num2write;
+ // converto 1-1 i char in byte...
+ for (int i = 0; i < num2write; i++)
+ {
+ DB_Byte[2 + i] = (byte)(val2write[i]);
+ }
+ currPLC.WriteBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, DB_Byte);
+ titolo = string.Format("WRITE BLOCK MEM: {0}", txtWriteAddr1.Text);
+ contenuto = "";
+ contenuto += string.Format("DT: {0} | DbNum: {1} | indiceMem: {2} | stringa: {3}{4}{4}", DataType.DataBlock, memoria.DbNum, memoria.indiceMem, num2write, Environment.NewLine);
+ showOut(titolo, contenuto);
+ }
+ sw.Stop();
+ tslRTime.Text = string.Format("{0}", sw.Elapsed);
+ }
+
+
+ ///
+ /// Scrivo memoria tipo STRING
+ ///
+ ///
+ ///
+ private void btnStrWrite_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiScritturaString();
+ }
+
+ private void txtIP_TextChanged(object sender, EventArgs e)
+ {
+ needRefresh = true;
+ }
+
+ private void txtRack_TextChanged(object sender, EventArgs e)
+ {
+ needRefresh = true;
+ }
+
+ private void cbCpuType_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ needRefresh = true;
+ }
+
+ private void txtSlot_TextChanged(object sender, EventArgs e)
+ {
+ needRefresh = true;
+ }
+
+ private void txtMemArea_TextChanged(object sender, EventArgs e)
+ {
+ needRefresh = true;
+ }
+
+ private void txtMemSize_TextChanged(object sender, EventArgs e)
+ {
+ needRefresh = true;
+ }
+
+ private void btnReadByte_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiLetturaByte();
+ }
+
+ private void btnReadWord_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiLetturaWord();
+ }
+
+ private void btnReadString_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiLetturaString();
+ }
+
+ private void btnReadDWord_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiLetturaDWord();
+ }
+ ///
+ /// Lettura real
+ ///
+ ///
+ ///
+ private void btnReadReal_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiLetturaReal();
+ }
+
+ private void btnNumWriteB_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiScritturaByte();
+ }
+
+ private void btnNumWriteDW_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiScritturaDWord();
+ }
+
+ private void btnNumWriteW_Click(object sender, EventArgs e)
+ {
+ setParamPlc();
+ eseguiScritturaWord();
+ }
+
+ private void btnReadStruct_Click(object sender, EventArgs e)
+ {
+ // effettua lettura intera struct...
+ setParamPlc();
+ eseguiLetturaStruct();
+ }
+ }
+
+}
diff --git a/SiemensS7/Siemens-S7-Test/TestMainForm.resx b/SiemensS7/Siemens-S7-Test/TestMainForm.resx
new file mode 100644
index 0000000..174ebc7
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/TestMainForm.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/ThermoObj.cs b/SiemensS7/Siemens-S7-Test/ThermoObj.cs
new file mode 100644
index 0000000..9cfd055
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/ThermoObj.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Siemens_S7_Test
+{
+ public struct ThermoParam
+ {
+ public ushort Id;
+ public UInt32 SetpointHMI;
+ public UInt32 SetpointPLC;
+ public UInt32 ValMax;
+ public UInt32 ValMin;
+ public ushort UnitMeasure;
+ }
+
+ public class ParamsList
+ {
+ public ThermoParam par_000 { get; set; }
+ public ThermoParam par_001 { get; set; }
+ public ThermoParam par_002 { get; set; }
+ //public List Elenco { get; set; }
+ //public ParamsList()
+ //{
+ // Elenco = new List();
+ // ThermoParam currParam = new ThermoParam();
+ // // inizializzo subito coi valori...
+ // for (ushort i = 0; i < 2; i++)
+ // {
+ // currParam = new ThermoParam()
+ // {
+ // Id = i
+ // };
+ // Elenco.Add(currParam);
+ // }
+ //}
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/connParam.cs b/SiemensS7/Siemens-S7-Test/connParam.cs
new file mode 100644
index 0000000..4c641b0
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/connParam.cs
@@ -0,0 +1,18 @@
+using S7.Net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Siemens_S7_Test
+{
+ public class connParam
+ {
+ public string ipAdrr = "";
+
+ public CpuType tipoCpu = CpuType.S7300;
+ public short slot = 0;
+ public short rack = 0;
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/logs/.placeholder.txt b/SiemensS7/Siemens-S7-Test/logs/.placeholder.txt
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/logs/.placeholder.txt
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/memAddress.cs b/SiemensS7/Siemens-S7-Test/memAddress.cs
new file mode 100644
index 0000000..ccc7096
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/memAddress.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Siemens_S7_Test
+{
+ public class memAddress
+ {
+ ///
+ /// Indice DB
+ ///
+ public int DbNum = 0;
+ ///
+ /// Tipo Memoria (DBD, DBW...)
+ ///
+ public string tipoMem = "";
+ ///
+ /// Indice partenza memoria (es DBD0 --> 0)
+ ///
+ public int indiceMem = 0;
+ ///
+ /// Inizializza da un formato stringa
+ ///
+ ///
+ 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);
+ }
+ }
+}
diff --git a/SiemensS7/Siemens-S7-Test/packages.config b/SiemensS7/Siemens-S7-Test/packages.config
new file mode 100644
index 0000000..fc54bec
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/packages.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/resources/MHT/MMapR.map b/SiemensS7/Siemens-S7-Test/resources/MHT/MMapR.map
new file mode 100644
index 0000000..6eec313
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/resources/MHT/MMapR.map
@@ -0,0 +1,36 @@
+# Commenti con cancelletto, struttura un variabile per riga, tipo chiave|valore (occhio che il separatore è configurato da .cofig come "charSep"); spazi e tabulazioni dovrei trimmarli in acquisizione (qui inseriti per comodità di lettura)
+# Segnali BIT per gestione MAPO-IOB-WIN "base"
+0.0|IOB_POWER_ON |BIT
+0.1|IOB_RUN |BIT
+0.2|IOB_COUNT |BIT
+0.3|IOB_ALARM |BIT
+0.4|IOB_MANUAL |BIT
+# segnali BIT x ACK
+0.5|ACK_STR |BIT
+0.6|ACK_ST_COM |BIT
+0.7|ACK_END_COM |BIT
+#bit x definizione ultimo pezzo (OK/SCARTO/RILAVORAZIONE)
+1.0|LAST_PZ_OK |BIT
+1.1|LAST_PZ_KO |BIT
+1.2|LAST_PZ_RIL |BIT
+# Vettori allarmi (banchi da 32)
+002|ALARMS_001 |4BYTE
+006|ALARMS_033 |4BYTE
+010|ALARMS_065 |4BYTE
+014|ALARMS_097 |4BYTE
+# Altro valori byte numerici (0..255)
+018|AUTO_POWER_OFF |BYTE
+019|OVR_SPEED |BYTE
+020|OVR_FEED |BYTE
+021|CURR_MODE |BYTE
+# valori word come UINT 16bit/Word
+022|COUNT_TOT |WORD
+024|RPM_PEZZO |WORD
+026|RPM_MOLA |WORD
+028|NUM_PZ_STOP |WORD
+030|MIN_TEO_STOP |WORD
+032|LOAD_PEZZO |WORD
+034|LOAD_MOLA |WORD
+036|TC_LAST_PZ |REAL
+040|MIS_H1_LAST_PZ |REAL
+044|MIS_H2_LAST_PZ |REAL
\ No newline at end of file
diff --git a/SiemensS7/Siemens-S7-Test/resources/MHT/MMapW.map b/SiemensS7/Siemens-S7-Test/resources/MHT/MMapW.map
new file mode 100644
index 0000000..cdcdfcb
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/resources/MHT/MMapW.map
@@ -0,0 +1,27 @@
+# Commenti con cancelletto, struttura un variabile per riga, tipo chiave|valore (occhio che il separatore è configurato da .cofig come "charSep"); spazi e tabulazioni dovrei trimmarli in acquisizione (qui inseriti per comodità di lettura)
+# Segnali BIT per gestione richeista lettura valori
+0.0|SIG_STR |BIT
+0.1|SIG_ST_COM |BIT
+0.2|SIG_END_COM |BIT
+# valori word come UINT 16bit/Word
+002|NUM_PZ_LOTTO |WORD
+# dati COMMESSA
+006|L_MAX_COMM |BYTE
+007|L_ACT_COMM |BYTE
+008|COD_COMMESSA |20CHAR
+# dati ARTICOLO
+006|L_MAX_ART |BYTE
+007|L_ACT_ART |BYTE
+008|COD_ARTICOLO |20CHAR
+# dati PROGRAMMA
+006|L_MAX_PROG |BYTE
+007|L_ACT_PROG |BYTE
+008|COD_PROGRAMMA |20CHAR
+# dati MACCHINA
+006|L_MAX_MACC |BYTE
+007|L_ACT_MACC |BYTE
+008|COD_MACCHINA |20CHAR
+# dati DIRECTORY
+006|L_MAX_DIR |BYTE
+007|L_ACT_DIR |BYTE
+008|COD_DIRECTORY |20CHAR
diff --git a/SiemensS7/Siemens-S7-Test/utils.cs b/SiemensS7/Siemens-S7-Test/utils.cs
new file mode 100644
index 0000000..818195d
--- /dev/null
+++ b/SiemensS7/Siemens-S7-Test/utils.cs
@@ -0,0 +1,266 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Configuration;
+using NLog;
+using System.Windows.Forms;
+
+namespace Siemens_S7_Test
+{
+ public class utils
+ {
+ ///
+ /// wrapper di log
+ ///
+ public static Logger lg;
+ ///
+ /// folder archiviazione dati configurazione (DATA\CONF)
+ ///
+ public static string confDir
+ {
+ get
+ {
+ return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath"));
+ }
+ }
+ ///
+ /// legge conf in formato char
+ ///
+ ///
+ ///
+ public static char CRC(string key)
+ {
+ char answ = '-';
+ try
+ {
+ answ = ConfigurationManager.AppSettings[key].ToCharArray()[0];
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// legge conf in formato stringa
+ ///
+ ///
+ ///
+ public static string CRS(string key)
+ {
+ string answ = "";
+ try
+ {
+ answ = ConfigurationManager.AppSettings[key].ToString();
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// legge conf in formato INT
+ ///
+ ///
+ ///
+ public static Int32 CRI(string key)
+ {
+ int answ = 0;
+ try
+ {
+ answ = Convert.ToInt32(CRS(key));
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// legge conf in formato BOOLean
+ ///
+ ///
+ ///
+ public static bool CRB(string key)
+ {
+ bool answ = false;
+ try
+ {
+ answ = Convert.ToBoolean(CRS(key));
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// Decodifica file allarme
+ ///
+ ///
+ ///
+ /// tipo memoria (R/D/...)
+ /// indirizzo di partenza memoria
+ /// dimensione singolo slot in byte
+ ///
+ 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());
+ }
+ ///
+ /// Decodifica file MAP (caso ESA/IOT)
+ ///
+ ///
+ ///
+ /// indirizzo Byte: indirizzo di partenza memoria
+ /// dimensione singolo slot in byte
+ /// indirizzo bit: numero riga x calcolo indice bit
+ ///
+ 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());
+ }
+ ///
+ /// Decodifica file MAP (caso FANUC/OSAI/...)
+ ///
+ ///
+ ///
+ /// tipo memoria (R/D/...)
+ /// indirizzo Byte: indirizzo di partenza memoria
+ /// dimensione singolo slot in byte
+ /// indirizzo bit: numero riga x calcolo indice bit
+ ///
+ 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());
+ }
+ ///
+ /// Legge il file di conf di una MAP di informazioni da gestire con lettura set memoria
+ ///
+ /// nome vettore memoria
+ /// file origine
+ /// dimensione (in byte) della memoria
+ /// dimensione (in byte) della memoria
+ 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(ref vettoreConf, numRiga);
+
+ if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili per file {1}", numRiga, nomeFile));
+ }
+ }
+
+ ///
+ /// Dato generico (per decodifica)
+ ///
+ 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;
+ }
+ }
+
+}