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

Integer transactionID - The TxID of the response. The TxID from the received request in the payload of the message handler must be specified here.

Integer systemBytes - The SystemBytes of the response. The SystemBytes from the received request in the payload of the message handler must be specified here.

String streamFunction - The stream and function of the SECS message to send, for example: "S1F14".

Any body - This 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.

String equipment - Name 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