106 lines
2.9 KiB
Java
106 lines
2.9 KiB
Java
package com.henrypump.poc;
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
/**
|
|
* Created by patrickjmcd on 2/1/17.
|
|
* POC Class
|
|
*
|
|
*/
|
|
|
|
public class POC implements Runnable{
|
|
protected Well thisWell;
|
|
private Thread t;
|
|
private boolean ioEnabled;
|
|
|
|
POC(String dbHostname){
|
|
ioEnabled = true;
|
|
thisWell = new Well(dbHostname, 99, 99, 7);
|
|
thisWell.getWellSetup();
|
|
}
|
|
|
|
POC(String simFileName, boolean ioEnabled, String dbHostname){
|
|
this.ioEnabled = ioEnabled;
|
|
if (this.ioEnabled) {
|
|
thisWell = new Well(dbHostname, simFileName,99, 99, 7);
|
|
} else {
|
|
thisWell = new Well(dbHostname, simFileName,99, 99, 99);
|
|
}
|
|
thisWell.getWellSetup();
|
|
}
|
|
|
|
|
|
public void run(){
|
|
new Thread(new CLScanner(this)).start();
|
|
if(ioEnabled){
|
|
new Thread(new IOControl(this)).start();
|
|
}
|
|
long sleepMilliseconds = (long) (thisWell.getDt() * 1000);
|
|
thisWell.setupFluidRatio(0.50, 0.50, 1.12);
|
|
thisWell.checkSafeties();
|
|
while (true) {
|
|
for (int i = 0; i <= thisWell.sim.getLastFilledIndex(); i++) {
|
|
thisWell.eval(i);
|
|
|
|
try {
|
|
Thread.sleep(sleepMilliseconds);
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public void start () {
|
|
System.out.println("Starting POC Thread");
|
|
if (t == null) {
|
|
t = new Thread (this, "POC-Thread");
|
|
t.start ();
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
if (args[0].equals("help")){
|
|
System.out.println("Pass command line parameters...");
|
|
System.out.println("=============");
|
|
System.out.println("");
|
|
System.out.println("Simulation Mode:");
|
|
System.out.println("-------------");
|
|
System.out.println("<String: simulation filename> <boolean: use IO> <String: database hostname/address (optional)>");
|
|
System.out.println("");
|
|
System.out.println("IO Mode:");
|
|
System.out.println("-------------");
|
|
System.out.println("<String: database hostname/address (optional)>");
|
|
System.out.println("");
|
|
System.out.println("If updating config via json file, place a config file named 'wellSetup.json' in the project directory.");
|
|
System.exit(2);
|
|
}
|
|
|
|
|
|
String dbHostname = "localhost";
|
|
if (args.length > 3){
|
|
dbHostname = args[3];
|
|
}
|
|
|
|
if (args.length == 1){
|
|
dbHostname = args[1];
|
|
}
|
|
|
|
if (args.length < 2){
|
|
final POC realPOC = new POC(dbHostname);
|
|
realPOC.start();
|
|
} else {
|
|
final POC simPOC = new POC(args[0], args[1].equals("true"), dbHostname);
|
|
simPOC.start();
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|