Is there a way to find the deviceId of an input. For example: If I have an input Named “Acromag 16 Input-1”. Is there a way to get the Deviceid so I can get the input’s status - Activated or Deactived?
Thank you.
Is there a way to find the deviceId of an input. For example: If I have an input Named “Acromag 16 Input-1”. Is there a way to get the Deviceid so I can get the input’s status - Activated or Deactived?
Thank you.
Try to run the ConfigAccessViaSDK sample. It will ilustrate how you can navigate and use the configuration from XProtect.
This is perfect. Thank you Bo
To specifically address the question of how to get a device ID by name, one way to do so is to use VideoOS.Platform.Configuration.Instance.GetItemsBySearch. Here’s a method which should return the first result. Note that some items may be found under the Management Server and also under the Recording Server, so the max results is set to 2.
While it’s possible to find items by name, it’s probably not the best idea for all applications. The sample Bo pointed out shows a good way to implement your own UI for selecting an item in case you don’t want/need the ItemPickerForm though.
private static Guid GetItemIdByName(string name)
{
try
{
var items = Configuration.Instance.GetItemsBySearch(name, 2, 60, out var result);
if (result == SearchResult.OK)
{
return items.First().FQID.ObjectId;
}
else
{
Debug.WriteLine($"Failed to get item by name. Result is '{result}'");
return Guid.Empty;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
return Guid.Empty;
}
}
Thank you Josh. This is very helpful and seems to work well. I will do some more testing between this and Bo’s suggestion. Thank you