# 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")