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

the parameter for method "create_dut"

hhz
2017-12-06
2017-12-07
  • hhz - 2017-12-06

    Hi,

    i want to create Enumeration (data Unit Type) by using Script method "create_dut()". In online help written:

    Zitat:
    create_dut(name, type, baseType)
    Creates a DUT with the specified name and type.
    Parameter: name (str)
    The name.
    Parameter: type (DutType)
    The type. Optional, the default is a structure.
    Parameter: baseType (str)
    The base type. This optional parameter is necessary for for Alias types, optional for STRUCTs and enums, and currently not allowed for unions.
    Returns: (IScriptObject)
    The IScriptObject of the newly created POU.

    But I don't know, how to name the DutType in script. as written in help Int or str. can not be accept.

    Thanks for any replay!

    BR.

     
  • hhz - 2017-12-07

    after long time search and probe. It works at the end.

    Here just a exsample for someone, who this use-case also interested. The complete command shall be :

    myDUT = Application.create_dut("STATE", DutType.Enumeration)     # add declaration of the ENUM 
          # here parameter "DutType" can be  DutType.Structure(default), DutType.Enumeration , DutType.Alias, DutType.Union .
    implementation = myDUT.textual_declaration.replace("""TYPE STATE :
    (
       Examples_INT := 0,    (* *)
       SEND,      (* Send messages *)
       READ,      (* Receive messages *)
       ERROR      (* error single *)
    );
    END_TYPE""")  
    
     

Log in to post a comment.