PLCDataManager
Introduction#
PLCDataManager is a software application that one one hand makes it possible to backup, restore and compare data modules of a PLC to or from an XML file, while on the other hand, the online/offline data can also be visualized and changed via structured views. The OPC, ODK and LibNoDave interfaces can be used for communication with the PLC.
Purpose and Objective##
Creation of module backups so that they can be reloaded again if necessary.
Definitions, Acronyms, Abbreviations##
- PLC: Programmable Logic Controller
- SPS: Speicher Programmierbare Steuerung
- LibNoDave: Free library for the communication with a PLC.
- ODK: Simatic WinAC Open Development Kit
- DDF: Data definition file, a file that describes the structure and mapping of data, in our case data from the PLC. A DDF may also contain a certain snapshot of the data.
- Mapping: a variable is mapped to a defined data area.
- UC: User Control
General Description#
The special features and setting options of the software are described below.
System Environment##
The software is written with C# Visual Studio 2010 for the Target framework .NET 4.0.
.NET 4.5 is not used since it does not guarantee any compatibility with XP.
System Start##
When starting the application, all information is read from a XML configuration file.
An existing configuration file named "PLCDataManagerConfig.xml" in the application directory is detected and loaded by PLCDataManager. If you would like to use other configuration files, you can supply a different configuration file name via the command line when starting the PLCDataManager.
Command Line Parameters###
Short | Long | Type | Default value | Description |
---|---|---|---|---|
name | name | |||
f | file | Parameter | PLCDataManager | Configuration file |
Config.xml | ||||
c | compare | Switch | Automatic comparison | |
s | save | Switch | Automatic save | |
r | restore | Switch | Automatic restore | |
v | visu | Switch | Displaying visualisation | |
(only in conjunction with c,s,r) |
Example:
Automatic comparison: | PLCDataManager.exe –f"C:\PLCDataManager.xml" –c |
---|---|
Automatic backup: | PLCDataManager.exe –f"C:\PLCDataManager.xml" –s |
Automatic backup | PLCDataManager.exe –f"C:\PLCDataManager.xml" –s -v |
with visualization: |
Automatic Mode###
These parameters enable executing the application in automatic mode. The c, s and r switches are not allowed simultaneously. There is, however, a prioritization if all three are specified:
Priority | Action |
---|---|
1 | Restore |
2 | Save |
3 | Compare |
The automatic comparison has a special feature: If the comparison should fail (NOK), a specific bit in a freely definable data word is set in the PLC (see "PLC Interface"). This bit is reset (OK) if a further automatic comparison run or manually triggered comparison no longer results in any differences.
PLC-triggered Mode###
A backup can also be initiated by the PLC. A special interface has to be supplied for this purpose. Furthermore, the files that are backed-up by a PLC-trigger can be different from the ones used in manual or automatic mode. See below for more details.
Data Handling##
The data is saved in a data definition file.
If the underlying structure of the data definitions changes, then the old backup file must be deleted before it is possible to create a new backup. Otherwise, the old structure applies!
User Interface#
Apart from the normal control elements, the user interface includes the IDATUC that is responsible for displaying the structures. The individual sections of the interface are described in detail below.
Control Elements##
[1] | Select and deselect | |
---|---|---|
[2] | Set the zoom factor for the entire application | |
[3] | Activate and deactivate the online mode (for details see Online Mode) | |
[4] | The following data is displayed in the Name column: | |
Level1: | Name of the data definition file | |
Level2: | Name of the mappings of the data definition file | |
Level3-Level[X-1]: | Name of the data structure | |
Level[x]: | Name of the variable | |
Every single object can be activated or deactivated by the checkbox | ||
If the character [*] is displayed after the name of the file definition, | ||
this item is also registered for the PLC-triggered-backup | ||
[5] | In this column the data type / name of the data structure is displayed | |
(here it is also possible to switch over for displaying the offset in | ||
binary or hexadecimal format) | ||
[6] | In this column the current value in the PLC is displayed | |
[7] | In this column the value that is stored in the last backup is displayed | |
(this column can also be edited) | ||
[8] | Start of the backup run from the PLC to the file | |
[9] | Start of the comparison run | |
[10] | Start of the restore run from the file to the PLC | |
[11] | Read the data from the PLC and display the data in the user interface | |
only the visible variables are read here) | ||
[12] | Read the data from the file and display the data in the user interface | |
(only the visible variables are read here) | ||
[13] | Writes the changes that were made in column [7] to the PLC |
Progress Displays and Feedbacks##
When executing an action, the following control elements are displayed.
A positive feedback during a comparison turns the TextBox green. The control elements first disappear after clicking on the TextBox.
A negative feedback during a comparison, or an error, turns the TextBox red. The control elements first disappear after clicking on the TextBox.
Structure Display and Data Manipulation##
The item for displaying and manipulating the structure is the core of this application and is also located at its centre. This control element maps the structures existing in the PLC. Hence, you can view, compare or change the current PLC data as well as the backed-up data.
Thanks to this type of data processing, a "Byte-Bit-Offset" (as common in the PLC-world) no longer has to be used, nor do the values have to be converted. It is also no longer necessary to know the details of all data types, such as the length information contained in the first two bits of a string, in order to manipulate them. This element does this by itself. If, however, it is important for you to see the addresses or the hexadecimal or binary values, this is possible, too. The representation of the values can easily be switched over using the "Type" column and the addresses can be displayed by activating the "Address" column (the addresses are displayed in pointer format).
Possible Columns###
It is also possible to display other columns (for details on how to do this, please see the chapter Configuration).
This figure shows the possible columns:
Additional column | Description |
---|---|
Address | This column displays the address of the variables in |
pointer format. | |
Access right | The access right indicates whether the variable can be |
read or written. This is parametrized in the mappings | |
with Write and Read operations. | |
Last value change | Here, the timestamp is displayed when the last update |
of the variable was performed. | |
(Last read operation of the UC) |
Online Mode###
With this button it is possible to activate an online mode and to deactivate it again. In the online operating mode, all variables currently visible in the structure display are updated cyclically with the current data in the PLC.
Configuration#
The configuration of the application is divided into two files. The first file (called "PLCDataManager.exe.config") contains the settings for the user interface, whereas the "PLCDataManager.xml"-file contains the settings for the application.
Configuration of the User Interface (UI)##
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="PLCDataManager.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<applicationSettings>
<PLCDataManager.Properties.Settings>
<setting name="DefaultFontSize" serializeAs="String">
<value>12</value>
</setting>
<setting name="Zoom" serializeAs="String">
<value>150</value>
</setting>
<setting name="ShowAccessRightColumn" serializeAs="String">
<value>False</value>
</setting>
<setting name="ShowLastValueChangeColumn" serializeAs="String">
<value>False</value>
</setting>
<setting name="ShowAddressColumn" serializeAs="String">
<value>True</value>
</setting>
</PLCDataManager.Properties.Settings>
</applicationSettings>
</configuration>
Variable | Description |
---|---|
DefaultFontSize | Sets the default font size. |
Zoom | Sets the initial zoom factor on start up. |
ShowAccessRightColumn | If "True", the "Access right" column is shown. |
ShowLastValueChangeColumn | If "True", the "Last value change" column is shown. |
ShowAddressColumn | If "True", the "Address" column is shown. |
Configuration of the Application##
<?xml version="1.0" encoding="UTF-8"?>
<Setup>
<Assemblies>
<Assembly path="ResolverImpl.dll"/>
<Assembly path="OPCReaderWriter.dll"/>
<Assembly path="DataDefReaderWriter.dll"/>
<Assembly path="S7Converter.dll"/>
<Assembly path="PLCDataManager.Logic.dll"/>
<Assembly path="ComparatorUC.dll"/>
</Assemblies>
<Instances>
<Resolvers>
<Resolver name="Resolver"/>
</Resolvers>
<Converters>
<Converter name="S7Converter"/>
</Converters>
<Comparators>
<Comparator name="UCComparator" />
</Comparators>
<BinaryReaderWriters>
<BinaryReaderWriter name="OPCReaderWriter">
<ServerName>OPC.SimaticNet</ServerName>
<ProtocolName>S7</ProtocolName>
<ConnectionName>RTX</ConnectionName>
<ItemSyntax>SimaticNet</ItemSyntax>
</BinaryReaderWriter>
<BinaryReaderWriter name="DataDefReaderWriter">
<File><![CDATA[><..\Dat\Konfig\PLCDataManagerConfig.xml//Setup/Instances/
PLCDataManagers/PLCDataManager[@name='PLCDataManager']/DefPaths;..\Dat\Konfig\
PLCDataManagerConfig.xml//Setup/Instances/PLCDataManagers/
PLCDataManager[@name='PLCDataManager']/DefPathsAuto]]>
</File>
<OutPath><![CDATA[><..\Dat\Konfig\PLCDataManagerConfig.xml//Setup/Instances/
PLCDataManagers/PLCDataManager[@name='PLCDataManager']/OutPaths]]>
</OutPath>
</BinaryReaderWriter>
</BinaryReaderWriters>
<PLCDataManagers>
<PLCDataManager name="PLCDataManager">
<DefPaths><![CDATA[..\Dat\Konfig\Normal]]></DefPaths>
<DefPathsAuto><![CDATA[..\Dat\Konfig\Auto]]></DefPathsAuto>
<OutPaths><![CDATA[..\Dat\DBSave]]></OutPaths>
<InterfaceDef><![CDATA[..\Dat\Konfig\Interface\Interface.xml]]>
</InterfaceDef>
<SaveCommand>PLCinterface.Steuern.Sichern</SaveCommand>
<CompareState>PLCinterface.status.Vergleich_io</CompareState>
<SaveFinished>PLCinterface.status.Sichern_beendet</SaveFinished>
<OptimizeMemUsage>False</OptimizeMemUsage>
<SaveFinishedBatchJob>D:\Programme\IDat\_PcDm_CopyToServer.bat
$OutPaths</SaveFinishedBatchJob>
<BatchJobTimeout>5000</BatchJobTimeout>
<BatchJobCancelled>PLCinterface.status.BatchJobCancelled
</BatchJobCancelled>
<Logger>
<log4net>
...
</log4net>
</Logger>
</PLCDataManager>
</PLCDataManagers>
</Instances>
</Setup>
Assemblies###
In this section, all required assemblies are specified.
Instances###
In this section, all required instances of the defined assemblies are configured.
Resolvers####
In this section, the Resolver is parametrized. The default configuration is sufficient for this application, you should not change it.
Converters####
In this section, the Converter is parametrized. The default configuration of the S7 converter is sufficient for this application, you should not change it.
Comparators####
In this section, the Comparators are parametrized. The default configuration of the UC Comparator is sufficient for this application, you should not change it.
BinaryReaderWriters####
In this section, the BinaryReaderWriters are parametrized. Two instances are required for this application.
The first BinaryReaderWriter must be configured for online access. You can select between OPC, ODK, Snap7 and LibNoDave as the communication path to the PLC. For ODK and LibNoDave the default configuration is sufficient in most cases, for OPC please see an example at the beginning of this chapter (for further details, please refer to the documentation of the relevant BinaryReaderWriter).
The second BinaryReaderWriter "DataDefReaderWriter" is configured for offline access.
You must not change any setting for this instance, since the application may not work correctly afterwards! Furthermore, these settings are deprecated and updated versions of this application will use an internal, hard-coded instance for offline access.
PLCDataManagers####
PLCDataManager#####
In this section, the paths and commands of the application are declared.
Variable | Description |
---|---|
DefPaths | Specifies the first location(s) of data definition files |
(DDF) for manual and auto backup. The files in this | |
location are ignored by the PLC-triggered backup! | |
There are several options here: | |
1.) Specification of the file names separated by a semicolon | |
2.) Specification of paths to one or more data definition files | |
separated by a semicolon | |
DefPathsPLCTriggered | Specifies the second location(s) of DDFs for manual and |
auto backup and it specifies the location(s) of the DDFs | |
that are used for the PLC-triggered backup. | |
Attention: A DDF must not be specified twice, | |
also in respect to the settings in DefPaths! | |
(the Options are the same as above) | |
OutPaths | The path where the backups are stored is specified here |
InterfaceDef | The path to a DDF that can serve as a PLC interface is |
specified here. | |
(If nothing is specified, the PLC interface is disabled) | |
SaveCommand | The PLC-variable responsible for starting a backup is |
specified here. Each time this variable changes from | |
False to True, the backup is triggered | |
CompareState | The PLC-variable that gets written to signal the |
comparison result to the PLC is specified here | |
(True=Unequal, False=Equal) | |
SaveFinished | he PLC-variable that gets set from PLCDataManager |
after the completion of a PLC-triggered backup is | |
specified here (this bit must be reset by the PLC | |
before triggering new backup cycle) | |
OptimizeMemUsage | This parameter ensures that the memory usage is reduced. |
Attention: Enabling this may have a negative impact on | |
the application performance | |
SaveFinishedBatchJob | A path to an executable file can be specified here. This |
file is executed after the backup is completed. This function, | |
for example, can be used to move the files to a backup server | |
BatchJobTimeOut | A timeout for the completion of the batch job can be specified |
here. If the job times out, it is cancelled. 0 = "no timeout" | |
BatchJobCancelled | If the batch job returns an error code, this bit is set. |
It is reset after the next successful run. | |
Logger | log4Net (open source logging system) is parameterised here. |
It is recommended to leave it as it is, since it determines | |
the location, size and content of the log files used for diag- | |
nosing purposes. If you’re interested, see the web for details. |
Data Definition File#
<?xml version="1.0" encoding="utf-8"?>
<DataDef Endianness="Host-Endianess" Encoding="Base16"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.insite-gmbh.de/IDAT/DataDef"
xsi:schemaLocation="http://www.insite-gmbh.de/IDAT/DataDef
TypeDefinition/DataDef.xsd">
<!-- Structs are the userdefined types -->
<Types>
<Struct name="DB_Optionen_Allgemein">
<Var name="Rechnername" type="STRING" length="16" />
<Var name="Ziel_BST1" type="STRING" length="8" />
<Var name="Ziel_BST2" type="STRING" length="8" />
<Var name="Ziel_BST3" type="STRING" length="8" />
<Var name="Ziel_BST4" type="STRING" length="8" />
<Var name="Ziel_BST5" type="STRING" length="8" />
<Var name="Ziel_BST6" type="STRING" length="8" />
<Var name="BST1_vorh" type="BOOL" />
<Var name="BST2_vorh" type="BOOL" />
<Var name="BST3_vorh" type="BOOL" />
<Var name="BST4_vorh" type="BOOL" />
<Var name="BST5_vorh" type="BOOL" />
<Var name="BST6_vorh" type="BOOL" />
<Var name="Repaplatz" type="BOOL" />
<Var name="HAP_NOT_Aus_vorhanden" type="BOOL" />
<Var name="Ausw_WT_zu_PalRepa_BST1" type="BOOL" />
<Var name="Fliessmontage" type="BOOL" />
<Var name="Pneumatik_vorhanden" type="BOOL" />
<Struct name="AP" countItems="6">
<Var name="virtuell" type="BOOL" />
<Var name="ApVisu_Vorh" type="BOOL" />
<Var name="AP_IST_DT" type="BOOL" />
<Var name="zugeordnet_zu" type="INT" />
</Struct>
<Var name="Konfig_Ordner_Pfad" type="STRING" length="80" />
<Var name="Safety_Checksum" type="DWORD" />
<Var name="SHUT_DOWN_Verz_Zeit" type="INT" />
<Var name="Shut_down_abgew" type="BOOL" />
<Var name="Shut_Down_OPC2USV" type="BOOL" />
</Struct>
</Types>
<!-- declare the Values you want to use -->
<Vars>
<Var name="Options" type="DB_Optionen_Allgemein" />
</Vars>
<!-- define the mapping and the operations on the values-->
<Mappings>
<Mapping name="Opt" var="Options" source="OPCReaderWriter" selector="251"
offset="0" type="BinaryFile" active="true" >
<Filters>
<Filter var="Safety_Checksum" />
</Filters>
<Operations>
<Read/>
<Write/>
</Operations>
</Mapping>
</Mappings>
</DataDef>
Types##
This section is filled by the Tool AWLConverter and contains the definitions of the data blocks. For further details, please refer to the documentation for AWLConverter.
Vars##
In this section, variables are declared that are elements of the element type declared in Types. These variables can then be used in the mappings.
Mappings##
Variables can be mapped to different data areas and read and write operations can then be executed via the mappings. Additionally, filters can be declared, too. These filters only apply to write operations. A filtered variable is not rewritten to the PLC.
PLC-Interface#
The data modules that can be backed-up by a PLC-trigger-bit must be parametrized in the configuration ("DefPathsPLCTriggered"). Furthermore, any bit will serve the purpose of an interface to the PLC in case of an automatic comparison. The data area must be declared via a data definition and the bits required must be specified in the configuration.
Currently supported bits are:
Control Bits:
SaveCommand | Backup request of the data definitions that are defined via the |
---|---|
"DefPathsPLCTriggered" (formerly "DefPathsAuto") setting. |
Status Bits:
SaveFinished | Backup request executed by PLC. (This bit is reset by |
---|---|
PLCDataManager once the SaveCommand bit has been | |
reset by the PLC.) | |
CompareState | If set, then the last comparison failed. |
BatchJobCancelled | If set, then there was an error code returned from the |
batch job or a timeout occurred. |
Example of a file definition for the PLC interfacec:
<?xml version="1.0" encoding="utf-8"?>
<DataDef Endianness="Host-Endianess" Encoding="Base16"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.insite-gmbh.de/IDAT/DataDef"
xsi:schemaLocation="http://www.insite-gmbh.de/IDAT/DataDef
TypeDefinition/DataDef.xsd">
<!-- Structs are the userdefined types -->
<Types>
<Struct name="DB_parasave">
<Struct name="status">
<Var name="Vergleich_io" type="BOOL" />
<Var name="Sichern_beendet" type="BOOL" />
<Var name="BatchJobCancelled" type="BOOL" />
</Struct>
<Struct name="Steuern">
<Var name="Res_0" type="BOOL" />
<Var name="Sichern" type="BOOL" />
<Var name="res" type="BOOL" />
</Struct>
</Struct>
</Types>
<!-- declare the Values you want to use -->
<Vars>
<Var name="PLCinterface" type="DB_parasave" />
</Vars>
<!-- define the mapping and the operations on the values-->
<Mappings>
<Mapping name="interface" var="PLCinterface" source="OPCReaderWriter"
selector="220" type="BinaryFile">
<Operations>
<Read/>
<Write/>
</Operations>
</Mapping>
</Mappings>
</DataDef>
Associated entries in the configuration:
<SaveCommand>PLCinterface.Steuern.Sichern</SaveCommand>
<CompareState>PLCinterface.status.Vergleich_io</CompareState>
<SaveFinished>PLCinterface.status.Sichern_beendet</SaveFinished>
<BatchJobCancelled>PLCinterface.status.BatchJobCancelled</BatchJobCancelled>
Installation#
A successful installation requires that
- Microsoft .NET Framework 4.0 Servicepack 1
- Microsoft Visual C++ 2010 Redistributable Package
- WIN AC RTX 2009 or higher for using ODK
are installed and available on the destination system under Windows.
PLCDataManager includes the following EXE and DLLs (date January 2013):
Assembly | Manufacturer |
---|---|
CommandLine.dll | |
ComparatorUC.dll | insite GmbH |
DataDef.dll | insite GmbH |
DataDefReaderWriter.dll | insite GmbH |
IDATUC.ViewModel.dll | insite GmbH |
IDATUC.ViewModel.resources.dll | insite GmbH |
IDATUC.WPFView.dll | insite GmbH |
Insite.Controls.dll | insite GmbH |
Interfaces.dll | insite GmbH |
Ioc.dll | insite GmbH |
libnodave.dll | |
libnodave.net.dll | |
LibNoDaveReaderWriter.dll | insite GmbH |
log4net.dll | The Apache Software Foundation |
ODKCCXLib.dll | insite GmbH |
ODKCCXLib_CS.dll | insite GmbH |
ODKCCXReaderWriter.dll | insite GmbH |
OPCReaderWriter.dll | insite GmbH |
PLCDataManager.exe | insite GmbH |
PLCDataManager.Logic.dll | insite GmbH |
PLCDataManager.resources.dll | insite GmbH |
PLCHelpers.dll | insite GmbH |
PLCItemAccessor.dll | insite GmbH |
PLCOPCAccessor.dll | insite GmbH |
PLCOPCdotNETLib.dll | VISCOM |
ResolverImpl.dll | insite GmbH |
S7Converter.dll | insite GmbH |
SMHeapManager.dll | insite GmbH |
ViewModelBase.dll | insite GmbH |
XPathDataReaderWriter.dll | insite GmbH |
These files can be copied to any directory and the application can then be started from there.
Document history#
Author | Date | Remarks |
---|---|---|
Benjamin Prömmer | January 2013 | Creation |
Ralf Gedrat | January 2013 | Brief editing |
Benjamin Prömmer | February 2013 | Behaviour of the PLC interface extended |
Benjamin Prömmer | February 2013 | New OptimizeMemUsage parameter extended |
Benjamin Prömmer | August 2013 | New parameter for Batchjob extended |
Benjamin Prömmer | December 2014 | Documentation reference changed from |
AWLXMLConverter to AWLConverter | ||
Benjamin Prömmer | 2015-09-16 | Bug fixes, enhancements: |
Automatic cmd without -v is now possible | ||
If a DB does not exist, comparison result | ||
will be displayed in red | ||
Column widths are stored for each user after | ||
shutting down the application | ||
A context menu was added that allows hiding | ||
of certain columns | ||
Filtered data is displayed with a grey text colour | ||
Failed comparisons are displayed with | ||
a red text colour | ||
In online-mode, online and offline | ||
data are now automatically refreshed | ||
Karsten Gorkow | 2016-01-11 | Changed some misleading information |
Karsten Gorkow | 2016-01-12 | Removed errors and unnecessary details |
Karsten Gorkow | 2016-01-14 | Minor changes and additions |