Skip to main content
Version: 7.9

system.secsgem.getResponse

This function is used in Python Scripting.

Description

Attempts to retrieve a response message from the Gateway. The transaction id from the sent message is used to retrieve the response.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.secsgem.deleteToolProgram(ppid)

Parameters

TypeParameterDescription
IntegertransactionIDThe transactionID of the request and response. The transactionID is used to retrieve the response. Typically used in conjunction with system.secsgem.sendRequest to generate a transactionID.
StringequipmentName of equipment connection.
IntegertimeoutSpecifies in seconds how long to wait for a response before returning None. If omitted the timeout will be 5 seconds.
IntegerpollSpecifies in milliseconds how often to poll the system for a response. If omitted the poll will be 150 milliseconds.

Returns

Object - A Python Object representing a SECS response message.

Scope

Gateway, Designer, Client

Code Examples

Code Snippet 1
# Replace the string below with the equipment name you want to send the request to.
myEquipment = "EquipmentOne"

# Define the contents of the body. We're using an empty string, since S1F1 doesn't expect a body, and we need to define something (Python's None will result in an exception).
body = ""

# Store the returned transactionID in a variable.
transactionID = system.secsgem.sendRequest("S1F1", True, body, myEquipment)

# Use the transactionID to lookup the response.
response = system.secsgem.getResponse(transactionID, myEquipment, 2)

# We're printing out the response here, but you could do something more useful instead.
print response
Code Snippet 2
# This example demonstrates how to retrieve the value of a Status Variable via S1F3.
# If using the simulator that comes with the SECS/GEM module, this example will return the current time from the Clock Status Variable.

# Replace the string below with the equipment name you want to send the request to.
myEquipment = "EquipmentOne"

# Define the contents of the body. The Clock Status Variable has an SVID of 1.
body = [{"format":"U4", "value":1}]

# Store the returned transactionID in a variable.
transactionID = system.secsgem.sendRequest("S1F3", True, body, myEquipment)

# Retrieve the response.
response = system.secsgem.getResponse(transactionID, myEquipment, 2)

## We need to do some digging to get the value of the Clock:
## -The response is a Dictionary.
## -Inside of the response is the key "body".
## -The value of "body" is a Python List containing another Dictionary (which has our Clock value)
## Thus we use [0] to access the Dictionary.
## -The Dictionary contains a key named "value", which is the value of our clock.
theDatetime = response["body"][0]["value"]

# We parse the date into something more human readable, and print it out.
print system.date.parse(theDatetime, "yyMMddHHmmss")