Leading Project for Biosimulation > Cell/Biodynamics Simulation > simBio
 

Bug ID S-16: Conductor.integrate Error Handling

Problem

The method that integrates the ordinary differential equation is not good in handle errors.

Description

First prepare() is called, then for every time step:

  1. calculate(double t)
  2. analyze(double t) of all Analyzer
  3. update(double t) of all Variable
  4. Elapsed time is renewed, and continues the calculation during duration.

Last end() is called.

Solution

When an exception occurs for any of the above methods we need to make a log and a popup error dialog if running in the GUI.

System Design

  1. If an exception occurs for any of the above methods then catch it (the integration will end), log it and save the exception in the Conductor class.
  2. In the method GUI.GUITargetFile.loadProc() see if any exceptions occurred by implementing a check in the model.addCalculationObserver(new CalculationObserver() {public void stop() {'implementation goes here'} and a popup error dialog for the exception by using GUI.showErrorDialog().
  3. The Conductor.run() will call the above CalculationObserver stop() method after the integration, whether an exception occurred or not.

Test

  1. To get an error to occur, make a Stub of a model that throws an exception in the calculation function (Vanderpol_model_1928).
  2. Make a model XML-file that calls the above model.
  3. To run the model in the GUI automatic, use a similar method as the function created to test if all XML files work, RunModelInGUI(). The testclass will be named ConductorTest.
  4. To test that the error dialog popup, check to see if the dialog exists after running the model. Use the class TestUtil that was created as a side effect of the XmlFilesTest, see Testcase that test all XML-files and see if It can find any instance of JOptionPane, same way as the testclass GUITest does.

Test Result

All the specified tests have been run with successful result.

Committed Files

Following five files have been committed:
/src/main/java/org/simBio/core/Conductor.java
/src/main/java/org/simBio/sim/gui/GUI.java
/src/test/resources/org/simBio/core/Vanderpol_model_1928Stub.java
/src/test/resources/org/simBio/core/Vanderpol_model_1928Stub.xml
/src/test/java/org/simBio/core/ConductorTest.java