<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/</id><updated>2020-02-27T14:48:20.155000Z</updated><subtitle>Recent posts to Need example of using IScriptDeviceRepository Interface</subtitle><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#9726" rel="alternate"/><published>2020-02-27T14:48:20.155000Z</published><updated>2020-02-27T14:48:20.155000Z</updated><author><name>jmohre</name><uri>https://forge.codesys.com/u/jmohre/</uri></author><id>https://forge.codesys.comc4f7a29a6ad40ddf6d6584d8e18e4fdf6b01ee14</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks Martin,&lt;/p&gt;
&lt;p&gt;I found "get_devices_of_vendor" this morning - it is a bit hidden .&lt;br/&gt;
But I did not take care of the cache issue and the different repositories.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Jörg&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#a970" rel="alternate"/><published>2020-02-27T14:48:19.562000Z</published><updated>2020-02-27T14:48:19.562000Z</updated><author><name>mkeller</name><uri>https://forge.codesys.com/u/mkeller/</uri></author><id>https://forge.codesys.com4d1b0d612a93a6e525a04492c6506efa3e37eecd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi jmohre.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;jmohre hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
What's the best way to remove all versions of all devices from the repository, which belong&lt;br/&gt;
to a certain vendor?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;try&lt;/span&gt;:
   &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;src&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;sources&lt;/span&gt;:
      &lt;span class="nv"&gt;devs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;get_all_devices&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;src&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;devsVendor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;devs&lt;/span&gt;.&lt;span class="nv"&gt;get_devices_of_vendor&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Some company&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;try&lt;/span&gt;:
         &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;dev&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;devsVendor&lt;/span&gt;:
            &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;remove_device&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;dev&lt;/span&gt;.&lt;span class="nv"&gt;device_id&lt;/span&gt;, &lt;span class="nv"&gt;src&lt;/span&gt;, &lt;span class="nv"&gt;False&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
      &lt;span class="nv"&gt;except&lt;/span&gt;:
         &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Failed to remove device description&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;finally&lt;/span&gt;:
   # &lt;span class="nv"&gt;Save&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;device&lt;/span&gt; &lt;span class="nv"&gt;cache&lt;/span&gt; &lt;span class="nv"&gt;because&lt;/span&gt; &lt;span class="nv"&gt;we&lt;/span&gt; &lt;span class="nv"&gt;used&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;remove_device&lt;/span&gt; &lt;span class="nv"&gt;without&lt;/span&gt;
   # &lt;span class="nv"&gt;saving&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;device&lt;/span&gt; &lt;span class="nv"&gt;cache&lt;/span&gt; &lt;span class="nv"&gt;because&lt;/span&gt; &lt;span class="nv"&gt;it&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;faster&lt;/span&gt;
   &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;save_device_cache&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Martin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#3081" rel="alternate"/><published>2020-02-27T14:48:17.999000Z</published><updated>2020-02-27T14:48:17.999000Z</updated><author><name>jmohre</name><uri>https://forge.codesys.com/u/jmohre/</uri></author><id>https://forge.codesys.com71be3f00a0bd49a9e32496760d3e1d056743c001</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, &lt;br/&gt;
