Test a script outside Profinity
profinity-script creates a script on a developer machine and runs it against a simulated Profinity, before the script file is copied into a profile.
The tool ships in the Profinity SDK download, in its profinity-script folder, and not with the Profinity install.
This page calls the downloaded SDK the kit.
The kit holds no Windows .exe. On Windows, run the tool from its folder as dotnet profinity-script.dll, followed by the command.
The kit also contains the Component Pack CLI (profinity-component-pack) and the Profinity.Sdk package.
The package on its own does not create or run a script.
The SDK is an add-on to the Desktop, Server, or Enterprise edition, licensed separately. Refer to Licensing. For a copy of the SDK, contact Prohelion.
The simulator does not start Profinity and does not need a CAN bus.
It calls the script the way Profinity does, and the script calls the same Profinity object.
Once the script is in a profile it needs the Scripting feature, which a Desktop, Server, or Enterprise edition includes.
Refer to Profinity Scripting.
A C# project in a generated folder references Profinity.Sdk.
To let the editor complete Profinity types, add the kit folder that contains that package as a local NuGet source. Use your editor's package source settings, or run dotnet nuget add source with the kit folder path and a name such as ProfinityKit.
profinity-script sim compiles and runs the script itself.
Create a runnable script
Install the .NET 10 runtime before you start. Python and Lua scripts need no other runtime, and C# scripts need no separate compiler.
Run the following commands from the kit's profinity-script folder.
With no arguments, profinity-script runs sim in the current directory.
-
Create a runnable Python script.
The command writes a folder named
runnableand prints its path. The folder holdsscript.py, which sets the tagranand writesranto the console, andsim.yaml, which the simulator reads.--languageacceptspython,lua, orcsharp, and it defaults topython. -
Change into that folder.
-
Run the simulator.
The command prints
ranand exits cleanly. That line is whatscript.pywrites withProfinity.Console.WriteLine.
profinity-script sim runnable, run from the profinity-script folder, does the same thing without changing directory.
The simulator reads sim.yaml, which sits next to the script, runs the script, and prints the lines the script writes to the console.
A script that only stores a tag or a setting prints nothing, and the run has still worked when the command exits cleanly.
Add Profinity.Console.WriteLine to see a stored value.
The command does not print tags, settings, notifications, or CAN frames on its own.
To run a tag-change, receiver, service, alert, firmware-load, or prompt script, create it from the matching template and edit sim.yaml.
Refer to profinity-script reference for the templates and every sim.yaml key.
Copy the script into a profile
When the console lines are right, copy the script file into the profile.
Leave sim.yaml on the developer machine.
Profinity runs the copied file.
- If the component already holds a script with the same file name, copy that file to a folder outside the profile.
The file sits in the folder named after the component, in the
componentsfolder of the profile. Saving replaces the file in place, so this copy is how you restore the earlier script. - Add a script component as described in How to write your first script.
A script that belongs to a Custom Component goes in that component, under the name the component already uses.
For a Python script, set Upload script file (optional) in the component's settings to the
.pyfile. Alternatively, paste the script into the script editor and select Save. - Review the script, then set Script mode to Run on demand and select Run Script. The status reads
Run 1 timeafter the first run. A script in a profile runs with the same operating system permissions as Profinity.
| What you see | Cause | What to do |
|---|---|---|
| The command does not start and reports an error from .NET | The .NET 10 runtime that the tool was built for is not installed. | Install that runtime, as described in Create a runnable script, then run the command again. |
| The command fails, or the simulator cannot cover a call the script makes | - | Refer to the errors and the limits of the simulator in the profinity-script reference. |
For what a script can do in a profile, refer to Profinity Scripting.