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 revisionPrevious revision
Next revision
Previous revision
xmlscripting-en [2021/05/05 19:36] – [Commands] peter_bastixmlscripting-en [2024/02/15 10:43] (current) – [Commands] rjversluis
Line 6: Line 6:
     * [[:text-en#variables|Text variables]]     * [[:text-en#variables|Text variables]]
     * Examples:     * Examples:
-      * [[:xmlscripting:xmldb-en|General]] | [[:micha68:virtualfbscript-en|Virtual Sensors]] | [[:micha68:extkeyboardscript-en|External keyboard]]  | [[:micha68:ampelscript-de|Traffic light (DE)]] | [[:users:nice2have:shuntingexample-de|Shunting (DE)]]+      * [[:xmlscripting:xmldb-en|General]] | [[:userpages:micha68:virtualfbscript-en|Virtual Sensors]] | [[:userpages:micha68:extkeyboardscript-en|External keyboard]]  | [[:userpages:micha68:ampelscript-de|Traffic light (DE)]] | [[:userpages:nice2have:shuntingexample-de|Shunting (DE)]] 
 + 
 + 
 +| [[:supportkey-en|{{:icons:key.png}}]] //XMLScript can only be used if a valid __**[[:supportkey-en|Support Key]]**__ is provided.// |
  
- \\ 
-^  NOT FOR NOVICE USERS !!!  ^ 
- \\ 
 {{:xmlscripting.png}}\\ {{:xmlscripting.png}}\\
- \\+ NOT FOR NOVICE USERS !!!  ^ 
 =====Warning===== =====Warning=====
   - Do not replace standard Rocrail functions with XMLScript.   - Do not replace standard Rocrail functions with XMLScript.
Line 189: Line 189:
 </xmlscript> </xmlscript>
 </code> </code>
-If the while loop is endless it will be stopped by the max attribute which is default 100.\\+If the while loop is endless it will be stopped by the max attribute which is default 10.\\ 
 +Higher max values than 100 will be truncated to 100 to avoid server blocking and crashing automatically running locomotives.\\
  
  
Line 284: Line 285:
 Call the function with the wanted ID: ''<call id="doeIets"/>''\\ Call the function with the wanted ID: ''<call id="doeIets"/>''\\
 Multiple functions are allowed.\\  Multiple functions are allowed.\\ 
 +Parameters can be accessed by %subparam1%...%subparamN%.\\
 +
 <code xml> <code xml>
 <xmlscript> <xmlscript>
Line 296: Line 299:
     <default>     <default>
       <sys cmd="stop"/>       <sys cmd="stop"/>
-      <call id="doeIets"/>+      <call id="doeIets" param="test1,test2"/>
     </default>     </default>
   </switch>   </switch>
Line 320: Line 323:
  \\  \\
 ====break==== ====break====
-Ends a foreach loop with or without condition. The cmt="reason" can be used for tracing.\\+Ends a foreach and while loop with or without condition. The cmt="reason" can be used for tracing.\\
 This statement has no effect if its not within a foreach loop.\\ This statement has no effect if its not within a foreach loop.\\
 <code xml> <code xml>
Line 366: Line 369:
 <code xml> <code xml>
 <xmlscript> <xmlscript>
-  <sub file="lib1.xml" id="doeIets"/>+  <sub file="lib1.xml" id="doeIets" param="test1,test2"/>
 </xmlscript> </xmlscript>
 </code> </code>
 If the function ID is set to underscore, id="_", then the whole XMLScript will be executed excluding function definitions.((12.545+))\\ If the function ID is set to underscore, id="_", then the whole XMLScript will be executed excluding function definitions.((12.545+))\\
 If no function ID is set the %oid% will be used to find a fitting function.\\ If no function ID is set the %oid% will be used to find a fitting function.\\
 +Parameters can be accessed by %subparam1%...%subparamN%.\\
  \\  \\
 Library example **lib1.xml**: Library example **lib1.xml**:
Line 388: Line 392:
 ====query==== ====query====
 With the query statement a variable can be used to get the attribute text and integer value of a certain object.\\ With the query statement a variable can be used to get the attribute text and integer value of a certain object.\\
 +A query does only provide object properties and no run time information.\\
 <code xml> <code xml>
   <query vr="var1" table="waybilllist" id="%oid%" get="cartype"/>   <query vr="var1" table="waybilllist" id="%oid%" get="cartype"/>
Line 399: Line 404:
 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.\\
  
-:!: Query variables must be XMLScript unique to avoid unexpected results. :!: |+| Query variables must be XMLScript unique to avoid unexpected results. :!: |
    
 ===Function example=== ===Function example===
Line 412: Line 417:
  \\  \\
 ====set==== ====set====
-With the set statement a variable can be used to set the attribute text or integer value of a certain object.\\+With the set statement a variable can be used to set the attribute text or integer value, depending of setint, of a certain object.\\
 <code xml> <code xml>
   <set vr="var1" table="waybilllist" id="%oid%" set="cartype" setint="false"/>   <set vr="var1" table="waybilllist" id="%oid%" set="cartype" setint="false"/>
Line 492: Line 497:
 | Sensor | fb | true, false, on, off | true = on, false = off | | Sensor | fb | true, false, on, off | true = on, false = off |
 | Output | co | on, off, active | | | Output | co | on, off, active | |
 +| Location | location | free | The 'free' state will check if the loco is allowed and if a location block is free. |
 | Block | bk | free, occupied, closed, open, reserved | | | Block | bk | free, occupied, closed, open, reserved | |
 | Turntable | tt | free, occupied, closed, open, reserved, #, pending | The # represents the current bridge position. \\ If state pending is true the bridge is moving. | | Turntable | tt | free, occupied, closed, open, reserved, #, pending | The # represents the current bridge position. \\ If state pending is true the bridge is moving. |
Line 497: Line 503:
 | 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, automatic, shunting, f0...f28, home, shunting | **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, shunting, f0...f28, home, shunting, train, !train | **block** is true if the loco is in a block \\ "**//blockID//**" is true if the loco is in a block with this "//blockID//" \\ **train** is true if a train is assigned to the loco \\ **!train** is true if no train is assigned to the loco
-| Car | car | empty, loaded, maintenance, cartype, waybill, "//blockID//" | See locomotive |+| Car | car | empty, loaded, maintenance, cartype, waybill, f0...f28, "//blockID//" | See locomotive |
 | Waybill | waybill | waiting, shipping, delivered, "//destinationID//", "//originID//" |  | | Waybill | waybill | waiting, shipping, delivered, "//destinationID//", "//originID//" |  |
 | Text | tx | on, off | In case the toggle switch option is set. | | Text | tx | on, off | In case the toggle switch option is set. |
Line 512: Line 518:
 =====Commands===== =====Commands=====
 Note: \\ Note: \\
-  * 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.+  * With "**Commands All**" all the object commands specified in the  __**[[https://wiki.rocrail.net/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 519: Line 525:
 ^ Object Name ^ Object type ^ Commands ^States ^ Remark ^ Example ^ ^ Object Name ^ Object type ^ Commands ^States ^ Remark ^ Example ^
 | Loco | lc | All https://wiki.rocrail.net/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://wiki.rocrail.net/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, group 1..7 | | 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" group="2"/>%% \\ F1-F4 group="1" \\ F5-F8 group="2" \\ ... \\ F25-F28 group="7" |
 | Switch | sw | All | | | Switch | sw | All | |
 | Signal | sg | All | | | Signal | sg | All | |
Line 528: Line 534:
 | Sensor | fb | All, on, off, flip | | | Sensor | fb | All, on, off, flip | |
 | Route | st | go, lock, free, classset, classadd, classdel | open, closed | The lock and free command needs the extra attribute **locid**="myLoco" | %%<st id="x" state="closed"/>%% | | Route | st | go, lock, free, classset, classadd, classdel | open, closed | The lock and free command needs the extra attribute **locid**="myLoco" | %%<st id="x" state="closed"/>%% |
-| Text | tx | showon, showoff | | Update event by format attribute. \\ The optional **bkid** and **lcid** may be used in the command also. | %%<tx id="tx1" format="the loco id is %lcid%"/>%% | +| Text | tx | showon, showoff, blink, on, off, click | | Update event by format attribute. \\ The optional **bkid** and **lcid** may be used in the command also. | %%<tx id="tx1" format="the loco id is %lcid%"/>%% \\ <text id="xyz" cmd="blink" blink="true"/> 
-| Variable | vr | random, start, stop \\ start, length (for substring) | | Set by attribute: %%value="0" text="zero"%% \\ To make it temporary set %%generated="true"%%| %%<vr id="var1" text="Rocrail"/>%% \\ %%<vr id="var2" text="@var1-XML-Scripting." tokeniser="-"/>%% \\ %%<vr id="var2" text="@var1" start="1" length="3"/>%% |+| Variable | vr | random, start, stop \\ start, length (for substring) | | Set by attribute: %%value="0" text="zero"%% \\ To make it temporary set %%generated="true"%% \\ **Update:** with 2.1.3268+ this is the default value \\ To make it static set %%generated="false"%%| %%<vr id="var1" text="Rocrail"/>%% \\ %%<vr id="var2" text="@var1-XML-Scripting." tokeniser="-"/>%% \\ %%<vr id="var2" text="@var1" start="1" length="3"/>%% |
 | 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 https://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 https://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 https://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 https://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 https://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 https://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 https://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 https://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, go, stop | | 
-| Light | light | flip, enable, disable | Enable a light from LightControl. | +| Light | light | flip, enable, disable | Enable a light from LightControl. 
-| Model | model | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#model | With modify the sub nodes will be replaced with the new ones. Als sub nodes will be deleted if no new ones are available. -> Use change instead. | %%<model cmd="change">%% \\ %%<tx id="x" backred="255" backgreen="0" backblue="0"/>%% \\ %%</model>%% | +| LightControl | lightctrl | go, stop | | Enable / disable LightControl. | %%<lightctrl cmd="go"/>%% \\ %%<lightctrl cmd="stop"/>%% 
 +| Model | model | All https://rocrail.net/software/rocrail-snapshot/rocrail/wrapper-en.html#model | | The modify is not supported, use change instead. | %%<model cmd="change">%% \\ %%<tx id="x" backred="255" backgreen="0" backblue="0"/>%% \\ %%</model>%% |  
 +| MVTrack | mv | reset, sets1, sets2, setdistance, setdistanceR | | | <mv cmd="sets2" s2="fb4712"/> |
  
 ====Attribute values==== ====Attribute values====
Line 574: Line 582:
  \\  \\
  
 +===== System variables =====
 +see: [[https://wiki.rocrail.net/doku.php?id=text-gen-en#variable]] \\
 =====Variable Format===== =====Variable Format=====
 With the format attribute it is possible to format variable content in the same way as printf.\\ With the format attribute it is possible to format variable content in the same way as printf.\\
Line 604: Line 614:
  
 =====Variables defined as "Generated"===== =====Variables defined as "Generated"=====
-As long as a variable does not need to store any values from runtime to runtime of Rocrail those variables can be defined as "generated": \\+In order to store a variable from runtime to runtime in Rocrail, these variables must be defined as "generated" "false": \\
 ====Example==== ====Example====
 <code xml> <code xml>
 <xmlscript> <xmlscript>
-  <vr id="vr_MSN3_lastUsedLocomotive" value="0" text="br89"/> +  <vr id="vr_MSN3_lastUsedLocomotive" value="0" text="br89" generated="false"/> 
-  <vr id="vr_MSN3_tmp" value="0" text="" generated="true"/>+  <vr id="vr_MSN3_tmp" value="0" text=""/>
 </xmlscript> </xmlscript>
 </code> </code>
xmlscripting-en.1620236184.txt.gz · Last modified: 2021/05/05 19:36 by peter_basti