Indi.An PLCCom for S7 Class Library Reference

PLCCom for S7 Class Library

PLCcom logo


First steps PLCCom for S7 .NET SDK

About this document

This document is intended to provide you with information about the provided functionalities. This is not a complete documentation, but a guide to help you getting started.

Further information can be found in

All information is supplied without any liability. All rights reserved and subject to change. The contents of this document are protected under international copyright laws. Without prior written consent from the copyright holder, no part of this documentation may be reproduced by means of photocopying, microfilm or other processes, or transcribed or translated into another language or computer language in any form.

Note: All product names or other names or brands referred to in this documentation are the trademarks or registered trademarks of their respective owners and are the property of those copyright owners. Any mention of brands serves purely as an indication to the intended purpose.

What provides PLCCom for S7 SDK?

The PLCcom for S7 library is a highly performant and optimized component especially designed for .NET developers to access data provided by a Siemens PLC in the most comfortable way. With PLCcom you can read and write data from a PLC with ease.

Plccom for S7 offers you the option of accessing address ranges with absolute addressing using Put/Get, as well as optionally accessing variables within optimized and non-optimized ranges using symbolic addressing (only in the Expert Symbolic Edition).

The driver can be integrated directly as a reference so that no API calls are necessary. PLCcom is platform independent and works on 32 as well as 64bit.

Within the scope of supply are various code examples to illustrate the connection between your application and different controllers. These examples can also be used in your own projects.

In its current version, PLCcom is compatible with S7 controllers (200, 300, 400, 1200, 1500, SoftSPS WinAC RTX as well as Logo! 0BA7 / 0BA8 / 0BA0 / 0BA1 / 0BA2) as well as CPUs from other manufacturers (e.g. VIPA 100V/200V/300V/300S, etc.)
Symbolic access is possible to S7 controllers of the 1200 and 1500 series.
The driver will be delivered with Code-Examples, which shows you how easy it is to connect the PLC to your application.

Communication:
Serial adapter MPI, Serial adapter PPI, MPI adapter USB, Ethernet TCP/IP, Green Cable (VIPA PLC only)



The following functions are also available (depending on the PLC type):

  • Access via put/get or symbolic addressing (S7-1200 / 1500 series only)
  • Password transfer to protected controllers with symbolic addressing
  • Read datablocks, inputs, outputs, flags, timer, counter
  • Subscribing to data areas (put/get) or variables (symbolic access)
  • Subscribing of alarms
  • Reading the actual alarm list
  • Acknowledge alarms
  • Multiple operations in a single function call. Every function returns a detailed result.
  • Simultaneous access of multiple CPUs
  • High performance access. Requests sent to the controller are reduced to the absolute necessary
  • Internal functions to read and write certain PLC datatypes with ease
  • Supply of the PLCcom dataserver for cyclically read accesses with event controlled notifications on value changes
  • Start and stop functionality for the CPU
  • Read serial number as well as firmware version
  • Read position of key switches
  • Read LED info
  • Read and write PLC time
  • Read system status list
  • Read block list
  • Read block lengths
  • Backup blocks
  • Restore blocks
  • Restore blocks with changed block number
  • Delete blocks
  • Read block details like code, generation language, author and more
  • Send connection password
  • Read diagnostic data
  • Auto Connect
  • Asynchronous connect
  • …and many more


Which programming platforms does PLCcom support?

PLCcom for S7 is available in the following .NET variants:

  • .NET Framework 4.7.2
  • .NET Framework 4.8
  • .NET Standard 2.1
  • .NET 5
  • .NET 6
  • .NET 7
  • .NET 8
  • .NET 9
  • .NET 10

Which system components are required for the operation of PLCcom?

The following system components are required for the operation of PLCcom:

  • Microsoft .net Framework 4.7.2 or higher (.net version)
  • Microsoft .net 5.0 up to .net 10 (.net version)

To run the sample programs provided, you need the following programming tools:

  • Visual Studio 2022 or higher (.net version)

Important information about using the .net version outside of Windows

Serial support is implemented within the current .net version with the System.IO.Ports dependency. Due to known lack of support for individual functionalities within the dependency, the following objects cannot be used outside of Windows:

  • PLCCom.MPI_Device
  • PLCCom.PPI_Device