sorry for capturing this topic, but my question might fit to that.&lt;/p&gt;
&lt;p&gt;What's the best way to remove all versions of all devices from the repository, which belong&lt;br/&gt;
to a certain vendor?&lt;/p&gt;
&lt;p&gt;I did not really find an interface that lists all installed devices of a specific vendor.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#e868" rel="alternate"/><published>2020-02-27T14:48:17.425000Z</published><updated>2020-02-27T14:48:17.425000Z</updated><author><name>DavidCozens</name><uri>https://forge.codesys.com/u/davidcozens/</uri></author><id>https://forge.codesys.comac33950e30eb230dde9b7b18ce0c6fe5946fe7cc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;M.Keller hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi DavidCozens.&lt;br/&gt;
You get the list of repository sources from the property  (see IScriptRepositorySourceList) of the device repository.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;sources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;device_repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sources&lt;/span&gt;
&lt;span class="n"&gt;mySource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;"My Device Repository"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;BR&lt;br/&gt;
Martin&lt;/p&gt;
&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Thank you - I have that part of my script working now.&lt;/p&gt;
&lt;p&gt;regards David&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#558e" rel="alternate"/><published>2020-02-27T14:48:16.829000Z</published><updated>2020-02-27T14:48:16.829000Z</updated><author><name>mkeller</name><uri>https://forge.codesys.com/u/mkeller/</uri></author><id>https://forge.codesys.com7e5696706449194b7821d2fb672f2a2d7c92fd5e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi DavidCozens.&lt;/p&gt;
&lt;p&gt;You get the list of repository sources from the property  (see IScriptRepositorySourceList) of the device repository.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;sources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;device_repository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sources&lt;/span&gt;
&lt;span class="n"&gt;mySource&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;"My Device Repository"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;BR&lt;br/&gt;
Martin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#db9e" rel="alternate"/><published>2020-02-27T14:48:15.200000Z</published><updated>2020-02-27T14:48:15.200000Z</updated><author><name>DavidCozens</name><uri>https://forge.codesys.com/u/davidcozens/</uri></author><id>https://forge.codesys.com9191a11f31b8d42fca57914fe5f1aa5d713205a4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;M.Keller hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi DavidCozens.&lt;br/&gt;
It is a bug. I added the Jira &lt;a class="" href="http://jira.3s-software.com/browse/CDS-49921" rel="nofollow"&gt;CDS-49921&lt;/a&gt; to our bug tracking, so it will be fixed eventually.&lt;br/&gt;
At the moment you need to specify a repository source to import or remove a device/vendor description.&lt;br/&gt;
BR&lt;br/&gt;
Martin&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;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?&lt;/p&gt;
&lt;p&gt;regards David&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#060d" rel="alternate"/><published>2020-02-27T14:48:14.582000Z</published><updated>2020-02-27T14:48:14.582000Z</updated><author><name>mkeller</name><uri>https://forge.codesys.com/u/mkeller/</uri></author><id>https://forge.codesys.comf1692f5445ac12c00721c2ab1b9adc0f0a06d2f6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi DavidCozens.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;DavidCozens hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
However the documentation for the source parameter in import_device and remove_device both say&lt;br/&gt;
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.&lt;br/&gt;
Any help would be much appreciated.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It is a bug. I added the Jira &lt;a class="" href="http://jira.3s-software.com/browse/CDS-49921" rel="nofollow"&gt;CDS-49921&lt;/a&gt; to our bug tracking, so it will be fixed eventually.&lt;/p&gt;
&lt;p&gt;At the moment you need to specify a repository source to import or remove a device/vendor description.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Martin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#9f5f" rel="alternate"/><published>2020-02-27T14:48:13.897000Z</published><updated>2020-02-27T14:48:13.897000Z</updated><author><name>DavidCozens</name><uri>https://forge.codesys.com/u/davidcozens/</uri></author><id>https://forge.codesys.com005654e16398c57aee5dffc891673f25cb18589b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;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.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;devices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;get_all_devices&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;MyUniqueText&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;device&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;devices&lt;/span&gt;:
    &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id: &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;, &lt;span class="nv"&gt;device&lt;/span&gt;.&lt;span class="nv"&gt;device_id&lt;/span&gt;, &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt; info= &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;,&lt;span class="nv"&gt;device&lt;/span&gt;.&lt;span class="nv"&gt;device_info&lt;/span&gt;.&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;remove_device&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;device&lt;/span&gt;.&lt;span class="nv"&gt;device_id&lt;/span&gt;, &lt;span class="nv"&gt;None&lt;/span&gt;, &lt;span class="nv"&gt;True&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;file&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;glob&lt;/span&gt;.&lt;span class="nv"&gt;glob&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;artefacts/*.devdesc.xml&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
    &lt;span class="nv"&gt;device_repository&lt;/span&gt;.&lt;span class="nv"&gt;import_device&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;file&lt;/span&gt;, &lt;span class="nv"&gt;None&lt;/span&gt;, &lt;span class="nv"&gt;True&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Installed &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;file&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Running this gives the error below for the line with remove_device, if I comment that line I get the same for import_device.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ArgumentNullException&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Traceback&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;most&lt;/span&gt; &lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="k"&gt;call&lt;/span&gt; &lt;span class="k"&gt;last&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="ss"&gt;"C:\Users\David\Documents\scripts\CODESYS\CheckoutProject.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Value&lt;/span&gt; &lt;span class="n"&gt;cannot&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;Parameter&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;source&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;However the documentation for the source parameter in import_device and remove_device both say&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Zitat:&lt;/strong&gt;&lt;br/&gt;
Remove the device from this repository source. If null the device is removed from the default repository source. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;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.&lt;br/&gt;
Any help would be much appreciated.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Need example of using IScriptDeviceRepository Interface</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/9f3063b7a2/?limit=25#b1b4" rel="alternate"/><published>2020-02-27T14:48:12.182000Z</published><updated>2020-02-27T14:48:12.182000Z</updated><author><name>DavidCozens</name><uri>https://forge.codesys.com/u/davidcozens/</uri></author><id>https://forge.codesys.combdbde49b8836383042d18da66e9d0b188388ac5e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>