How to edit dutsettings in code

using

IDut[] duts = DutSettings.Current.ToArray()

we can have access to the list of duts. after editing the list how to save it on setting file (Settings\Bench\Defaul\DUTs.xml)?

Hi @teder.ted,

Just call DutSettings.Current.Save(), this should save all modifications done to DutSettings.Current to the file.

If you want to verify, you can call DutSettings.Current.Invalidate() (or something like that. Dont remember 100%). Then call DutSettings.Current to load it again from the file.

1 Like

Hi @teder.ted ,

You may already now it, but if you want to add or remove you should use following methods. These methods must be executed by the Dispatcher thread since they are a part of the CollectionView in the Editor. I encountered a similar problem and solution is adding PresentationFramework.dll and WindowsBase.dll as reference assemblies to the project.

System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
    DutSettings.Current.Add(MyDut1); // Add IDut object
    DutSettings.Current.Remove(MyDut1); // Remove a IDut object
});

DutSettings.Current.Save();  // Save Dut Settings

To save the changes you can call DutSettings.Current.Save() method after editing Dut settings.

3 Likes

Thanks.
Calling

DutSettings.Current.Save();

It causes this error:

Method not found: ‘System.collections,generic.IEnumerable’1<System.String> OpenTap.TapSerializer.GetUsedFiles()’

also calling

testPlan.Save()

for saving external parameters

I clean the project and delete all assemblies and just worked!

2 Likes