Sending Events To Ocularis

At times you want to send events to an Ocularis server, and use Ocularis’ event distribution system to send notifications to operators and clients. This is – fortunately – a pretty simple operation.

We are going to create a small WinForm app that simulates two sensors with two rules each, without further ado, lets start by creating a simple WinForm app.

Add references to

  • System.Messaging
  • EventTypes.dll

System.Messaging enables .NET to use Microsoft Message Queuing, while EventTypes provides the classes of object we will be sending to the Ocularis Server. Ocularis is using Microsoft Message Queue which provides a safe and reliable store- and forward mechanism. That means that even if the server is down, or unreachable, events will be sent when it comes back up. No additional code is necessary, but naturally the events will arrive with a delay if the server is unreachable for some period of time – but at least you will eventually be notified.

In your implementation file, you can add these two lines

Next up, we need to define some GUIDs. We need one for the system itself, one for each sensor, and one for each rule – so all in all we need 7 GUIDs. I suggest using Visual Studios GUIDGEN tool (Tools/Create GUID). In this sample, the GUIDs comes to this:

In the handler for [Register With Server] we need to create the code to register at the Ocularis Server. To do this we need to create an XML fragment that describes the system (this is just a string with some XML in it), wrap the fragment in an object and send it across using the Message Queue.

In my example, constructing the XML fragment is done like this:

Now let us register at the server. In the application, the server input field is mapped to _ctrlServerIP (a textbox), so we proceed with this..

That’s it. If it all went well, we should see the source in the admin, with the two sensors and the rules attached.

To trigger an event, we simply create another object and send it across the server queue.

The solution files can be found at OnSSI’s SDK Page