Attempting to create an instance of the above classes outside of Windows results in a PlatformNotSupportedException.



Important notes for using PLCcom with S7-1200/1500 controllers


Prerequisites for the Put/Get access

It is possible to access inputs, outputs, flags, and non-optimized DBs. Access to an S7-1200 or 1500 is disabled by default. You must perform the following steps:

Up to firmware version 3.0 (S7-1500 and ET200SP) or 4.6 (S7-1200):

  1. Allow general access. In the Properties settings, under Protection, enable the option 'Allow access to PUT/GET communication from remote partner'.
  2. Enable access to your databases. Go to the database properties and disable 'optimized access'.
  3. Load into the PLC, done!

If the changes have no effect, use "advanced download to device" to load into the PLC.

Firmware version 3.1 (S7-1500, ET200SP, or S7-1200 G2) or 4.7 (S7-1200) and higher:

  1. Go to "Security settings" in the project navigation.
  2. Double-click on "Users and Roles."
  3. Select the "Roles" tab.
  4. Create a new role and assign it a name, for example, "HMI_Access."
  5. Open the "Runtime Rights" tab.
  6. Select the appropriate PLC in the "Function rights categories."
  7. Activate the "HMI access" access level in the "Function rights."
  8. Go to the "Users" tab in the "Users and roles" area.
  9. Activate the "Anonymous" user.
  10. Confirm the message displayed with "OK."
  11. Assign the newly created role to the anonymous user under "Assigned Roles."
  12. Open the "Device View."
  13. Go to the "Properties" of the CPU.
  14. Select "Protection & Security > Connection Mechanisms" in the area navigation.
  15. Activate the option "Allow access via PUT/GET communication by remote partners."
  16. Translate the project and transfer the changes to the CPU.

To perform symbolic access to Siemens S7-1200, S7-1500, or PLCSim with PLCcom, the following requirements apply:

TLS access (TIA version 17 or higher):

  • Supports symbolic access to PLC and PLCSim
  • S7-1200: Firmware from V4.5 tested up to V4.7 [TIA V21] *
  • S7-1200 G2: Firmware from V4.0 tested up to V4.1 [TIA V21] *
  • S7-1500: Firmware from V2.9 tested up to V4.1 [TIA V21] *
  • Authentication possible using password or username/password

Legacy access (up to TIA version 16) ** :

  • S7-1200: Firmware tested from V4.1 to V4.7 [TIA V21] *
  • S7-1500: Firmware tested from V2.1 to V4.1 [TIA V21] *
  • Symbolic access to PLC with password authentication
  • Authentication possible (exception: no password-protected access to PLCSim)

* Tested and approved within the specified firmware versions. Older or newer versions have not been tested; functionality is not guaranteed.

** Depending on the firmware version, legacy access must be explicitly enabled within the controller.


Supported features depending on PLC type


Feature

S7-1200
S7-1500
ET200SP

(Symbolic)
Legacy Communication
*1)

S7-1200 (G2)
S7-1500
ET200SP

(Symbolic)
Secure Communication

S7-200
(Put/Get) *7

S7-300
(Put/Get)

S7-400
(Put/Get)

S7-1200
(Put/Get)

S7-1500
ET200SP

(Put/Get)

WinAC RTX
(Put/Get)
*2)

Logo!
(Put/Get)
*3)

Read data

YesYesYesYesYesYesYesYesYes

Speed optimizations
combined area reads

YesYesYesYesYesYesYesYesYes

Write data

YesYesYesYesYesYesYesYesYes

Subscribe variables

Yes
native
Yes
native
Yes
via data
server
Yes
via data
server
Yes
via data
server
Yes
via data
server
Yes
via data
server
Yes
via data
server
Yes
via data
server

Read structures

YesYesNoNoNoNoNoNoNo

Deep Lookup *6

YesYesNoNoNoNoNoNoNo

Read full data blocks
as structure

YesYesNoNoNoNoNoNoNo

Deep Lookup *6

YesYesNoNoNoNoNoNoNo

TLS: verify server certificate

YesYesNoNoNoNoNoNoNo

TLS: provide trusted server certificates

YesYesNoNoNoNoNoNoNo

Advanced optimizations
for fast symbolic reads

YesYesNoNoNoNoNoNoNo

Subscribing to alarms

