Creating and Modifying Alarms for Audio Event Detection in XProtect

Dear XProtect Support Team,

We are implementing an audio event detection system and need to integrate it with the XProtect platform. The goal is to raise alarms based on the type and source of detected audio events. However, we face challenges with managing user-defined events at scale.

Given the potential scale of deployment (e.g., 100 to 1,000 devices), creating separate user-defined events for each device and event type is not practical. We are looking for a solution that simplifies the creation and management of alarms while still supporting dynamic event types and device-specific configurations.

Our requirements are:

  1. Alarm Definition: We need a method to programmatically create alarm definitions and dynamically associate them with cameras and maps based on the audio event’s source and type.
  2. Modification of Related Cameras and Maps: We would like to modify existing alarms to update the associated cameras and maps without extensive manual configuration.

From the provided SDK samples, we found examples for listing alarms but not for creating or modifying them to meet our needs. Could you guide us on:

  • Whether it’s possible to programmatically create and manage alarm definitions through the SDK or other means?
  • How we can dynamically associate cameras and maps with alarms?

Your assistance in simplifying the alarm configuration process will significantly enhance the usability of our solution within the XProtect system.

This is how we currently managed to trigger the alarm:

private void SendUserDefinedEvent(ConnectPro.Models.AudioAnalytics.AudioEventDetected audioEvent, Item item)

{

try

{

    EnvironmentManager.Instance.PostMessage(

                new VideoOS.Platform.Messaging.Message(

                    VideoOS.Platform.Messaging.MessageId.Control.TriggerCommand), item.FQID);

}

catch (Exception ex)

{

    MessageBox.Show(ex.ToString());

}

}

//Audio Event Definition

public class AudioEventDetected

{

/// <summary> </summary>

public string FromDirno { get; set; }

/// <summary> </summary>

public string FromName { get; set; }

/// <summary> </summary>

public string EventType { get; set; }

/// <summary></summary>

public string Probability { get; set; }

public DateTime Time { get; set; }

}

Thank you in advance for your support!

Best regards,

Toni Gregov

I have an idea that you shouldn’t use user-defined events but instead use analytics events.

When you have an analytics event you can have the camera or the microphone as source, and you can have related cameras in the event, generally you can put a lot of information data in an analytics event.

When the event has a source this can be used in rules and alarm definitions.

There is no association with maps in the same direct fashion, maps when it comes to alarms in the alarm manager in Smart Client are managed by the Alarm Definition.

I will link to some info

https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_data_1_1_analytics_event.html&tree=tree_search.html?search=analytics

https://doc.developer.milestonesys.com/html/index.html?base=gettingstarted/intro_events.html&tree=tree_search.html?search=analytics

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/analyticseventtriggervialibrary/readme.html&tree=tree_search.html?search=analytics

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/analyticseventtriggervialibrary/readme.html&tree=tree_search.html?search=analytics

Hi, Thank you for the help.

I’ll definitely look into the analytics events but I found a working solution that fits our needs perfectly:

We first look for the device that matches the registered devices on the recording server)r, and then we use that information to create the alarm.

Unfortunately, there is no map information (or at least I do not know how to relate the map to the new alarm).

private void AddAlarm(Item item, ConnectPro.Models.AudioAnalytics.AudioEventDetected audioEvent)

{

Item xpDevice = GetSourceDeviceRegisteredInXprotect(audioEvent);

EventSource eventSource = new EventSource()

{

    FQID = xpDevice .FQID,

    Name = [xpDevice.Name](https://xpDevice.Name)

};

EventHeader eventHeader = new EventHeader()

{

    ID = Guid.NewGuid(),

    Class = "NewEventToRule",

    Type = audioEvent.EventType,

    Timestamp = DateTime.Now,

    Message = $"From {audioEvent.FromDirno}",

    Name = $"Audio Event: {audioEvent.EventType}",

    Source = eventSource,

    Priority = 2,

    PriorityName = "Medium"

};

Alarm alarm = new Alarm()

{

    EventHeader = eventHeader,

    StateName = "In progress",

    State = 4,

    AssignedTo = "test ([\\\\test)](file://test\))"

};

// Send the Alarm directly to the EventServer.

EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewAlarmCommand) { Data = alarm });

}

The reason that you miss a map is that the Smart Client Alarm Manager (SCAM) takes the map from the Alarm Definition.

The recommendation is that you send an event (any type, could be user-defined, could be analytics), and a Alarm Definition transforms the event to an alarm.

The reason for the recommendation is, amongst other things, that the administrator of the XProtect VMS can handle whether alarms should be made by temporarily or permanently disable an Alarm Definition.

https://developer.milestonesys.com/s/article/Create-an-alarm-from-a-MIP-SDK-based-application

If you do an event instead of an Alarm and you make an Alarm Definition that includes a map, you will in the SCAM see a map when an alarm is picked on the alarm list.