Adds ability to change mode from website

This commit is contained in:
Patrick McDonagh
2017-03-08 10:01:03 -06:00
parent a0025610f4
commit aab7537972
6 changed files with 134 additions and 95 deletions

View File

@@ -213,13 +213,13 @@ public class WebServer{
if ((user.length() > 0) && (action.length() > 0)) {
switch (action) {
case "manual":
attachedPOC.thisWell.setRunMode("MANUAL");
attachedPOC.thisWell.setRunModeString("MANUAL");
break;
case "poc":
attachedPOC.thisWell.setRunMode("POC");
attachedPOC.thisWell.setRunModeString("POC");
break;
case "timer":
attachedPOC.thisWell.setRunMode("TIMER");
attachedPOC.thisWell.setRunModeString("TIMER");
break;
default:
respJSON.put(action, "not implemented");

View File

@@ -106,7 +106,7 @@ public class Well {
private boolean permissiveOK;
private long strokesSinceStart = 0;
private long startupStrokes = 1;
private long startupStrokes = 10;
private long strokesToday = 0;
private long strokesLifetime;
private int pointCounter =0;
@@ -305,6 +305,16 @@ public class Well {
} else {
fluidGasRatio = dbFluidGasRatio;
}
double dbRunMode = db.getSetpoint("runMode");
if (dbRunMode == Double.MIN_VALUE){
runMode = RUNMODE_MANUAL; // DEFAULT VALUE
System.out.println("Using default value of " + runMode + " for runMode.");
db.storeSetpoint("runMode", (double) runMode);
} else {
setRunMode((int) dbRunMode);
System.out.println("Run Mode set to " + getRunModeString());
}
}
private void initializeMeasurements(){
@@ -521,7 +531,7 @@ public class Well {
}
}
public void setRunMode(String runModeString){
public void setRunModeString(String runModeString){
switch (runModeString){
case "POC":
runMode = RUNMODE_POC;
@@ -540,6 +550,10 @@ public class Well {
}
}
public void setRunMode(int runMode) {
this.runMode = runMode;
}
public double getCurrentSurfacePosition() {
return currentSurfacePosition;
}