How to emulate plugins with executables in ESAPI.

Photo by Luca Bravo on Unsplash

Hello!

Often we are caught up with an executable script that should work with the context of some patient.

Carlos Anderson came up with a solution to this problem when he created the ESAPI Essentials Package.

However there’s some limitation of the extent of the StandaloneContext library. One would need to perform the same code over and over to launch the executable that should be the first in the folder that you are launching the binary plugin.

https://github.com/redcurry/EsapiEssentials/blob/master/src/EsapiEssentials/Standalone/StandaloneRunner/StandaloneRunner.cs

If you’re a CITRIX user, you should be used to open a patient to launch an executable. So it will not bother your normal proccess.

Basically this post will be dedicated to fix the issue of running always the first executable in the folder. And pass the ScriptContext via CommandLine arguments to any executable we click with an OpenFileDialog.

This is the pipeline described:

Starting

Let`s start a fresh .NET Framework Library solution in Visual Studio called ContextStandalone.

Remember to reference the VMS.TPS libraries.

In the project properties, change to x64 compilation, and to change the project assembly name to ContextStandalone.esapi , this will be important, when you compile the name of the binarty will be ContextStandalone.esapi.dll

Rename the first file, from Class1.cs to Script.cs

Code the following lines into the Script.cs file:

Next, add the CommandLineParser library via NuGet Package Manager to your project.

Now we are going to replicate Carlos Anderson`s code creating a ScriptContextArgs.cs file and coding:

Create another .cs file, called RunStandalone.cs and code the following lines into this file:

Compile those 3 files into ContextStandalone.esapi.dll using the Ctrl+Shift+B shortcut in Visual Studio.

Now you can simply run any Standalone with context.

Testing a simple Standalone

Let’s do a simple test right now. Creating a new .NET Console Application solution called LogPatientFields.

In the project properties, change to x64 compilation. Remember to reference the VMS.TPS libraries.

Add CommandLineParser to the project via NuGet Package Manager.

Add the ScriptContextArgs.cs to this project as well

Copy the following code to Program.cs:

Compile your project via Visual Studio pressing Ctrl+Shift+B.

Running the emulated plugin:

Open Eclipse ExternalBeamPlanning in any plan you wish to print the beams information. Click in Tools/Scripts/Folder/Change Folder.

Find the folder you compile ContextStandalone.esapi.dll

Run the script:

Select the Executable Compiled LogPatientFields.exe and open:

This is the result:

Now you can do it with all your executables. Even if they don’t have ScriptContext the ContextStandalone.esapi.dll works too. So you don’t have to copy the files to the local disk and run.

Thanks for the attention !

😃

2nd year Radiotherapy Physics Resident

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store