Yes
*4)
Yes
*4)
NoNoNoNoNoNoNo

Reading actual alarms list

Yes
*4)
Yes
*4)
NoNoNoNoNoNoNo

Acknowledging alarms

Yes
*4)
Yes
*4)
NoNoNoNoNoNoNo

Reading data from multiple areas combined

YesYesYesYesYesYesYesYesYes

Multiple read and write accesses in a common function call

YesYesNoYesYesYesYesYesYes

Reading or writing multiple values simultaneously in different areas

YesYesNoYesYesYesYesYesYes

Starting and stopping the CPU

YesYesYesYesYesYesYesYesYes

Reading and setting the PLC system time

YesYesYesYesYesNoNoYesYes

Get basic info from PLC e.g. Modell, ordernumber, Firmware etc.

YesYesYesYesYesYesYesYesYes

Get mode and state from CPU

YesYesNoYesYesNoNoYesYes

Get LEDs mode from PLC
(on, off, indicating)

YesYesNoYesYesNoNoYesNo

Reading system status list SSL
(if existing)

NoNoNoYesYesNoNoYesNo

Get diagnostic data

NoNoNoYesYesNoNoYesNo

Unlocking a protected connection
via (user) password transfer

Yes
*5)
YesYesYesYesNoNoYesNo

Read a list of created PLC objects.
(All or specific block type
e.g. only OBs)

YesYesYesYesYesNoNoYesNo

Read length of
a specific block

NoNoYesYesYesNoNoYesNo

Read a specific block in
MC7-format and save to a select file
(Backup)

NoNoYesYesYesNoNoYesNo

Get specific
block properties e.g.
(version, author,
Create language and many more)

Yes
restricted
Yes
restricted
YesYesYesNoNoYesNo

Restore block data
from a selectable MC7-file
(Restore)

NoNoYesYesYesNoNoYesNo

Restore in
different blocks

NoNoYesYesYesNoNoYesNo

Delete blocks

NoNoYesYesYesNoNoYesNo
*1) Legacy Communication not for S7-1200 G2
*2) WinAC RTX from version 2010 onwards
*3) Logo! Controller from 0BA7
*4) Not available for S7-1200
*5) Connections to simulated controllers only without password
*6) Subvariables directly from the result – even if only a parent node (DB/Struct/Array) was read. See: https://github.com/Indi-An/PLCcomforS7-examples-dotnet
*7) Due to the lack of availability of S7-200 SMART controllers within Europe, these controllers are not officially supported.


The following data types are supported for Put/Get optimized read and write functions:

Data TypeAccess
Raw (Byte Array)Read and Write
BitRead and Write
ByteRead and Write
WordRead and Write
DWordRead and Write
LWordRead and Write
INTRead and Write
DINTRead and Write
LINTRead and Write
RealRead and Write
LRealRead and Write
BCD8Read and Write
BCD16Read and Write
BCD32Read and Write
BCD64Read and Write
DateRead and Write
TimeRead and Write
LTimeRead and Write
Date_And_TimeRead and Write
LDate_And_TimeRead and Write
Time_OF_DAYRead and Write
LTime_OF_DAYRead and Write
DTLRead and Write
S5TimeRead and Write
CharRead and Write
StringRead and Write
S7_StringRead and Write
S7_WStringRead and Write


The following data types are supported for symbolic optimized read and write functions:

Data TypeAccess
Array[n..m]Read and Write the entire structure or individual elements
BoolRead and Write
ByteRead and Write
WordRead and Write
DWordRead and Write
LWordRead and Write
SIntRead and Write
IntRead and Write
DIntRead and Write
LIntRead and Write
USIntRead and Write
UIntRead and Write
UDIntRead and Write
ULIntRead and Write
RealRead and Write
LRealRead and Write
DateRead and Write
TimeRead and Write
LTimeRead and Write
Date_And_TimeRead and Write
LDate_And_TimeRead and Write
Time_Of_DayRead and Write
LTime_Of_DayRead and Write
S5TimeRead and Write
CharRead and Write
WCharRead and Write
StringRead and Write
WStringRead and Write
TimerRead and Write
CounterRead and Write
CREFRead and Write the entire structure or individual elements
NREFRead and Write the entire structure or individual elements
DTLRead and Write the entire structure or individual elements
ErrorStructRead and Write the entire structure or individual elements
IEC_COUNTERRead and Write the entire structure or individual elements
IEC_DCOUNTERRead and Write the entire structure or individual elements
IEC_LCOUNTERRead and Write the entire structure or individual elements
IEC_LTIMERRead and Write the entire structure or individual elements
IEC_SCOUNTERRead and Write the entire structure or individual elements
IEC_TIMERRead and Write the entire structure or individual elements
IEC_UCOUNTERRead and Write the entire structure or individual elements
IEC_UDCOUNTERRead and Write the entire structure or individual elements
IEC_ULCOUNTERRead and Write the entire structure or individual elements
IEC_USCOUNTERRead and Write the entire structure or individual elements
StructReading permitted for the entire structure or individual elements, writing only for individual elements


