Interface miMod(Model) – step 0031 – January 2010
There are several types of SrrTrains Models
Intrinsic Models
Static Models
Vehicle Models
Remark: SrrTrains does not pose any requirements on Non-SrrTrains Models, that might be used in SrrTrains model railroad layouts, too.
Intrinsic models are implemented as part of a module, using SRR objects directly. Such models do NOT provide the miMod(Model) interface.
Static models are provided as X3D prototypes, providing the miMod(Model) interface to be loaded and initialized by a module statically.
Vehicle models, providing the miMod(Model) interface to be loaded and initialized by the SRR Controller – TMM.
Static models use SRR objects to implement (a part of) their functionality.
Furthermore they may use the SrrTracer prototype to output diagnostic information.
Both options require to have an object ID (objId) and to be initialized with the module parameters (modParam).
Therefore SrrTrains requires the following minimum interface from a static model:
The static model shall be implemented as a <ProtoDeclare> node in an external file.
The model author shall document how to reach the prototype file (URL).
The model author shall document the origin and orientation of the local coordinate system in relation to the model (enabling the module author to create a surrounding <Transform> node with the right values of translation and rotation).
Alternatively, the model author shall provide and document some fields at the interface, that allow to set position and orientation of the model.
The prototype defined in the <ProtoDeclare> shall provide at least the following interface.
<ProtoDeclare
name='NameOfTheStaticModel'>
<ProtoInterface>
<field
accessType='inputOutput' name='objId' type='SFString'/>
<field
accessType='inputOutput' name='modParam'
type='SFNode'/>
</ProtoInterface>
<ProtoBody>
:
:
:
</ProtoBody>
</ProtoDeclare>
The prototype shall use the objId and the modParam to initialize all contained SRR objects and an optional SrrTracer instance.
Vehicle models are loaded by the SRR Controller – TMM. The convention is, that the file, that is referenced by an URL, must create one or more X3D nodes, when being loaded with Browser.createVrmlFromURL().
The second node will be taken as the model's instance.
After having loaded the model, the SRR Controller will
set standalone to false
set the quasiModule field to the quasi-module-name that has to be used instead of a module name in trace output and network sensor IDs
set the objId of the instance of the model
initialize the model with the modParam parameter
wait, until the model outputs initialized != null (success case) or initialized = null (failure case)
When unloading a model, the SRR Controller will
set the enabled parameter of the model to false.
Hence, SrrTrains requires the following minimum interface from a vehicle model
The vehicle model shall be implemented in an external file, accessible by a URL.
When loading the file with Browser.createVrmlFromUrl(), the second node of the created scene shall represent the instance of the vehicle.
This vehicle shall be instrumented by SRR objects (a so-called specific vehicle prototype).
The instance of the vehicle shall offer at least following fields
<field
accessType='inputOutput' name='objId' type='SFString'/>
<field
accessType='inputOutput' name='quasiModule' type='SFString'/>
<field
accessType='inputOutput' name='modParam' type='SFNode'/>
<field
accessType='inputOutput' name='standalone' type='SFBool'
value="true"/>
<field accessType='outputOnly'
name='initialized' type='SFNode'/>
<field
accessType='inputOutput' name='enabled' type='SFBool' value='true'/>
objId, quasiModule and modParam shall be used to initialize the contained specific vehicle prototype and to initialize an optional instance of SrrTracer. The value of objId will be set by the SRR Controller – TMM.
The value of standalone shall be forwarded to the specific vehicle prototype, SRR Controller – TMM will set this value to false, after having loaded the vehicle.
The value of enabled shall be forwarded to the specific vehicle prototype and it shall be used to enable/disable all other time sensors / network sensors etc. of the model.
When the specific vehicle prototype reports initialized, the vehicle model shall forward this value to the user (SRR Controller – TMM).
<Scene>
<ProtoDeclare
name='MyFirstWagon'>
<!-- ****************************
external interface of the prototype
********************************* -->
<ProtoInterface>
<field
accessType='inputOutput' name='vIdleRotation' type='SFFloat'
value="1.0"/>
<field accessType='inputOutput'
name='idleRotate' type='SFBool' value="false"/>
<field
accessType='inputOutput' name='objId' type='SFString'/>
<field
accessType='inputOutput' name='quasiModule'
type='SFString'/>
<field accessType='inputOutput'
name='modParam' type='SFNode'/>
<field
accessType='inputOutput' name='standalone' type='SFBool'
value="true"/>
<field accessType='outputOnly'
name='initialized' type='SFNode'/>
<field
accessType='inputOutput' name='enabled' type='SFBool'
value='true'/>
</ProtoInterface>
<ProtoBody>
<!--
**************************** external prototypes
********************************* -->
<ExternProtoDeclare
name='SrrWagon2axA' url='"../srr/SrrWagon2axA.x3d"
"http://members.chello.at/christoph.valentin/srr/SrrWagon2axA.x3d"'>
<field
accessType='inputOutput' name='objType' type='SFString'
value='SrrWagon2axA'/>
<field accessType='inputOutput'
name='version' type='SFFloat' value='0.0031'/>
<field
accessType='inputOutput' name='objId' type='SFString'/>
<field
accessType='inputOutput' name='quasiModule'
type='SFString'/>
<field accessType='inputOutput'
name='mass' type='SFFloat' value="1000"/>
<field
accessType='inputOutput' name='wee' type='SFFloat'
value="0.0025"/>
<field
accessType='inputOutput' name='length' type='SFFloat'
value="5.0"/>
<field accessType='inputOutput'
name='axlesPositions' type='MFFloat' value='1.0 4.0'/>
<field
accessType='inputOutput' name='axle0' type='SFNode'/>
<field
accessType='inputOutput' name='axle1' type='SFNode'/>
<field
accessType='inputOutput' name='transformationWagon'
type='SFNode'/>
<field accessType='inputOutput'
name='vIdleRotation' type='SFFloat' value="1.0"/>
<field
accessType='inputOutput' name='idleRotate' type='SFBool'
value="false"/>
<field
accessType='inputOutput' name='vConstControl'
type='SFNode'/>
<field accessType='inputOutput'
name='vConstEnableControl' type='SFNode'/>
<field
accessType='inputOutput' name='dozeControl'
type='SFNode'/>
<field accessType='inputOutput'
name='standalone' type='SFBool' value='true'/>
<field
accessType='inputOutput' name='visible' type='SFInt32'/>
<field
accessType='outputOnly' name='basicallyInitialized'
type='SFNode'/>
<field accessType='inputOutput'
name='modParam' type='SFNode'/>
<field
accessType='outputOnly' name='initialized' type='SFNode'/>
<field
accessType='inputOutput' name='enabled' type='SFBool'
value='true'/>
<field accessType='outputOnly'
name='staticModel' type='SFBool'/>
<field
accessType='inputOutput' name='exitViewpoint'
type='SFNode'/>
<field accessType='inputOnly'
name='deleteTrain'
type='SFTime'/>
</ExternProtoDeclare>
:
:
:
<Group
DEF='PrototypeRootNode'>
<Switch
DEF='MasterOnOff'>
<Group>
<!--
**************************** graphical representation of the first
axle ********************************* -->
<Transform
DEF="FirstAxleTransform1" >
<Transform
DEF="FirstAxleTransform2"
>
:
:
:
</Transform>
</Transform>
<!--
**************************** graphical representation of the second
axle ********************************* -->
<Transform
DEF="SecondAxleTransform1" >
<Transform
DEF="SecondAxleTransform2"
>
:
:
:
</Transform>
</Transform>
<!--
**************************** graphical representation of the body
of the wagon ********************************* -->
<Transform
DEF="BodyTransform1">
<Transform
DEF="BodyTransform2"
>
:
:
:
</Transform>
</Transform>
</Group>
</Switch>
<!--
**************************** SRR-objects for the functionality of
the wagon ********************************* -->
<ProtoInstance
DEF="SrrWagon2ax" name='SrrWagon2axA'>
<fieldValue
name='mass' value='1600'/>
<fieldValue name='length'
value='8.155'/>
<fieldValue name='axlesPositions'
value='2.235 5.92'/>
<fieldValue
name="axle0">
<ProtoInstance DEF="Axle0"
name="SrrAxle">
<fieldValue name="inverse"
value="false"/>
<fieldValue
name="transformation">
<ProtoInstance
DEF="SrrTransformFromSrrObjectAxle0"
name="SrrTransformationA"/>
</fieldValue>
<fieldValue
name="wheelRadius"
value="0.51"/>
</ProtoInstance>
</fieldValue>
<fieldValue
name="axle1">
<ProtoInstance DEF="Axle1"
name="SrrAxle">
<fieldValue name="inverse"
value="false"/>
<fieldValue
name="transformation">
<ProtoInstance
DEF="SrrTransformFromSrrObjectAxle1"
name="SrrTransformationA"/>
</fieldValue>
<fieldValue
name="wheelRadius"
value="0.51"/>
</ProtoInstance>
</fieldValue>
<fieldValue
name="transformationWagon">
<ProtoInstance
DEF="SrrTransformFromSrrObjectWagon"
name="SrrTransformationA"/>
</fieldValue>
:
:
:
<IS>
<connect
nodeField="standalone"
protoField="standalone"/>
</IS>
</ProtoInstance>
<ROUTE
fromField='visible' fromNode='SrrWagon2ax' toField='whichChoice'
toNode='MasterOnOff'/>
<ROUTE fromField='transformation'
fromNode='SrrTransformFromSrrObjectAxle0' toField='transfToX3D'
toNode='SrrTransformFromSrrObjectAxle0'/>
<ROUTE
fromField='translation' fromNode='SrrTransformFromSrrObjectAxle0'
toField='translation' toNode='FirstAxleTransform1'/>
<ROUTE
fromField='rotation1' fromNode='SrrTransformFromSrrObjectAxle0'
toField='rotation' toNode='FirstAxleTransform1'/>
<ROUTE
fromField='rotation2' fromNode='SrrTransformFromSrrObjectAxle0'
toField='rotation' toNode='FirstAxleTransform2'/>
<ROUTE
fromField='transformation' fromNode='SrrTransformFromSrrObjectAxle1'
toField='transfToX3D'
toNode='SrrTransformFromSrrObjectAxle1'/>
<ROUTE
fromField='translation' fromNode='SrrTransformFromSrrObjectAxle1'
toField='translation' toNode='SecondAxleTransform1'/>
<ROUTE
fromField='rotation1' fromNode='SrrTransformFromSrrObjectAxle1'
toField='rotation' toNode='SecondAxleTransform1'/>
<ROUTE
fromField='rotation2' fromNode='SrrTransformFromSrrObjectAxle1'
toField='rotation' toNode='SecondAxleTransform2'/>
<ROUTE
fromField='transformation' fromNode='SrrTransformFromSrrObjectWagon'
toField='transfToX3D'
toNode='SrrTransformFromSrrObjectWagon'/>
<ROUTE
fromField='translation' fromNode='SrrTransformFromSrrObjectWagon'
toField='translation' toNode='BodyTransform1'/>
<ROUTE
fromField='rotation1' fromNode='SrrTransformFromSrrObjectWagon'
toField='rotation' toNode='BodyTransform1'/>
<ROUTE
fromField='rotation2' fromNode='SrrTransformFromSrrObjectWagon'
toField='rotation'
toNode='BodyTransform2'/>
:
:
:
</Group>
</ProtoBody>
</ProtoDeclare>
<Viewpoint
description="defaultViewpoint" position="3 1.75 3"
orientation="0 1 0 1.0"/>
<ProtoInstance
name='MyFirstWagon'/>
<NavigationInfo
type='"EXAMINE"'/>
</Scene>