CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Fri Jul 28, 2017 1:41 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Feb 27, 2017 5:08 pm 
Offline

Joined: Tue Feb 21, 2017 10:15 am
Posts: 8
Hello there,

i have a device object in my python script which has user-defined parameters which are shown in the codesys gui in the "general" tab of said device. how can i access and modify these in my python script? i already found the
Code:
myDevice.device_parameters
list, but
Code:
len(myDevice.device_parameters)
equals zero.

what is the right name for the list of user-defined parameters?

Greetings


Top
   
PostPosted: Mon Feb 27, 2017 6:21 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 202
Hi AndreasDeDeDe.

There are device parameters and there are host parameters. Maybe your device has no device parameters.

Look at my example in my previous post.

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: Thu Mar 30, 2017 10:24 am 
Offline

Joined: Tue Feb 21, 2017 10:15 am
Posts: 8
I found the correct parameters:

device.connectors[0].host_parameters

and the concrete parameters are accessible over

masterParams = master.connectors[0].host_parameters

masterParams.by_id(id)

and id can be found with the printtree function (i guess, or it was another tree func, it's been a while. anyway, it's helpful):

Code:
def printtree_rec(treeobj, depth=0):
   name = treeobj.get_name(False)   
   if treeobj.is_device:
      deviceid = treeobj.get_device_identification()
      print("{0} - {1} {2}".format("--"*depth, name, deviceid))
   for child in treeobj.get_children(False):
      printtree_rec(child, depth+1)

def printTree(proj):
   for obj in proj.get_children():
      printtree_rec(obj)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 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