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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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;
}
}
}
}
Aggregations