Start/Stop recording on specific camera using SendMessage

I have this piece of code

private void FireAlarm(string alarmName, FQID source, string sourceName)
        {
 
            EventHeader eventHeader = new EventHeader()
            {
                ID = Guid.NewGuid(),
                Class = "Demo",
                Type = "Demo Alarm",
                Timestamp = DateTime.Now,
                Message = "Demo Alarm Message",
                Name = alarmName,
                
                Source = new EventSource { FQID = source, Name = sourceName }
            };
            var reference = new Reference() { FQID = source };
            ReferenceList references = new ReferenceList
            {
                reference
            };
            Alarm eventData = new Alarm
            {
                EventHeader = eventHeader,
                ReferenceList = references
            };
            EnvironmentManager.Instance.SendMessage(new Message(MessageId.Server.NewAlarmCommand) { Data = eventData });
        }

Now, camera may not record when alarm is triggered, so I want to start recording some time before alarm and stop it after few seconds.

I tried

EnvironmentManager.Instance.SendMessage(new Message(MessageId.Control.StartRecordingCommand), e.Source.FQID);

where e is EventHeader, FQID is correct, but there is no recordings for specified camera.

First, please create an event (and a rule and an alarm definition) and then this event triggers an alarm and a rule to record. This is our recommendation and how it best works in XProtect.

This question is similar -

https://developer.milestonesys.com/s/question/0D53X00006RabJiSAJ/how-to-trigger-an-event-that-is-catch-by-a-rule

This knowledge base article might be interesting for you to read –

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

On the other hand, we are wondering why there is no recordings for specified camera.

Please explore this sample – Video Viewer sample and the start and stop recording buttons, does recording start and stop? https://doc.developer.milestonesys.com/html/index.html?base=samples/videoviewer_sample.html&tree=tree_search.html?search=videoview

Hi,

Tanks for hints, I changed logic to work as per your suggestion and eventually I was able to figure out why there wasn’t any recordings.

Event was raised when camera becomes enabled but my rule starts before feed rule so nothing was recorded.