Hi Kevin,
Sorry for the massive posts, but the more information the better!
This is the script that spits out the data into the table:
# Start date and end date are self explanatory
# Hide cleared and acknowledged is as well
# groups is a list of groupIDs of which we want the alarms for, or an empty list for all groups
# sites is a list of siteIDs of which we want the alarms for, or an empty list for all sites
# it doesn't make tons of sense to use the groups and sites parameters at the same time - if so,
# then a site must be in the groups list AND the site list to be accepted
def populateAlarmsTable(startDate="2005-01-01", endDate="", hideClearedAndAckd=True, groups=[], sites=[]):
import app
import system
tableHeaders = ["siteName","device","groupName","clearTime","ackUser","activeTime","alarmStatus","alarmName","ackTime","siteId","deviceId","uuid"]
tableData = []
states = []
if (hideClearedAndAckd):
states = ["ClearUnacked","ActiveUnacked","ActiveAcked"]
else:
states = ["ClearUnacked","ActiveUnacked","ActiveAcked", "ClearAcked"]
sysAlarms = system.alarm.queryJournal(startDate, endDate, "PMCS_Alarms_Journal",state=states)
for alarm in sysAlarms:
tableRow=[]
ackData = alarm.getAckData()
clearedData = alarm.getClearedData()
activeData = alarm.getActiveData()
reftable = app.siteutil.getDeviceClliFromAlarmPath(str(alarm.getSource()))
deviceId = app.siteutil.getDeviceIdFromReftable(reftable)
siteId = app.siteutil.getDeviceParameter(deviceId, "siteid")
groupId = app.siteutil.getSiteParameter(siteId, "groupid")
# If this is not in the accepted sites list, skip
if (len(sites) != 0):
if (siteId not in sites):
continue
# If this is not in the accepted groups list, skip
if (len(groups) != 0):
if (groupId not in groups):
continue
# SiteName
tableRow.append(app.siteutil.getSiteParameter(siteId, "sitename"))
# Device
tableRow.append(app.siteutil.getDeviceParameter(deviceId, "name"))
# Group
tableRow.append(app.siteutil.getSiteParameter(siteId, "groupname"))
# Clear Time
if clearedData is not None:
#tableRow.append(clearedData["eventTime"])
#tableRow.append("eventTime")
tableRow.append("state:'"+str(alarm.getState())+"'")
else:
#tableRow.append("")
tableRow.append("state:'"+str(alarm.getState())+"'")
# Ack User
if ackData is not None:
tableRow.append("ack data TODO")
else:
tableRow.append("ack data TODO")
# Active Time
if activeData is not None:
#tableRow.append(activeData["eventTime"])
tableRow.append("eventTime")
else:
tableRow.append("Active data null")
# Alarm Status
# 0 - red background + warning icon = Active Unacked
# 1 - yellow + warning = Active Acked
# 2 - blue + info = Clear Unacked
# 3 - clear + checkmark = Clear Acked
state = 5
if (str(alarm.getState()) == "Active, Unacknowledged"):
state = 0
elif (str(alarm.getState()) == "Active, Acknowledged"):
state = 1
elif (str(alarm.getState()) == "Cleared, Unacknowledged"):
state = 2
elif (str(alarm.getState()) == "Cleared, Acknowledged"):
state = 3
tableRow.append(state)
# Alarm Name
tableRow.append(app.siteutil.getAlarmName(alarm.getSource(), True))
# Ack Time
if ackData is not None:
#tableRow.append(ackData["eventTime"])
tableRow.append("eventTime")
else:
tableRow.append("ack data TODO")
# Site ID
tableRow.append(siteId)
# Device ID
tableRow.append(deviceId)
# UUID
tableRow.append(alarm.getId())
tableData.append(tableRow)
# Build the dataset to return
ret = system.dataset.toDataSet(tableHeaders, tableData)
return ret
Thanks for looking into this.