Powervision provides a powerful scripting interface allowing the developer to write Angelscript code to accomplish programming tasks. Angelscript is very similar to C++ so will look familiar to most programmers.
Powervision has a built in function library that allows scripting code to interact with Powervision applications, events, and variables. These are detailed in the Function Reference tab in the scripting interface. Examples of how to implement the library functions can be found in the Example: Script Library Functions Article.
The Scripting Syntax Reference tab has a complete listing of the Angels Script syntax, standard and extended library functions. Many example configurations listed in the Examples section of our support site use scripting functions that provide a good examples, use the search function to search on key words script or scripting. Online tutorials are available for Angel Script as well.
When you add a script two things get created, the script file and the first Script Event. The script file may contain one or more script events, locally created functions, and variables. More than one script file can be created in any folder to help organize the project. Use the script file Group property to place it into a desired folder, the current folder will be the default.
The script event is similar to a function, it must be called to perform the tasks. The script event creates a handle to an event by the same name and group folder in the configuration. This event at the configuration level is what will be called to execute the functions. It can be called just like a User Event. Multiple script events can be created in the same script file by selecting the add event button at the bottom. The name of the event in the script file must match the name of its configuration event. The script event name will have the $ character around it.
Variables declared within the context of a event or function will be local to that event. The standard Angelscript rules apply with respect to data types.
Variables declared outside of a function or event in the body of the script file are global meaning they can be shared by all of the functions or events.
To test your code syntax select the compile button at the bottom of the screen. Any errors will show up in the console window. Double clicking on the error will take you to the line of code in the script.
The following scripting example is a continuation of our engine temperature control system. We have previously demonstrated how to implement this same logic using State Machines and Activity Programs, this example shows how to perform the same functions using scripting. If you are familiar with scripting this is the easiest way of all three to implement this function.
In this video we will show how to use a Script Program to monitor an engines coolant temperature and determine if it is too cold or too hot and either turn on a heater or fan cooling. There are three states the engine can exist in, nominal, under temp, and over temp. The script if/else comparison statements to determine which state it is in and if the fan or heater needs to be turned on.
Please sign in to leave a comment.