diff --git a/help/en/html/tools/scripting/WhatWhere.shtml b/help/en/html/tools/scripting/WhatWhere.shtml index d6d84d0250d..5d51e3be99e 100644 --- a/help/en/html/tools/scripting/WhatWhere.shtml +++ b/help/en/html/tools/scripting/WhatWhere.shtml @@ -29,6 +29,8 @@

JMRI: "What...Where" of Jython Scripting with JMRI

+ +

Other interesting tidbits about scripting in JMRI with Jython

@@ -36,7 +38,9 @@ @@ -48,7 +52,8 @@

See also Jython/Python Language for general info about the language.

- + +

Where should I store my JMRI Jython scripts?

@@ -68,6 +73,7 @@

[Go to top of page]

+

Where can I find more information on the JMRI classes?

@@ -100,9 +106,43 @@ - -

What do the words "import", - "class" mean?

+ +

What is the difference between System Names and User Names?

+ +

Click for more information on Names and Naming.

+ +

System names for sensors, turnouts, lights and others, are connection specific. A LocoNet sensor + name begins with "LS" while a CMRI sensor begins with "CS" and an internal sensor with "IS". + "provide" methods check the prefix of the passed string to determine if it matches a defined connection + or internal. If so, and the rest of the name is valid, the sensor is created. If a match does not + exist, it assigns the prefix for the first connection in the currently open connection list.

+ +

Example: If your connections are LocoNet and CMRI, a provideSensor request without a prefix of LS, + CS or IS, will be assigned LS. If the name value is not one to four numeric digits (a LocoNet + requirement), you get a bad format error. Memories are only internal, so provideMemory uses "IM" as + the default prefix.

+ +

Since System names follow a prescribed format, there is a procedure for checking whether a name + is valid. Use this code to create a sensor with a valid name:

+ + +
+        try:
+           sensors.validateSystemNameFormat(MySensorSystemName)
+        except jmri.NamedBean.BadSystemNameException:
+           print 'Invalid name: ', MySensorSystemName 
+        
+ +

User names are set after input and outputs are created. They can be any character string you want. + You can use user name or system name in scripts and Logix. The use of user names is recommended for + these purposes if there is the possibility that you will be changing your control system in which case + system names will be changing as well.

+ +

[Go to top of page]

+ + + +

What do the words "import", "class" mean?

They're part of the jython language used for the scripting. @@ -147,14 +187,33 @@
- + +

Why should I base my scripts on "Siglet" and "AbstractAutomaton" classes?

+ + + +
+ +

Scripts are part of the main JMRI program. This creates a bit of a problem: when something goes wrong + in a script, it may crash JMRI. When a script goes to sleep, the whole program sleeps. However, if you want + to run independent of JMRI, you can via a separate "thread." The Siglet and AbstractAutomaton classes have + created to allow you to base your scripts on a class that will run as an independent thread but with the + ability to communicate with the rest of JMRI. For more information, see + the section on threads.

+ +

Effectively, each Automat or Siglet is a separate program running when it needs to. Since they run in + separate threads, they can wait for something to happen while the rest of the JMRI program proceeds - a + very useful capability indeed.

+ +
+ + +

What's the difference between the "Siglet" and "AbstractAutomaton" classes?

- (Maybe not a frequently asked question, but it - needs to go somewhere) - +

Some examples use the AbstractAutomaton class as a base, while others use the @@ -224,6 +283,7 @@

+