SAT9/.resources/c061c6d70b93aa5fe02e343f2880fa3e7ec7f03c72d710feddaca4cd02d48b80

32 lines
1.1 KiB
Plaintext

def send_shelve_request(whid, ids, action, duration, messages):
"""
Creates a alarm shelve request to send to the web socket from a button in SCADA.
Args:
ids = List of strings. Unique material handling equipment ids.
request = String Type of request i.e Start, Stop, Reset.
Returns:
N/A
"""
"""{"action": "shelve", "parameters": {"sourceId": "PLC01", "siteId": "DNG2", "durationMinutes": 2,
shelvedTime:""}}"""
messages_to_send = {}
message_list = []
for i,j in enumerate(ids):
parameters = {}
message_payload = {}
parameters["sourceId"] = j
parameters["siteId"] = whid
parameters["id"] = messages[i]
if action == "shelve":
parameters["durationMinutes"] = duration
time_now = system.date.now()
parameters["shelvedTime"] = (system.date.toMillis(time_now)/1000)
message_payload["parameters"] = parameters
message_payload["action"] = action
message_list.append(message_payload)
messages_to_send["message_list"] = message_list
message_send_tag_path = "[%s_SCADA_TAG_PROVIDER]System/wbsckt_messages_send" % (whid)
system.tag.writeBlocking([message_send_tag_path],[system.util.jsonEncode(messages_to_send)])