Skip to main content

Siemens S7 API reference

Siemens S7 connector programming specifications

FairCom provides specific API actions to configure the Siemens S7 connector. Be sure to enable the Siemens S7 service before requesting data from a Siemens S7 server.

Request examples

Note

The FairCom createInput JSON action is used to define the specifics of a connector device and the desired data.

Minimal request

{
  "api": "hub",
  "action": "createInput",
  "params": {
    "inputName": "mySiemensS7",
    "serviceName": "siemensS7",
    "settings": {
      "ipAddress": "127.0.0.1",
      "rack": 0,
      "slot": 2,
      "dataCollectionIntervalMilliseconds": 5000,
      "propertyMapList": [
        {
          "propertyPath": "flag1",
          "memoryArea": "db",
          "dataBlockNumber": 1,
          "offset": 0,
          "dataType": "word"
        }
      ]
    },
    "tableName": "siemensS7Table"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "api": "hub",
  "action": "createInput",
  "params": {
    "inputName": "mysiemensS7",
    "serviceName": "siemensS7",
    "settings": {
      "ipAddress": "127.0.0.1",
      "rack": 0,
      "slot": 2,
      "packageSize": 500,
      "dataCollectionIntervalMilliseconds": 1000,
      "dataCollectionBufferCount": 5,
      "propertyMapList": [
        {
          "propertyPath": "status",
          "memoryArea": "db",
          "dataBlockNumber": 1,
          "offset": 0,
          "amount": 1,
          "dataType": "bit",
          "bitPosition": 3
        },
        {
          "propertyPath": "nerrors",
          "memoryArea": "db",
          "dataBlockNumber": 1,
          "offset": 2,
          "amount": 3,
          "dataType": "doubleword"
        },
        {
          "propertyPath": "temperature",
          "memoryArea": "db",
          "dataBlockNumber": 1,
          "offset": 20,
          "amount": 2,
          "dataType": "real"
        }
      ]
    },
    "databaseName": "ctreeSQL",
    "ownerName": "admin",
    "tableName": "siemensS7Table",
    "retentionPolicy": "autoPurge",
    "retentionPeriod": 30,
    "retentionUnit": "day",
    "metadata": {
    }
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

A response to a request is "0" when successful. A non-zero value response indicates an error occurred.

{
    "result": {},
    "requestId": "00000007",
    "errorCode": 0,
    "errorMessage": ""
}

Not yet available.

Siemens S7 connector programming specifications for FairCom Edge

API referenceJSON Hub APIconnectorSiemens S7Siemens API referenceS7 APIS7 connector api reference

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Note

See createInput for "params" properties that are common to all connectors.

Table 1. Siemens S7 specific connector "params" properties summary

Property

Description

Default

Type

Limits (inclusive)

dataCollectionBufferCount

(optional) specifies the number of times the collector retrieves and caches data from the device before writing the data to the integration table

1

integer

1 to 65535

dataCollectionIntervalMilliseconds

(optional) specifies the number of milliseconds to wait until reading PLC data again. For example, 15000 means 15 seconds

10000

integer

co and negative values are invalid

dataPersistenceStrategy

(optional) specifies when the connector writes collected data to the specified table

"onSchedule"

string

"onSchedule"
"onChange"

immediatelyCollectDataOnStart

(optional) configures the input to collect data immediately when the server or connector starts. This occurs even if the data persistence strategy is to collect data changes

false

Boolean

true
false

serviceName

specifies which type of input to create

 

string

"siemensS7"

settings

specifies properties needed to configure the data source of the input

 

array of objects

settings
.ipAddress

specifies the PLC/Equipment IPV4 Address.

 

string

settings
.packageSize

(optional) specifies the package size in bytes used to communicate with the PLC. 

Higher numbers allow the connector to retrieve more data in fewer requests.

If not specified, the PLD PDU size is used.

integer

240 to 960

settings
.propertyMapList

specifies which data the connector requests and where to put it in the generated JSON.

 

array of objects

settings
.propertyMapList
.amount

(optional) specifies the number of consecutive "dataType" values the connector retrieves.

The connector retrieves 3 one-byte values when "amount" is 3 and "dataType" is "byte".  

The connector retrieves 2 four-byte values when "amount" is 2 and "dataType" is "real".

If "dataType" is "bit", "amount" must be 1 because the connector retrieves one 8-bit byte for each bit. See bitPosition below.

1

integer

1 to 65535

settings
.propertyMapList
.bitPosition

(optional) if "dataType":"bit" , "bitPosition" defines which of the eight zero-based bits to read from the byte the connector retrieves.

0

integer

0 to 7

settings
.propertyMapList
.dataBlockNumber

specifies the number of the Data Block memory area where the connector retrieves data.

It is ignored unless "memoryArea":"db".

Required if "memoryArea": "db"

integer

1 to 65535

settings
.propertyMapList
.dataType

specifies the data type of memory retrieved by the connector.

If "memoryArea":"ct", "dataType" must be "counter"

If "memoryArea":"tm", "dataType" must be "timer".

 

string

"bit"

inside a byte

"byte"

8-bit integer

"ubyte"

unsigned 8-bit integer

"word"

16-bit integer

"uword"

unsigned 16-bit integer

"doubleword"

32-bit integer

"udoubleword"

unsigned 32-bit integer

"real"

32-bit float

"counter"

16-bit integer

"timer"

16-bit integer

settings
.propertyMapList
.memoryArea

specifies the type of memory area where the connector retrieves data.

 

string

"pe"

Process Inputs

"pa"

Process Outputs

"mk"

Flags "Merkers"

"db"

Data Block

"ct"

Counters

"tm"

Timers

settings
.propertyMapList
.offset

specifies the offset to the starting byte in the memory area where the connector retrieves data.

 

integer

0 to 4294967296

settings
.propertyMapList
.propertyPath

specifies the JSON path in the JSON document where the connector puts the data it collects. It is the tag name of the data being collected

 

string

JSON path

settings
.rack

specifies the PLC Rack number.

 

integer

0 to 7

settings
.slot

specifies the PLC Slot number.

 

integer

1 to 31



How to horizontally scroll a table

To scroll the table right or left, mouse over the table, hold down shift , and move the mouse wheel down or up.

The "propertyPath" property is a required string that specifies the JSON Path in the JSON document where the connector puts the data it collects. It is the tag name of the data being collected. You can use this property to take collected data and store it in any location in the JSON document generated by the connector. For example, the setting "propertyPath": "temperature" causes the server to take a value it collects, such as 20.1, and store it in a "temperature" property, such as { "temperature": 20.1 }.

Would you like to provide feedback?