diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9ca011a..60dbcb4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,9 +2,12 @@
-
+
+
+
+
@@ -14,6 +17,7 @@
+
@@ -37,44 +41,40 @@
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -83,114 +83,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -207,6 +121,11 @@
+
+
+ sPositionPrevious
+
+
@@ -220,13 +139,16 @@
-
-
-
+
-
+
+
+
+
+
+
@@ -238,10 +160,10 @@
-
+
-
-
+
+
@@ -259,7 +181,6 @@
-
@@ -324,14 +245,35 @@
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -456,6 +398,8 @@
+
+
@@ -536,6 +480,14 @@
+
+
+
+
+
+
+
+
@@ -551,36 +503,37 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
+
@@ -588,16 +541,169 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -605,7 +711,6 @@
-
@@ -629,7 +734,6 @@
-
@@ -645,7 +749,6 @@
-
@@ -653,10 +756,6 @@
-
-
-
-
@@ -665,19 +764,12 @@
-
+
-
-
-
-
-
-
-
-
+
@@ -686,117 +778,20 @@
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -805,29 +800,124 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/henrypump/poc/AnalogIn.java b/src/main/java/com/henrypump/poc/AnalogIn.java
index c5bde9f..d7aa258 100644
--- a/src/main/java/com/henrypump/poc/AnalogIn.java
+++ b/src/main/java/com/henrypump/poc/AnalogIn.java
@@ -23,17 +23,6 @@ public class AnalogIn {
private double euMax;
private double[] history = new double[100];
- static {
- try {
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
AnalogIn(int channel, double rawMin, double rawMax, double euMin, double euMax){
this.channel = channel;
if (channel != 99) {
diff --git a/src/main/java/com/henrypump/poc/Card.java b/src/main/java/com/henrypump/poc/Card.java
index db795ae..aa70a0d 100644
--- a/src/main/java/com/henrypump/poc/Card.java
+++ b/src/main/java/com/henrypump/poc/Card.java
@@ -48,12 +48,14 @@ public class Card {
private double tubingMovement;
private double strokeSpeed;
- private double plungerTravel;
- private double dailyProduction;
private double structuralLoading;
private double polishedRodHorsepower;
private double pumpHorsepower;
+ private double fluidBBLMoved;
+ private double waterBBLMoved;
+ private double oilBBLMoved;
+ private double gasMCFMoved;
private long strokeStartTime;
@@ -138,18 +140,62 @@ public class Card {
return tubingMovement;
}
- public double getPlungerTravel() {
- return plungerTravel;
- }
-
- public double getDailyProduction() {
- return dailyProduction;
- }
-
public double getStructuralLoading() {
return structuralLoading;
}
+ public double getPumpIntakePressure() {
+ return pumpIntakePressure;
+ }
+
+ public double getFluidLevel() {
+ return fluidLevel;
+ }
+
+ public double getStrokeSpeed() {
+ return strokeSpeed;
+ }
+
+ public double getPolishedRodHorsepower() {
+ return polishedRodHorsepower;
+ }
+
+ public double getPumpHorsepower() {
+ return pumpHorsepower;
+ }
+
+ public LPPair getSurfaceLoadMax() {
+ return surfaceLoadMax;
+ }
+
+ public LPPair getSurfaceLoadMin() {
+ return surfaceLoadMin;
+ }
+
+ public LPPair getDownholeLoadMax() {
+ return downholeLoadMax;
+ }
+
+ public LPPair getDownholeLoadMin() {
+ return downholeLoadMin;
+ }
+
+ public double getFluidBBLMoved() {
+ return fluidBBLMoved;
+ }
+
+ public double getWaterBBLMoved() {
+ return waterBBLMoved;
+ }
+
+ public double getOilBBLMoved() {
+ return oilBBLMoved;
+ }
+
+ public double getGasMCFMoved() {
+ return gasMCFMoved;
+ }
+
public int getNumPointsUsed() {
return numPointsUsed;
}
@@ -227,7 +273,8 @@ public class Card {
};
void calcStrokeData(int numSlices, double fluidGradient, double rodDepth, double anchorDepth, double tubingCSA,
- double pumpArea, double frictionEstimate, double structuralRating)
+ double pumpArea, double frictionEstimate, double structuralRating,
+ double waterBBLRatio, double oilBBLRatio, double gasMCFRatio)
{
calculateSPM();
surfacePositionMax = positionMax(surfacePosition, surfaceLoad, numPointsUsed);
@@ -303,6 +350,11 @@ public class Card {
downholeNetStrokeLength = bottomCorner.getPosition() - downholePositionMin.getPosition();
fillageCalculated = (downholeNetStrokeLength / downholeAdjustedGrossStrokeLength) * 100.0;
fillageEstimated =(downholeNetStrokeLength / downholeGrossStrokeLength) * 100.0;
+ fluidBBLMoved = downholeNetStrokeLength * pumpArea * 0.00010307;
+ oilBBLMoved = fluidBBLMoved * oilBBLRatio;
+ waterBBLMoved = fluidBBLMoved * waterBBLRatio;
+ gasMCFMoved = fluidBBLMoved * gasMCFRatio;
+
if (fillageEstimated > 100)
fillageEstimated = 100.0;
diff --git a/src/main/java/com/henrypump/poc/Database.java b/src/main/java/com/henrypump/poc/Database.java
index e3ab7a3..2b7d840 100644
--- a/src/main/java/com/henrypump/poc/Database.java
+++ b/src/main/java/com/henrypump/poc/Database.java
@@ -50,16 +50,20 @@ public class Database {
public long newCard(Card inpCard){
MongoCollection collection = database.getCollection("cards");
List s_p = new ArrayList();
- for(Double pt: inpCard.getSurfacePosition()) { s_p.add(pt);}
-
List s_l = new ArrayList();
- for(Double pt: inpCard.getSurfaceLoad()) { s_l.add(pt);}
-
List d_p = new ArrayList();
- for(Double pt: inpCard.getDownholePosition()) { d_p.add(pt);}
-
List d_l = new ArrayList();
- for(Double pt: inpCard.getDownholeLoad()) { d_l.add(pt);}
+ int numPointsScan = inpCard.getNumPointsUsed();
+ double[] sp = inpCard.getSurfacePosition();
+ double[] sl = inpCard.getSurfaceLoad();
+ double[] dp = inpCard.getDownholePosition();
+ double[] dl = inpCard.getDownholeLoad();
+ for(int i = 0; i < numPointsScan; i++ ) {
+ s_p.add(sp[i]);
+ s_l.add(sl[i]);
+ d_p.add(dp[i]);
+ d_l.add(dl[i]);
+ }
Document doc = new Document("strokeNumber", inpCard.getStrokeNumber())
.append("surface_position", s_p)
diff --git a/src/main/java/com/henrypump/poc/DigitalIn.java b/src/main/java/com/henrypump/poc/DigitalIn.java
index 2c3988d..afe8b95 100644
--- a/src/main/java/com/henrypump/poc/DigitalIn.java
+++ b/src/main/java/com/henrypump/poc/DigitalIn.java
@@ -33,7 +33,9 @@ public class DigitalIn {
}
public int read(){
- lastValue = gpioPin.read();
+ if (channel != 99 ) {
+ lastValue = gpioPin.read();
+ }
return lastValue;
}
diff --git a/src/main/java/com/henrypump/poc/DigitalOut.java b/src/main/java/com/henrypump/poc/DigitalOut.java
index 687fc54..75f58eb 100644
--- a/src/main/java/com/henrypump/poc/DigitalOut.java
+++ b/src/main/java/com/henrypump/poc/DigitalOut.java
@@ -17,17 +17,6 @@ public class DigitalOut {
private Gpio gpioPin;
private int value;
- static {
- try {
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
DigitalOut(int channel, int startupValue){
this.channel = channel;
if (channel != 99) {
diff --git a/src/main/java/com/henrypump/poc/GUI.java b/src/main/java/com/henrypump/poc/GUI.java
new file mode 100644
index 0000000..4736a3b
--- /dev/null
+++ b/src/main/java/com/henrypump/poc/GUI.java
@@ -0,0 +1,68 @@
+package com.henrypump.poc;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * Created by patrickjmcd on 2/3/17.
+ */
+public class GUI extends Frame {
+ private TextField txtRunStatus;
+ private TextField txtSurfacePosition, txtSurfaceLoad, txtDownholePosition, txtDownholeLoad;
+ private final POC attachedPOC;
+
+ GUI(POC attachedPOC){
+ this.attachedPOC = attachedPOC;
+ //create components
+ txtRunStatus=new TextField();
+ txtRunStatus.setBounds(60,50,100,20);
+ txtRunStatus.setText(Integer.toString(attachedPOC.thisWell.getRunStatus()));
+
+ txtSurfacePosition = new TextField();
+ txtSurfacePosition.setBounds(30,80,100,20);
+
+ txtSurfaceLoad = new TextField();
+ txtSurfaceLoad.setBounds(150,80,100,20);
+
+ txtDownholePosition = new TextField();
+ txtDownholePosition.setBounds(30,110,100,20);
+
+ txtDownholeLoad = new TextField();
+ txtDownholeLoad.setBounds(150,110,100,20);
+
+
+ Button startButton = new Button("START");
+ startButton.setBounds(100,150,80,30);
+
+ Button stopButton = new Button("STOP");
+ stopButton.setBounds(100,200,80,30);
+
+ //register listener
+// startButton.addActionListener(new ActionListener(){
+// public void actionPerformed(ActionEvent e){
+// this.attachedPOC.thisWell.start("guibutton");
+// txtRunStatus.setText(Integer.toString(thisWell.getRunStatus()));
+// }
+// });
+//
+// stopButton.addActionListener(new ActionListener(){
+// public void actionPerformed(ActionEvent e){
+// thisWell.stop("guibutton");
+// txtRunStatus.setText(Integer.toString(thisWell.getRunStatus()));
+// }
+// });
+
+ //add components and set size, layout and visibility
+ add(startButton);
+ add(stopButton);
+ add(txtRunStatus);
+ add(txtSurfacePosition);
+ add(txtSurfaceLoad);
+ add(txtDownholePosition);
+ add(txtDownholeLoad);
+ setSize(300,300);
+ setLayout(null);
+ setVisible(true);
+ }
+};
diff --git a/src/main/java/com/henrypump/poc/Measurement.java b/src/main/java/com/henrypump/poc/Measurement.java
new file mode 100644
index 0000000..09060b6
--- /dev/null
+++ b/src/main/java/com/henrypump/poc/Measurement.java
@@ -0,0 +1,75 @@
+package com.henrypump.poc;
+
+/**
+ * Created by patrickjmcd on 2/3/17.
+ */
+public class Measurement {
+ private double currentValue;
+ private double lastValue;
+ private double average;
+ private double total;
+ private double max;
+ private double min;
+ private double[] totalHistory = new double[30];
+ private double[] averageHistory = new double[30];
+ private long numMeasurements;
+
+ Measurement(){
+ average = 0;
+ total = 0;
+ numMeasurements = 0;
+ max = Double.MIN_VALUE;
+ min = Double.MAX_VALUE;
+ }
+
+ public double getCurrentValue() {
+ return currentValue;
+ }
+
+ public double getLastValue() {
+ return lastValue;
+ }
+
+ public double getAverage() {
+ return average;
+ }
+
+ public double getTotal() {
+ return total;
+ }
+
+ public long getNumMeasurements() {
+ return numMeasurements;
+ }
+
+ public void update(double value)
+ {
+ lastValue = currentValue;
+ currentValue = value;
+
+ numMeasurements = numMeasurements + 1;
+ average = average * (((float)numMeasurements - 1)/(float)numMeasurements) + (currentValue / (float)numMeasurements);
+ total = total + value;
+
+ max = Math.max(max, currentValue);
+ min = Math.min(min, currentValue);
+ };
+
+ public void endOfDay(){
+ for(int i = 28; i >= 0; i--){
+ totalHistory[i] = totalHistory[i+1];
+ averageHistory[i] = averageHistory[i+1];
+ }
+
+ totalHistory[0] = total;
+ averageHistory[0] = average;
+
+ total = 0;
+ average = 0;
+ max = Double.MIN_VALUE;
+ min = Double.MAX_VALUE;
+ }
+
+
+
+}
diff --git a/src/main/java/com/henrypump/poc/POC.java b/src/main/java/com/henrypump/poc/POC.java
index eac529b..683d578 100644
--- a/src/main/java/com/henrypump/poc/POC.java
+++ b/src/main/java/com/henrypump/poc/POC.java
@@ -2,34 +2,80 @@ package com.henrypump.poc;
/**
* Created by patrickjmcd on 2/1/17.
+ * POC Class
+ *
*/
+import java.awt.*;
+import java.awt.event.*;
public class POC implements Runnable{
- private Well thisWell;
+ protected Well thisWell;
private int simLoops;
- private double tubingMovement;
- private double pumpIntakePressure;
- private double fluidLoad;
- private double fluidLevel;
private Thread t;
- private DigitalIn startBtn = new DigitalIn(8);
- private DigitalIn stopBtn = new DigitalIn(9);
- private DigitalOut led2 = new DigitalOut(2, 0);
- private DigitalOut led3 = new DigitalOut(3, 0);
- private DigitalOut led4 = new DigitalOut(4, 0);
- private DigitalOut led5 = new DigitalOut(5, 0);
- private DigitalOut runIndicator = new DigitalOut(6,0);
+ private DigitalIn startBtn, stopBtn;
+ private DigitalOut led2, led3, led4, led5;
+ private DigitalOut runIndicator;
+
+ private boolean ioEnabled;
+ private boolean guiEnabled;
+
POC(String wellName, String wellSetupJsonFile, int simLoops){
- thisWell = new Well(wellName);
+ ioEnabled = true;
+ guiEnabled = false;
+ thisWell = new Well(wellName, 99, 99, 7);
thisWell.parseJSONFile(wellSetupJsonFile);
thisWell.printTapers();
this.simLoops = simLoops;
+
+ // IO
+ startBtn = new DigitalIn(8);
+ stopBtn = new DigitalIn(9);
+ led2 = new DigitalOut(2, 0);
+ led3 = new DigitalOut(3, 0);
+ led4 = new DigitalOut(4, 0);
+ led5 = new DigitalOut(5, 0);
+ runIndicator = new DigitalOut(6,0);
+
+
+ String headlessProp = !guiEnabled ? "true" : "false";
+ System.setProperty("java.awt.headless", headlessProp);
+ System.out.println(java.awt.GraphicsEnvironment.isHeadless());
}
- POC(String wellName, String wellSetupJsonFile, String simFileName, int simLoops){
- thisWell = new Well(wellName, simFileName);
+ POC(String wellName, String wellSetupJsonFile, String simFileName, boolean ioEnabled, int simLoops){
+ this.ioEnabled = ioEnabled;
+ if (this.ioEnabled) {
+ guiEnabled = false;
+ thisWell = new Well(wellName, simFileName,99, 99, 7);
+
+ // IO
+ startBtn = new DigitalIn(8);
+ stopBtn = new DigitalIn(9);
+ led2 = new DigitalOut(2, 0);
+ led3 = new DigitalOut(3, 0);
+ led4 = new DigitalOut(4, 0);
+ led5 = new DigitalOut(5, 0);
+ runIndicator = new DigitalOut(6,0);
+
+ } else {
+ thisWell = new Well(wellName, simFileName,99, 99, 99);
+ guiEnabled = true;
+ // IO
+ startBtn = new DigitalIn(99);
+ stopBtn = new DigitalIn(99);
+ led2 = new DigitalOut(99, 0);
+ led3 = new DigitalOut(99, 0);
+ led4 = new DigitalOut(99, 0);
+ led5 = new DigitalOut(99, 0);
+ runIndicator = new DigitalOut(99,0);
+ }
+
+ String headlessProp = !guiEnabled ? "true" : "false";
+ System.setProperty("java.awt.headless", headlessProp);
+ System.out.println(java.awt.GraphicsEnvironment.isHeadless());
+
thisWell.parseJSONFile(wellSetupJsonFile);
thisWell.printTapers();
this.simLoops = simLoops;
@@ -46,7 +92,7 @@ public class POC implements Runnable{
int loopCounter = 0, loopLimit = simLoops, led2out, led3out, led4out,led5out;
double pos;
long sleepMilliseconds = (long) (thisWell.getDt() * 1000);
-
+ thisWell.setupFluidRatio(0.25, 0.75, 1.12);
thisWell.checkSafeties();
while (true) {
while (loopCounter < loopLimit && (thisWell.getRunStatus() == Well.RUNSTATUS_RUNNING || thisWell.getRunStatus() == Well.RUNSTATUS_STARTING)) {
@@ -60,8 +106,7 @@ public class POC implements Runnable{
thisWell.eval(i);
- pos = thisWell.getCurrentPosition();
-
+ pos = thisWell.getCurrentSurfacePosition();
led2.write(pos > 20.0 ? 1 : 0);
led3.write(pos > 40.0 ? 1 : 0);
led4.write(pos > 60.0 ? 1 : 0);
@@ -77,7 +122,8 @@ public class POC implements Runnable{
}
loopCounter++;
}
-
+
+
if (startBtn.read() == 1) thisWell.start("startbutton");
if (stopBtn.read() == 1) thisWell.stop("stopbutton");
if (startBtn.read() == 1 && stopBtn.read() == 1) {
@@ -101,9 +147,11 @@ public class POC implements Runnable{
public static void main(String[] args) {
- final POC thisPOC = new POC("Barney", args[0], args[1], 100);
+ final POC thisPOC = new POC("Barney", args[0], args[1], true, 100);
thisPOC.start();
}
}
+
+
diff --git a/src/main/java/com/henrypump/poc/Well.java b/src/main/java/com/henrypump/poc/Well.java
index 0335a70..14e5779 100644
--- a/src/main/java/com/henrypump/poc/Well.java
+++ b/src/main/java/com/henrypump/poc/Well.java
@@ -28,11 +28,13 @@ public class Well {
protected Database db;
// IO
- AnalogIn inclinometer = new AnalogIn(99, 0, 100, 0, 100);
- AnalogIn loadCell = new AnalogIn(99, 0, 50000, 0, 50000);
- DigitalOut runCommand = new DigitalOut(7, 0);
- private double currentPosition;
- private double currentLoad;
+ AnalogIn inclinometer;
+ AnalogIn loadCell;
+ DigitalOut runCommand;
+ private double currentSurfacePosition;
+ private double currentSurfaceLoad;
+ private double currentDownholePosition;
+ private double currentDownholeLoad;
// CARDS
private Card currentCard;
@@ -131,19 +133,50 @@ public class Well {
private int[] count = new int[11];
private double sPositionPrevious;
- Well(String wellName){
+ // Fluid Makeup
+ private double fluidOilRatio; // BBL of oil per 1 BBL fluid
+ private double fluidWaterRatio; // BBL of water per 1 BBL fluid
+ private double fluidGasRatio; // MCF of gas per 1 BBL fluid
+
+ // Measurements
+ private Measurement strokeSpeed = new Measurement();
+ private Measurement downholeGrossStroke = new Measurement();
+ private Measurement downholeNetStroke = new Measurement();
+ private Measurement fluidLevel = new Measurement();
+ private Measurement fluidLoad = new Measurement();
+ private Measurement inflowRate = new Measurement();
+ private Measurement peakPolishedRodLoad = new Measurement();
+ private Measurement minPolishedRodLoad = new Measurement();
+ private Measurement percentRun = new Measurement();
+ private Measurement polishedRodHP = new Measurement();
+ private Measurement pumpHP = new Measurement();
+ private Measurement fluidProduced = new Measurement();
+ private Measurement oilProduced = new Measurement();
+ private Measurement waterProduced = new Measurement();
+ private Measurement gasProduced = new Measurement();
+ private Measurement pumpIntakePressure = new Measurement();
+ private Measurement surfaceStrokeLength = new Measurement();
+ private Measurement tubingMovement = new Measurement();
+
+ Well(String wellName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
this.wellName = wellName;
db = new Database();
strokesLifetime = db.getLastStrokeNum() + 1;
currentCard = new Card(strokesLifetime);
+ inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100);
+ loadCell = new AnalogIn(loadCellChannel, 0, 50000, 0, 50000);
+ runCommand = new DigitalOut(runCommandChannel, 0);
}
- Well(String wellName, String simFileName){
+ Well(String wellName, String simFileName, int inclinometerChannel, int loadCellChannel, int runCommandChannel){
this.wellName = wellName;
sim = new Simulation(simFileName);
db = new Database();
strokesLifetime = db.getLastStrokeNum() + 1;
currentCard = new Card(strokesLifetime);
+ inclinometer = new AnalogIn(inclinometerChannel, 0, 100, 0, 100);
+ loadCell = new AnalogIn(loadCellChannel, 0, 50000, 0, 50000);
+ runCommand = new DigitalOut(runCommandChannel, 0);
}
public double getDt() {
@@ -297,12 +330,20 @@ public class Well {
return runMode;
}
- public double getCurrentPosition() {
- return currentPosition;
+ public double getCurrentSurfacePosition() {
+ return currentSurfacePosition;
}
- public double getCurrentLoad() {
- return currentLoad;
+ public double getCurrentSurfaceLoad() {
+ return currentSurfaceLoad;
+ }
+
+ public double getCurrentDownholePosition() {
+ return currentDownholePosition;
+ }
+
+ public double getCurrentDownholeLoad() {
+ return currentDownholeLoad;
}
public long getStartupStrokes() {
@@ -329,6 +370,12 @@ public class Well {
return direction;
}
+ public void setupFluidRatio(double oilRatio, double waterRatio, double gasRatio){
+ fluidOilRatio = oilRatio;
+ fluidWaterRatio = waterRatio;
+ fluidGasRatio = gasRatio;
+ }
+
// WELL COMMAND FUNCTIONS
public void start(String initiator){
if (runStatus == RUNSTATUS_STOPPED && permissiveOK){
@@ -707,7 +754,7 @@ public class Well {
{
topLoadArray[1][lengthRequired[1]] = loadMult * (sLoad - rodWeightFluidTotal) + sbfriction;
}
-
+ sPositionPrevious = sPosition;
int j = 1;
while (j <= tapersAllowed)
{
@@ -752,13 +799,13 @@ public class Well {
public void eval(){
checkSafeties();
- currentPosition = inclinometer.readScaled();
- currentLoad = loadCell.readScaled();
- LPStatus lastPoint = calc(currentPosition, currentLoad);
+ currentSurfacePosition = inclinometer.readScaled();
+ currentSurfaceLoad = loadCell.readScaled();
+ LPStatus lastPoint = calc(currentSurfacePosition, currentSurfaceLoad);
if(runStatus == RUNSTATUS_STARTING || runStatus == RUNSTATUS_RUNNING) {
if (lastPoint.getStatus() == GOOD_STATUS) {
- currentCard.setSurfacePosition(pointCounter, currentPosition);
- currentCard.setSurfaceLoad(pointCounter, currentLoad);
+ currentCard.setSurfacePosition(pointCounter, currentSurfacePosition);
+ currentCard.setSurfaceLoad(pointCounter, currentSurfaceLoad);
currentCard.setDownholePosition(pointCounter, lastPoint.getPosition());
currentCard.setDownholeLoad(pointCounter, lastPoint.getLoad());
}
@@ -773,7 +820,7 @@ public class Well {
currentCard.calcStrokeData(150, fluidGradient,
rodDepthTotal, tubingAnchorDepth,
tubingCrossSectionalArea, pumpArea,
- frictionEstimate, structuralRating);
+ frictionEstimate, structuralRating, fluidWaterRatio, fluidOilRatio, fluidGasRatio);
for (int j = 98; j >= 0; j--) {
cardStorage[j + 1] = cardStorage[j];
}
@@ -794,17 +841,64 @@ public class Well {
}
}
+ public void endOfStroke(){
+ currentCard.setNumPointsUsed(pointCounter + 1);
+ currentCard.calcStrokeData(150, fluidGradient,
+ rodDepthTotal, tubingAnchorDepth,
+ tubingCrossSectionalArea, pumpArea,
+ frictionEstimate, structuralRating, fluidWaterRatio, fluidOilRatio, fluidGasRatio);
+ for (int j = 98; j >= 0; j--) {
+ cardStorage[j + 1] = cardStorage[j];
+ }
+ cardStorage[0] = currentCard;
+ currentCard.printCard("none", true);
+ strokesSinceStart++;
+ strokesToday++;
+ strokesLifetime++;
+
+ strokeSpeed.update(currentCard.getStrokeSpeed());
+ downholeGrossStroke.update(currentCard.getDownholeGrossStrokeLength());
+ downholeNetStroke.update(currentCard.getDownholeNetStrokeLength());
+ fluidLevel.update(currentCard.getFluidLevel());
+ fluidLoad.update(currentCard.getFluidLoad());
+ peakPolishedRodLoad.update(currentCard.getSurfaceLoadMax().getLoad());
+ minPolishedRodLoad.update(currentCard.getSurfaceLoadMin().getLoad());
+ polishedRodHP.update(currentCard.getPolishedRodHorsepower());
+ pumpHP.update(currentCard.getPumpHorsepower());
+ fluidProduced.update(currentCard.getFluidBBLMoved());
+ oilProduced.update(currentCard.getOilBBLMoved());
+ waterProduced.update(currentCard.getWaterBBLMoved());
+ gasProduced.update(currentCard.getGasMCFMoved());
+ pumpIntakePressure.update(currentCard.getPumpIntakePressure());
+ surfaceStrokeLength.update(currentCard.getSurfaceStrokeLength());
+ tubingMovement.update(currentCard.getTubingMovement());
+
+ printTotals();
+
+ currentCard = new Card(strokesLifetime);
+ pointCounter = -1;
+ if (strokesSinceStart > startupStrokes){
+ runStatus = RUNSTATUS_RUNNING;
+ }
+
+ }
+
public void eval(int simPoint){
checkSafeties();
- currentPosition = inclinometer.readScaledSim(sim.getPositionAtIndex(simPoint));
- currentLoad = loadCell.readScaledSim(sim.getLoadAtIndex(simPoint));
- LPStatus lastPoint = calc(currentPosition, currentLoad);
+ currentSurfacePosition = inclinometer.readScaledSim(sim.getPositionAtIndex(simPoint));
+ currentSurfaceLoad = loadCell.readScaledSim(sim.getLoadAtIndex(simPoint));
+
+ LPStatus lastPoint = calc(currentSurfacePosition, currentSurfaceLoad);
+ if (lastPoint.getStatus() == GOOD_STATUS){
+ currentDownholePosition = lastPoint.getPosition();
+ currentDownholeLoad = lastPoint.getLoad();
+ }
if(runStatus == RUNSTATUS_STARTING || runStatus == RUNSTATUS_RUNNING) {
if (lastPoint.getStatus() == GOOD_STATUS) {
- currentCard.setSurfacePosition(pointCounter, currentPosition);
- currentCard.setSurfaceLoad(pointCounter, currentLoad);
- currentCard.setDownholePosition(pointCounter, lastPoint.getPosition());
- currentCard.setDownholeLoad(pointCounter, lastPoint.getLoad());
+ currentCard.setSurfacePosition(pointCounter, currentSurfacePosition);
+ currentCard.setSurfaceLoad(pointCounter, currentSurfaceLoad);
+ currentCard.setDownholePosition(pointCounter, currentDownholePosition);
+ currentCard.setDownholeLoad(pointCounter, currentDownholeLoad);
}
if (inclinometer.getHistory(0) > inclinometer.getHistory(1))
@@ -813,25 +907,7 @@ public class Well {
direction = DIRECTION_DOWN;
if (direction == DIRECTION_UP && lastDirection == DIRECTION_DOWN && pointCounter > 0) {
- currentCard.setNumPointsUsed(pointCounter + 1);
- currentCard.calcStrokeData(150, fluidGradient,
- rodDepthTotal, tubingAnchorDepth,
- tubingCrossSectionalArea, pumpArea,
- frictionEstimate, structuralRating);
- for (int j = 98; j >= 0; j--) {
- cardStorage[j + 1] = cardStorage[j];
- }
- cardStorage[0] = currentCard;
- currentCard.printCard("none", true);
- System.out.println("Cards in DB: " + db.newCard(currentCard));
- strokesSinceStart++;
- strokesToday++;
- strokesLifetime++;
- currentCard = new Card(strokesLifetime);
- pointCounter = -1;
- if (strokesSinceStart > startupStrokes){
- runStatus = RUNSTATUS_RUNNING;
- }
+ endOfStroke();
}
lastDirection = direction;
pointCounter++;
@@ -843,15 +919,44 @@ public class Well {
runCommand.write(0);
}
}
+ public void printTotals(){
+
+ V2_AsciiTable taperTable = new V2_AsciiTable();
+ taperTable.addRule();
+ taperTable.addRow("Measuremnt", "Average", "Total");
+ taperTable.addStrongRule();
+ taperTable.addRow("Stroke Speed", strokeSpeed.getAverage(), strokeSpeed.getTotal());
+ taperTable.addRow("DH Gross Stroke", downholeGrossStroke.getAverage(), downholeGrossStroke.getTotal());
+ taperTable.addRow("DH Net Stroke", downholeNetStroke.getAverage(), downholeNetStroke.getTotal());
+ taperTable.addRow("Fluid Level", fluidLevel.getAverage(), fluidLevel.getTotal());
+ taperTable.addRow("Fluid Load", fluidLoad.getAverage(), fluidLoad.getTotal());
+ taperTable.addRow("Peak PR Load", peakPolishedRodLoad.getAverage(), peakPolishedRodLoad.getTotal());
+ taperTable.addRow("Min PR Load", minPolishedRodLoad.getAverage(), minPolishedRodLoad.getTotal());
+ taperTable.addRow("PR HP", polishedRodHP.getAverage(), polishedRodHP.getTotal());
+ taperTable.addRow("Pump HP", pumpHP.getAverage(), pumpHP.getTotal());
+ taperTable.addRow("Fluid Produced", fluidProduced.getAverage(), fluidProduced.getTotal());
+ taperTable.addRow("Oil Produced", oilProduced.getAverage(), oilProduced.getTotal());
+ taperTable.addRow("Water Produced", waterProduced.getAverage(), waterProduced.getTotal());
+ taperTable.addRow("Gas Produced", gasProduced.getAverage(), gasProduced.getTotal());
+ taperTable.addRow("Pump Intake Pressure", pumpIntakePressure.getAverage(), pumpIntakePressure.getTotal());
+ taperTable.addRow("Surf Stroke Length", surfaceStrokeLength.getAverage(), surfaceStrokeLength.getTotal());
+ taperTable.addRow("Tubing Movement", tubingMovement.getAverage(), tubingMovement.getTotal());
+ taperTable.addRule();
+ V2_AsciiTableRenderer rend = new V2_AsciiTableRenderer();
+ rend.setTheme(V2_E_TableThemes.UTF_LIGHT.get());
+ rend.setWidth(new WidthAbsoluteEven(100));
+ RenderedTable rt = rend.render(taperTable);
+ System.out.println(rt);
+ System.out.println();
+ }
public void allOutputsOff(){
runCommand.write(0, true);
}
public static void main( String[] args ){
- Well thisWell = new Well("Barney");
+ Well thisWell = new Well("Barney", args[1], 99, 99, 99);
thisWell.parseJSONFile(args[0]);
- // thisWell.parseJSONFile("/Users/patrickjmcd/Henry_Pump/poc-java/wellSetup.json");
thisWell.printTapers();
}
diff --git a/target/classes/com/henrypump/poc/AnalogIn.class b/target/classes/com/henrypump/poc/AnalogIn.class
index d898522..2cd9263 100644
Binary files a/target/classes/com/henrypump/poc/AnalogIn.class and b/target/classes/com/henrypump/poc/AnalogIn.class differ
diff --git a/target/classes/com/henrypump/poc/Card.class b/target/classes/com/henrypump/poc/Card.class
index 14a21ca..2427407 100644
Binary files a/target/classes/com/henrypump/poc/Card.class and b/target/classes/com/henrypump/poc/Card.class differ
diff --git a/target/classes/com/henrypump/poc/Database.class b/target/classes/com/henrypump/poc/Database.class
index e2d301f..37bc482 100644
Binary files a/target/classes/com/henrypump/poc/Database.class and b/target/classes/com/henrypump/poc/Database.class differ
diff --git a/target/classes/com/henrypump/poc/DigitalIn.class b/target/classes/com/henrypump/poc/DigitalIn.class
index ad6c7bb..4eb85bf 100644
Binary files a/target/classes/com/henrypump/poc/DigitalIn.class and b/target/classes/com/henrypump/poc/DigitalIn.class differ
diff --git a/target/classes/com/henrypump/poc/DigitalOut.class b/target/classes/com/henrypump/poc/DigitalOut.class
index 90ecc83..d4325e0 100644
Binary files a/target/classes/com/henrypump/poc/DigitalOut.class and b/target/classes/com/henrypump/poc/DigitalOut.class differ
diff --git a/target/classes/com/henrypump/poc/GUI.class b/target/classes/com/henrypump/poc/GUI.class
new file mode 100644
index 0000000..00db113
Binary files /dev/null and b/target/classes/com/henrypump/poc/GUI.class differ
diff --git a/target/classes/com/henrypump/poc/Measurement.class b/target/classes/com/henrypump/poc/Measurement.class
new file mode 100644
index 0000000..798f1cb
Binary files /dev/null and b/target/classes/com/henrypump/poc/Measurement.class differ
diff --git a/target/classes/com/henrypump/poc/POC.class b/target/classes/com/henrypump/poc/POC.class
index 810dfdf..33d1c43 100644
Binary files a/target/classes/com/henrypump/poc/POC.class and b/target/classes/com/henrypump/poc/POC.class differ
diff --git a/target/classes/com/henrypump/poc/Well.class b/target/classes/com/henrypump/poc/Well.class
index ae66638..8b517ff 100644
Binary files a/target/classes/com/henrypump/poc/Well.class and b/target/classes/com/henrypump/poc/Well.class differ
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
index c167f71..971c92a 100644
--- a/target/maven-archiver/pom.properties
+++ b/target/maven-archiver/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven
-#Thu Feb 02 18:00:05 CST 2017
+#Fri Feb 03 16:32:08 CST 2017
version=1.0-SNAPSHOT
groupId=com.henrypump.poc
artifactId=poc-java
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
index 826d4bb..4e61eec 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -1,11 +1,13 @@
com/henrypump/poc/LPPair.class
+com/henrypump/poc/Simulation.class
+com/henrypump/poc/Well.class
+com/henrypump/poc/Database.class
+com/henrypump/poc/Measurement.class
com/henrypump/poc/AnalogIn.class
com/henrypump/poc/Card.class
-com/henrypump/poc/Simulation.class
com/henrypump/poc/DigitalIn.class
com/henrypump/poc/POC.class
com/henrypump/poc/App.class
-com/henrypump/poc/Well.class
-com/henrypump/poc/Database.class
com/henrypump/poc/LPStatus.class
com/henrypump/poc/DigitalOut.class
+com/henrypump/poc/GUI.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
index fb01cbf..4f1447a 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -1,11 +1,13 @@
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/Well.java
+/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/Card.java
+/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/Measurement.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/Simulation.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/LPStatus.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/AnalogIn.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/LPPair.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/App.java
-/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/Card.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/POC.java
+/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/GUI.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/Database.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/DigitalOut.java
/Users/patrickjmcd/Henry_Pump/poc-java/src/main/java/com/henrypump/poc/DigitalIn.java
diff --git a/target/original-poc-java-1.0-SNAPSHOT.jar b/target/original-poc-java-1.0-SNAPSHOT.jar
index 47bf08b..3dc754b 100644
Binary files a/target/original-poc-java-1.0-SNAPSHOT.jar and b/target/original-poc-java-1.0-SNAPSHOT.jar differ
diff --git a/target/poc-java-1.0-SNAPSHOT.jar b/target/poc-java-1.0-SNAPSHOT.jar
index e856cf1..3dc754b 100644
Binary files a/target/poc-java-1.0-SNAPSHOT.jar and b/target/poc-java-1.0-SNAPSHOT.jar differ
diff --git a/target/surefire-reports/TEST-com.henrypump.poc.AppTest.xml b/target/surefire-reports/TEST-com.henrypump.poc.AppTest.xml
index be250c8..f97f1b7 100644
--- a/target/surefire-reports/TEST-com.henrypump.poc.AppTest.xml
+++ b/target/surefire-reports/TEST-com.henrypump.poc.AppTest.xml
@@ -1,5 +1,5 @@
-
+
@@ -62,5 +62,5 @@
-
+
\ No newline at end of file
diff --git a/target/surefire-reports/com.henrypump.poc.AppTest.txt b/target/surefire-reports/com.henrypump.poc.AppTest.txt
index ca190c6..889eba0 100644
--- a/target/surefire-reports/com.henrypump.poc.AppTest.txt
+++ b/target/surefire-reports/com.henrypump.poc.AppTest.txt
@@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: com.henrypump.poc.AppTest
-------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec