Library: AC_ModuleBase
The module basic library AC_ModuleBase is part of the module concept of the CODESYS Application Composer. All modules which are developed to be available in the module tree configurator have to be derived from this basic library.
Instance name
The property InstanceName
of the base class returns a string which contains the name of the module instance.
Property in IInstanceBase
:PROPERTY InstanceName : STRING(255)
Return value: Instance name of the module instance
Tip
Proxy instances return the instance name of the remote module instance.
Module info
PROPERTY ModuleInfo : POINTER TO ModuleInfo
: This property returns a pointer to a ModuleInfo function block with method PROPERTY ModuleType : STRING(255)
.
PROPERTY ModuleType : STRING(255)
: This property returns the module name which is qualified by the name space of the module library. (The name space is relative to the primary project.)
Instance path
The function GetInstancePath(IModule)
returns the instance path of a module instance. The instance path is built by concatenating the instance names of all ancestors, starting from the toplevel module down to the given instance. The instance names are separated by dots. If the resulting instance name is longer than 255 characters, an empty string is returned.
PROPERTY InstancePath : STRING(255)
Flat navigation
The function GetPrevModule(IModule)
and GetNextModule(IModule)
allow to jump to the previous or to the next element (if the module tree is regarded as a flat list of module instances). The modules are returned in depth-first preorder of the module tree. Module references are skipped if there is no previous or no next module.
Alternatively the function block DepthFirstRange
can be used which lists all instances starting at a specific instance. The function GetDepthFirstRange
returns a range function block instance (of type DepthFirstRange
) which lists the complete tree, starting at a given instance.
Hierarchically navigation
The interface IModuleTree
allows to navigate in the module tree. An object of this interface is provided to each module by use of a pointer to an instance of type MEnv
. This pointer is passed to the function SetIdentification
. Module references are skipped in the navigation. The order of child nodes corresponds to the order of the module instances in the module tree.
GetParent(itfM : IModule) : IModule
: IModule: Returns the parent instance of a given module instance. For toplevel module instances the return value is 0.
GetFirstChild(itfM : IModule) : IModule
: Returns the first child of a given module instance. For module instances without children the return value is 0
NextSibling(itfM : IModule) : IModule
: Returns the next sibling of a module instance. For module instances with no further sibling it returns 0. It can be called for toplevel instances, too.
PrevSibling(itfM : IModule) : IModule
: Returns the previous sibling of a module instance. For module instances with no previous sibling it returns 0. It can be called for toplevel instances, too.
GetFirstToplevelInstance() : IModule
: Returns the first toplevel instance of the tree. It returns 0 if the tree is empty.
Navigation to ancestors, siblings and children
The function block AncestorRange
allows to access all ancestors of an instance, starting at the instance itself. The function block SiblingRange
allows to access all following siblings of an instance in the module tree, starting at the instance itself. The function GetChildRange
returns a range element (type SiblingRange
) of all children of an instance.
Navigation to toplevel
The function GetToplevelRange
returns a range instance (type SiblingRange
) which provides access to all toplevel instances. The function GetToplevelInstance
returns the toplevel module that is an ancestor of the given instance.