Passing the license key:


Before using the PLCcom library, you must have a license key for the current version. You can either purchase this license key as a time-limited trial key or purchase a license key in advance.

This license key must be passed to the library as follows:


C#
//Note: with blank fields the library runs 15 minutes during a debugging session.
authentication.User = "your user name";
authentication.Serial = "your user serial key";



First programming steps:


Embedding the PLCcom library in your project couldn’t be easier. It’s done with a few lines of code as shown in this few steps:



table1



Syntax: Create and initialize PLCcom-device-Object

Example Put/Get Access
C#
PLCcomDevice device = new TCP_ISO_Device("192.168.1.100", 0, 2,  ePLCType.S7_300_400_compatibel);
Example Symbolic Access
C#
// Create a device object for the modern TLS access (TIA version 17 or higher)
SymbolicDevice mySymbolicDevice = new Tls13Device("192.168.1.10");

// Connect
ConnectResult connectResult = mySymbolicDevice.Connect();

if (connectResult.Quality != OperationResult.eQuality.GOOD)
{
    Console.WriteLine($"Connect not successfull! Quality:  {connectResult.Quality} Message: {connectResult.Message}");
    return;
}

Optimized reading and writing of data


For optimized reading and writing, the read and write accesses in a ReadWriteRequestSet object are grouped together.
The optimized access to the PLC data is initialized via one or more ReadDataRequest and / or WriteDataRequest objects.
These requests are passed to the ReadWriteRequestSet-Object and triggered with the command ReadWriteData and processed optimally on request.
The result of the operation is returned to the developer as ReadWriteResultSet, where the individual ReadDataResult and / or WriteDataResult objects are located for further evaluation.

Note: Function not available for PPI connections, please refer to the function overview on our website www.plccom.net





table



Optimization options



The ReadWriteRequestSet object has been equipped with various parameterization and optimization options. The method RequestSet.SetOperationOrder(eOperationOrder) can be used to specify whether the write or read accesses are performed first. By default, the data is first written and then read. The following methods are used to parameterize the data optimization to be performed: RequestSet.SetReadOptimizationMode(eReadOptimizationMode) and RequestSet.SetWriteOptimizationMode(eWriteOptimizationMode).
By default, the optimizations are disabled "NONE".

The enum eReadOptimizationMode has the following members:
  • NONE:
    No optimization, all read requests are read one after the other. Safe but slow.
  • CROSS_AREAS:
    In CROSS_AREAS mode, the read requests are merged across areas. Advantage: fragmented areas (e.g., data across multiple datablocks) can be read and written simultaneously
  • COMBINE_AREAS:
    In COMBINE_AREAS mode, read requests from the same areas are combined. Advantage: Fast and high-performance access to data of the same areas (for example, data in the same datablock)
  • AUTO:
    PLCcom automatically selects the best optimization method. Only the minimum required PLC read accesses are carried out.
    Only in Expert edition available


The enum eWriteOptimizationMode has the following members:
  • NONE:
    No optimization, all read requests are written one after the other. Safe but slow.
  • CROSS_AREAS:
    In CROSS_AREAS mode, the read requests are merged across areas. Advantage: fragmented areas (e.g. data across multiple datablocks) can be read and written simultaneously


Example

C#
PLCcomDevice device = new TCP_ISO_Device("192.168.1.100", 0, 2, ePLCType.S7_300_400_compatibel);

ReadWriteRequestSet myRequestSet = new ReadWriteRequestSet();

