For calculating virtual sensors you need to create scripts. You can create these from the machine page in the innius Admin app. On the right side of the section 'Scripts' you click on the three dots to add a new script:
Then it will open the script editor, this screen will be explained below:
- When you want to view/edit an existing script, you can easily select it from the dropdown to switch.
- When you start a new script, you should assign a title and description. Keep these short and unique. In the description, explain briefly in simple terms what the script is for.
- Here you need to select the sensors which need to be calculated and the sensors which are used in the in calculation. The sensors which can be calculated should be of the type 'virtual' or 'manual'. You need to check the 'output' option for the sensors which need to be calculated. And the code is the alias which you should use in the script itself. For example, in the screenshot below, the sensor 'AC' will be calculated, and the sensor 'CO' is used in the calculation:
- To start editing a new script or one with a current edit mode, you need to click in the editor area. For more information about the script language refer to this article: The script language. See the script examples as a reference as well: Script examples.
- Once you have written some script, you can either "Cancel", "Test," or "Save" your edits to it.
In a new script, the "Cancel" button becomes available once the script has been saved, and clicking it will then revert back to the previous save. In scripts with previously activated versions, the cancel button becomes available in a "Current edit." Clicking it cancels and exits the current edit, regardless of whether it has been saved or not.
Clicking "Test" will test the script for errors. If errors are found, a dialog box will indicate on which line the error has been found. Correct these errors and then test it again, until no errors are found. You must remove all errors before your script can be activated.
Clicking "Save" will save the script. Saving allows you to leave the script editor and return to continue editing the script another time. It does not activate the script. Once a script has been saved and has no errors, it can be activated by pushing the "Activate" button.
- The script edit history is an archive of all the active versions of the script. This way, sensor data can be viewed in the light of what the script was doing at any given time.
Once a script has been activated, it will receive a time stamp in the edit history and a green circle will appear next to it. Any previously active scripts will become inactive and move down the list. Historic script versions can be viewed by clicking on them, but cannot themselves be deleted, edited, or reactivated. However, they can be duplicated and used as the basis for a new version by clicking on the menu option "Duplicate," which will create a "Current edit."
If you are working on a current edit, be aware that clicking to view a previous version will cause the current edit to close. If this happens, return to the machine list and re-open the script editor. The last saved version of the current edit will then be displayed.
The active script can be deactivated by clicking on the menu option "Deactivate." Once deactivated, it can also be reactivated again in the same way.