Alarm status表中Active and UnAsk的计数与Mysql中的记录不一致

在MySql中,我使用Sql 语句查询Active and UnAsk的报警记录:SELECT * FROM (SELECT * FROM alarm_events group by eventid, eventid having count(*)=1) as A
where A.eventtype=0 and A.eventflags=0 得到6条记录,
但是在Alarm Status table中只显示有两条激活未确认的记录。这是什么原因呢?



Yes.

The journal holds each event. The ack would be a separate event.

If you need what is in the status table (instead of the journal), consider using system.alarm.queryStatus().

谢谢您的回复. 我使用[system.alarm.queryStatus()] 获得的结果和alarm status table中的一致,也是只有两条激活未确认的记录. 但是这无法满足我的需要. 报表统计中我需要统计一段时间不同报警类型的数量, 在手机端进行报警信息的反馈内容录入. 这些都需要与mysql中的记录交互. 我想知道数据不一致的原因是什么? 是我的sql语句不对吗.或者alarm status table从数据库检索Active and UnAsk记录的sql语句是什么.

One thing that might be incorrect in your query is A.eventtype=0 will only return Clear Unacknowledged records. If you want all Unacknowledged you would need to be searching for A.eventtype in (0, 2) which would get you Clear Unacknowledged and Active Unacknowledged.

You may also want to play around or remove A.eventflags as that is a binary representation of different events on the alarm:

Bit 0: System event
Bit 1: Shelved event
Bit 2: System Ack
Bit 3: Is Acknowledged
Bit 4: Is Clear
Bit 5: From Enabled State Change

Garth