I have made a custom property searchString on my alarm table and it is bound to a textbox’s text value. I have the following code:
def filterAlarm(self, alarmEvent):
#valid search string given
if self.searchString:
#lower everything
search = searchString.lower()
label = alarmEvent.get("Label").lower()
#look for searchString in label
if search in label:
#show if found
return True
else:
#hide if not found
return False
#show all if no search string given
else:
return True
Entering a value in the textbox does not change the events in the table. All alarm events are still shown. Am I missing something?
Do I need to use a propertyChange event to fire the extension function? If so, how do I call it?
The filterAlarm extension function should be getting invoked once per alarm every 2.5 refresh-rate-property milliseconds when the alarm status table automatically polls in the background. If you throw a debug print or similar (above any of your own code) is that happening?
def filterAlarm(self, alarmEvent):
#valid search string given
searchString = self.parent.parent.getComponent('Text Field').text
if searchString:
#lower everything
search = searchString.lower()
label = alarmEvent.get("Label").lower()
#look for searchString in label
if search in label:
#show if found
return True
else:
#hide if not found
return False
#show all if no search string given
else:
return True
I guess the alarm table doesn’t like custom properties
Any ideas on how to filter the label for an Alarm Journal?
I tried calling it from the text box propertyChange script but the object retrieved is not a Vision.Components.AlarmJournalTable it’s a com.inductiveautomation.factorypmi.application.com object
if event.propertyName == 'text':
table = event.source.parent.getComponent('Container').getComponent('Alarm Journal')
table.filterAlarm()
Stole this idea and put an invisible “refresh” button next to the text box. Works nicely.
if event.propertyName == 'text':
button = event.source.parent.getComponent('Button 1')
button.doClick()
#current startDate
startDate = event.source.parent.parent.startDate
#add one minute and set the date to "refresh"
startDate = system.date.addMinutes(startDate, -1)
event.source.parent.getComponent('Container').getComponent('Popup Calendar').date = startDate
#subtract one minute and set the date to "refresh"
startDate = system.date.addMinutes(startDate, 1)
event.source.parent.getComponent('Container').getComponent('Popup Calendar').date = startDate