Search in sources :

Example 6 with SolverEvent

use of cbit.vcell.solver.server.SolverEvent in project vcell by virtualcell.

the class AbstractSolver method fireSolverProgress.

/**
 * Method to support listener events.
 */
protected void fireSolverProgress(double progress) {
    // Create event
    SolverEvent event = new SolverEvent(this, SolverEvent.SOLVER_PROGRESS, SimulationMessage.solverProgress(progress), progress, getCurrentTime(), null);
    VCMongoMessage.sendSolverEvent(event);
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == SolverListener.class) {
            ((SolverListener) listeners[i + 1]).solverProgress(event);
        }
    }
}
Also used : SolverListener(cbit.vcell.solver.server.SolverListener) SolverEvent(cbit.vcell.solver.server.SolverEvent)

Example 7 with SolverEvent

use of cbit.vcell.solver.server.SolverEvent in project vcell by virtualcell.

the class AbstractSolver method fireSolverAborted.

/**
 * Method to support listener events.
 */
protected void fireSolverAborted(SimulationMessage message) {
    // Create event
    SolverEvent event = new SolverEvent(this, SolverEvent.SOLVER_ABORTED, message, getProgress(), getCurrentTime(), message.getHtcJobId());
    VCMongoMessage.sendSolverEvent(event);
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == SolverListener.class) {
            ((SolverListener) listeners[i + 1]).solverAborted(event);
        }
    }
}
Also used : SolverListener(cbit.vcell.solver.server.SolverListener) SolverEvent(cbit.vcell.solver.server.SolverEvent)

Example 8 with SolverEvent

use of cbit.vcell.solver.server.SolverEvent in project vcell by virtualcell.

the class AbstractSolver method fireSolverPrinted.

/**
 * Method to support listener events.
 */
protected void fireSolverPrinted(double timepoint) {
    // Create event
    SolverEvent event = new SolverEvent(this, SolverEvent.SOLVER_PRINTED, SimulationMessage.solverPrinted(timepoint), getProgress(), timepoint, null);
    VCMongoMessage.sendSolverEvent(event);
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == SolverListener.class) {
            ((SolverListener) listeners[i + 1]).solverPrinted(event);
        }
    }
}
Also used : SolverListener(cbit.vcell.solver.server.SolverListener) SolverEvent(cbit.vcell.solver.server.SolverEvent)

Example 9 with SolverEvent

use of cbit.vcell.solver.server.SolverEvent in project vcell by virtualcell.

the class AbstractSolver method fireSolverStopped.

/**
 * Method to support listener events.
 */
protected void fireSolverStopped() {
    // Create event
    SolverEvent event = new SolverEvent(this, SolverEvent.SOLVER_STOPPED, SimulationMessage.solverStopped("stopped by user"), getProgress(), getCurrentTime(), null);
    VCMongoMessage.sendSolverEvent(event);
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == SolverListener.class) {
            ((SolverListener) listeners[i + 1]).solverStopped(event);
        }
    }
}
Also used : SolverListener(cbit.vcell.solver.server.SolverListener) SolverEvent(cbit.vcell.solver.server.SolverEvent)

Example 10 with SolverEvent

use of cbit.vcell.solver.server.SolverEvent in project vcell by virtualcell.

the class JavaSimulationExecutable method runSimulation.

private void runSimulation() throws SolverException {
    solver = SolverFactory.createSolver(new File(userDirectory), simulationTask, true);
    solver.addSolverListener(new SolverListener() {

        public final void solverAborted(SolverEvent event) {
            sendFailed(event.getSimulationMessage());
        }

        public final void solverFinished(SolverEvent event) {
            sendCompleted(event.getProgress(), event.getTimePoint(), event.getSimulationMessage());
        }

        public final void solverPrinted(SolverEvent event) {
            // can never get data messages here
            sendNewData(event.getProgress(), event.getTimePoint(), event.getSimulationMessage());
        }

        public final void solverProgress(SolverEvent event) {
            // can never get progress message here
            sendProgress(event.getProgress(), event.getTimePoint(), event.getSimulationMessage());
        }

        public final void solverStarting(SolverEvent event) {
            sendStarting(event.getSimulationMessage());
        }

        public final void solverStopped(SolverEvent event) {
            if (lg.isTraceEnabled())
                lg.trace("Caught solverStopped(" + event.getSource() + ")");
        // Don't send message anymore because the dispatcher will update the database anyway no matter if the worker responds
        // workerMessaging.sendStopped(event.getProgress(), event.getTimePoint());
        }
    });
    solver.startSolver();
    while (true) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        }
        cbit.vcell.solver.server.SolverStatus solverStatus = solver.getSolverStatus();
        if (solverStatus != null) {
            if (solverStatus.getStatus() != SolverStatus.SOLVER_STARTING && solverStatus.getStatus() != SolverStatus.SOLVER_READY && solverStatus.getStatus() != SolverStatus.SOLVER_RUNNING) {
                break;
            }
        }
    }
}
Also used : SolverStatus(cbit.vcell.solver.server.SolverStatus) SolverListener(cbit.vcell.solver.server.SolverListener) File(java.io.File) SolverEvent(cbit.vcell.solver.server.SolverEvent)

Aggregations

SolverEvent (cbit.vcell.solver.server.SolverEvent)10 SolverListener (cbit.vcell.solver.server.SolverListener)10 File (java.io.File)4 SimulationTask (cbit.vcell.messaging.server.SimulationTask)3 SimulationContext (cbit.vcell.mapping.SimulationContext)2 Simulation (cbit.vcell.solver.Simulation)2 SimulationJob (cbit.vcell.solver.SimulationJob)2 TempSimulation (cbit.vcell.solver.TempSimulation)2 SolverStatus (cbit.vcell.solver.server.SolverStatus)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)1 MathMappingCallbackTaskAdapter (cbit.vcell.mapping.MathMappingCallbackTaskAdapter)1 MathMappingCallback (cbit.vcell.mapping.SimulationContext.MathMappingCallback)1 VCMessagingException (cbit.vcell.message.VCMessagingException)1 VCellServiceMXBeanImpl (cbit.vcell.message.server.jmx.VCellServiceMXBeanImpl)1 OutputContext (cbit.vcell.simdata.OutputContext)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 DataProcessingInstructions (cbit.vcell.solver.DataProcessingInstructions)1 SimulationOwner (cbit.vcell.solver.SimulationOwner)1 SolverException (cbit.vcell.solver.SolverException)1