Introduction
Getters and Setters
To read parameters from the hardware, the setup tool uses a getter command. In order to write a value to the hardware, a setter is used. For example, the getter for the proportional constant is "KP%m=?". The symbol %m is replaced by GDK with the axis being set. The setter for this command is "KP%m=%n". The symbol %n is replaced by GDK with the value to be set.
The following is a list of symbols replaced by GDK.
Symbol | Meaning | Example | Example after Substitution |
---|---|---|---|
%b | Axis Bank | "SG%b;SP%m=?" | SG0;SPA=? |
%m | Axis Indicator | "KD%m=?" | KDA=? |
%n | Value to set | "KD%m=%n" | KDA=64.0 |
%r | Range as defined in the <r> element | "AQ%r,%n" | AQ1,4 |
JavaScript Engine
To provide flexibility in how parameters are read and written, the Setup tool uses a JavaScript engine. Elements in setup.xml are passed through the script engine providing more powerful capabilities.
For example, the setter for Axis Motor Off is if(n==0){"SH%m";}else{"MO%m";}. Prior to evaluation, GDK loads the desired value into the JavaScript Global Parameter, n. The above script will result in, e.g., SHA if the value of n is zero, and MOA otherwise.
The following is a list of JavaScript global parameters loaded by GDK.
Parameter | Meaning | JavaScript Example |
---|---|---|
alias | The GDK connection alias | |
c | A comma, used for delimiting | |
coms | The current connection type | if(coms!="Ethernet"){"IA%n";} |
id | The hardware ID of the controller | |
m | The current axis | |
n | The desired value | if(n){"PW%n,%n";} |
r | The current range value | |
rv | The controller's firmware revision | |
sn | The hardware serial number |
Most elements used by Setup do not require the full capabilities of the JavaScript engine. However, all elements are passed through the engine. It is important to quote string literals to ensure that they are evaluated properly. JavaScript errors will be noted in the GDK Log.
The Element Tags
<setup version="2.0">
This is the XML root element. It contains the version of the setup syntax.
<p>
<p display="false" key="DMC40_0, DMC42_0, DMC50_0, DMC41_3, DMC30_0, DMC31_0, DMC21_2, DMC18_6, DMC18_2">
Defines a hardware parameter.
The optional attribute display indicates if the user will be able to see this parameter in the setup window. The default value is true. If the user holds the ctrl when clicking the read from hardware button, the parameter is displayed unconditionally.
The rest of the XML elements are all sub-elements of the <p> element.
<n>
<n>"MO%m"</n>
Defines the name of the hardware parameter.
String literals should be quoted.
<d>
<d>"Axis %m Motor Off"</d>
Defines a description for the hardware parameter.
String literals should be quoted.
<c>
<c>"Filter/Control"</c>
Defines a catagory for the hardware parameter.
String literals should be quoted.
<g>
<g>"MG{Z10}_MO%m"</g>
The getter for the parameter.
The optional attribute property is used to save the value retrieved from the getter into a JavaScript global property. This is useful when a future command depends on the value of this property.
<g property="'vf'">"VF?"</g><!-- load the user's value into JavaScript global object property -->
String literals should be quoted, single quotes (') make quoting strings in already quoted attribute values easier to read.
<s>
<s>if(n==0){"SH%m";}else{"MO%m";}</s>
The setter for the parameter.
String literals should be quoted.
<r>
<r>1:8</r>
Defines the range for use in the %r symbol.
<v>
<v>3.14</v>
The previously read value. The <v> tag is not used in the bundled GDK XML files. It is used when saving a controller's memory to file.