Hello everyone,
I am trying to write a script which will function as follow:
- One alarm must be selected from alarm status table.
-Once the alarm is selected, a button will be pressed to show the display path of the selected alarm in text box.
Is it do-able? If yes, any help will be appreciated.
Thank you
The Alarm Status Table doesn’t provide any visibility into a user’s selection of rows, either through props or Component Events. Due to this, there is no way to track what row a user has selected.
The only way available to use ANY external component to display any info about an alarm in the Alarm Status Table (selected or not) is if filtering is applied to the table (AlarmStatusTable.props.filters
object) and AlarmStatusTable.props.filters.active.results.enabled
is true
. If those conditions are met, you have access to the alarm object within AlarmStatusTable.props.filters.active.results.data
, and so you could obtain the Display Path from that object.
Note that this filtering is NOT the same filtering as that which is applied through the Alarm Status Table’s UI - this filtering is entirely done through property manipulation, and so you would need to manage it with additional inputs like Text Fields.
It may be possible to have a named query binding to a dataset on a table. Although you won’t have access to the built-in alarm status table functionality, you can script with python to show, hide, or alter the data as needed by using that dataset.
Official 8.0 Docs for Alarm Status Table, Vision Table, Named Query Bindings, Datasets, and Python Scripting.
(Note: Keep in mind that Python Datasets and Ignition Datasets need to be converted for usage with the other, otherwise they may not play nicely with each other
Datasets are also immutable. So you must assign the returned dataset to a new variable to be able to alter the values)
In 7.9x we use the onDoubleClicked Extension function to do something similar.
print str(alarmEvent.get('DisplayPath'))
Will print the double clicked alarms display path to the console.
@MMaynard: The Perspective Alarm Status Table does not pass AlarmEvent objects to interaction Events, so that won’t work if he’s using Perspective.
He didn’t specify perspective
I automatically defaulted to Perspective, when @MMaynard is correct - you didn’t specify Perspective. I still believe you are asking about Perspective because Vision actually provides access to a dataset of the currently selected alarms, but here’s how you could obtain your desired behavior in Vision:
Place a Label and a Button.
As part of the Button’s onActionPerformed
or onClick
Event, supply a Script with the following code:
display_path = event.source.parent.getComponent('Alarm Status Table').selectedAlarms.getValueAt(0, 'DisplayPath')
event.source.parent.getComponent('Label').text = display_path
Note that this does not prevent a user from selecting multiple alarms, and if they do so it will only display the path of the FIRST alarm selected. This code does also not prevent an error from occurring should NO alarms be selected.
Thank you for your reply. I am using vision.
@cmallonee I have used your code. When I click the button, the label turns blank white and does not return display path.
@cmallonee Check out the second column named as display path. I am trying to grab this one.
Don’t be deceived: If no Display Path is explicitly set for an alarm, I believe we just toString() the original path IN THE TABLE. This does not mean that an alarm actually has a Display Path property in the Dataset.