If you want to get the information directly from the selected alarms in the alarm status table, here is a guide to doing it.
Currently, there are 23 properties that show up in the standard alarm status table model. The columns are indexed 0 through 22, and each specific column retains its specific model index no matter how the columns are arranged or rearranged in the table.
Here is a map of the columns:
# Model Index Column Name
# 0 ackNotes
# 1 Ack Time
# 2 Ack'ed By
# 3 Active Pipeline
# 4 Clear Pipeline
# 5 Ack Pipeline
# 6 Active Time
# 7 Clear Time
# 8 Event Value
# 9 Deadband
# 10 Display Path
# 11 Acked?
# 12 Active?
# 13 Clear?
# 14 Name
# 15 Notes
# 16 Priority
# 17 Source Path
# 18 Current State
# 19 Event ID
# 20 Unacknowledged Duration
# 21 Active Duration
# 22 Label
It looks like the columns you are interested in are 0 and 2
Whenever I need to directly manipulate the data from an alarm status table, I get the table model, and I get the desired values from it in the same way that values are obtained from a basic dataset. In the alarm status table, the checkboxes are actually in a separate table from the main table, so I've developed a function that allows me to get either the main table or the checkbox table based on a passed value. Here is my function modified to suit your usage case:
alarmStatusTable = system.gui.getParentWindow(event).getComponentForPath('Root Container.Alarm Status Table') #This will need to be changed if the alarm status table has a custom name or if the table is not directly in the root container
def getTable(tableType):#Retrieves a specified jTable instance from the alarmStatusTable
def tableSearch(tableType, alarmStatusTable):
if alarmStatusTable.componentCount > 0:
for component in alarmStatusTable.getComponents():
if 'AlarmStatusTable$1' in str(component.__class__) and tableType == 'main':
return component
elif 'JideTable' in str(component.__class__) and tableType == 'checkbox':
return component
else:
table = tableSearch(tableType, component)
if table is not None:
return table
return None
return tableSearch(tableType, alarmStatusTable)
mainTable = getTable('main')
checkboxTable = getTable('checkbox')
mainModel = mainTable.getModel()
checkboxModel = checkboxTable.getModel()
headers = ['Event ID', 'Ack Notes', 'Acked By']
data = []
for row in range(checkboxModel.rowCount):
if checkboxModel.getValueAt(row, 0):#This will only be true if the checkbox is selected
dataRow = []#add any of the columns listed in the provided column model map in whatever order is desired
dataRow.append(mainModel.getValueAt(row, 19)) #19 = Event ID Column
dataRow.append(mainModel.getValueAt(row, 0)) #0 = Ack Notes Column
dataRow.append(mainModel.getValueAt(row, 2)) #2 = Ack'd by Column
data.append(dataRow)
ds = system.dataset.toDataSet(headers, data)
Here is the result:
If you do want to pull in the values using queryStatus for purposes of building a proper dataset, here is a script that will pull in all 23 columns:
state = ['ActiveUnacked', 'ActiveAcked', 'ClearUnacked']
alarms = system.alarm.queryStatus(state = state) #Optional: Filtering the result
headers = ['ackNotes', 'Ack Time', "Ack'ed By", 'Active Pipeline', 'Clear Pipeline', 'Ack Pipeline', 'Active Time', 'Clear Time', 'Event Value', 'Deadband', 'Display Path', 'Acked?', 'Active?', 'Clear?', 'Name', 'Notes', 'Priority', 'Source Path', 'Current State', 'Event ID', 'Unacknowledged Duration', 'Active Duration', 'Label']
data = []
for alarm in alarms:
ackNotes = alarm.getOrElse('ackNotes', None)
ackTime = alarm.getOrElse('eventTime', None) if alarm.acked else None
ackedBy = alarm.getOrElse('ackUser', None)
activePipeline = alarm.getOrElse('activePipeline', None)
clearedPipeline = alarm.getOrElse('clearPipeline', None)
ackPipeline = alarm.getOrElse('ackPipeline', None)
activeTime = alarm.getOrElse('activeTime', None)
clearTime = alarm.getOrElse('clearTime', None)
eventValue = alarm.getOrElse('eventValue', None)
deadBand = alarm.getOrElse('deadband', None)
displayPath = alarm.displayPath #This also Works:.getDisplayPath() AND This also works: .getOrElse('displayPath', None)
acked = alarm.acked #This also works: .getOrElse('isAcked', None)
active = alarm.getOrElse('isActive', None) #In my experimentation, .active didn't work
clear = alarm.cleared #This also works: .getOrElse('isClear', None)
name = alarm.name #This also works.getName() AND This also works: .getOrElse('name', None)
notes = alarm.notes #This also works: .getNotes() AND This also works: .getOrElse('notes', None)
priority = alarm.priority #This also works: .getPriority() AND This also works:.getOrElse('priority', None)
sourcePath = alarm.source #This also works: getSource() AND This also works: .getOrElse('source', None)
currentState = alarm.state #This also works: .getState() #The following DID NOT return the expected result: .getOrElse('eventState', None)
eventID = alarm.id #This also works: .getID()
unacknowledgedDuration = alarm.getOrElse('ackDuration', None)
activeDuration = alarm.getOrElse('activeDuration', None)
label = alarm.label #This also works: .getLabel()
data.append([ackNotes, ackTime, ackedBy, activePipeline, clearedPipeline, ackPipeline, activeTime, clearTime, eventValue, deadBand, displayPath, acked, active, clear, name, notes, priority, sourcePath, currentState, eventID, unacknowledgedDuration, activeDuration, label])
dataset = system.dataset.toDataSet(headers, data)