//set optimize options
myRequestSet.SetOperationOrder(eOperationOrder.WRITE_BEVOR_READ);
myRequestSet.SetReadOptimizationMode(eReadOptimizationMode.AUTO);
myRequestSet.SetWriteOptimizationMode(eWriteOptimizationMode.CROSS_AREAS);

//declare a ReadRequest object set the request parameters, 
//in this case => read 10 Bytes from DB1 at Byte 0
ReadDataRequest readRequest = new ReadDataRequest(eRegion.DataBlock,  //Region                                                                       
     1,                  //DB only for datablock operations otherwise 0                                                                       
     0,                  //read start adress                                                                       
     eDataType.BYTE,     //desired datatype                                                                       
     10);                //Quantity of reading values

//add the read request to the request set
myRequestSet.AddRequest(readRequest);

//declare a WriteRequest object set the request parameters, 
//in this case => write 4 bytes to DB100 at address 0
WriteDataRequest myWriteRequest = new WriteDataRequest(eRegion.DataBlock, //Region
    100,             //DB                                                                        
    0);              //start address

//add writable Data here
//in  this case => write 4 bytes in DB100
myWriteRequest.addByte(new byte[] { 11, 12, 13, 14 });

//add the write request to the request set
myRequestSet.AddRequest(myWriteRequest);

//....... add more requests to request set

//read, write and getting the results
ReadWriteResultSet results = device.ReadWriteData(myRequestSet);

// evaluate the results of read operations...
foreach (ReadDataResult res in results.GetReadDataResults())
{
   //for getting read results see chapter simple read
}

//...and evaluate the results of write operations
foreach (WriteDataResult res in results.GetWriteDataResults())
{
   //for getting write results see chapter simple write
}

Optimized reading of symbolic variables


In the current version of PLCcom for S7, symbolic read access via ReadSymbolicRequest can be optimized to reduce the number of PLC read operations when reading many variables. This can improve cycle time and reduce network overhead.
Optimization is enabled by passing an additional parameter to the constructor of ReadSymbolicRequest. If no optimization mode is specified, eSymbolicReadOptimizationMode.NONE is applied automatically.

Note: The optimization mode only affects symbolic read access. Write access is not affected.

Limitations:
  • The optimization options are only available in the Expert Edition.
  • The SMART optimization mode is only available for TLS access (SymbolicDevice is Tls13Device).
Optimization possibilities (symbolic access):
The enum eSymbolicReadOptimizationMode provides the following members (in ascending order of optimization strength):
  • NONE: No optimization. Each variable is read individually (maximum transparency, slower for large variable sets).
  • OBJECT_BASED: PLCcom can group variables within a root object (e.g., within the same data block/structure/array).
  • CROSS_OBJECT: Like OBJECT_BASED, variables can also be grouped across multiple root objects (e.g., multiple data blocks).
  • SMART: Intelligent execution plan for best performance (TLS only with Tls13Device).
Important note on using optimization for symbolic access:
During the first read operation with a ReadSymbolicRequest, PLCcom creates an internal execution plan based on the chosen optimization mode and caches it for reuse. This plan is discarded as soon as the variable list in the request changes (e.g., variables are added/removed/modified). Therefore, optimizations are most beneficial when the same request instance is reused across cycles; the first read may be noticeably slower than subsequent cycles.

❌ Example Wrong: Recreate request in each cycle
C#
// The plan is recreated in each cycle -> unnecessary overhead
for (int i = 0; i < 1000; i++)
{
    var req = new ReadSymbolicRequest(eSymbolicReadOptimizationMode.CROSS_OBJECT);
    req.AddFullVariableName("DataBlock_1.ByteValue");
    req.AddFullVariableName("DataBlock_1.RealValue");
    req.AddFullVariableName("DataBlock_1.SIntValue");
    req.AddFullVariableName("DataBlock_1.UDIntValue");

    var res = mySymbolicDevice.ReadData(req);
    // ... evaluation ...
}
✅ Example Correct: Create request once, then reuse it
C#
// Create request once (plan is built during the first read)
var reqReuse = new ReadSymbolicRequest(eSymbolicReadOptimizationMode.CROSS_OBJECT);
reqReuse.AddFullVariableName("DataBlock_1.ByteValue");
reqReuse.AddFullVariableName("DataBlock_1.RealValue");
reqReuse.AddFullVariableName("DataBlock_1.SIntValue");
reqReuse.AddFullVariableName("DataBlock_1.UDIntValue");

