Search in sources :

Example 1 with ApplicationMessage

use of cbit.vcell.solvers.ApplicationMessage in project vcell by virtualcell.

the class SmoldynSolver method getApplicationMessage.

/**
 * show progress.
 * Creation date: (7/13/2006 9:00:41 AM)
 * @return cbit.vcell.solvers.ApplicationMessage
 * @param message java.lang.String
 */
protected ApplicationMessage getApplicationMessage(String message) {
    String SEPARATOR = ":";
    String DATA_PREFIX = "data:";
    String PROGRESS_PREFIX = "progress:";
    if (message.startsWith(DATA_PREFIX)) {
        double timepoint = Double.parseDouble(message.substring(message.lastIndexOf(SEPARATOR) + 1));
        setCurrentTime(timepoint);
        return new ApplicationMessage(ApplicationMessage.DATA_MESSAGE, getProgress(), timepoint, null, message);
    } else if (message.startsWith(PROGRESS_PREFIX)) {
        String progressString = message.substring(message.lastIndexOf(SEPARATOR) + 1, message.indexOf("%"));
        double progress = Double.parseDouble(progressString) / 100.0;
        // setCurrentTime(startTime + (endTime-startTime)*progress);
        return new ApplicationMessage(ApplicationMessage.PROGRESS_MESSAGE, progress, -1, null, message);
    } else {
        throw new RuntimeException("unrecognized message");
    }
}
Also used : ApplicationMessage(cbit.vcell.solvers.ApplicationMessage)

Example 2 with ApplicationMessage

use of cbit.vcell.solvers.ApplicationMessage in project vcell by virtualcell.

the class SundialsSolver method propertyChange.

/**
 * Insert the method's description here.
 * Creation date: (6/27/2001 2:33:03 PM)
 */
public void propertyChange(java.beans.PropertyChangeEvent event) {
    super.propertyChange(event);
    if (event.getSource() == getMathExecutable() && event.getPropertyName().equals("applicationMessage")) {
        String messageString = (String) event.getNewValue();
        if (messageString == null || messageString.length() == 0) {
            return;
        }
        ApplicationMessage appMessage = getApplicationMessage(messageString);
        if (appMessage != null && appMessage.getMessageType() == ApplicationMessage.DATA_MESSAGE) {
            try {
                printToFile(appMessage.getProgress());
            } catch (IOException e) {
                e.printStackTrace(System.out);
            }
        }
    }
}
Also used : ApplicationMessage(cbit.vcell.solvers.ApplicationMessage) IOException(java.io.IOException)

Example 3 with ApplicationMessage

use of cbit.vcell.solvers.ApplicationMessage in project vcell by virtualcell.

the class GibsonSolver method getApplicationMessage.

/**
 * show progress.
 * Creation date: (7/13/2006 9:00:41 AM)
 * @return cbit.vcell.solvers.ApplicationMessage
 * @param message java.lang.String
 */
protected ApplicationMessage getApplicationMessage(String message) {
    String SEPARATOR = ":";
    String DATA_PREFIX = "data:";
    String PROGRESS_PREFIX = "progress:";
    if (message.startsWith(DATA_PREFIX)) {
        double timepoint = Double.parseDouble(message.substring(message.lastIndexOf(SEPARATOR) + 1));
        setCurrentTime(timepoint);
        return new ApplicationMessage(ApplicationMessage.DATA_MESSAGE, getProgress(), timepoint, null, message);
    } else if (message.startsWith(PROGRESS_PREFIX)) {
        String progressString = message.substring(message.lastIndexOf(SEPARATOR) + 1, message.indexOf("%"));
        double progress = Double.parseDouble(progressString) / 100.0;
        // setCurrentTime(startTime + (endTime-startTime)*progress);
        return new ApplicationMessage(ApplicationMessage.PROGRESS_MESSAGE, progress, -1, null, message);
    } else {
        throw new RuntimeException("unrecognized message");
    }
}
Also used : ApplicationMessage(cbit.vcell.solvers.ApplicationMessage)

Example 4 with ApplicationMessage

use of cbit.vcell.solvers.ApplicationMessage in project vcell by virtualcell.

the class HybridSolver method getApplicationMessage.

/**
 * show progress.
 * Creation date: (7/13/2006 9:00:41 AM)
 * @return cbit.vcell.solvers.ApplicationMessage
 * @param message java.lang.String
 */
protected ApplicationMessage getApplicationMessage(String message) {
    String SEPARATOR = ":";
    String DATA_PREFIX = "data:";
    String PROGRESS_PREFIX = "progress:";
    if (message.startsWith(DATA_PREFIX)) {
        double timepoint = Double.parseDouble(message.substring(message.lastIndexOf(SEPARATOR) + 1));
        setCurrentTime(timepoint);
        return new ApplicationMessage(ApplicationMessage.DATA_MESSAGE, getProgress(), timepoint, null, message);
    } else if (message.startsWith(PROGRESS_PREFIX)) {
        String progressString = message.substring(message.lastIndexOf(SEPARATOR) + 1, message.indexOf("%"));
        double progress = Double.parseDouble(progressString) / 100.0;
        // setCurrentTime(startTime + (endTime-startTime)*progress);
        return new ApplicationMessage(ApplicationMessage.PROGRESS_MESSAGE, progress, -1, null, message);
    } else {
        throw new RuntimeException("unrecognized message");
    }
}
Also used : ApplicationMessage(cbit.vcell.solvers.ApplicationMessage)

Example 5 with ApplicationMessage

use of cbit.vcell.solvers.ApplicationMessage in project vcell by virtualcell.

the class HybridSolver method propertyChange.

/**
 * Insert the method's description here.
 * Creation date: (10/11/2006 11:16:02 AM)
 */
public void propertyChange(java.beans.PropertyChangeEvent event) {
    super.propertyChange(event);
    if (event.getSource() == getMathExecutable() && event.getPropertyName().equals("applicationMessage")) {
        String messageString = (String) event.getNewValue();
        if (messageString == null || messageString.length() == 0) {
            return;
        }
        ApplicationMessage appMessage = getApplicationMessage(messageString);
        if (appMessage != null && appMessage.getMessageType() == ApplicationMessage.PROGRESS_MESSAGE) {
            try {
                printToFile(appMessage.getProgress());
            } catch (IOException e) {
                e.printStackTrace(System.out);
            }
        }
    }
}
Also used : ApplicationMessage(cbit.vcell.solvers.ApplicationMessage) IOException(java.io.IOException)

Aggregations

ApplicationMessage (cbit.vcell.solvers.ApplicationMessage)10 IOException (java.io.IOException)3 TimeBounds (cbit.vcell.solver.TimeBounds)1