ReplaceHardware task error

We are using MIPSDK 2023 R2 on XProtect Corporate 2024 R1.

The manual replacement of an Axis Camera (AXIS M4327-P Panoramic Camera) with 12 channels and an Axis Camera (AXIS P3344 Fixed Dome Network Camera) with one channel succeeds without error from the Management Client. However, the same camera gives an error when replaced using the code below.

Code:

HardwareDriver hwDriver = primRecServer.recServer.HardwareDriverFolder.HardwareDrivers.FirstOrDefault(x => x.Path == primHW.HardwareDriverPath);

ReplaceHardwareServerTask reptas1 = secHW.ReplaceHardware();

reptas1.SetProperty(“Address”, uriCamAddress.Host);

reptas1.SetProperty(“Port”, uriCamAddress.Port.ToString());

reptas1.SetProperty(“UseHttps”, bHTTPSEnabled.ToString());

reptas1.SetProperty(“HttpsPort”, iHTTPSPort.ToString());

reptas1.SetProperty(“UserName”, primHW.UserName);

reptas1.SetProperty(“Driver”, hwDriver.Number.ToString());

reptas1.SetProperty(“CustomDriverData”, “”);

reptas1.SetProperty(“AllowDeletingDisabledDevices”, “true”);

reptas1.SecurePassword = secureStringPassword;

ServerTask task = reptas1.ExecuteMethod(“ReplaceHardware”);

if (task.Path != null)

task.UpdateState();

while (task.State != StateEnum.Error && task.State != StateEnum.Success)

{

System.Threading.Thread.Sleep(1000);

task.UpdateState();

}

if (task.State == StateEnum.Success)

{

pushLogs("ReplaceHardware: Success - " + secHW.DisplayName, bEnhancedLogging);

}

else

{

pushLogs("ReplaceHardware: Error - " + secHW.DisplayName + " " + task.ErrorText, true);

}

Error:

ReplaceHardware: Error - AXIS M4327-P Panoramic Camera (192.168.0.202) Could not replace the hardware.

The existing hardware contains more devices than the new hardware.

The hardware replacement process will delete disabled redundant devices.

You must disable all devices that may be deleted.

Hi @Code Vega​,

The “replace hardware” capability was added to the configuration api based on a somewhat more limited implementation compared to the wizard in the Management Client. In Management Client, when you replace hardware and the new driver will have fewer camera channels compared to the original, you have the opportunity in the user interface to choose which camera channels from the original hardware will be associated with the available camera channels on the destination hardware. For example, if the old driver had 4 camera channels, and the new driver has one camera channel, three of the old channels would be deleted by the replace-hardware operation, but you have a clear user experience to guide you through the process of choosing which channel to keep.

In the configuration api implementation, when the operation will result in any deleted devices, the devices you are willing to part with must be disabled before the replace-hardware operation. So if you plan to keep channel 1 and let channels 2-4 be removed, you must first disable channels 2-4. Then, with “AllowDeletingDisabledDevices” set to “true”, the operation should succeed.

Hallo,

I have code working to add a new camera using the MIP SDK component. But now I’m looking for simple code to replace hardware. Your code is very usefull but I’m missing a part. Can you share the code where you define and set “secHW”?

Thanks.

In OP’s example code “secHW” is a “VideoOS.Platform.ConfigurationItems.Hardware” object. Here’s the docs on the Hardware class: https://doc.developer.milestonesys.com/mipsdk/index.html?base=MIPhelp%2Fclass_video_o_s_1_1_platform_1_1_configuration_items_1_1_hardware.html

Thanks for the response. But I know that “secHW” in OP’s example code is a “VideoOS.Platform.ConfigurationItems.Hardware” object. It needs ‘ServerId’ (that I have) and VideoOS.ConfigurationApi.ClientService.ConfigurationItem that I can not find how to create from an excisting camera on the recording server.

It also accepts the serverid and the “path”, which for a hardware object looks like “Hardware[guid]”. You can also get the hardware objects as a child item of a recording server under the collection “Recorder.HardwareFolder.Hardwares”, and you can get Recorder objects as the child of a Management Server using “ManagementServer.RecordingServerFolder.RecordingServers”.

The root Management Server object can be instantiated with “new ManagementServer(Configuration.Instance.ServerFQID)”.

Thank you, this was very helpful.