Control 1 NX VMS and Multi Video Analytics Server
AnsweredI have a problem with SDK plugin code. Please help me understand this.
Now I have 1 NX server + 3 VA (video analytics) server. I want to send channel 1 (camera 1) to VA1 , channel 2 to VA 2 and channel 3 to VA3 for analytics by these code:
void Engine::doObtainDeviceAgent(Result<IDeviceAgent*>* outResult, const IDeviceInfo* deviceInfo)
...
if (condition)
{
*outResult = new DeviceAgent(this, deviceInfo, (char*)deviceInfo->id(), (char*)deviceInfo->name(), (char*)deviceInfo->url(), (char*)m_vaIp1.c_str());
}
else if (!condition)
{
*outResult = new DeviceAgent(this, deviceInfo, (char*)deviceInfo->id(), (char*)deviceInfo->name(), (char*)deviceInfo->url(), (char*)m_vaIp2.c_str());
}
else
{
*outResult = new DeviceAgent(this, deviceInfo, (char*)deviceInfo->id(), (char*)deviceInfo->name(), (char*)deviceInfo->url(), (char*)m_vaIp3.c_str());
}
m_vaIp1, m_vaIp2, m_vaIp3 are VA IP address.
If VA server is okie. The program was fine. But with some condition the socket between VA1 and NX is closed. So I want the code inside else if is called (send channel to VA2 automatically).
The code maybe like this:
if (condition)
{
*outResult = new DeviceAgent(this, deviceInfo, (char*)deviceInfo->id(), (char*)deviceInfo->name(), (char*)deviceInfo->url(), (char*)m_vaIp1.c_str());
if (outResult->value())
{
*outResult = new DeviceAgent(this, deviceInfo, (char*)deviceInfo->id(), (char*)deviceInfo->name(), (char*)deviceInfo->url(), (char*)m_vaIp2.c_str());
}
}
I read outResult have some method such as: isOK, error, value...
But I dont know how to call the right method for the condition 2. Please help me.
Thank you so much!
-
Hello Linh,
Let me ask several questions, please.
> Now I have 1 NX server + 3 VA (video analytics) server. I want to send channel 1 (camera 1) to VA1 , channel 2 to VA 2 and channel 3 to VA3 for analytics by these code:Is the channel2 a separate physical camera from the channel 1 (camera 1)?
Is the channel3 a separate physical camera from the channel 1 (camera 1)?
Or channel 1 , channel 2, channel 3 are three channels of the same physical camera?
Can you share a screenshot of Desktop client with your camera in the resource tree, please?*outResult = new DeviceAgent(this, deviceInfo, (char*)deviceInfo->id(), (char*)deviceInfo->name(), (char*)deviceInfo->url(), (char*)m_vaIp1.c_str());
You don't need to pass additional parameters like (char*)deviceInfo->id() etc. , because you can invoke them inside the DeviceAgent's constructor, since deviceInfo is accessible inside the constructor.
0 -
Hi Andrey,
Thank you for your support,
I have 3 separate camera (cam1, cam 2, and cam 3) with the different IP address.

I am calling DeviceAgent in Engine (with this function- void Engine::doObtainDeviceAgent(Result<IDeviceAgent*>* outResult, const IDeviceInfo* deviceInfo).
You can see at the function parameter Result<IDeviceAgent*>* outResult.

Please help me how to control the return result. I mean when the outResult is good, when it is not good.
outResult = new DeviceAgent(this, deviceInfo, (char...
0 -
Hi Linh,
Here is what I would recommend.
When you enable your plugin on a camera a new DeviceAgent class instance is created, i.e. one DeviceAgent instance per camera.
1. In the "deviceAgentSettingsModel" of the Engine's manifest you could define a setting for video analytics server. For example,
"deviceAgentSettingsModel": {
"type": "Settings",
"items": [
{
"type": "TextField",
"name": "tfVideoAnlyticsServer",
"caption": "Video analytics server",
"description": "Name or IP address of a ideo analytics server",
"defaultValue": ""
}
.....Every DeviceAgent would have this setting configurable in Nx Desktop. So, you could configure in Nx Desktop
VA1 for channel 1,
VA2 for channel 2
VA3 for channel 3
Of course, the tfVideoAnlyticsServer setting could be initialized be a value read from your plugin's config file or something.2. You can process the value of the tfVideoAnlyticsServer setting in the DeviceAgent::settingsReceived().
Regarding this
> m_vaIp1, m_vaIp2, m_vaIp3 are VA IP address.
> If VA server is okie. The program was fine. But with some condition the socket between VA1 and NX is closed. So I want the code inside else if is called (send channel to VA2 automatically).Of course, the tfVideoAnlyticsServer setting value could contain a coma-delimited list of servers: VA1, VA2, VA3
When DeviceAgent detects there is something wrong with the socket to VA1, it could select the next VA to connect to from the list.In this scenario, you don't need to deal with modification of helper classes.
0 -
Hi @...,
We have not heard back from you in a while, so we are going to assume your question has been answered and set this topic to 'Answered'.
0 -
Yes, I am trying to do what Andrey suggested. Thank you.
0
Please sign in to leave a comment.
Comments
5 comments