This guide provides an overview of how the Process Runner Class can be used to launch external scripts as their own process on a separate thread. The Process Runner’s main advantage is that it allows Zendir Editor Simulation levels to start any external software for Software In the Loop (SwIL) applications. The TCP Demo
provided with Zendir Editor is an example of how the Process Runner Class can be used to launch external software via a button in the simulation’s User Interface.
Process Runner Workflow
To begin using the Process Runner, an instance needs to be created using Unreal Engines Construct Object from Class
, with the class set to Process Runner, as shown below. Promoting the return value to a variable is highly recommended due to the remainder of this workflow.
Once the Process Runner exists, multiple processes can be started with the Start
and Start Path
functions. Both functions return a unique ID for the thread/process that can be used to Stop
the specific process. In both functions, the Arguments parameter is optional and can be left as an empty string. The Start Path
Function requires an absolute path to the intended file, whilst Path Environment Variables can be called in the base Start
function in the Process Name field.
As previously mentioned, the Stop function stops a specific process by terminating the thread it operates on and will return a flag if the stop operation succeeds. Alternativity, the Dispose function can be used to stop every active thread/process at once.
WARNING
A Mandatory requirement when using the Process Runner is to stop any created Processes at the end of the Simulation. This can be achieved by calling Dispose from each constructed Process Runner on the
End Play Event
of Unreal. The TCP Demo shows how this can be achieved whilst also closing the TCP connection.
Example Use Case: TCP Demo
The TCP Demo Provided with Zendir Editor within the Demos\External folder, uses the Process Runner to launch the Python script provided with the Demo. In the demo, the base Start
function is used to launch Python, with the path to the provided script passed as an argument. As shown above, the Start function is called on a Custom Event that is bound to the UI Button widget.