Save alarm log to SQL Server table

Hello, I am looking to create my own alarm logging and am hoping that Ignition has a simple method for doing this. I have several boolean PLC tags that I want to track and when they are active ,insert a record with timestamp into SQL Server and then when cleared, write the timestamp to the corresponding record in the SQL table. Other than writing scripts, is there a more simple method to handle this?

Thanks.

Not really. You could use a transaction group with any change on the boolean as a the trigger, but you'll get separate entries in the DB for each change, and sometimes some extras. A decent database can tie the edges together for you (lead() or lag() functions) but it isn't trivial.

A transaction group for each boolean doesn't scale, though. The closest you could get would be a gateway tag change event that subscribes to all interesting booleans and does the above, but includes a reference to the source boolean in what it stores in the DB.

Thank you. Too bad there is not a canned way to do this. This is a typical process.

The built in Alarm Journal does this automatically.
It writes every transition for each configured alarm to the alarm tables with timestamps.
Any particular reason you can’t use the alarm journal?

I would like to use it, but I do not want to have 2 records per incident. For example, I would like to insert a record and then update it when the alarm is acknowledged/cleared. Is that possible?

Thanks.

Not that I am aware of.
But you can do some record combining to pull alarm data.
something like


   SELECT source 
  ,max(CASE WHEN eventtype = 0 THEN eventtime END) AS activetime
  ,max(CASE WHEN eventtype = 2 THEN eventtime END) AS ackedtime
  ,max(CASE WHEN eventtype = 1 THEN eventtime END) AS clearedtime
   FROM alarm_events
   GROUP BY source
1 Like