Hello everyone,
I am trying to make an alarm popup that is attached to a view/component (analog indicator for ex) that we already are using the idea is the following:
- create custom properties on the component that have indirect tag bindings via a udt_path parameter on the component, this is how I will get whether the alarm is true and certain metadata that relates to the alarm etc.
- If the custom property that is related to the alarm value changes there is a change script that either adds or removes it from an items array.
- if any alarms on the component are true when you double click the component it will open a popup, that has an accordion in the view, which gets passed the items array custom property of the component on that double click.
The error that I am receiving is that on the double click often times it will have an error saying Error_InvalidPathSyntax root/Accordion.items[2].header.content.text Unable to build tag path, indirection reference(s) [1] did not produce a value.
When I log the items array right before the double click all of the header.content.text values are there. It only happens with the third item in the array and not every time that I click it. I am sure there is something under the hood that I am not aware of with the bindings that is leading this awry.
Thank you for the time
Here is some code
change script for alarm
Summary
prop = self.custom.alarms.bAlm_H
updated_items = []
if (currentValue.value == True):
item = alarm_popups.makeItem(prop, prop["tagname"], self.view.params.udt_path)
updated_items = self.custom.items + [item]
elif (currentValue.value == False):
updated_items = alarm_popups.removeItem(self.custom.items, prop, prop["tagname"])
else:
updated_items = self.custom.items
sorted_items = sorted(updated_items, key=lambda x: x["severity"], reverse=True)
self.custom.items = sorted_items
double click event
Summary
_logger = system.util.getLogger("Alarm Popup Click logger")
position = {'top':event.pageY,'left':event.pageX}
popup_id = self.custom.popup_id
items = self.custom.items
if(self.custom.in_alarm):
_logger.info(str(items))
system.perspective.openPopup(id=popup_id, view="alarm_accordion", position=position, params = {"items": items, "id": popup_id}, showCloseIcon = False, draggable = True)
these are the scripts that I am calling
Summary
def makeItem(alarm_type, tagname, udt):
item = {"severity": alarm_type["severity"],
"expanded": False,
"header": {
"content": {
"type": "text",
"text": tagname
}
},
"body": {
"viewPath": "alarm_popup", "viewParams": {
"alarm_name": alarm_type["alarm_name"],
"parent_path": udt
}
}
}
return item
def removeItem(items, alarm_type, tagname):
for i, item in enumerate(items):
if (item["header"]["content"]["text"] == tagname):
items.pop(i)
return items