From Interactive System for Ice sheet Simulation
Jump to: navigation, search



Model Interface


The model interface class allows the model to be selected dynamically at runtime.

public interface IModel extends Runnable {
    String Name();
    String SpecXMLFile();
    boolean isRunning();
    void start(DynamicTree tree, LogFile logger);
    void start(String command, String configFile, LogFile logger);
    void start(String command, LogFile logger);
    void stop();
    void Launch();
    Process getProcess();    

Creating a new model

  1. Create a new project and add a reference to Echo
  2. Create a new class that implements Models.IModel and extends Runnable
  3. Implement the necessary methods
    1. Start(String, String, LogFile) --> used by eduISIS
    2. Start(String, LogFile) --> used by ISIS
    3. run() --> internally called, actually does the work of running the model.
    4. Name() --> This is used when finding a model by it's name. It must return a unique string within all plugins in the bin/plugins directory. It's unknown what will happen if a duplicate is added. It would probably just use which ever it found first. For example, the PISM model's Name() function returns "PISM". Pseudo namespaces should be used in custom models to avoid duplicate problems.


 Echo.LogFile log = new Echo.LogFile(txtareaLog, Echo.Constants.userOutputPath() + File.separator + g.Name() + "_Log.txt");
 g.start(logic.getElementManager().getModelToRun(), educationalConfigurationFile.toString(), log);


The model will handle creating a new thread and calling the run() method.
EduISIS runs the model by calling start(String, String, LogFile). ISIS runs the model by calling start(String,LogFile)
This is different because eduISIS does not have a dynamicTree control.


A callback method is in the works which will allow a method in the calling application to be called with the model finishes. Initially this will probably just fire a RunComplete function but could also be used to add a progress bar.

Where to place models

Echo will look in /data/Models for jar files that implement IModel.
If /data/Models does not exist, it will be created automatically.

Finding available pluggins

Models.GetAvailablePlugins() will search /data/Models and return the Name of each model as a List of strings
Models.getInstance(String) takes a model name and returns an instance of that model.