Hi
I am trying to store couple of alarm journal parameters into table.
state = ["ClearUnacked", "ClearAcked"]
data = system.alarm.queryJournal(state = state, provider = 'test')
for item in data:
print(item.get('name'))
print(item.get('ackTime')
I am trying to show Active Time, Inactive Time, Ack Time, Ack user, Ack Notes into the table.
for item.get('ActiveTime'), item.get('AckTime') returning value of item.get('EventTime')
How to get those values, can someone guide.
You will struggle to use print()
in a useful way in Ignition scripting.
Is there a reason you are not using the Alarm Journal Component?
Your use case seems to be just listing Alarms from the Journal in a standard way?
1 Like
I am trying to get few of the data from alarm journal and merge it with my own alarm history table.
is there a better way to achieve own alarm history tabl?
Can you show us where you are trying to put these values with this script?
Also show us what you have tried and any errors you get?
I was trying to create my own Alarm History table and get the dataset from above scripts.
However it was working for queryStatus not for queryJournal.
As of now I have taken data from alarm_events table and written a trigger to insert and update another table.
but still I am not able to figure it out how to get the alarm associated data to my table.
results = system.db.runNamedQuery('getAlarmHistory')
columns = ['ActiveTime', 'InActiveTime', 'tag', 'alm', 'AcknowledgeTime', 'AckUser', 'AckNotes']
rows = []
def split_alarm_name(alarm_name):
try:
tag = alarm_name.split('/tag:')[1].split(':/alm:')[0]
alm = alarm_name.split(':/alm:')[1]
return tag, alm
except IndexError:
return None, None
for row in results:
alarm_name = row['AlarmName']
tag, alm = split_alarm_name(alarm_name)
dataset_row = [
row['ActiveTime'],
row['InActiveTime'],
tag,
alm,
row['AcknowledgeTime'],
row['AckUser'],
row['AckNotes']
]
rows.append(dataset_row)
dataset = system.dataset.toDataSet(columns, rows)
return dataset