Operation¶
The user created script runs on the device every time the device boots. This includes waking from sleep.
Note
The total script size must be less than 12188 bytes.
In order to process data as it’s collected by the device or to trigger events, a callback function can be registered by the script. These callback functions are then invoked when the device completes a measurement cycle, or a button is pressed from the Senquip Portal. See the Examples section for specific implementation details.
Custom Data Parameters¶
Custom data paramters are configured for the device in a table on the Senquip Portal. The visibility, name and units for each custom parameter (cp) can be modified. A parameter’s value can be sent in a data message as either a number (using dispatch_double()) or a string (using dispatch_string()). See examples section.
Trigger Parameters¶
Warning
Triggering actions on the device must not be used for safety critical applications. The system connected to the device must tolerate network delays and malfunction.
Each trigger parameter added will create a button on the main data page of the Senquip Portal. The name of the button and the colour can be customised. When a user clicks a button, a command is queued and then sent to the device. When the device receives the command, a trigger callback function is invoked and the index of the trigger parameter is passed in. See examples section for specific details.
Note
Triggering an action on the device does not provide feedback on the effect of the action. It is highly recommended the device is setup to monitor a physical parameter that will indicate if the trigger was successful or not. For example: if the trigger turns a pump on, monitor for changes in flow rate.
Custom Settings¶
Custom settings can be enabled for use by the script. These settings are permanently stored in the device’s FLASH memory like all other configuration values. Settings can either be a number or string type. The visibility, name and units for each custom setting can be modified from the Scripting page.
Once settings have been configured and enabled from the Scripting page, they will show up under the device’s Setting page on the Custom tab.
Note
When a user applies a change from the Settings page it causes the device to reboot, and the script to run again.
Settings can be set and read from the script using the Cfg.set(path) and Cfg.get(path) function calls. See examples section for more detail.
Warning
Excessive use of Cfg.Set() from the script will wear internal FLASH memory. The FLASH memory can typically endure 100 000 write cycles.