Defining a trigger for a Siemens (TCP Send) unsolicited message

To define a trigger that executes when a Siemens unsolicited message is sent, follow the steps for defining a new trigger.
For complete information on defining projects and triggers, see Defining a trigger.

Every trigger identifies the trigger event type, which identifies when the trigger will be executed.

The PLC Logic Events category will list the available event types, based on the drivers that are installed on the node.
The Siemens driver supports the receipt of TCP Send unsolicited messages sent from Siemens PLCs. The Siemens (TCP Send) event type will support the receipt of TCP Send messages sent to a S7 Listener device using the TCP Protocol value. 

Siemens (TCP Send) event type trigger

To define a trigger that executes when a Siemens TCP Send unsolicited message is received, select the Siemens (TCP Send) trigger event type. The Event tab becomes active with parameters that accommodate the event type. 

Siemens (TCP Send) trigger parameters

Parameter Description
Device Name A list of all of the Siemens S7 Listener devices that have been defined on the node. The S7 Listener devices that process the TCP Send message must have a Protocol value of TCP.
For information about the S7 Listener device type and the Protocol parameter, see Using the Workbench to define a Siemens S7 Listener device.
Data Length (Bytes) Specifies the received messages, by length, that will execute the trigger.

This parameter allows the user to use the data length value contained in the message as a filter to associate specific triggers with specific messages. The first four bytes of the TCP Send message must contain the remaining length of the message. The portion of the message after the first four bytes is the data section of the message.

A value of 0 in this parameter means the trigger will execute whenever a message of any length is received by the S7 Listener device selected in the Device Name parameter.

Siemens (TCP Send) event type trigger event variables

When a Siemens (TCP Send) event type trigger executes, PLC data associated with the message is available as trigger event variables. The trigger event variables are available to trigger actions that have input or source parameters are: 

Event Variable Data type Description
Data BINARY This is the data from the Siemens PLC. It is sent by the ladder logic running on the PLC as part of the TCP Send message. The data type is binary, allowing the user to process it as a single data element, an array of elements of a specific data type, or a combination of different data types.
Data Length INT4 The number of bytes in the data portion of the message.
Device Name String, length 128 characters The name of the S7 Listener device that received the message.
IP Address String, length 32 characters The IP address of the PLC that sent the TCP Send message.

There are no output event variables associated with this event.

Siemens (TCP Send) event type trigger runtime behavior

A started trigger will execute only when a message is received by the Siemens S7 Listener device and the size of the message matches the value specified in the Data Length (Bytes) parameter. In this way, unique triggers can be defined to process specific messages.
For example: Trigger A can be defined to handle messages that are 100 bytes in length, while Trigger B can be defined to handle messages that are 500 bytes in length.
This event definition is flexible enough though to allow for one trigger to handle all messages, regardless of message length. This is done by entering a value of 0 in the Data Length (Bytes) parameter. This indicates that messages with any length received by the Siemens S7 Listener device will execute the trigger.

Note: All triggers that are defined and are in a started state, that match the message length criteria, whether by having an exact match or by having a value of 0 specified in the message Data Length parameter, will be fired when an S7 message is received.
For example: Trigger A is defined to execute upon receipt of a Siemens TCP Send message that is 100 words in length. Trigger B is also defined to execute upon receipt of a Siemens TCP Send message, but has a 0 value in the Data Length (Bytes) parameter. Both triggers are in a started state.

  • When the Siemens S7 Listener device receives a TCP Send message that is exactly 100 words in length, Trigger A and Trigger B will be executed.
  • When the Siemens S7 Listener device receives a second TCP Send message that is not 100 words in length, Trigger B will be executed.
    Now in this same example, the state of Trigger A is changed from Started to Stopped, while Trigger B remains in a Started state. When the Siemens S7 Listener receives a message that is 100 words in length, Trigger B will be executed.