Skip to content

Deploy a plugin for Experimenter subsystem

Tino Herrmann edited this page Sep 19, 2020 · 2 revisions

Naming of plugin class

The class, which is loaded and called by Experimenter subsystem as plugin, must be have the prefix ExecutorPlugin. This is necessary to find and match available plugins in the program directory of Experimenter.

For example:
Is your experiment software called as MyProgram, so it is recommended your plugin class has a name like ExecutorPluginMyProgram.

Include the plugin api

To program a plugin for Experimenter subsystem, the plugin api must be include in your C#-project. For this purpose the compiled libraries

    DataModel.dll
    Experimenter.ExecutorPlugin.dll

must be include in a C# project file as follows:

<ItemGroup>
  <Reference Include="DistributedExperimentation.DataModel">
    <HintPath>./Experimenter.PluginAPI/DataModel.dll</HintPath>
  </Reference>
  <Reference Include="DistributedExperimentation.Experimenter.ExecutorPlugin">
    <HintPath>./Experimenter.PluginAPI/Experimenter.ExecutorPlugin.dll</HintPath>
  </Reference>
</ItemGroup>

After that, using directives must be include in your plugin class:

using DistributedExperimentation.DataModel;
using DistributedExperimentation.Experimenter.ExecutorPlugin

The following example shows a minimal plugin class:

using System;
using DistributedExperimentation.DataModel;
using DistributedExperimentation.Experimenter.ExecutorPlugin;

namespace MyProgram.Plugin
{
  public class ExecutorPluginMyProgram: IExecutorPlugin
  {
    public void execute(IExperimentSeries eSeries)
    {
    }
  }
}

Now you can start to program your individual application logic for the interaction to your experiment software.

Program to the plugin api

The plugin api requires to implement at least following method:

public void execute(IExperimentSeries eSeries)

In this method the object representation of an defined experiment set (json) is supplied by the c# class eSeries. To access, for example, to a specific experiment task inside of an experiment set, you can proceed same as an array:

IExperiment experiment1 = eSeries.getExperiments()[0];

Has the first experiment task, for example, two primitive parameter (integer and string), so you can access as follows:

IParameterList parameters = experiment1.getParameters();
IParameter parameter1 = parameters.get((uint)0);
IParameterValue parameter1Value = parameter1.getValue();
IIntegerValue parameter1Int = (IIntegerValue)parameter1Value;
int parameter1IntCSharp = (int)parameter1Int.getIntegerValue();

IParameter parameter2 = parameters.get((uint)1);
IParameterValue parameter2Value = parameter2.getValue();
ICharacterStringValue parameter2String = (ICharacterStringValue)parameter2Value;
String parameter2StringCSharp = parameter2String.getCharacterStringValue();

Owns the first experiment task, in addition a third complex parameter, which consists of two primitive parameter (both integer), so you can obtain the values as follows:

IParameter parameter3 = parameters.get((uint)2);
IParameterValue parameter3Value = parameter3.getValue();
if (!parameter3Value.isPrimitive()) {
  IParameterList subParameters = (IParameterList)parameter3;
  IParameter subParameter1 = subParameters.get((uint)0);
  IParameterValue subParameter1Value = subParameter1.getValue();
  IIntegerValue subParameter1Int = (IIntegerValue)subParameter1Value;
  int subParameter1IntCSharp = (int)subParameter1Int.getIntegerValue();
  // read subParameter2 like subParameter1 ...
}

With method isPrimitive() you can check whether a parameter owns an primitive value. These is useful for type casting. In addition, the types IExperimentSeries, IExperiment, IParameterList and IParameter provide the methods getId(), getName() and getDescription(). These allow to access of corresponding documentation attributes.

Test and usage of a plugin

The compiled plugin must be add in program directory of Experimenter subsystem. This is the directory, which contain the executable file of Experimenter subsystem (Experimenter.UI). For test purposes the Experimenter subsystem has a optional parameter --plugin-path or -p, with you can pass an explicit path to the plugin file. For example, a call of Experimenter subsystem under Linux could be look as follows:

./Experimenter.UI -e "@/home/user/definitions.json" -p "/home/user/myplugins/ExecutorPluginMyProgram.dll"