Hello,
I am trying to use the ConfigAPIBatch/ConfigAPIImport to import Hardware with a .xml file.
Problem is I have no idea what this file should look like.
Could you please provide me a template ? Fields should contain something like IP, Port, Username, Password, driverID.
Thank you
If you have an XProtect Professional (or other e-code XProtect) you should explore the format by doing and export configuration.
If you do not have an XProtect e-code VMS you should abandon that format and create your own format which include the information you mention.
The XProtect e-code config file (and exported config file) is a very big and very complex file and is in fact not documented.
We only have XProtect Corporate available right now, is it possible for you to send us an exported Professional .XML configuration file so we could use it as example ?
In a test system I have 6 devices giving a 307 KB config file.
It does not make sense to use a 100+ KB file for those 4 values you need. Please change the sample and use something different like your own csv file.
Could you please send use this file anyway or any other valid XML configuration file ? We will adapt the sample for our use in the future, probably with csv. For now we are just looking for a valid XML configuration file.
Thanks
Sorry to press you, but we really need this file, is it possible for you to send it to us ?
I have started making a new sample. I think a sample that uses the new strongly typed classes is desirable. So here is the first key routine needed. I believe this is the way forward for you. Do not use the config files from e-code servers when you are not even working with e-code servers
I have not included login, and a format to feed the routine through a file, but I trust you can add it. (Next version of the MIP SDK I hope to have accomplished a full sample.)
static private bool AddCamera(string parms)
{
string[] parameters = parms.Split(',');
string ip = parameters[0];
string user = parameters[1];
string pass = parameters[2];
string drivernr = parameters[3];
string hwname = parameters[4];
string cameraName = parameters[5];
string rsName = parameters[6];
int drivernum = int.Parse(drivernr);
ManagementServer managementServer = new ManagementServer(EnvironmentManager.Instance.MasterSite);
RecordingServer recordingServer = managementServer.RecordingServerFolder.RecordingServers.FirstOrDefault(x => x.Name == rsName);
if (recordingServer == null)
{
Console.WriteLine("Error. Did not find recording server: " + rsName);
return false;
}
string hardwareDriverPath = recordingServer.HardwareDriverFolder.HardwareDrivers.Where(x=>x.Number == drivernum).FirstOrDefault()?.Path;
if (hardwareDriverPath == null)
{
Console.WriteLine("Error. Did not find hardware driver: " + drivernum);
return false;
}
Console.WriteLine("Will now attempt to add: " + cameraName);
ServerTask addHardwareServerTask = recordingServer.AddHardware(ip, hardwareDriverPath, user, pass);
while (addHardwareServerTask.State != StateEnum.Error && addHardwareServerTask.State != StateEnum.Success)
{
System.Threading.Thread.Sleep(1000);
addHardwareServerTask.UpdateState();
}
Console.WriteLine("Hardware add task: " + addHardwareServerTask.State);
if (addHardwareServerTask.State == StateEnum.Error)
{
Console.WriteLine("Hardware add error: " + addHardwareServerTask.ErrorText);
return false;
}
else if (addHardwareServerTask.State == StateEnum.Success)
{
string path = addHardwareServerTask.Path; // For the added hardware
Hardware hardware = new Hardware(EnvironmentManager.Instance.MasterSite.ServerId, path);
hardware.Name = hwname;
hardware.Enabled = true;
hardware.Save();
Camera camera = hardware.CameraFolder.Cameras.First();
camera.Name = cameraName;
camera.Enabled = true;
camera.Save();
// alter other camera properties(?)
}
return true;
}
You can find the driver number on the supported hardware pages. https://www.milestonesys.com/community/business-partner-tools/supported-devices/xprotect-corporate-and-xprotect-expert/
Hello, thank you for your work. It seems to do what we were looking for, except that i forgot to mention that the hardware we are trying to add is not physically connected. We would like to preconfigure a server, so that once installed somewhere cameras just need to be plugged in to be used. This is my bad, forgot to mention this point.