Plugins

Architecture

../_images/Plugins_MeCoSimBasics_MultisetsViewer.png

MeCoSim provides an architecture of plugins that permits the definition of additional functionalities and features not initially provided by MeCoSim, that is, plugins. Following we present videos of some plugins provided by MeCoSim developers, but any developer could add its own plugins to MeCoSim. If your are interested in developing new plugins for MeCoSim or making them available to the community please contact us (lvalencia@us.es).

Plugins configuration for menu calls

  • MeCoSim plugins are programs that we can include in MeCoSim in order to provide additional functionality to the core, the default available features. These plugins should include some jar files, along with other desired external programs and files. We can ask MeCoSim to call specific entry points in classes contained in the jar files, providing the needed parameteres to the methods that are waiting to be called.
  • Plugins can be installed from repositories inside MeCoSim, or can be downloaded somewhere (for instance, from Github MeCoSim plugins site) and copied in plugins directory inside mecosim-rgnc folder. Both mechanisms make jar files available to be used in MeCoSim, but there is a small difference: when installed from repositories, some default properties values are included in plugins-properties file. However, when manually downloading, we should also include the default values for properties (these initial properties might be provided by plugins developers along with the jar files). Anyway, we can always modify the contents of plugins-parameters file.
  • We can define a number of plugin calls from a single plugin jar file, by setting the right properties in the file. For each plugin call defined, we will have a new menu item in our menu of Plugins in MeCoSim custom apps.

The structure of a plugin call we want to include in Plugins menu is as follows:

plugin-myplugincall = mypluginPackage.MainClass # Class of the entry point method to call
pluginname-myplugincall = Run My Plugin         # Name we want to see in the menu item
pluginmethod-myplugincall = myPluginMethod      # Entry point method
pluginparam-myplugincall-1 = My param           # First param for the array to sent to method (there might be a number of them)
pluginjar-myplugincall-1 = MyPluginJar.jar      # First jar file part of the plugin (there might be several ones)
pluginorder-myplugincall = 1                    # Relative order of my menu item
pluginintegrated-myplugincall = true            # Flag to integrate in program flow or run in non-blocking mode

At the end of this page a number of plugin calls configurations is given in the form of a table permiting filtering the information in order to clarify the roles of the different elements.

The signature of the methods to act as entry points shoul be of this type:

public static void myentryPoint (String [] args, ISimulator sim, IMeCoSimConfig config)

The only mandatory parameter is args, receiving the params as configured in properties file when indicating pluginparam-.... The other two parameters are optional in the signature, so if the method present parameters of such types they will be passed from MeCoSim, while if some parameter is not present then it will not be necessary for MeCoSim to send that information.

The interface ISimulator is part of pLinguaCore and includes:

public interface ISimulator extends Serializable {
    public void setPsystem(Psystem psystem);
    public PrintStream getInfoChannel();
    public void runUntilTimeOutorSteps(long timeOut, int steps);
    public Psystem getPsystem();
    public void setInfoChannel(PrintStream infoChannel);
    public void runUntilTimeOut(long timeOut);
    public void run() throws PlinguaCoreException;
    public void runSteps(int steps) throws PlinguaCoreException;
    public boolean step() throws PlinguaCoreException;
    public boolean alternateStep() throws UnsupportedOperationException;
    public int countAlternatives() throws UnsupportedOperationException;
    public boolean stepBack() throws UnsupportedOperationException;
    public void reset();
    public boolean supportsStepBack();
    public boolean supportsAlternateSteps();
    public Configuration getCurrentConfig();
    public double getTime();
    public boolean isTimed();
    public void setTimed(boolean time);
    public int getVerbosity();
    public void setVerbosity(int verbosity);
    public boolean stepsBackAvailable();
    public void cleanPreviousConfigurations();
    public void setCurrentConfig(Configuration configuration);
    public void stopThread();
    public boolean isFinished();
}

The interface IMeCoSimConfig is part of MeCoSim and includes:

public interface IMeCoSimConfig {
    public String getPropertiesPath();
    public String getUserfilesPath();
    public String getConfigPath();
    public String getDataPath();
    public String getDatabasePath();
    public String getBinPath();
    public IGeneralData getGeneralData();
    public File getPLinguaFile();
    public Map<String,Number> getParameters();
    public void setParameters(Map<String,Number> pars);
    public Map<String,String> getTextParameters();
    public void setTextParameters(Map<String,String> pars);
}

This interface IGeneralData that appears as part of IMeCoSimConfig is a simple interface containing:

public interface IGeneralData {
    public abstract String getAppName();
    public abstract int getIdApp();
    public abstract String getModelPath();
    public abstract int getSimulatedCycles();
    public abstract int getStepsByCycle();
}

Examples of plugins configuration

This link provides a number of examples of properties configuration:

Plugins in simulation params

Another very important use of plugins is the extension of functionality to be used when generating simulation params: