CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Dec 18, 2018 4:27 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: export/import devices
PostPosted: Fri Oct 20, 2017 1:22 pm 
Offline

Joined: Wed Dec 10, 2014 12:57 pm
Posts: 23
Hi,
I need to export and import devices from one repository to another. I can see the export option in codesys, but i do not find the corresponding option in ScriptDeviceDescrition
Attachment:
1.JPG


to get the device I'm using this code:

Code:
for id in range(0, DevRepList.__len__()):   # for some reaseon for Dev in DevRepList wont work
      if DevRepList[id].name == "X-Soft":
         XList=device_repository.get_all_devices(DevRepList[id])
         for  xDev in XList:
            pass # do export

Is it possible at all to export devices?

Thanks,
Nina


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Mon Oct 23, 2017 9:25 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi Nina.

Nina wrote:
Code:
for id in range(0, DevRepList.__len__()):   # for some reaseon for Dev in DevRepList wont work
      if DevRepList[id].name == "X-Soft":
         XList=device_repository.get_all_devices(DevRepList[id])
         for  xDev in XList:
            pass # do export

About the first line of your code: Where does the DevRepList come from?

Nina wrote:
Is it possible at all to export devices?

The export of device descriptions was added with CODESYS V3.5 SP10 and the Scripting API does not support it yet. I added an entry to our bug tracking so it will be implemented at some point.

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Mon Oct 23, 2017 10:38 am 
Offline

Joined: Wed Dec 10, 2014 12:57 pm
Posts: 23
M.Keller wrote:
About the first line of your code: Where does the DevRepList come from?


sorry, i forgot the first line:
Code:
DevRepList=device_repository.sources
for id in range(0, DevRepList.__len__()):   # for some reaseon for Dev in DevRepList wont work
      if DevRepList[id].name == "X-Soft":
         XList=device_repository.get_all_devices(DevRepList[id])
         for  xDev in XList:
            pass # do export


Thanks for adding to jira


Top
   
PostPosted: Mon Oct 23, 2017 11:20 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi Nina.

The iteration of device_repository.sources should work. I tested it with the following code and had no problem:

Code:
sources = device_repository.sources
assert(len(sources) > 0, "no repo sources")

print("Available sources of the device repository:")
for src in sources:
   print("- {}: {}".format(src.name, src.location_url))

count = 0
print("Get all device descriptions from a specific source")
sysRepoSource = sources["System Repository"]
devColl = device_repository.get_all_devices(sysRepoSource)
for dev in devColl:
   printDeviceDesc(dev)
   count += 1
   if count > 100:
      break

You find the complete source code as attachment.

BTW: You can get the repo source by name. The syntax for it is sources["some name"]. It will return the matching repo source or None if there is none with that name.

BR
Martin


You do not have the required permissions to view the files attached to this post.

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited