Skip to content

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.

  1. Create a runnable Python script.

    profinity-script new runnable --language python
    

    The command writes a folder named runnable and prints its path. The folder holds script.py, which sets the tag ran and writes ran to the console, and sim.yaml, which the simulator reads. --language accepts python, lua, or csharp, and it defaults to python.

  2. Change into that folder.

    cd runnable
    
  3. Run the simulator.

    profinity-script sim
    

    The command prints ran and exits cleanly. That line is what script.py writes with Profinity.Console.WriteLine.

    ran
    

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.

  1. 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 components folder of the profile. Saving replaces the file in place, so this copy is how you restore the earlier script.
  2. 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 .py file. Alternatively, paste the script into the script editor and select Save.
  3. Review the script, then set Script mode to Run on demand and select Run Script. The status reads Run 1 time after 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.