Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

add device to an explicit connector

Anonymous
2016-03-16
2016-03-17
  • Anonymous - 2016-03-16

    Originally created by: AT_TE

    Hello,

    Is it possible to add a device to an explicit connector?

    I tried the following step but it doesn't work:

    connector.add("NewDevice",device_type,device_id,device_version)
    

    CODESYS puts the message: 'ScriptDeviceConnector' object has no attribute 'add'

     
  • mkeller - 2016-03-17

    Hi.

    Explicit connectors are special device objects which can be found in the normal object tree.

    Here some example code which adds a SoftMotion device and plugs a camera into a slot:

    proj = projects.primary
    dev = proj.find("Device")[0]
    conn = dev.find("SoftMotion General Axis Pool")[0]
    if conn.is_explicit_connector:
    Β  Β print("add SM device")
    Β  Β conn.add("SM_Drive_PosControl", 1025, "0000 0001", "3.5.7.0")
    conn = dev.find("Camera device")[0]
    if conn.is_explicit_connector:
    Β  Β camDev = conn.find("<Empty>")[0]
    Β  Β print("plug camera")
    Β  Β camDev.plug("MyCam", 502, "0000 0002", "1.0.0.0")
    

    BR
    Martin

     

Log in to post a comment.