Change User-Defined parameters of a Device

2017-02-27
2017-03-30
  • AndreasDeDeDe - 2017-02-27

    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 ```

    myDevice.device_parameters

    list, but

    len(myDevice.device_parameters)

    ``` equals zero.

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

    Greetings

     
  • mkeller - 2017-02-27

    Hi AndreasDeDeDe.

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

    previous post.

    BR
    Martin

     
  • AndreasDeDeDe - 2017-03-30

    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):

    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)
    
     

Log in to post a comment.