SAT9/.resources/fa6a79c476ed4b2e3b249c2170c18b017f4837f61a31444a04ec3f31583c2cdf
2025-04-18 19:44:27 +04:00

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