In the DemoAccessControlPlugin some code is provided to clear all alarms of a given sourceId and EventType. There are two cases:
- If all alarms of a given sourceId/EventType in the MIP system are cleared, then clear all alarms for that sourceId/EventType in the access control system.
- If an alarm of a given sourceId/EventType in the access control system is cleared then clear all alarms for that sourceId/EventType in the MIP system.
There can be multiple alarms in both systems with the same EventType/SourceId.
I would like to only clear one particular alarm at a time from each system, instead of all of them. How would I go about doing that?
For reference, below is the code in the DemoAccessControlPlugin from the AlarmSynchronizer.cs class:
private void \_client\_AlarmCleared(object sender, AlarmClearedEventArgs e)
{
// Close all corresponding alarms in the VMS
var vmsAlarms = \_alarmRepository.GetAlarmsForSource(e.DoorId, e.EventTypeId, false);
foreach(var alarm in vmsAlarms)
{
\_alarmRepository.UpdateAlarm([alarm.Id](https://alarm.Id), new ACAlarmUpdateRequest { State = BuiltInAlarmStates.Closed });
}
}
private async void \_alarmRepository\_AlarmChanged(object sender, AlarmChangedEventArgs e)
{
// Only handle closed alarms
if (e.Alarm.StateId != BuiltInAlarmStates.Closed)
{
return;
}
// If all alarms for this source and event type are closed in VMS, close corresponding alarm in the Demo Access Control system
var doorId = e.Alarm.ExternalSourceId;
var eventTypeId = e.Alarm.ExternalEventTypeId;
var alarms = \_alarmRepository.GetAlarmsForSource(doorId, eventTypeId, false);
if (!alarms.Any())
{
try
{
await \_client.CloseAlarmAsync(doorId, eventTypeId);
}
catch (DemoApplicationClientException ex)
{
// A retry mechanism would probably be in order...
ACUtil.Log(true, "DemoACPlugin.AlarmManager", "Error closing alarm in Demo Access Control system: " + ex.Message);
}
}
}
Hi Lou,
I would like to take a step back and explain the idea behind two-way alarm synchronization.
Let’s say Access Control System reports that door has been tampered. The way Access Control System informs VMS about it is through access control event. In order for VMS to trigger an alarm, matching alarm definition needs to be in place. It is not possible to fire an alarm directly to the VMS.
Access Control System can send multiple events about specific door being tampered which will result in multiple alarms being generated. If tempered state has been cleared in the Access Control System, all relevant alarms in the VMS will be closed. By not doing this (leaving some alarms not closed and clearing the state in Access Control System) we would introduce false assumption that something is wrong in the Access Control System.
However, from the VMS, you could close individual alarms related to the tampered door state. But only when the last one has been closed, state of the door will be cleared in the Access Control System.
Hope this makes sense. I would recommend you to test this functionality yourself using the DemoAccessControlPlugin and DemoACServerApplication. If you still have doubts, please let us know.
Have a great day!
Best regards,
Milos
Thanks for the explanation Milos. The users of our access control system typically clear one individual alarm at a time. If there are 2 door forced alarms for the main entrance to the building in the access control system and one is closed in the access control system then all of the alarms in the VMS are closed. This will leave no alarms in the VMS and one in the access control system. This seems inconsistent…
In any case, I will pass on your explanation and we will think about the business requirements and whether this behavior would be OK or not.
If we do need to sync alarm closing on an individual alarm basis would this even be possible using the plugin framework? One way to do this would be to match up alarm ID’s between the VMS and the access control system, but I couldn’t figure out a way to do that. Maybe you know of a way?
Thanks again for your help, have a nice weekend!
-Lou
Milos, we decided to go with the default behavior for now (clear all related alarms). So there’s no need to get back to me on the follow-up question that I had in my previous reply. Thanks again for the help.
-Lou