ScriptIecLanguageObjectContainer

class ScriptIecLanguageObjectContainer.PouType(value)

Bases: Enum

Defines the type of the POU which is to be created.

Version added:

3.5.9.0

Program = 1

A Program.

FunctionBlock = 2

A function block.

Function = 3

A function.

class ScriptIecLanguageObjectContainer.DutType(value)

Bases: Enum

Defines the type of the DUT which is to be created.

Version added:

3.5.9.0

Structure = 1

A structure.

Enumeration = 2

An enumeration.

Alias = 3

An alias.

Union = 4

A union.

EnumerationWithTextList = 5

An enumeration with integrated text list support.

class ScriptIecLanguageObjectContainer.SpecialPouType(value)

Bases: Enum

Defines the type of special POUs (with implicit checks) which have to be created.

Version added:

3.5.12.10

none = 1

No special POU.

check_bounds = 2

Bound checks.

Appropriate handling of bound violations; such handling includes setting flags or changing field indices.

check_pointer = 3

Pointer checks.

check_range_unsigned = 4

Check range unsigned.

check_range_signed = 5

Check range signed.

check_div_real_64 = 6

Check division real 64 bit.

check_div_real_32 = 7

Check division real 32 bit.

check_div_int_64 = 8

Check division real 64 bit.

check_div_int_32 = 9

Check division real 32 bit.

check_l_range_unsigned = 10

L-range checks unsigned.

check_l_range_signed = 11

L-range checks signed.

class ScriptIecLanguageObjectContainer.ScriptIecLanguageObjectContainer

Bases: object

This allows objects to create POU like objects, the methods will be available in the project root as well as applications, and folders below them.

The extended settings and specializations which are available in the “Add Object” dialog, but not available in this interface, can be implemented by direct access of the textual declaration part via ScriptObjectWithTextualDeclaration - for example, setting derived interfaces, or persistent or constant GVLs.

Version added:

3.5.9.0

create_pou(type: SpecialPouType)

Creates a POU with implicit checks according to the specified type.

Adding a check function will provoke a full recompile and prohibit an online change.

Version added:

3.5.12.10

Parameters:

type (SpecialPouType) – The SpecialPouType which should be created.

Raises:

Exception – Any exception which might occur (e. G. if an object with the same name already exists within the same namespace or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created POU.

create_gvl(name)

Creates a GVL with the specified name.

Parameters:

name (str) – The name.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created GVL.

create_dut(name, type=DutType.Structure, baseType=None)

Creates a DUT with the specified name and type.

As with manual object creation in the UI, enums will get the attribute ‘strict’ with compiler versions >= 3.5.7.0, and additionally the attribute ‘qualified_only’ with compiler version 3.5.8.0.

Parameters:
  • name (str) – The name.

  • type (DutType) – The type.

  • 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.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created DUT.

create_interface(name, baseInterfaces='__System.IQueryInterface')

Creates an interface with the specified name.

Parameters:
  • name (str) – The name.

  • baseInterfaces (str) – The base interfaces (comma separated).

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created interface.

create_persistentvars(name)

Creates a persistent GVL with the specified name.

Parameters:

name (str) – The name.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created persistent GVL.

class ScriptIecLanguageObjectContainer.ScriptIecLanguageMemberContainer

Bases: object

This allows objects to create POU like member objects, the methods will be available on POUs, Interfaces, GVLs, and folders below them.

The extended settings and specializations which are available in the “Add Object” dialog, but not available in this interface, can be implemented by direct access of the textual declaration part via ScriptObjectWithTextualDeclaration - for example, setting derived interfaces, or persistent or constant GVLs.

Version added:

3.5.9.0

See also: ScriptTreeObject

create_property(name, return_type='int', language=None)

Creates a property with the specified name and type.

Parameters:
  • name (str) – The name.

  • return_type (str) – The return type.

  • language (Guid or None) – The language for the getter and setter. Optional, the default is structured text. It is illegal to specify a language for interface properties.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created property.

create_method(name, return_type=None, language=None)

Creates a method with the specified name and type.

Methods cannot be added to GVLs or Functions.

Parameters:
  • name (str) – The name.

  • return_type (str) – The return type.

  • language (Guid or None) – The language for the getter and setter. Optional, the default is structured text.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created method.

create_action(name, language=None)

Creates an action with the specified name and type.

Actions cannot be added to GVLs or Functions.

Parameters:
  • name (str) – The name.

  • language (Guid or None) – The language for the getter and setter. Optional, the default is structured text.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created action.

create_transition(name, language=None)

Creates an transition with the specified name and type.

Transitions cannot be added to GVLs or Functions.

Parameters:
  • name (str) – The name.

  • language (Guid or None) – The language for the getter and setter. Optional, the default is structured text.

Raises:

Exception – Any exception which might occur (e. G. if the name is not an IEC identifier, or an object with the same name already exists within the same namespace, or the language guid is not valid, or the object cannot be created under this parent.

Return type:

ScriptObject

Returns:

The ScriptObject of the newly created transition.

class ScriptIecLanguageObjectContainer.ScriptImplementationLanguage

Bases: object

Defines the Guids for the standard IEC 61131-3 languages and those available as CODESYS extensions.

An instance of this interface will be injected with the name “ImplementationLanguages”.

Version added:

3.5.9.0

property st

Gets the language guid for ST / Structured Text.

Return type:

Guid

property cfc

Gets the language guid for CFC / Continous Flow Chart (free layout FUP).

Return type:

Guid

property page_oriented_cfc

Gets the language guid for Page oriented CFC / Continous Flow Chart (free layout FUP).

Return type:

Guid

property fbd

Gets the language guid for FBD / Function Block Diagram (FBS).

Return type:

Guid

property instruction_list

Gets the language guid for IL / Instruction List (AWL).

Return type:

Guid

property ladder

Gets the language guid for LD / Ladder Diagram (KOP).

Return type:

Guid

property sfc

Gets the language guid for SFC / Secuential Function Chart (AS).

Currently, SFC cannot be used for ScriptIecLanguageObjectContainer.create_pou() with PouType.Function, ScriptIecLanguageMemberContainer.create_method(), ScriptIecLanguageMemberContainer.create_property() and ScriptIecLanguageMemberContainer.create_transition().

Return type:

Guid

property uml_statechart

Gets the language guid for the uml statechart.

The UML AddOn needs to be installed for this language. See also: http://store.codesys.com/codesys-uml.html

Return type:

Guid