Can we use camera groups in an event server plugin?

In an event server plugin, we have created custom actions which can be used in the rule engine. If the actionItem is of Kind.Camera it is possible to choose a camera group as the actionItem. When the action is triggered, it executes on all cameras in the group, even cameras that have been added to the group after the creation of the rule.

In another scenario, we define the actionItem as a plugin-defined custom Item which has FQIDs as a property. An FQID may refer to a camera group. When the action is triggered, we wish to find which cameras can be found in this group, and execute the action on these. However, it seems that the event server cannot see user defined camera groups (We have used the ConfigDump sample to confirm this). Is this true, and if so, is there a way to get around it? If the event server is not aware of the groups, how does the server know to execute the action on the cameras in the group when the actionItem is of Kind.Camera?

If you explore the ConfigAccessViaSDK sample (standalone) you will see that you can switch between UserDefined which will give you the defined camera groups and SystemDefined which will give you an “All cameras” group. https://doc.developer.milestonesys.com/html/index.html?base=samples/configaccess_sample.html&tree=tree_2.html

Unfortunately it is a known limitation that the Configuration.Instance.GetItems(ItemHierarchy.UserDefined) is not implemented in the Event Server environment, if you test this it will give the same items as GetItems(ItemHierarchy.SystemDefined) or GetItems() will.

This limitation leads to the plugin being unable to read the groups and the group members.

Because this is not implemented in the Event Server you will need a workaround. It is possible to use the Configuration API to read the camera groups and read the group members.

As an experiment I put this in the Config Dump sample BackgroundDump class (recursive method because of possible sub-grouping):

private void GetCameraGroups()
{
	ManagementServer mgt = new ManagementServer(EnvironmentManager.Instance.MasterSite.ServerId);
	var camGroups = mgt.CameraGroupFolder.CameraGroups;
	foreach (var grp in camGroups)
	{
		ShowCameras(grp, "");
	}
}
private void ShowCameras(CameraGroup cameraGroup, string filler)
{
	EnvironmentManager.Instance.Log(false, "ConfigDump", filler + $"{cameraGroup.DisplayName} contains {cameraGroup.CameraFolder.Cameras.Count()} cameras ", null);
	foreach (var cam in cameraGroup.CameraFolder.Cameras)
	{
		EnvironmentManager.Instance.Log(false, "ConfigDump", filler + $"+ {cam.DisplayName}", null);
	}
	var camGroups = cameraGroup.CameraGroupFolder.CameraGroups;
	EnvironmentManager.Instance.Log(false, "ConfigDump", filler + $"{cameraGroup.DisplayName} contains {camGroups.Count} subGroups", null);
	foreach (var cg in camGroups)
	{
		ShowCameras(cg, filler + "---");
	}
}