To create a parameter block in a script and/or add additional resources to a script, insert the following block at the beginning of the code:
""" <parameters> <company>My Company</company> <title>My Script</title> <version>1.0</version> <parameter> <type>caption</type> <name>Settings</name> </parameter> <parameter> <type>channel</type> <id>param_channel_1</id> <name>Camera</name> <value></value> </parameter> <parameter> <type>integer</type> <name>Parametr 1</name> <id>param_1</id> <value>100</value> <min>1</min> <max>100000</max> </parameter> <resources> <resource>httpserver.py</resource> <resource>index.html</resource> </resources> </parameters> """
The parameter tab in the script editor will look like this:
After that, the parameter value specified in the value tags can be used in the script using the parameter identifier specified in the id tags:
def f(): message("Camera %s" % param_channel_1) message("Parametr 1 = %s" % param_1) f()
The following values may be used as the parameter type specified in the type tags:
- caption - A name (for example, the name of a group of parameters)
<parameter> <type>caption</type> <name>Settings</name> </parameter>
- integer - An integer
<parameter> <type>integer</type> <name>Parametr 1</name> <id>param_1</id> <value>100</value> <min>1</min> <max>100000</max> </parameter>
- float - A real number
<parameter> <type>float</type> <name>Parametr 1</name> <id>param_2</id> <value>6.00</value> <min>1.00</min> <max>10.00</max> </parameter>
- string - A string (for example, a template name)
<parameter> <type>string</type> <name>Template to generate current report</name> <id>tpl_for_events</id> <value>AutoTRASSIR</value> </parameter>
- boolean - A logical expression
<parameter> <type>boolean</type> <id>autoupdate_events</id> <name>Autoupdate of measurements</name> <value>0</value> </parameter>
- date - A date
<parameter> <type>date</type> <id>date_start</id> <name>Start date</name> <value>2014-03-01</value> </parameter>
- time - Time
<parameter> <type>time</type> <id>time_start</id> <name>Start time</name> <value>10:00:00</value> </parameter>
- string_list - A comma-separated value list
<parameter> <type>string_list</type> <id>cams</id> <name>Cameras</name> <value>cam1,cam2,cam3</value> </parameter>
- string_from_list - A list of values to choose from
<parameter> <type>string_from_list</type> <id>user_function</id> <name>User function</name> <value>U1</value> <string_list>U1,U2,U3,U4,U5,U6,U7,U8,U9,U10</string_list> </parameter>
- channel - A field to select one of the channels connected to a TRASSIR server
<parameter> <type>channel</type> <id>channel_id</id> <name>Camera</name> <value></value> </parameter>
- objects - A field for selecting TRASSIR objects
<parameter> <type>objects</type> <id>objects_id</id> <name>Objects</name> <value></value> </parameter>
- server - A field for selecting a TRASSIR server
<parameter> <type>server</type> <id>server_id</id> <name>Server</name> <value></value> </parameter>
In the resources tags, specify the relative path to the file that will be run together with the script.