Using a default item as EventSource

Hello. I’m developing an Event Server plugin that handles alarms from another system and sends alarms to the Event Server. I wanted to know if it’s possible to specify a plugin-defined item as the EventSource of the alarm?

I did some experiments, but my experiments had negative result. I was not able to use a controller (created in our Sensor Monitor sample) as event source.

I will do some follow up, whether this leads to a workaround or to a request for developing new functionality for the MIP SDK I cannot say yet.

I must have had a temporary issue, because when I today revisit my test it works. Now I hope what I learned will fit your question and what you need.

My experiment was to change the SmartClientExtension plugin sample, instead of using the currently selected camera as item source, I used ItemPicker to choose an item defined in the Sensor Monitor sample. This worked, the event can be seen and the event can be used to trigger an Alarm Definition.

I did the following modification to the sample (PlaybackSidePanelUserControl.cs)

private void button2_Click(object sender, EventArgs e)
{
    VideoOS.Platform.UI.ItemPickerForm form = new VideoOS.Platform.UI.ItemPickerForm();
    form.AutoAccept = true;
    form.Init(Configuration.Instance.GetItemConfigurations(new Guid("2a13d169-8803-4ab2-b45b-5c1f1c453c93"), null, new Guid("57d0ed4b-3baf-4fc0-aa1b-d333a82f2f12")));
    if (form.ShowDialog() == DialogResult.OK)
    {
        Item item = form.SelectedItem;
        DateTime dateTime = DateTime.Now;
        EventSource eventSource = null;
        eventSource = new EventSource()
        {
            FQID = item.FQID,
            Name = item != null ? item.Name : "Some camera"
        };
        EventHeader eventHeader = new EventHeader()
        {
            ID = Guid.NewGuid(),
            Class = "NewAlarm",
            Type = "EventButton",
            Timestamp = dateTime,
            Message = "MyAnalyticsEvent",
            Name = "Pressed by user",
            Priority = (ushort)3,
            Source = eventSource
        };
        EventData eventData = new EventData()
        {
            EventHeader = eventHeader
        };
        EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventCommand) { Data = eventData });
    }
}