CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Fri Dec 15, 2017 3:07 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Dec 06, 2017 3:34 pm 
Offline

Joined: Wed Apr 13, 2016 10:27 am
Posts: 20
Hi,

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

Quote:
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.


Top
   
PostPosted: Thu Dec 07, 2017 4:11 pm 
Offline

Joined: Wed Apr 13, 2016 10:27 am
Posts: 20
:D 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 :
Code:
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""") 


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