The main_context file
- Last UpdatedJan 24, 2023
- 2 minute read
The main_context.xml is a script file that is used as an index of files to be loaded to run the entire project. Virtual plant projects have many graphic context files.
According to cfg_commons.xml file parameter main.graphicContext this is the base file for loading the simulation contents.
Only a few files that are automatically run by the system and the graphic context logic file do not have to be listed.
Good practice
A good practice is to create a list of defines; one for each section of the plant and to use them to enable/disable loading of set of files.
Being the 'main' project file, the main_context.xml can be used to store commands of general usage with their activation routes, often based on scene loading such as global.onEnter.
An example could be a command that deactivates after loading. This is done to ensure all the animations are not running at the same time and consuming FPS.
Code example
Code example for the main_context file.
<!-- defines --> <define name="load.section01" value="true" />
<define name="load.section02" value="true" />
<define name="load.section03" value="true" />
<define name="load.section04" value="true" />
<define name="load.section05-06" value="true" />
<define name="load.piperack" value="true" />
<define name="load.shares" value="true" />
<!-- sections --> <if condition="@def:load.section01@">
<include name="user\Section01.xml"/>
</if>
<if condition="@def:load.section02@">
<include name="user\Section02.xml"/>
</if>
<if condition="@def:load.section03@">
<include name="user\Section03.xml"/>
</if> <if condition="@def:load.section04@">
<include name="user\Section04.xml"/>
</if>
<if condition="@def:load.section05-06@">
<include name="user\Section05-06.xml"/>
</if>
<if condition="@def:load.piperack@">
<include name="user\Piperack.xml"/>
</if>
<!--animation name --> <if condition="@def:load.section01@">
<include name="user\E801.xml"/>
<include name="user\T801_NEW.xml"/>
<include name="user\E1304.xml"/>
<include name="user\T1401.xml"/>
</if> <if condition="@def:load.section02@">
<include name="user\G400.xml"/>
<include name="user\WF207.xml"/>
</if> <if condition="@def:load.section04@">
<include name="user\T1001_NEW.xml"/>
<include name="user\T1002_NEW.xml"/>
<include name="user\E701.xml"/>
</if> <if condition="@def:load.section05-06@">
<include name="user\ST2001.xml"/>
<include name="user\GT1501.xml"/>
<include name="user\D1903.xml"/>
</if>
<!-- logic files -->
<include name="user\animation_override.xml"/>
<include name="user\Animation_keysensors.xml"/>
<include name="user\liquidInside.xml"/>
<include name="user\initialCondition.xml"/>
<include name="user\weather.xml"/>
<include name="user\trends.xml"/>
<include name="user\pumps.xml"/>
<include name="user\pressureGauges.xml"/>
<include name="user\specials.xml"/>
<include name="user\logger.xml"/>
<include name="user\camera_settings.xml"/>
<if condition="@def:load.shares@">
<include name="user\shares.xml"/>
</if>