I want to use a python script to add and remove device descriptors. It appears that the IScriptDeviceRepository Interface added in 3.5.9.0 gives me the methods I require, but I've been unable to work out how to get an object that implements the interface.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've got a bit further now, I found a global named . What I want to do is to ensure that I remove old versions of a set of device descriptors and add in new ones. I've managed to find the devices I want to remove, however either removing or importing devices is giving problems.
devices=device_repository.get_all_devices("MyUniqueText")fordeviceindevices:
  print("id: ", device.device_id, " info= ",device.device_info.name)
  device_repository.remove_device(device.device_id, None, True)forfileinglob.glob("artefacts/*.devdesc.xml"):
  device_repository.import_device(file, None, True)
  print("Installed "+file)
Running this gives the error below for the line with remove_device, if I comment that line I get the same for import_device.
However the documentation for the source parameter in import_device and remove_device both say
Zitat:
Remove the device from this repository source. If null the device is removed from the default repository source.
I've spent quite a while digging through the API's and I haven't managed to work out another value that I could use for the parameter.
Any help would be much appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
DavidCozens hat geschrieben:
However the documentation for the source parameter in import_device and remove_device both say
I've spent quite a while digging through the API's and I haven't managed to work out another value that I could use for the parameter.
Any help would be much appreciated.
It is a bug. I added the Jira CDS-49921 to our bug tracking, so it will be fixed eventually.
At the moment you need to specify a repository source to import or remove a device/vendor description.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
M.Keller hat geschrieben:
Hi DavidCozens.
It is a bug. I added the Jira CDS-49921 to our bug tracking, so it will be fixed eventually.
At the moment you need to specify a repository source to import or remove a device/vendor description.
BR
Martin
Hi Martin,
Thank you. I have however been unable to find an API call to give me access to any repository source. How do I find the default repository source?
regards David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
M.Keller hat geschrieben:
Hi DavidCozens.
You get the list of repository sources from the property (see IScriptRepositorySourceList) of the device repository.
jmohre hat geschrieben:
What's the best way to remove all versions of all devices from the repository, which belong
to a certain vendor?
The following example code iterates through the device sources, gets a list of all devices for a specific vendor and removes them from the device repository:
try:
  forsrcindevice_repository.sources:
    devs=device_repository.get_all_devices(src)
    devsVendor=devs.get_devices_of_vendor("Some company")
    try:
      fordevindevsVendor:
        device_repository.remove_device(dev.device_id, src, False)
    except:
      print("Failed to remove device description")finally:
  # Savethedevicecachebecauseweusedtheremove_devicewithout
  # savingthedevicecachebecauseitisfaster
  device_repository.save_device_cache()
The call of is important because otherwise the devices still appear in the repository after a restart of CODESYS but the files of the device were deleted.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to use a python script to add and remove device descriptors. It appears that the IScriptDeviceRepository Interface added in 3.5.9.0 gives me the methods I require, but I've been unable to work out how to get an object that implements the interface.
I've got a bit further now, I found a global named . What I want to do is to ensure that I remove old versions of a set of device descriptors and add in new ones. I've managed to find the devices I want to remove, however either removing or importing devices is giving problems.
Running this gives the error below for the line with remove_device, if I comment that line I get the same for import_device.
However the documentation for the source parameter in import_device and remove_device both say
I've spent quite a while digging through the API's and I haven't managed to work out another value that I could use for the parameter.
Any help would be much appreciated.
Hi DavidCozens.
It is a bug. I added the Jira CDS-49921 to our bug tracking, so it will be fixed eventually.
At the moment you need to specify a repository source to import or remove a device/vendor description.
BR
Martin
Hi Martin,
Thank you. I have however been unable to find an API call to give me access to any repository source. How do I find the default repository source?
regards David
Hi DavidCozens.
You get the list of repository sources from the property (see IScriptRepositorySourceList) of the device repository.
BR
Martin
BR
Martin
Hi Martin,
Thank you - I have that part of my script working now.
regards David
Hi,
sorry for capturing this topic, but my question might fit to that.
What's the best way to remove all versions of all devices from the repository, which belong
to a certain vendor?
I did not really find an interface that lists all installed devices of a specific vendor.
Regards
Hi jmohre.
The following example code iterates through the device sources, gets a list of all devices for a specific vendor and removes them from the device repository:
The call of is important because otherwise the devices still appear in the repository after a restart of CODESYS but the files of the device were deleted.
BR
Martin
Thanks Martin,
I found "get_devices_of_vendor" this morning - it is a bit hidden .
But I did not take care of the cache issue and the different repositories.
Regards
Jörg