Skip to main content
Version: 8.1

system.secsgem.sendResponse

This function is used in Python Scripting.

Description

Sends a JSON-formatted SECS response message to a message sent by a tool. An equipment connection must be configured for the tool in the Gateway, and this must be used within a Message Handler to create a Custom Message Response Handler.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.secsgem.sendResponse(transactionID, systemBytes, streamFunction, body, equipment)

Parameters

TypeParameterDescription
IntegertransactionIDThe TxID of the response. The TxID from the received request in the payload of the message handler must be specified here.
IntegersystemBytesThe SystemBytes of the response. The SystemBytes from the received request in the payload of the message handler must be specified here.
StringstreamFunctionThe stream and function of the SECS message to send. Example: "S1F14"
AnybodyThis contains the body of a SECS response. The argument can be a Python Object or JSON string representing the body of a SECS message. If this argument is a string then it will be converted to a Python Object using the system.util.jsonDecode function.
StringequipmentName of the equipment connection to use.

Returns

Nothing

Scope

Gateway, Perspective Session

Code Examples

Code Snippet - Sending a S1F1 Message
# This will create a logger that will print to the console that a custom response is happening for S6F12.
# It will then send the response with system.secsgem.sendResponse().
equipment= payload['Equipment']
txId = payload['TxID']
systemBytes = payload['SystemBytes']
message = payload['Message']

msg = "Equipment=" + equipment
msg += ", TxID=" + str(txId)
msg += ", SystemBytes=" + str(systemBytes)
msg += ", Message=" + message
logger = system.util.getLogger("SECSGEM.Gateway.S6F12Handler")
logger.info("S6F12Handler: Sending back response to S6F11 message:" + msg)

body = '{"format":"B", "value": 0, "doc":"ACKC6, Acknowledge Code", "codeDesc": "Accepted"}'
system.secsgem.sendResponse(txId, systemBytes, "S6F12", body, equipment)
logger.info("S6F12Handler: S612 response sent")

Keywords

system secsgem sendResponse, secsgem.sendResponse