From 0b5cdf1f8e856c3fa3d4933b9210cc4a22fba2c7 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Wed, 15 Feb 2017 16:26:44 -0600 Subject: [PATCH] Adds well name to config file. Option to startup with external DB --- barneyWell.json | 1 + build.gradle | 15 ++++++++++- kiesha7265Well.json | 1 + src/main/java/com/henrypump/poc/Database.java | 5 ++++ .../java/com/henrypump/poc/IOControl.java | 2 +- src/main/java/com/henrypump/poc/POC.java | 27 +++++++------------ src/main/java/com/henrypump/poc/Well.java | 17 ++++++++---- viceroyWell.json | 1 + 8 files changed, 45 insertions(+), 24 deletions(-) diff --git a/barneyWell.json b/barneyWell.json index 653fda3..bd7f102 100644 --- a/barneyWell.json +++ b/barneyWell.json @@ -1,4 +1,5 @@ { + "wellName": "Barney", "deltaT": 0.06, "pumpDiameter": 1.5, "fluidGradient": 0.45, diff --git a/build.gradle b/build.gradle index 28b73bd..389df61 100644 --- a/build.gradle +++ b/build.gradle @@ -39,6 +39,11 @@ remotes { user = 'root' identity = file('henryPumpDev') } + edisonOP { + host = '10.20.155.218' + user = 'root' + identity = file('henryPumpDev') + } } //create a single Jar with all dependencies @@ -53,7 +58,7 @@ task fatJar(type: Jar) { with jar } -task deploy << { +task deployUSB << { ssh.run { session(remotes.edison) { put from: 'build/libs/poc-java-all-1.0-SNAPSHOT.jar', into: '/home/root' @@ -61,6 +66,14 @@ task deploy << { } } +task deployOP << { + ssh.run { + session(remotes.edisonOP) { + put from: 'build/libs/poc-java-all-1.0-SNAPSHOT.jar', into: '/home/root' + } + } +} + task runRemote << { ssh.run { session(remotes.edison) { diff --git a/kiesha7265Well.json b/kiesha7265Well.json index d10fbd6..d622ab4 100644 --- a/kiesha7265Well.json +++ b/kiesha7265Well.json @@ -1,4 +1,5 @@ { + "wellName": "Kiesha 7265", "deltaT": 0.1, "pumpDiameter": 2.0, "fluidGradient": 0.45, diff --git a/src/main/java/com/henrypump/poc/Database.java b/src/main/java/com/henrypump/poc/Database.java index 2545365..f90ccad 100644 --- a/src/main/java/com/henrypump/poc/Database.java +++ b/src/main/java/com/henrypump/poc/Database.java @@ -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; diff --git a/src/main/java/com/henrypump/poc/IOControl.java b/src/main/java/com/henrypump/poc/IOControl.java index 212c83c..aa1a31c 100644 --- a/src/main/java/com/henrypump/poc/IOControl.java +++ b/src/main/java/com/henrypump/poc/IOControl.java @@ -35,7 +35,7 @@ public class IOControl implements Runnable { private void exitPOC(){ allOutputsOff(); - System.exit(99); + System.exit(0); } public void allOutputsOff(){ diff --git a/src/main/java/com/henrypump/poc/POC.java b/src/main/java/com/henrypump/poc/POC.java index 979602f..14591bd 100644 --- a/src/main/java/com/henrypump/poc/POC.java +++ b/src/main/java/com/henrypump/poc/POC.java @@ -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(); } } diff --git a/src/main/java/com/henrypump/poc/Well.java b/src/main/java/com/henrypump/poc/Well.java index e1afa76..b15f8f0 100644 --- a/src/main/java/com/henrypump/poc/Well.java +++ b/src/main/java/com/henrypump/poc/Well.java @@ -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(); } diff --git a/viceroyWell.json b/viceroyWell.json index 1fba860..2a47dbc 100644 --- a/viceroyWell.json +++ b/viceroyWell.json @@ -1,4 +1,5 @@ { + "wellName": "Viceroy Test Trailer", "deltaT": 0.1, "pumpDiameter": 1.5, "fluidGradient": 0.45,