Using "TriggerTime" key as Output setting causes exception

When using the DemoDriver sample, if you try to add a setting to the Output called “TriggerTime” the following exception will be thrown in “HardwareDriver” recording server log.

To reproduce, take the Demo Driver sample and add this field in “BuildFields” method of configuration manager:

f.Add(new NumberSetupField()
{
    Key = "TriggerTime",
    DisplayName = "TriggerTimes",
    DisplayNameReferenceId = Guid.Empty,
    MinValue = 0,
    MaxValue = 100,
    IsReadOnly = false,
    ReferenceId = Guid.Parse("30dac874-c8c4-443a-b876-bda9e37679f4"),
    DefaultValue = 25,
});

and this setting in “BuildDevices” method:

devices.Add(new OutputDeviceDefinition()
 {
     DisplayName = "Output 1",
     DeviceId = Constants.Output1.ToString(),
     SupportSetState = true,
     SupportTrigger = true,
     DeviceType = DeviceType.Output,
     Settings = new Dictionary<string, string>()
     {
         {"TriggerTime", "5" }
     }
 });

Issue is resolved by nemaning the key from “TriggerTime” to something else like “OutputTriggerTime”.

Exception:

2023-11-06 15:31:07.042+01:00 [ 96] ERROR - 00000000-0000-0000-0000-000000000000 http://127.0.0.1:22222/ MIPDriverFrameworkHardwareDriver.SetupNewDriver(), ex=System.ArgumentException: An item with the same key has already been added.

at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)

at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)

at VideoOS.Common.Integration.Definition.CapabilitiesCollection..ctor(MainDefinition mainDefinition, capabilitiesType capabilities)

at VideoOS.Common.Integration.Definition.DeviceDefinition.get_Capabilities()

at VideoOS.IO.Drivers.HardwareDriverBase.SetupDevices(IEnumerable`1 deviceSetupInfoCollection)

at VideoOS.IO.Drivers.MIPDriverFrameworkHardwareDriver.SetupNewDriver(String activationDefinitionXml, Uri uri, String userName, String password, String driverProxyName, String customDriverData, String initialDriverSettings)

We can confirm your observations after testing in the Milestone test labs.

We are thinking that all outputs should have a trigger time property even if you do not add it as a setting.

We will investigate deeper and figure out whether you should be able to add this setting or you should have this setting even if you do not add it in the driver.

For now please use the workaround of using another name for the key.

Following your post Milestone has made a change for future versions, 2024R1 and forward. After the change outputs will always have a trigger time “Output Trigger Time (msec)” setting, after this change this will the same for Driver Framework based drivers and regular drivers from the device packs.

Until 2024R1 you will have to use a workaround introducing a setting with a key different from “TriggerTime”.