User Tools

Site Tools


userpages:hermannk:departdelay-en

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
userpages:hermannk:departdelay-en [2021/02/26 19:49] – [Introduction] hermannkuserpages:hermannk:departdelay-en [2022/11/21 18:22] (current) – removed hermannk
Line 1: Line 1:
-====== Depart Delay ====== 
-This XML-script solution was requested by a user who needed an extra amount of time for the build-in "Depart Delay" of a block. \\ 
-Direct jump to the [[userpages:hermannk:departdelay-en#the_workspace|workspace]] . \\ 
- 
-===== Introduction ===== 
-The properties of a block hold a "Depart Delay" value (in seconds). As the loco gets the "start" command the velocity command is delayed by the "Depart Delay" value. Because of special reasons this value should be increased for certain locos. \\ 
- \\ 
-For that the "departdelay" value of a block has to be modified. \\ 
-  <bk id="bk1" departdelay="10"/> \\ 
-The timing is important! It will be too late at the DEPART-event of the block! At that time the old "departdelay" value is used for execution. \\ 
-So this solution uses \\ 
-- the IN-event to prepare the new "departdelay" value of the block and \\ 
-- the DEPART-event to reset the "departdelay" value of the block to its original value. \\ 
-With that the new "departdelay" value is used for execution at the time of the velocity command for the loco. \\ 
- \\ 
-To make it complete the XML-script will only be executed for those locos which belong to the class "DELAY". \\ 
-  <query vr="vr_ddS_class" table="lclist" id="myloco" get="class"/> 
-  <if condition="@vr_ddS_class = DELAY"> \\ 
- \\ 
-|  Direct jump to the [[userpages:hermannk:departdelay-en#the_workspace|workspace]].  | 
- 
-===== Explaining the script ===== 
-==== Preparations ==== 
-At first a solution for a block named "bk1" is shown. At the end the general solution can be seen. \\ 
-The XML-script will be named "**ac_departdelaySet.xml**". \\ 
-The ID of all variables of this script start with the string "**vr_ddS_**". \\ 
- \\ 
-The new alternative "departdelay" value is stored in the variable "**vr_ddS_delayValue**" at the very beginning of the script to make it easier for a user to change that value. In this solution there will be just **one** alternative value. \\ 
-  <vr id="vr_ddS_delayValue" text="" value="10" generated="true"/> 
-Because this script is called at two different events the actual event is saved in "**vr_ddS_state**". \\ 
-  <vr id="vr_ddS_state" text="%state%" generated="true"/> 
-Because this script should only be executes for locos of class "DELAY" we query for the loco ID and for the class of that loco and store the values in "**vr_ddS_locid**" and "**vr_ddS_class**". \\ 
-  <vr id="vr_ddS_locid" text="" generated="true"/> 
-  <query vr="vr_ddS_locid" table="bklist" id="%callerid%" get="locid"/> 
-  <vr id="vr_ddS_class" text="" generated="true"/> 
-  <query vr="vr_ddS_class" table="lclist" id="@vr_ddS_locid" get="class"/> 
-At the end of the preparation the variable for the new value "**vr_ddS_newValue**" is cleared. \\ 
-  <vr id="vr_ddS_newValue" text="0" value="0" generated="true"/> 
-  <trace text="ac_departdelaySet: begin %callerid% @vr_ddS_state @vr_ddS_locid @vr_ddS_class " /> 
- 
-==== State IN ==== 
-It is assumed now that a loco of class "DELAY" is IN this block. \\ 
-The original value is saved in "**vr_ddS_orgValue**". \\ 
-      <vr id="vr_ddS_orgValue" text="-1" value="-1" generated="false"/> 
-      <query vr="vr_ddS_orgValue" table="bklist" id="%callerid%" get="departdelay"/> 
-The new value is prepared in "** vr_ddS_newValue**". \\ 
-      <vr id="vr_ddS_newValue" value="#vr_ddS_delayValue"/> 
-==== State DEPART ==== 
-It is assumed now that a loco of class "DELAY" is DEPARTing this block. \\ 
-The original value is prepared at this time in "** vr_ddS_newValue**". \\ 
-      <vr id="vr_ddS_newValue" value="#vr_ddS_orgValue"/> 
-==== Changing the Depart Delay value ==== 
-It is still assumed that a loco of class "DELAY" is using this block. \\ 
-The **model** of the calling block (**%callerid%**) needs got be changed by the new value "#vr_ddS_newValue": 
-    <model cmd="change"> 
-      <bk id="%callerid%" departdelay="#vr_ddS_newValue"/> 
-    </model> 
-As can be seen the value attribute ("#") is used with "#vr_ddS_newValue" - not the text attribute ("@"). \\ 
- 
-===== The script (single block) ===== 
-At first this variant of the script will only work for just one block. \\ 
-All comments and all trace lines are removed: \\ 
-  <xmlscript> 
-  <vr id="vr_ddS_delayValue" text="" value="10" generated="true"/> 
-  <vr id="vr_ddS_state" text="%state%" generated="true"/> 
-  <vr id="vr_ddS_locid" text="" generated="true"/> 
-  <query vr="vr_ddS_locid" table="bklist" id="%callerid%" get="locid"/> 
-  <vr id="vr_ddS_class" text="" generated="true"/> 
-  <query vr="vr_ddS_class" table="lclist" id="@vr_ddS_locid" get="class"/> 
-  <vr id="vr_ddS_newValue" text="0" value="0" generated="true"/> 
-  <if condition="@vr_ddS_class = DELAY"> 
-  <then> 
-    <if condition="@vr_ddS_state = in"> 
-    <then> 
-      <vr id="vr_ddS_orgValue" text="-1" value="-1" generated="false"/> 
-      <query vr="vr_ddS_orgValue" table="bklist" id="%callerid%" get="departdelay"/> 
-      <vr id="vr_ddS_newValue" value="#vr_ddS_delayValue"/> 
-    </then> 
-    </if> 
-    <if condition="@vr_ddS_state = depart"> 
-    <then> 
-      <vr id="vr_ddS_newValue" value="#vr_ddS_orgValue"/> 
-    </then> 
-    </if> 
-    <model cmd="change"> 
-      <bk id="%callerid%" departdelay="#vr_ddS_newValue"/> 
-    </model> 
-  </then> 
-  </if> 
-  </xmlscript> 
- 
-===== The script (multiple blocks) ===== 
-This variant of the script will work for more than one block. \\ 
-Therefore each variable has to be defined for each block that should call this script.\\ 
-This is done by adding the calipers ID "%callerid%" to each used variable ID. \\ 
-The variable "**vr_ddS_state**" will be named "**vr_ddS_%callerid%_state**" (which results in "**vr_ddS_bk1_state**" for block "bk1") and so on. \\ 
-:!: This requires all corresponding blocks to have "well formed" IDs (no spaces, no special characters, no ...). \\ 
-All comments and all trace lines are removed: \\ 
-  <xmlscript> 
-  <vr id="vr_ddS_delayValue" text="" value="10" generated="true"/> 
-  <vr id="vr_ddS_%callerid%_state" text="%state%" generated="true"/> 
-  <vr id="vr_ddS_%callerid%_locid" text="" generated="true"/> 
-  <query vr="vr_ddS_%callerid%_locid" table="bklist" id="%callerid%" get="locid"/> 
-  <vr id="vr_ddS_%callerid%_class" text="" generated="true"/> 
-  <query vr="vr_ddS_%callerid%_class" table="lclist" id="@vr_ddS_%callerid%_locid" get="class"/> 
-  <vr id="vr_ddS_%callerid%_newValue" text="0" value="0" generated="true"/> 
-   
-  <if condition="@vr_ddS_%callerid%_class = DELAY"> 
-  <then> 
-    <if condition="@vr_ddS_%callerid%_state = in"> 
-    <then> 
-      <vr id="vr_ddS_%callerid%_orgValue" text="-1" value="-1" generated="false"/> 
-      <query vr="vr_ddS_%callerid%_orgValue" table="bklist" id="%callerid%" get="departdelay"/> 
-      <vr id="vr_ddS_%callerid%_newValue" value="#vr_ddS_delayValue"/> 
-    </then> 
-    </if> 
-   
-    <if condition="@vr_ddS_%callerid%_state = depart"> 
-    <then> 
-      <vr id="vr_ddS_%callerid%_newValue" value="#vr_ddS_%callerid%_orgValue"/> 
-    </then> 
-    </if> 
-   
-    <model cmd="change"> 
-      <bk id="%callerid%" departdelay="#vr_ddS_%callerid%_newValue"/> 
-    </model> 
-  </then> 
-  </if> 
-  </xmlscript> 
- 
-===== Installation ===== 
-The test plan looks like this. (direct jump to the [[userpages:hermannk:departdelay-en#the_workspace|workspace]] download) \\ 
-{{:userpages:hermannk:departdelay_plan.png?}} \\ 
- 
- 
-==== The action definition ==== 
-The action is named "**ac_departdelaySet**" and is calling an external script "**ac_departdelaySet.xml**". \\ 
-{{:userpages:hermannk:departdelay_action_definition.png?|}} \\ 
-==== The block properties ==== 
-The block should have defined "wait" = YES. \\ 
-The depart delay of the block may be of any value - here a value of "4" is used. \\ 
-{{:userpages:hermannk:departdelay_block_general.png?}} \\ 
-The list of actions for this block must hold \\ 
-- action ID "ac_departdelaySet" for the state "in" \\ 
-- action ID "ac_departdelaySet" for the state "depart" \\ 
-The other entries just display the depart delay value of the block in a text field of the plan. They are included in the test workspace. \\ 
-{{:userpages:hermannk:departdelay_block_action.png?}} \\ 
-==== The loco properties ==== 
-The loco should have set "Use depart delay" = YES. \\ 
-The loco should have set "Class" = "DELAY". \\ 
-{{:userpages:hermannk:departdelay_loco_details.png?}} \\ 
-==== Test sequence ==== 
-Start each loco (do not use "Virtual start"), \\ 
-- simulate the appropriate sensors and \\ 
-- watch the delay the loco gets a velocity command larger than zero. \\ 
-Remark: the "departdelay" value is not used by Rocrail in case of using "Virtual start loco"! \\ 
-Have fun. \\ 
-==== The workspace ==== 
-The {{ :userpages:hermannk:departdelay.zip|workspace}} to test the script. \\ 
  
userpages/hermannk/departdelay-en.1614365365.txt.gz · Last modified: 2021/02/26 19:49 by hermannk