Device S7 - Data Type Conversion
In use cases where the S7 device resource uses a WORD data type with a Int16 number, a WORD has two bytes, should converts to a integer.
The following extract from a device profile defines the NodeName DB4.DBW2 as valueType Int16:
Example - Device Profile
name: S7-Device
manufacturer: YIQISOFT
description: Example of S7 Device
model: Siemens S7
labels: [ISO-on-TCP]
deviceResources:
- name: word
description: PLC word
isHidden: false
properties:
valueType: Int16
readWrite: RW
attributes:
NodeName: DB4.DBW2
Read Command
A Read Command is executed as follows:
- The Client executes a Read Command;
- The device service sends the Read Command to read a
WORDdata; - The S7 Device returns a two byte data;
- The device service parses the data;
- The device service cast the data to a Int16 value;
- The device service returns returns json format to the Client.

Write Command
A Write Command is executed as follows:
- The Client executes a Write Command to write a In16 value;
- The device service cast Int16 value to a two bytes;
- The device service convert to binary;
- The device service send write a request to the S7 device;
- The device service returns result json to the Client.

When to Transform Data
You generally need to transform data in any time, because S7 devive only receives its particular data type.
Supported Transformations
The supported transformations are as follows:
From NodeName |
Bit(s) | To valueType |
Address Sample |
|---|---|---|---|
| Bool | 1 | Bool | DB1.DBX0.0 |
| Byte | 8 | Uint | DB1.DBB1 |
| Word | 16 | Int16 | DB1.DBW2 |
| DWord | 32 | Int32 | DB1.DBD4 |
| Int | 16 | Int16 | DB1.DBW6 |
| DInt | 32 | Int32 | DB1.DBD8 |
| Real | 32 | Float32 | DB1.DBD20 |