control the well from a text-based cli
This commit is contained in:
103
src/main/java/com/henrypump/poc/CLScanner.java
Normal file
103
src/main/java/com/henrypump/poc/CLScanner.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import javax.sound.midi.Soundbank;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/8/17.
|
||||
*/
|
||||
class CLScanner implements Runnable {
|
||||
|
||||
private final POC poc;
|
||||
CLScanner(POC poc){
|
||||
this.poc = poc;
|
||||
}
|
||||
|
||||
private void startWell(){
|
||||
poc.thisWell.start("commandline");
|
||||
}
|
||||
|
||||
private void stopWell(){
|
||||
poc.thisWell.stop("commandline");
|
||||
}
|
||||
|
||||
private void exitPOC(){
|
||||
System.exit(99);
|
||||
}
|
||||
|
||||
private void runStatus(){
|
||||
System.out.println("Run Status: " + poc.thisWell.getRunStatusString());
|
||||
}
|
||||
|
||||
private void showTapers(){
|
||||
poc.thisWell.printTapers();
|
||||
}
|
||||
|
||||
private void showTotals(){
|
||||
poc.thisWell.printTotals();
|
||||
}
|
||||
|
||||
private void help(){
|
||||
System.out.println("");
|
||||
System.out.println("== HELP MENU ==");
|
||||
System.out.println("");
|
||||
System.out.println("POSSIBLE COMMANDS");
|
||||
System.out.println("start -- Issues the start command");
|
||||
System.out.println("stop -- Issues the stop command");
|
||||
System.out.println("status -- Gets the current run status");
|
||||
System.out.println("showtapers -- Gets the current taper and well parameters");
|
||||
System.out.println("showtotals -- Gets the current totals and averages");
|
||||
System.out.println("exit -- Quits the program");
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void run() {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String input = "";
|
||||
while (sc.hasNextLine()) {
|
||||
input = sc.nextLine();
|
||||
switch(input){
|
||||
case "start":
|
||||
startWell();
|
||||
break;
|
||||
case "stop":
|
||||
stopWell();
|
||||
break;
|
||||
case "exit":
|
||||
exitPOC();
|
||||
break;
|
||||
case "status":
|
||||
runStatus();
|
||||
break;
|
||||
case "showtotals":
|
||||
showTotals();
|
||||
break;
|
||||
case "showtapers":
|
||||
showTapers();
|
||||
break;
|
||||
case "help":
|
||||
help();
|
||||
break;
|
||||
default:
|
||||
if (input.startsWith("welltest")){
|
||||
String[] testParams = input.split(" ");
|
||||
ZonedDateTime timestamp = ZonedDateTime.parse(testParams[1]);
|
||||
poc.thisWell.wellTest = new WellTest(timestamp,
|
||||
Double.parseDouble(testParams[2]), Double.parseDouble(testParams[3]),
|
||||
Double.parseDouble(testParams[4]), Double.parseDouble(testParams[5]),
|
||||
Double.parseDouble(testParams[6]), poc.thisWell.db.getPreviousDailyTotal(timestamp)
|
||||
);
|
||||
poc.thisWell.db.newWellTest(poc.thisWell.wellTest);
|
||||
poc.thisWell.wellTest.print();
|
||||
} else {
|
||||
help();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user