User Tools

Site Tools


xmlscripting-en

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
xmlscripting-en [2018/12/06 11:36]
rjversluis [State Objects]
xmlscripting-en [2019/05/12 10:24] (current)
rjversluis [clock]
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 | - |
 +The systemtick will overflow at 4294967295(119.3 hours) on 32bit and 18446744073709551615 on 64bit systems.\\
  
 + \\
 =====Condition format===== =====Condition format=====
 | value | comparator | value |\\ | value | comparator | value |\\
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.1544092562.txt.gz · Last modified: 2018/12/06 11:36 by rjversluis