Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

defmodule

  • Last UpdatedDec 16, 2023
  • 3 minute read

Use the defmodule command to create a module definition. Module definitions are useful for embedding XR content inside a single recipient and accessing them through a single interface.

Use the Module node to create instances of a defmodule. The same defmodule can be instanced multiple times. An instanced Module is similar to an actual node with configuration input and output fields.

Platform support

This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P Hololens platforms.

XR-WIN

XR-P-WIN

XR-P-IOS

XR-P-AND

XR-P-WASM

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Creating a module definition

When creating a defmodule, the following elements should be provided inside it:

  • A set of configuration items to use to configure the module behavior.

  • A set of input and output items to define module read/write ports.

  • The module logic or even better a set of include statements to point module logic files.

    Note: Due to its nature, it is highly recommended that you put the module logic inside a namespace and private statements.

Code example

This is a code example of defmodule.

<defmodule name="capitalizer" version="1.0.0" >

<configuration name="mandatoryConfig" isMandatory="true" type="sstring" />

<configuration name="nonMandatoryConfig" type="sstring" value="DEFAULT_VALUE" />

<configuration name="nonMandatoryConfig2" isMandatory="false" type="sfloat" value="0.1" />

<configuration name="nonMandatoryConfig3" isMandatory="[@exists:myVar]" type="sbool" value="true" />

<input name="string" type="sstring" />

<output name="string" type="sstring" />

<include name="modules/capitalizer/capitalizer_logic.xml" />

</defmodule>

Accessing module elements from within defmodule script

A defmodule defines a set of module interface fields. These fields, together with name and version properties are accessible from within the defmodule using the following wildcards.

Fields

Type

Wildcard

Module name

sstring

%module.name%

Module version

sstring

%module.version%

configuration

Defined in configuration.

%module.configurationName%

Code example

This script sample shows how to use such references for the input, output, and configuration statements.

<namespace name="%module.name%">

<Var name="NAMESPACE::capitalizerVar_1" type="sstring" value="%module.mandatoryConfig%" />

<Var name="NAMESPACE::capitalizerVar_2" type="sfloat" value="%module.nonMandatoryConfig2%" />

<Var name="NAMESPACE::capitalizerVar_3" type="sbool" value="%module.nonMandatoryConfig3%" />

<!-- Route from module logic to module logic node input/output fields -->

<route from="%module.name%.input_string" to="%module.name%.output_string" value="[@%module.name%.input_string.toUpper()]" />

</namespace>

Fields

These are the fields for defmodule command.

Fields

Type

Use

Default value

Description

name

sstring

Mandatory

Not set

The name of the module template.

version

sstring

Optional

Not set

The version of the defmodule. This value is used by the system to prevent use of different module versions that can create inconsistencies.

In This Topic
TitleResults for “How to create a CRG?”Also Available in