N-Way Switch – step 0031 – February 2010

1 Purpose of SrrSwitchB

SrrSwitchB is very similar to SrrSwitchA. It differs mainly in the fact, that the state of the switch is not represented by an SFBool but by an SFInt32 to enable n-way switching (e.g. for 3-way turnouts).

2 User Interface of SrrSwitchB (uiObj)

SrrSwitchB is an external prototype that is available at the directory srr/.

<ProtoDeclare name='SrrSwitchB'>

<ProtoInterface>

<field accessType='inputOutput' name='objType' type='SFString' value='SrrSwitchB'/>

<field accessType='inputOutput' name='version' type='SFFloat' value='0.0031'/>

<field accessType='inputOutput' name='quasiModule' type='SFString'/>

<field accessType='inputOutput' name='objId' type='SFString'/>

<field accessType='inputOutput' name='numberOfStates' type='SFInt32' value='2'/>

<field accessType='inputOutput' name='duration' type='SFFloat' value='1'/>

<field accessType='inputOutput' name='lock' type='SFNode'/>

<field accessType='inputOutput' name='modParam' type='SFNode'/>

<field accessType='inputOutput' name='enabled' type='SFBool' value="true"/>

<field accessType='outputOnly' name='initialized' type='SFNode'/>

<field accessType='inputOnly' name='toggle' type='SFBool'/>

<field accessType='inputOutput' name='actualState' type='SFInt32' value='0'/>

<field accessType='outputOnly' name='isActive' type='SFBool'/>

<field accessType='outputOnly' name='softState' type='SFFloat'/>

</ProtoInterface>

objId, quasiModule

The user sets the objId and the quasiModule before initialization of the switch object. The objId is unique within the module. The quasiModule needs only be set in case of global (vehicle) models.

numberOfStates

The user has to chose, how many states the switch shall support

duration

is set by the user. It’s the duration of the switching process from one state to the next state in seconds. This value is used as a basis for the animation (softState).

modParam

is needed for the initialization. This value was delivered by the module coordinator SrrModCoord after the registration and initialization of the module. The user routes this event from SrrModCoord to SrrSwitchB.

initialized

fires an SFNode event, after the switch has been initialized. This is needed by other SRR objects that contain a switch to coordinate the initialisation procedure.

enabled

can be used to disable all active elements of the SRR object if the model is unloaded.

toggle

Each scene instance can trigger the change of the scheduled state and its distribution to all scene instances. Independent whether the switch is active or not (whether an animation is ongoing or not), the scheduled value will be changed (if the new value will exceed the minimum/maximum of the animation, the direction of the switching process will change).

actualState

As soon as the animation has finished, this field will fire an event with the end state (0 to numberOfStates – 1).

The user can set an initial value in this field.

isActive

fires true at the begin of the switching process and false at the end (when actualState is being set).

softState

is a floating point value within the interval from 0.0 to (numberOfStates - 1) * 1.0 and interpolates the switching process linearly. You can use this event as input to an interpolator node for the desired animation of the switch.

lock

The user can attach an SrrLock object to the SrrSwitchB. If a lock is attached, the switch may be locked due to the locked state of the lock (depending on carried keys and contained keys). The lock has to be created by the user, but it will be initialized by the SrrSwitchB and get the object ID <objId>.Lock.