Sharing variables
- Last UpdatedDec 04, 2023
- 2 minute read
The virtual plant application supports multi-player. There must be a way to define which data requires updating in the different nodes of a running runtime. You can do this with the share declarations.
Guidelines
-
Declare a field as shared to exchange it among the application nodes. This means also that all the variables exchanged through the bridge towards external applications, such as the process simulator must be defined as shares. Otherwise, the bridge application cannot read and write the values.
-
The avatars and simulation-related shares are embedded into the simulation module PAK. There is no need to do anything to these.
-
All the item-type nodes defined by the Graphic Context Editor of the XR Studio automatically share one or more parameter. To check this, open a graphic context file as text.
-
In all other cases, declare the share explicitly. Every project typically has a shares.xml file that stores these additional shares (commands, vars). Follow this approach so that you can use the Bridge Generator to automatically populate the needed shares.
-
Generally, the share has the direction set to inout. This enables every application node to work as a source, while also receiving the variation as listeners. Only mark parameters that must be managed exclusively by a particular node (XR Instructor, XR Viewer, or the XR Bridge) as in or out. This may lead to different share options on different application nodes, so manage it carefully.
Code example
This is a code example for sharing variables.
<ItemValve name="0800-RF001" displayName="@lang:valveDisplayName@" displayValue="[*'{0:P1}',n:@0800-RF001.value@]" labelTextureFont="Arial,Bold,21" labelTextureColor="0.17 0.22 0.71" labelPosition="-19.86523 1.921733 -18.57275" group="RF0800_001" itemPosition="-19.86523 1.687828 -18.57275" tags="Valve,Section01" overridePosition="-19.86523 1.667114 -18.57275" statesHandle="1.57,0" invertRotation="True" action.open.hotkey="LT" action.open.text="@lang:actionOpen@" action.close.hotkey="RT" action.close.text="@lang:actionClose@" action.check.text="@lang:actionCheck@ " action.setop.text="@lang:actionSetOp@"/>
<share field="0800-RF001.value" direction="inout" stateZero="true"/>
<share field="0800-RF001.op" direction="inout"/>
Standard item shares
These share fields for standard items.
|
Item Type |
Parameter |
Direction |
StateZero |
|---|---|---|---|
|
ItemBasic |
value |
Inout |
True |
|
ItemPushButton |
value |
Inout |
True |
|
ItemStateDisplay |
value |
Inout |
True |
|
ItemAlarm |
value |
Inout |
True |
|
ItemKnobSelector |
value |
Inout |
True |
|
ItemTextDisplay |
value |
Inout |
True |
|
ItemGauge |
value |
Inout |
True |
|
ItemLevelDisplay |
value |
Inout |
True |
|
ItemTrendPopup |
value |
Inout |
True |
|
var0 |
Inout |
True |
|
|
var1 |
Inout |
True |
|
|
var2 |
Inout |
True |
|
|
ItemValve |
value |
Inout |
True |
|
op |
Inout |
False |
|
|
ItemLiquidLevel |
value |
Inout |
True |