// Then read again (subsequent cycles benefit from the plan)
for (int i = 0; i < 1000; i++)
{
    var res = mySymbolicDevice.ReadData(reqReuse);
    // ... evaluation ...
}

Complete Example

C#
// Create a device object for the modern TLS access (TIA Version 17 or higher).
SymbolicDevice mySymbolicDevice = new Tls13Device("192.168.1.100");

// Or, if you want to use the legacy access for older TIA / firmware versions:
// SymbolicDevice mySymbolicDevice = new LegacySymbolicDevice("192.168.1.100");

// Connect
ConnectResult connectResult = mySymbolicDevice.Connect();
if (connectResult.Quality != OperationResult.eQuality.GOOD)
{
    Console.WriteLine(string.Concat(
        "Connect not successful! Quality: ", connectResult.Quality,
        " Message: ", connectResult.Message));
    return;
}

// Choose an optimization mode.
// You can change this single line to test the impact on performance.
eSymbolicReadOptimizationMode optimizationMode = eSymbolicReadOptimizationMode.CROSS_OBJECT;

// Build request (the optimization mode is applied here).
ReadSymbolicRequest readRequest = new ReadSymbolicRequest(optimizationMode);
readRequest.AddFullVariableName("DataBlock_1.ByteValue");
readRequest.AddFullVariableName("DataBlock_1.RealValue");
readRequest.AddFullVariableName("DataBlock_1.SIntValue");
readRequest.AddFullVariableName("DataBlock_1.UDIntValue");

// Read from device
var readResult = mySymbolicDevice.ReadData(readRequest);

// Print values
foreach (PlcCoreVariable variable in readResult.Variables)
{
    Console.WriteLine(string.Concat(
        variable.VariableDetails.FullVariableName,
        " Value: ",
        variable.Value));
}

Start PLC


A PLC can be started by calling StartPLC(). An OperationResult object is received as the result.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
OperationResult res = device.StartPLC();

Stop PLC


A PLC can be stopped by calling StopPLC(). An OperationResult object is received as the result.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
OperationResult res = device.StopPLC();

Get PLC time


To get the current time of the PLC you can use the function getPLCClockTime(). A PLCClockTimeResult object will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
PLCClockTimeResult res = device.GetPLCClockTime();

Set PLC time


The time of the PLC can be set by using the SetPLCClickTime command. A date object has to be given as a parameter to the function. A PLCClockTimeResult object will be returned as the result.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
OperationResult res = device.SetPLCClockTime(DateTime.Now);

Get basic PLC information


With the command GetBasicInfo you can get information like type, module version or firmware version of the CPU. A BasicInfoResult object is returned as the result.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
BasicInfoResult res = device.GetBasicInfo();

Get CPU mode


To get the current mode of the CPU (e.g. run, startup, stop, etc.) you can use the command GetCPUMode. A CPUModeInfoResult object will be returned as the result.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
CPUModeInfoResult res = device.GetCPUMode();

Get LED state


To get the current LED state (e.g. on, off, flashing, etc.) you can use the command GetLEDInfo. A LEDInfoResult object will be returned as the result

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
LEDInfoResult res = device.GetLEDInfo();

Get system status list


The function GetSystemStatusList enables you to access the system status list in the PLC. For further information on the system status list contact the PLC manufacturer or read the corresponding manual.
As a result a SystemStatusList object will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
SystemStatusListResult res = device.GetSystemStatusList(SSL_ID, SSL_Index);

Get diagnostic info


The command GetDiagnosticInfo serves for requesting the current diagnostic data list from the CPU. As the result a DiagnosticInfoResult object will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
DiagnosticInfoResult res = device.GetDiagnosticInfo();

PLCcom data server (only in expert version)


With the PLCcom data server you’re able to monitor memory ranges on the PLC. Whenever data changes an event is fired to inform the user. The communication between PLCcom and the PLC is optimized in a way that needed requests are reduced to a minimum.

Furthermore it’s possible to define connectors for filesystem or SQL database logging. It’s also possible to save an image of current variables and values into the filesystem or SQL database. For extended security these data can be stored encrypted. Methods for decryption are enclosed.


