SAT9/.resources/dbcb4cd64af26986092e022d84ec4d4cbb4a77d3d4a6d8d6a3d54fc6f8ae2e8c

32 lines
1000 B
Plaintext

def get_alarms_to_shelve(self):
"""This function is used to perform the shelving function on
single or multiple alarms. It receives an alarm data dictionary
from a row in the alarm table and generates a shelving dict to trigger
a tag change script on the gateway.
Args:
self: Reference to the component that is calling this function
Returns:
Executes the shelving function. Does not return any results.
Raises:
KeyError: Raises an exception.
"""
selected_rows = self.custom.alarms_to_shelve
shelve_time = self.props.value
alarms_to_shelve = []
messages_to_shelve = []
for i in selected_rows:
# alarm_id = i.get("AlarmId")
alarm_id = i.get("value",{}).get("SourceId",{}).get("value")
alarm_id = alarm_id.replace(" ", "")
message = i.get("value",{}).get("Alarm_id",{}).get("value")
alarms_to_shelve.append(alarm_id)
messages_to_shelve.append(message)
duration = shelve_time
self.props.value = ""
return alarms_to_shelve ,messages_to_shelve, duration