blob: 4350cf7db6cccffe2cf1cb08e50d4fa7a4b5ab4d [file] [log] [blame]
package org.eclipse.stem.solvers.fd.impl;
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.stem.core.model.STEMTime;
/**
* A job for the finite difference solver
*
*/
public class FdJob extends Job {
public FdJob(String n, short thread, FiniteDifferenceImpl s) {
super(n);
this.threadnum = thread;
this.solver = s;
}
public static int COMPUTE_DELTAS = 0;
public static int CHECK_DELTAS = 1;
public static int APPLY_DELTAS = 2;
protected double progress;
protected double t;
protected FiniteDifferenceImpl solver;
protected STEMTime time;
long timeDelta;
int cycle;
short threadnum;
int step;
public double getProgress() {
return this.progress;
}
public void setProgress(double p) {
this.progress = p;
}
protected IStatus run(final IProgressMonitor monitor) {
IStatus status = Status.CANCEL_STATUS;
if (step == COMPUTE_DELTAS) {
solver.computeDeltasStep(time,timeDelta,threadnum);
status = new Status(IStatus.OK, "unknownId", "");
} else if (step == CHECK_DELTAS) {
double adjustmentFactor = solver.checkDeltasStep(threadnum);
status = new Status(IStatus.OK, "unknownId", adjustmentFactor + "");
} else if (step == APPLY_DELTAS) {
solver.applyDeltasStep(threadnum);
status = new Status(IStatus.OK, "unknownId", "");
}
return status;
}
}