Adds well name to config file. Option to startup with external DB
This commit is contained in:
@@ -35,6 +35,11 @@ public class Database {
|
||||
database = mongoClient.getDatabase(pocDatabase);
|
||||
}
|
||||
|
||||
Database(String dbHostname){
|
||||
mongoClient = new MongoClient(dbHostname);
|
||||
database = mongoClient.getDatabase(pocDatabase);
|
||||
}
|
||||
|
||||
public long getLastStrokeNum(){
|
||||
|
||||
long lastStroke = 0;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class IOControl implements Runnable {
|
||||
|
||||
private void exitPOC(){
|
||||
allOutputsOff();
|
||||
System.exit(99);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public void allOutputsOff(){
|
||||
|
||||
@@ -10,36 +10,25 @@ import java.time.ZonedDateTime;
|
||||
|
||||
public class POC implements Runnable{
|
||||
protected Well thisWell;
|
||||
private int simLoops;
|
||||
private Thread t;
|
||||
|
||||
|
||||
private boolean ioEnabled;
|
||||
|
||||
POC(String wellName, String wellSetupJsonFile, int simLoops){
|
||||
POC(String wellSetupJsonFile, String dbHostname){
|
||||
ioEnabled = true;
|
||||
thisWell = new Well(wellName, 99, 99, 7);
|
||||
thisWell = new Well(dbHostname, 99, 99, 7);
|
||||
thisWell.parseJSONFile(wellSetupJsonFile);
|
||||
// thisWell.printTapers();
|
||||
this.simLoops = simLoops;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
POC(String wellName, String wellSetupJsonFile, String simFileName, boolean ioEnabled, int simLoops){
|
||||
POC(String wellSetupJsonFile, String simFileName, boolean ioEnabled, String dbHostname){
|
||||
this.ioEnabled = ioEnabled;
|
||||
if (this.ioEnabled) {
|
||||
thisWell = new Well(wellName, simFileName,99, 99, 7);
|
||||
|
||||
thisWell = new Well(dbHostname, simFileName,99, 99, 7);
|
||||
} else {
|
||||
thisWell = new Well(wellName, simFileName,99, 99, 99);
|
||||
// IO
|
||||
thisWell = new Well(dbHostname, simFileName,99, 99, 99);
|
||||
}
|
||||
|
||||
thisWell.parseJSONFile(wellSetupJsonFile);
|
||||
// thisWell.printTapers();
|
||||
this.simLoops = simLoops;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +67,11 @@ public class POC implements Runnable{
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
final POC thisPOC = new POC("Barney", args[0], args[1], args[2].equals("true"), 100);
|
||||
String dbHostname = "localhost";
|
||||
if (args.length > 3){
|
||||
dbHostname = args[3];
|
||||
}
|
||||
final POC thisPOC = new POC(args[0], args[1], args[2].equals("true"), dbHostname);
|
||||
thisPOC.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +173,9 @@ public class Well {
|
||||
private Measurement surfaceStrokeLength;
|
||||
private Measurement tubingMovement;
|
||||
|
||||
Well(String wellName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
Well(String dbHostname, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
this.wellName = wellName;
|
||||
db = new Database();
|
||||
db = new Database(dbHostname);
|
||||
strokesLifetime = db.getLastStrokeNum() + 1;
|
||||
currentCard = new Card(strokesLifetime);
|
||||
inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100);
|
||||
@@ -184,10 +184,10 @@ public class Well {
|
||||
initializeMeasurements();
|
||||
}
|
||||
|
||||
Well(String wellName, String simFileName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
Well(String dbHostname, String simFileName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
|
||||
this.wellName = wellName;
|
||||
sim = new Simulation(simFileName);
|
||||
db = new Database();
|
||||
db = new Database(dbHostname);
|
||||
strokesLifetime = db.getLastStrokeNum() + 1;
|
||||
currentCard = new Card(strokesLifetime);
|
||||
inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100);
|
||||
@@ -357,6 +357,10 @@ public class Well {
|
||||
this.structuralRating = structuralRating;
|
||||
}
|
||||
|
||||
public void setWellName(String wellName) {
|
||||
this.wellName = wellName;
|
||||
}
|
||||
|
||||
public String getWellName() {
|
||||
return wellName;
|
||||
}
|
||||
@@ -534,6 +538,9 @@ public class Well {
|
||||
Object obj = parser.parse(new FileReader(jsonFilename));
|
||||
JSONObject well = (JSONObject) obj;
|
||||
|
||||
Object newWellName = well.get("wellName");
|
||||
if (newWellName != null) wellName = (String) newWellName;
|
||||
|
||||
Object newDeltaT = well.get("deltaT");
|
||||
if (newDeltaT != null) dt = (Double) newDeltaT;
|
||||
|
||||
@@ -1069,7 +1076,7 @@ public class Well {
|
||||
|
||||
|
||||
public static void main( String[] args ){
|
||||
Well thisWell = new Well("Barney", args[1], 99, 99, 99);
|
||||
Well thisWell = new Well(args[1], 99, 99, 99);
|
||||
thisWell.parseJSONFile(args[0]);
|
||||
thisWell.printTapers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user