Federation mode single sensor status.

I am working on Component Integration. Version of SDK 2019R2.

The problem I faced is that I am not able to ask for the single sensor status of the federated server. I am using the following code :

_messageCommunication.TransmitMessage(

    new Message(MessageCommunication.ProvideCurrentStateRequest, new\[\] { item.FQID.ObjectId.ToString() }),

    null, item.FQID, null);

I tried different variations of items in request:

_messageCommunication.TransmitMessage(

    new Message(MessageCommunication.ProvideCurrentStateRequest, new\[\] { item.FQID.ObjectId.ToString() }),

    null, null, null); And other;

So I am creating the NotificationProvider for each server I can find. (The code for adding servers was taken from multiSiteStatusViewer).

I can receive all the sensors from all systems and even such request works fine:

_messageCommunication.TransmitMessage(

    new Message(MessageCommunication.ProvideCurrentStateRequest),

    null, null, null);

But not for the specific sensor.

Thanks in advance,

Oleksandr

Are you asking for the status of cameras or similar or have you implemented your own items?

I am asking for the statuses of existing items in Milestone system (cameras, outputs, inputs)

It is possible to ask for the status of XProtect system defined items, e.g. cameras.

When issuing the ProvideCurrentStateRequest, you fill the Data part with an Array of “Guid.ToString()”, e.g. FQID.ObjectId.ToString().

The request needs to be sent to EventServer via MessageCommunication.Transmit, and the result will come back with messageId= ProvideCurrentStateResponse

The Message.Data field is an Array of ItemState’s

Please take a look at StatusViewer component sample.

https://doc.developer.milestonesys.com/html/index.html?base=samples/statusviewer_sample.html&tree=tree_2.html

I did the experiment and added a new button to that sample, you can see my code here:

private void button1_Click(object sender, EventArgs e)
{
	string[] cams = new string[3];
	Item cam = new Item();
	ItemPickerForm form = new ItemPickerForm();
	form.KindFilter = Kind.Camera;
	form.AutoAccept = true;
	form.Init(Configuration.Instance.GetItems());
	if (form.ShowDialog() == DialogResult.OK)
	{
		cam = form.SelectedItem;
		cams[0] = cam.FQID.ObjectId.ToString();
		button1.Text = cam.Name;
		try
		{
			// Ask for current state of all Items
			_messageCommunication.TransmitMessage(
				new VideoOS.Platform.Messaging.Message(MessageCommunication.ProvideCurrentStateRequest, cams), null, null, null);
		}
		catch (MIPException)
		{
			MessageBox.Show(
				"Unable to connect to EventServer's MessageCommunication service (default port 22333) - will retry every 5 seconds",
				"Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
		}
	}
}

Hi Bo,

Sorry for the delay. I could progress with your help. Thanks much.

Here is where I am now.

Since I have no visual interface I reached to the point when using Federation mode I get all Servers same way as in MultiSiteStatusViewer example.

After that I do GetItems().

Now I have a NotificationProvider for each of servers and when I want to find out the state of single sensor I just have to pass the

_messageCommunication.TransmitMessage(new VideoOS.Platform.Messaging.Message(MessageCommunication.ProvideCurrentStateRequest, cams), null, null, null);

But I cannot find the way to connect _messageCommunication and the sensor.

So an example:

I have 2 servers.

I create 2 notification providers.

I get different cameras.

The Id of notification provider is the same as XPCO server has.

The serverId of camera is the same as XPCORS server has.

How can I connect a camera and notificationProvider?

Is there a connection between XPCO and XPCORS except for the name?

How can I get all XPCORS ? Can I receive status updates for them?

Sorry for so many questions, let me know if the description was informative.

Thank you,

Oleksandr

I tried an experiment. I added a button to the sample and added this code:

private void button1_Click(object sender, EventArgs e)
{
 
	string[] cams = new string[3];
	Item cam = new Item();
	ItemPickerForm form = new ItemPickerForm();
	form.KindFilter = Kind.Camera;
	form.AutoAccept = true;
	form.Init(Configuration.Instance.GetItems());
	if (form.ShowDialog() == DialogResult.OK)
	{
		cam = form.SelectedItem;
		cams[0] = cam.FQID.ObjectId.ToString();
		button1.Text = cam.Name;
		foreach (var sm in _dicServerObjects.Values)
		{
			var item = Configuration.Instance.GetItem(sm.SiteItem.FQID.ServerId, cam.FQID.ObjectId, Kind.Camera);
			if (item != null)
			{
				sm.MessCommunication.TransmitMessage(new VideoOS.Platform.Messaging.Message(MessageCommunication.ProvideCurrentStateRequest, cams), null, null, null);
			}
		}
	}
}

Note how I utilize the collection of message communication objects that is in the dictionary.

I hope this help better than explanations, I have an idea that it might..

Thank you,

Another question is if it is an efficient way of asking for a camera state if we have for example 10 servers and 1000 cameras on each.

For now I will take your sample.

Thank you very much

The answer is no.

What would be most effective is to develop an Event Server plugin, this can monitor the local messages on NewEventsIndication. In a federated setup these Event Server plugins can push information on change to your application or service.