User Tools

Site Tools


xmlscripting-en

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
xmlscripting-en [2018/11/12 08:56] – external edit 127.0.0.1xmlscripting-en [2019/05/12 10:18] – [clock] rjversluis
Line 16: Line 16:
 XML scripting can be used in combination with __**[[:actions-en#types_commands_parameters|run ext. program]]**__ action.\\ XML scripting can be used in combination with __**[[:actions-en#types_commands_parameters|run ext. program]]**__ action.\\
 Its primary goal is to simplify and to reduce the number of actions and conditions.\\ Its primary goal is to simplify and to reduce the number of actions and conditions.\\
-The XML used for the scripting is the same as used in the __**[[http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en-index.html|Rocrail plan.xml]]**__.\\+The XML used for the scripting is the same as used in the __**[[https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en-index.html|Rocrail plan.xml]]**__.\\
  
  \\  \\
Line 370: Line 370:
 Instead of the subidx the subid can also be used if the sub node has an ID.\\ Instead of the subidx the subid can also be used if the sub node has an ID.\\
    
 +===Function example===
 +The loco ID, //locid//, is retrieved from block **cb4** in variable **lcid**.\\
 +The function command requires a loco ID, which is provided by the text contents of the variable **@lcid**.\\
 +<code xml>
 +<xmlscript>
 +  <query vr="lcid" table="bklist" id="cb4" get="locid"/>
 +  <fn id="@lcid" fnchanged="3" f3="true"/>
 +</xmlscript>
 +</code>
  \\  \\
 ====set==== ====set====
Line 382: Line 391:
 </code> </code>
 Instead of the subidx the subid can also be used if the sub node has an ID.\\ Instead of the subidx the subid can also be used if the sub node has an ID.\\
- + \\ 
 +====clock==== 
 +| 15401+ | 
 +With the clock get command: 
 +<code xml> 
 +  <clock cmd="get"/>  
 +</code> 
 +three variables will be updated. 
 +^ Variable name ^ Value ^ Text ^ 
 +| modeltime | hour * 3600 + minute * 60 + seconds | hh:mm.ss | 
 +| realtime | hour * 3600 + minute * 60 + seconds | hh:mm.ss | 
 +| systemtick | count of 10ms since Rocrail server start | - | 
  \\  \\
  
Line 444: Line 465:
 | System | sys | go, stop | | | System | sys | go, stop | |
 | Automode | auto | on, off | | | Automode | auto | on, off | |
-| Locomotive | lc | fwd, rev, +, -, min, mid, cruise, max, block, "//blockID//", steam, diesel, electric, automobile, idle, wait, auto, f0...f28, home | **block** is true if the loco is in a block \\ "**//blockID//**" is true if the loco is in a block with this "//blockID//" |+| Locomotive | lc | fwd, rev, +, -, min, mid, cruise, max, block, "//blockID//", steam, diesel, electric, automobile, idle, wait, automatic, f0...f28, home | **block** is true if the loco is in a block \\ "**//blockID//**" is true if the loco is in a block with this "//blockID//" |
 | Car | car | empty, loaded, maintenance, cartype, waybill, "//blockID//" | See locomotive | | Car | car | empty, loaded, maintenance, cartype, waybill, "//blockID//" | See locomotive |
 | Waybill | waybill | waiting, shipping, delivered, "//destinationID//", "//originID//" |  | | Waybill | waybill | waiting, shipping, delivered, "//destinationID//", "//originID//" |  |
Line 458: Line 479:
 =====Commands===== =====Commands=====
 Note: \\ Note: \\
-  * With "**Commands All**" all the object commands specified in the  __**[[http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en-index.html|Rocrail plan.xml]]**__ are supported.+  * With "**Commands All**" all the object commands specified in the  __**[[https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en-index.html|Rocrail plan.xml]]**__ are supported.
   * The special implemented action commands are listed separately.   * The special implemented action commands are listed separately.
  
Line 464: Line 485:
  \\  \\
 ^ Object Name ^ Object type ^ Commands ^States ^ Remark ^ Example ^ ^ Object Name ^ Object type ^ Commands ^States ^ Remark ^ Example ^
-| Loco | lc | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#lc | | The bkid attribute can be used to get a loco ID from a block. \\ Command %%"regularreset"%% is the same as %%"softreset"%% but removes the assigned schedule too. |+| Loco | lc | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#lc | | The bkid attribute can be used to get a loco ID from a block. \\ Command %%"regularreset"%% is the same as %%"softreset"%% but removes the assigned schedule too. |
 | Function | fn | All and fndesc, fncmd | | The fnchanged or the fndesc, function description, attribute  signals which function has been changed: f0...f28 (true/false). \\ The fncmd can be used for on/off/flip. | %%<fn id="loco1" fndesc="Horn" fncmd="flip"/>%% | | Function | fn | All and fndesc, fncmd | | The fnchanged or the fndesc, function description, attribute  signals which function has been changed: f0...f28 (true/false). \\ The fncmd can be used for on/off/flip. | %%<fn id="loco1" fndesc="Horn" fncmd="flip"/>%% |
 | Switch | sw | All | | | Switch | sw | All | |
Line 478: Line 499:
 | Action control | actionctrl |  | | The id in the actionctrl is a reference to an existing action. Condition child nodes may be added. | | Action control | actionctrl |  | | The id in the actionctrl is a reference to an existing action. Condition child nodes may be added. |
 | Operator | operator | emptycar, loadcar, addcar, leavecar | | In the carids attribute a list of cars must be specified. | | Operator | operator | emptycar, loadcar, addcar, leavecar | | In the carids attribute a list of cars must be specified. |
-| System | sys | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#sys | | +| System | sys | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#sys | | 
-| Automat | auto | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#auto | |+| Automat | auto | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#auto | |
 | Car | car | empty, loaded, maintenance, assignwaybill, resetwaybill, loco & function | empty, loaded, maintenance, cartype, location | %%<car id="test" cmd="assignwaybill" waybill="testbill"/>%% | | Car | car | empty, loaded, maintenance, assignwaybill, resetwaybill, loco & function | empty, loaded, maintenance, cartype, location | %%<car id="test" cmd="assignwaybill" waybill="testbill"/>%% |
-| Staging block | sb | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#sb | | +| Staging block | sb | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#sb | | 
-| Fiddle Yard | seltab | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#seltab | | +| Fiddle Yard | seltab | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#seltab | | 
-| Location | location | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#location | | | %%<location id="Blaak" cmd="info" svalue="tx1"/>%% | +| Location | location | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#location | | | %%<location id="Blaak" cmd="info" svalue="tx1"/>%% | 
-| Clock | clock | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#clock | |   // Set clock on System time: // \\  %%<clock divider="1" hour="%syshour%" minute="%sysmin%"/>%% +| Clock | clock | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#clock | |   // Set clock on System time: // \\  %%<clock divider="1" hour="%syshour%" minute="%sysmin%"/>%% 
-| Turntable | tt | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#tt | | +| Turntable | tt | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#tt | | 
-| External | ext | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#ext | |+| External | ext | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#ext | |
 | Weather | weather | setweather, weathertheme | | | Weather | weather | setweather, weathertheme | |
 | Light | light | flip, enable, disable | Enable a light from LightControl. | | Light | light | flip, enable, disable | Enable a light from LightControl. |
-| Model | model | All http://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#model | With modify the sub nodes may contain attributes which will be merged in the objects. | %%<model cmd="change">%% \\ %%<tx id="x" backred="255" backgreen="0" backblue="0"/>%% \\ %%</model>%% | +| Model | model | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#model | With modify the sub nodes may contain attributes which will be merged in the objects. | %%<model cmd="change">%% \\ %%<tx id="x" backred="255" backgreen="0" backblue="0"/>%% \\ %%</model>%% | 
  
 ====Attribute values==== ====Attribute values====
Line 520: Line 541:
  \\  \\
  
 +=====Variable Format=====
 +With the format attribute it is possible to format variable content in the same way as printf.\\
 +====Example====
 +<code xml>
 +<xmlscript>
 +  <vr id="var1" value="3" text="Hello"/>
 +  <vr id="var2" value="5" text="RocrailFans"/>
 +  <vr id="var3" format="%s%02d:%04d%s" text="@var1 #var1 #var2 @var2"/>
 +  <trace text="@var3"/>
 +</xmlscript>
 +</code>
 +Output __with__ the format attribute looks like:
 +<code>
 +Hello03:0005RocrailFans
 +</code>
 +Output __without__ the format attribute looks like:
 +<code>
 +Hello 3 5 RocrailFans
 +</code>
 +
 +
 +
 + \\
 =====Tips===== =====Tips=====
 ====XML Well Formed==== ====XML Well Formed====
xmlscripting-en.txt · Last modified: 2024/02/15 10:43 by rjversluis