def set_session_variables(self, search_id, device_search_id): """ chnaged from:(self, search_id, device_search_id, plc_tag_path, display_cc, detailed_view) This function is used to set the custom session variables in the perspective session. Args: self: This is a reference to the object that is calling this function. search_id: Type string, this should be a UDT name. device_search_id: Type string, display path of the alarm. Returns: None. Raises: None. """ self.session.custom.searchId = search_id self.session.custom.deviceSearchId = device_search_id def navigate_to_alarm(self, event): """ This function is used to navigate to a detailed view when double clicking a row in the active alarm table. It takes the Ignition alarm id to return the alarm information from the "System/ActiveAlarms" tag. Args: self: This is a reference to the object that is clicked on the screen. event: This is a reference to the event that is clicked on the screen. Returns: None. Raises: None. """ alarm_id = event.value.get("AlarmId") tags_to_read = system.tag.readBlocking(["Configuration/DetailedViews","System/ActiveAlarms"]) pages_decoded = system.util.jsonDecode(tags_to_read[0].value) active_alarms = system.util.jsonDecode(tags_to_read[1].value) UDT = active_alarms.get(alarm_id,{}).get("UDT_tag") bit_position = active_alarms.get(alarm_id,{}).get("bitPosition") name = active_alarms.get(alarm_id,{}).get("Name") page_id = active_alarms.get(alarm_id,{}).get("PageId","None") page = UDT.split("_")[0] if page_id != "None" and len(page_id)>0: page_id = page_id.split("-")[0] udt_to_read = "%s/Parameters.AREA" % (page_id) else: udt_to_read = "%s/Parameters.AREA" % (page) system.perspective.print(udt_to_read) read_area = system.tag.readBlocking([udt_to_read]) area = read_area[0].value page_name = "/"+page display_path = active_alarms.get(alarm_id,{}).get("DisplayPath") check_keys = pages_decoded.get(page,0) if page_id != "None" and page_id != "": page = page_id.split("-")[0] url_to_navigate = "/DetailedView/%s/%s" % (page_id, page) set_session_variables(self, UDT, display_path) system.perspective.navigate(page = url_to_navigate) system.perspective.sendMessage("plc-to-display", payload = {"device":page_id, "show_controls":True, "area":area}, scope = "page") elif check_keys != 0: set_session_variables(self, UDT, display_path) url_to_navigate = "/DetailedView/%s/%s" % (page, page) system.perspective.navigate(page = url_to_navigate ) system.perspective.sendMessage("plc-to-display", payload = {"device":page, "show_controls":True, "area":area}, scope = "page") else: for i in pages_decoded: page_list = pages_decoded[i] if page in page_list: set_session_variables(self, UDT, display_path) url_to_navigate = "/DetailedView/%s/%s" % (i,i) system.perspective.navigate(page = url_to_navigate) system.perspective.sendMessage("plc-to-display", payload = {"device":i, "show_controls":True, "area":area}, scope = "page")