table



Example

C#
PLCcom.PLCComDataServer.PLCComDataServer myDataServer = null;
PLCcomDevice device = null;

Console.WriteLine("Start Connect to TCPIP device...");
//Create an PLCcom-device instance
device = new TCP_ISO_Device("192.168.1.100", 0, 2, ePLCType.S7_300_400_compatibel);

//set autoconnect to true and idle time till disconnect to 10000 milliseconds
device.setAutoConnect(true, 10000);

//Create an instance depending on the device type
Console.WriteLine("Create DataServer PLCDataServerTCP1...");
myDataServer = new PLCcom.PLCComDataServer.PLCComDataServer_TCP("PLCDataServerTCP1", (TCP_ISO_Device)device, 500);

//register incoming events
myDataServer.OnConnectionStateChange += new PLCcom.PLCComDataServer.PLCComDataServer.ConnectionStateChangeEventHandler(myDataServer_OnConnectionStateChange);
myDataServer.OnReadDataResultChange += new PLCcom.PLCComDataServer.PLCComDataServer.ReadDataResultChangeEventHandler(myDataServer_OnReadDataResultChange);
myDataServer.OnIncomingLogEntry += new PLCcom.PLCComDataServer.PLCComDataServer.OnIncomingLogEntryDelegate(myDataServer_OnIncomingLogEntry);

//define new request
Console.WriteLine("Create new Request Read 4 Bytes from DB1 at address 0 ...");
ReadDataRequest RequestItem1 = new ReadDataRequest(eRegion.DataBlock,          //Region
                                                   1,                          //datablock
                                                   0,                          //startAdress
                                                   eDataType.BYTE,             //target data type
                                                   4);                         //Quantity

//add new request to plccom data server
myDataServer.AddReadDataRequest(RequestItem1, "Request1");

//define new request
Console.WriteLine("Create new Request Read 10 DWord from Flags_Markers at address 4 ...");
ReadDataRequest RequestItem2 = new ReadDataRequest(eRegion.Flags_Markers,      //Region
                                                   0,                          //datablock
                                                   4,                          //startAdress
                                                   eDataType.DWORD,            //target data type
                                                   4);                         //Quantity

//add new request to plccom data server
myDataServer.AddReadDataRequest(RequestItem2, "Request2");


//add one or more Logging connectors with logging and writing of a data image into filesystem or database
//in this case create a new FileSystemConnector instance
PLCcom.ExternalLogging.LoggingConnector con = new PLCcom.ExternalLogging.FileSystemConnector(
   System.Threading.Thread.GetDomain().BaseDirectory, //Target folder 
   "FileSystemConnector1",                             //unique connector name
   ';',                                                //text separator recommendation ';'
   true,                                               //activate progressive logging
   true,                                               //activate image writing
   PLCcom.ExternalLogging.eImageOutputFormat.dat,      //output format .dat or .xml
   10,                                                 //restrict the maximum number of files. -1 = Disabled. 
   24,                                                 //restrict the maximum age of files. -1 = Disabled. 
   30,                                                 //restrict the maximum size of files. -1 = Disabled. 
   string.Empty); //If you enter an encryption password, the data is stored in encrypted form. 

//add Connector to Dataserver
myDataServer.AddOrReplaceLoggingConnector(con);

//start PLCcom data server
myDataServer.StartServer();
Console.ReadLine();

//stop PLCcom data server
myDataServer.StopServer();

Send password (only in expert version)


The function sendPassWord allows users to unlock password protected PLCs by passing the password to the function. An OperationResult object will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
OperationResult res = device.sendPassWord("PW");

Get object list from PLC (only in expert version)


With the command GetBlockList you’re able to get a complete object list, or a list of specific block type (e.g. data block), from the PLC. A BlockListResult object is returned which contains all data.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
BlockListResult res = device.GetBlockList(BlockType);

Get length of an object (only in expert version)


The command GetBlockLength returns a BlockListLengthResult object containing the length of the requested object from the PLC.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
BlockListLengthResult res = device.GetBlockLenght(BlockType, BlockNumber);

Backup an object (only in expert version)


With the function ReadPLCBlock_MC7 the code of a specific block can be accessed and saved in mc7 format. Further block details like code, language, author, etc. are read. A ReadPLCBlockResult object will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
eBlockType BlockType = eBlockType.FB;
int BlockNumber = 1;

//open SaveFileDialog
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "*.mc7|*.mc7|*.bin|*.bin|*.*|*'.*";
DialogResult dr = sfd.ShowDialog();
if (dr == DialogResult.OK)
{
   //read Block into ReadPLCBlockResult
   ReadPLCBlockResult res = device.ReadPLCBlock_MC7(BlockType, BlockNumber);

  if (res.Quality == OperationResult.eQuality.GOOD)
     {
  //save buffer in specified file
  System.IO.FileStream fs = new System.IO.FileStream(sfd.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
  fs.Write(res.Buffer, 0, res.Buffer.Length);
  fs.Close();
  MessageBox.Show("Block " + BlockType.ToString() + BlockNumber.ToString() + "successful saved" + sfd.FileName, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
       }
 }

Restore an object (only in expert version)


Supplemental to the backup function, the function WritePLCBlock_MC7 restores a backup file back into the PLC. It’s also possible to restore the data with a changed block number. To pass the data a WritePLCBlockRequest is used. An OperationResult object will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "*.mc7|*.mc7|*.bin|*.bin|*.*|*'.*";
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
 System.IO.FileStream fs = new System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);

 byte[] buffer = new byte[fs.Length];
 fs.Read(buffer, 0, (int)fs.Length);
 fs.Close();

 WritePLCBlockRequest Requestdata = new WritePLCBlockRequest(buffer);
 //Write Buffer into PLC
 OperationResult res = device.WritePLCBlock_MC7(Requestdata);

 if (res.Quality == OperationResult.eQuality.GOOD)
 {
  MessageBox.Show("Block " + Requestdata.BlockInfo.Header.BlockType.ToString() + Requestdata.BlockInfo.Header.BlockNumber.ToString() + resources.GetString("successful_saved_PLC") + ofd.FileName, 
 }
}

Delete an object (only in expert version)


The function DeleteBlock enables one to delete a specific PLC object. An OperationResult object with additional information will be returned.

Not available for all CPUs. Please note the function overview on our website https://www.indi-an.com/en/plccom/for-s7/overview-of-features/.




table



Example

C#
OperationResult res = device.DeleteBlock(BlockType, BlockNumber);

Namespaces

PLCcom Global Namespace for PLCCom for S7 Assembly
PLCcom.Core Core components shared by PLCcom for S7 (common infrastructure and utilities).
PLCcom.Core.S7Plus S7+ core implementation (symbolic access, data model, and communication building blocks).
PLCcom.Core.S7Plus.AddressSpace Address space and node handling for symbolic navigation and variable resolution.
PLCcom.Core.S7Plus.Alarm Alarm and event related types for S7+ controllers.
PLCcom.Core.S7Plus.DataTypes PLC data type definitions and conversion helpers for S7+ datatypes.
PLCcom.Core.S7Plus.Interfaces Public interfaces used by the S7+ core (abstractions for extensibility and testing).
PLCcom.Core.S7Plus.Subscription Subscription and cyclic read infrastructure for S7+ variables and events.
PLCcom.Core.S7Plus.Tls TLS/security related helpers for encrypted S7+ communication.
PLCcom.Core.S7Plus.Variables Variable model for S7+ (typed variables, metadata, and value handling).
PLCcom.Core.S7Plus.Variables.Arrays Array variable types and array-specific handling for S7+.
PLCcom.Core.S7Plus.Variables.SparseArrays Sparse array representations and helpers for efficient access to large arrays.
PLCcom.Core.S7Plus.Variables.Structs Struct/UDT variable types and hierarchical child variable handling.
PLCcom.Core.S7Plus.Variables.Structs.Arrays Arrays of structs and related typed handling for S7+.
PLCcom.Enums.S7Plus Enumerations used by the S7+ API and implementation.
PLCcom.ExternalLogging Extension of PLCCom namespace for logging in external databases or to the file system
PLCcom.PLCComDataServer Extension of PLCCom namespace to create instances of PLCComDataServer objects
PLCcom.Requests.S7Plus Request types for S7+ operations (read/write, browse, subscription, etc.).
PLCcom.Results.S7Plus Result/response types returned by S7+ requests (read results, status, metadata).