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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class Card {
|
||||
private double polishedRodHorsepower;
|
||||
private double pumpHorsepower;
|
||||
private double fluidBBLMoved;
|
||||
private double fluidBBLMovedAdjusted;
|
||||
private double waterBBLMoved;
|
||||
private double oilBBLMoved;
|
||||
private double gasMCFMoved;
|
||||
@@ -184,6 +185,11 @@ public class Card {
|
||||
return fluidBBLMoved;
|
||||
}
|
||||
|
||||
|
||||
public double getFluidBBLMovedAdjusted() {
|
||||
return fluidBBLMovedAdjusted;
|
||||
}
|
||||
|
||||
public double getWaterBBLMoved() {
|
||||
return waterBBLMoved;
|
||||
}
|
||||
@@ -350,7 +356,8 @@ public class Card {
|
||||
downholeNetStrokeLength = bottomCorner.getPosition() - downholePositionMin.getPosition();
|
||||
fillageCalculated = (downholeNetStrokeLength / downholeAdjustedGrossStrokeLength) * 100.0;
|
||||
fillageEstimated =(downholeNetStrokeLength / downholeGrossStrokeLength) * 100.0;
|
||||
fluidBBLMoved = downholeNetStrokeLength * pumpArea * 0.00010307 * kFactor;
|
||||
fluidBBLMoved = downholeNetStrokeLength * pumpArea * 0.00010307;
|
||||
fluidBBLMovedAdjusted = fluidBBLMoved * kFactor;
|
||||
oilBBLMoved = fluidBBLMoved * oilBBLRatio;
|
||||
waterBBLMoved = fluidBBLMoved * waterBBLRatio;
|
||||
gasMCFMoved = fluidBBLMoved * gasMCFRatio;
|
||||
|
||||
@@ -12,18 +12,12 @@ import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.model.Sorts;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.mongodb.client.MongoCursor;
|
||||
|
||||
import static com.mongodb.client.model.Aggregates.limit;
|
||||
import static com.mongodb.client.model.Filters.*;
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import static com.mongodb.client.model.Updates.*;
|
||||
import com.mongodb.client.result.UpdateResult;
|
||||
|
||||
import javax.print.Doc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -76,6 +70,7 @@ public class Database {
|
||||
.append("downhole_position", d_p)
|
||||
.append("downhole_load", d_l);
|
||||
collection.insertOne(doc);
|
||||
System.out.println("Stored stroke number " + inpCard.getStrokeNumber() + " as " + doc.getObjectId("_id"));
|
||||
return collection.count();
|
||||
}
|
||||
public void close(){
|
||||
@@ -83,7 +78,7 @@ public class Database {
|
||||
}
|
||||
|
||||
public long newMeasurement(Measurement inpMeasurement){
|
||||
String df = Date.from(Instant.now()).toString();
|
||||
String df = ZonedDateTime.now().toString();
|
||||
MongoCollection<Document> collection = database.getCollection("wellData");
|
||||
Document doc = new Document("tagname", inpMeasurement.getTagName())
|
||||
.append("currentValue", inpMeasurement.getCurrentValue())
|
||||
@@ -91,13 +86,29 @@ public class Database {
|
||||
.append("minDailyValue", inpMeasurement.getDailyMin())
|
||||
.append("dailyAverage", inpMeasurement.getAverage())
|
||||
.append("dailyTotal", inpMeasurement.getTotal())
|
||||
.append("numMeasurements", inpMeasurement.getNumMeasurements())
|
||||
.append("timestamp", df);
|
||||
collection.insertOne(doc);
|
||||
System.out.println("Stored " + inpMeasurement.getCurrentValue() + " for " + inpMeasurement.getTagName());
|
||||
return collection.count();
|
||||
}
|
||||
|
||||
public Document getLastStoredMeasurement(String tagName){
|
||||
MongoCollection<Document> collection = database.getCollection("wellData");
|
||||
MongoCursor<Document> cursor = collection.find(eq("tagname", tagName)).sort(Sorts.descending("timestamp")).limit(1).iterator();
|
||||
Document lastStoredDoc = new Document();
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
lastStoredDoc = cursor.next();
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
return lastStoredDoc;
|
||||
}
|
||||
|
||||
public long newDailyTotal(Measurement inpMeasurement){
|
||||
String df = Date.from(Instant.now()).toString();
|
||||
String df = ZonedDateTime.now().toString();
|
||||
MongoCollection<Document> collection = database.getCollection("gaugeOffData");
|
||||
Document doc = new Document("tagname", inpMeasurement.getTagName())
|
||||
.append("currentValue", inpMeasurement.getCurrentValue())
|
||||
@@ -111,7 +122,7 @@ public class Database {
|
||||
|
||||
}
|
||||
|
||||
public double getPreviousDailyTotal(Date inpDateTime){
|
||||
public double getPreviousDailyTotal(ZonedDateTime inpDateTime){
|
||||
String isoInpDateTime = inpDateTime.toString();
|
||||
MongoCollection<Document> wellTestCollection = database.getCollection("gaugeOffData");
|
||||
MongoCursor<Document> cursor = wellTestCollection.find(and(eq("tagname", "Fluid Produced"), lte("timestamp", isoInpDateTime)))
|
||||
@@ -128,7 +139,7 @@ public class Database {
|
||||
};
|
||||
|
||||
public long newWellTest(WellTest inp){
|
||||
String df = Date.from(Instant.now()).toString();
|
||||
String df = ZonedDateTime.now().toString();
|
||||
MongoCollection<Document> collection = database.getCollection("wellTestData");
|
||||
Document doc = new Document("testStartTime", df)
|
||||
.append("testHours", inp.getTestHours())
|
||||
@@ -144,7 +155,7 @@ public class Database {
|
||||
return collection.count();
|
||||
}
|
||||
|
||||
public Document getPreviousWellTest(Date inpDateTime){
|
||||
public Document getPreviousWellTest(ZonedDateTime inpDateTime){
|
||||
String isoInpDateTime = inpDateTime.toString();
|
||||
MongoCollection<Document> wellTestCollection = database.getCollection("wellTestData");
|
||||
MongoCursor<Document> cursor = wellTestCollection.find(lte("testStartTime", isoInpDateTime))
|
||||
|
||||
@@ -49,6 +49,10 @@ public class DigitalOut {
|
||||
}
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
try {
|
||||
DigitalOut testOut2 = new DigitalOut(2, 0);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
/**
|
||||
@@ -37,6 +41,26 @@ public class Measurement {
|
||||
this.sendDelta = sendDelta;
|
||||
this.lastSentValue = 0.0;
|
||||
this.sendTimeDelta = sendTimeDelta;
|
||||
|
||||
Document lastStored = this.db.getLastStoredMeasurement(this.tagName);
|
||||
try {
|
||||
ZonedDateTime timestamp = ZonedDateTime.parse((CharSequence) lastStored.get("timestamp"));
|
||||
if (isToday(timestamp)){
|
||||
this.average = lastStored.getDouble("dailyAverage");
|
||||
this.total = lastStored.getDouble("dailyTotal");
|
||||
this.lastSentValue = lastStored.getDouble("currentValue");
|
||||
this.dailyMax = lastStored.getDouble("maxDailyValue");
|
||||
this.dailyMin = lastStored.getDouble("minDailyValue");
|
||||
this.lastSentTimestamp = timestamp.toEpochSecond();
|
||||
this.numMeasurements = lastStored.getLong("numMeasurements");
|
||||
System.out.println("Using stored value from " + timestamp.toString() + " for " + this.tagName);
|
||||
} else {
|
||||
System.out.println("Cannot use stored value from " + timestamp.toString() + " for " + this.tagName);
|
||||
}
|
||||
} catch (NullPointerException e){
|
||||
System.out.println("There was no previous measurement in the database for " + this.tagName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Measurement(String tagName, boolean storeInDatabase){
|
||||
@@ -83,9 +107,17 @@ public class Measurement {
|
||||
return dailyMin;
|
||||
}
|
||||
|
||||
public static boolean isToday(ZonedDateTime inpZDT){
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
if (now.toLocalDate().equals(inpZDT.toLocalDate())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
public void update(double value)
|
||||
{
|
||||
long currentTimestamp = System.currentTimeMillis();
|
||||
long currentTimestamp = ZonedDateTime.now().toEpochSecond();
|
||||
lastValue = currentValue;
|
||||
currentValue = value;
|
||||
|
||||
@@ -101,6 +133,7 @@ public class Measurement {
|
||||
currentTimestamp - lastSentTimestamp > (sendTimeDelta * 1000)){
|
||||
long l = db.newMeasurement(this);
|
||||
lastSentValue = currentValue;
|
||||
lastSentTimestamp = currentTimestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 2/1/17.
|
||||
* POC Class
|
||||
*
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
|
||||
public class POC implements Runnable{
|
||||
protected Well thisWell;
|
||||
@@ -19,16 +17,12 @@ public class POC implements Runnable{
|
||||
private DigitalOut runIndicator;
|
||||
|
||||
private boolean ioEnabled;
|
||||
private boolean guiEnabled;
|
||||
|
||||
|
||||
|
||||
POC(String wellName, String wellSetupJsonFile, int simLoops){
|
||||
ioEnabled = true;
|
||||
guiEnabled = false;
|
||||
thisWell = new Well(wellName, 99, 99, 7);
|
||||
thisWell.parseJSONFile(wellSetupJsonFile);
|
||||
thisWell.printTapers();
|
||||
// thisWell.printTapers();
|
||||
this.simLoops = simLoops;
|
||||
|
||||
// IO
|
||||
@@ -40,16 +34,11 @@ public class POC implements Runnable{
|
||||
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, boolean ioEnabled, int simLoops){
|
||||
this.ioEnabled = ioEnabled;
|
||||
if (this.ioEnabled) {
|
||||
guiEnabled = false;
|
||||
thisWell = new Well(wellName, simFileName,99, 99, 7);
|
||||
|
||||
// IO
|
||||
@@ -63,7 +52,6 @@ public class POC implements Runnable{
|
||||
|
||||
} else {
|
||||
thisWell = new Well(wellName, simFileName,99, 99, 99);
|
||||
guiEnabled = true;
|
||||
// IO
|
||||
startBtn = new DigitalIn(99);
|
||||
stopBtn = new DigitalIn(99);
|
||||
@@ -74,12 +62,8 @@ public class POC implements Runnable{
|
||||
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();
|
||||
// thisWell.printTapers();
|
||||
this.simLoops = simLoops;
|
||||
}
|
||||
|
||||
@@ -91,14 +75,14 @@ public class POC implements Runnable{
|
||||
}
|
||||
|
||||
public void run(){
|
||||
int loopCounter = 0, loopLimit = simLoops, led2out, led3out, led4out,led5out;
|
||||
new Thread(new CLScanner(this)).start();
|
||||
int led2out, led3out, led4out,led5out;
|
||||
double pos;
|
||||
boolean newWellTest = true;
|
||||
long sleepMilliseconds = (long) (thisWell.getDt() * 1000);
|
||||
thisWell.setupFluidRatio(0.50, 0.50, 1.12);
|
||||
thisWell.checkSafeties();
|
||||
while (true) {
|
||||
while (loopCounter < loopLimit && (thisWell.getRunStatus() == Well.RUNSTATUS_RUNNING || thisWell.getRunStatus() == Well.RUNSTATUS_STARTING)) {
|
||||
while (thisWell.getRunStatus() == Well.RUNSTATUS_RUNNING || thisWell.getRunStatus() == Well.RUNSTATUS_STARTING) {
|
||||
for (int i = 0; i <= thisWell.sim.getLastFilledIndex(); i++) {
|
||||
if (startBtn.read() == 1) thisWell.start("startbutton");
|
||||
if (stopBtn.read() == 1) thisWell.stop("stopbutton");
|
||||
@@ -123,22 +107,6 @@ public class POC implements Runnable{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
loopCounter++;
|
||||
}
|
||||
|
||||
if (newWellTest){
|
||||
System.out.println("Previous kFactor = " + thisWell.db.getLatestKFactor());
|
||||
Date nowDate = Date.from(Instant.now());
|
||||
double lastProductionMeasured = thisWell.db.getPreviousDailyTotal(nowDate);
|
||||
thisWell.wellTest = new WellTest(nowDate, 24.0, .35, .20, .15, 1.25, lastProductionMeasured);
|
||||
thisWell.db.newWellTest(thisWell.wellTest);
|
||||
System.out.println("Well Test @ " + nowDate.toString());
|
||||
System.out.println("kFactor: " + thisWell.wellTest.getkFactor());
|
||||
System.out.println("oilRatio: " + thisWell.wellTest.getOilRatio());
|
||||
System.out.println("waterRatio: " + thisWell.wellTest.getWaterRatio());
|
||||
System.out.println("gasRatio: " + thisWell.wellTest.getGasMCFRatio());
|
||||
newWellTest = false;
|
||||
System.out.println("Last kFactor = " + thisWell.db.getLatestKFactor());
|
||||
}
|
||||
|
||||
|
||||
@@ -165,11 +133,11 @@ public class POC implements Runnable{
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
final POC thisPOC = new POC("Barney", args[0], args[1], true, 100);
|
||||
final POC thisPOC = new POC("Barney", args[0], args[1], args[2].equals("true"), 100);
|
||||
thisPOC.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Created by patrickjmcd on 1/31/17.
|
||||
@@ -96,7 +97,7 @@ public class Well {
|
||||
private double tubingCrossSectionalArea;
|
||||
|
||||
// Statuses
|
||||
private int runStatus;
|
||||
private volatile int runStatus;
|
||||
public static final int RUNSTATUS_STOPPED = 0;
|
||||
public static final int RUNSTATUS_STARTING = 1;
|
||||
public static final int RUNSTATUS_RUNNING = 2;
|
||||
@@ -119,7 +120,7 @@ public class Well {
|
||||
private int lastDirection = DIRECTION_UNKNOWN;
|
||||
|
||||
// Modes
|
||||
private int runMode;
|
||||
private volatile int runMode;
|
||||
public static final int RUNMODE_POC = 0;
|
||||
public static final int RUNMODE_MANUAL = 1;
|
||||
public static final int RUNMODE_TIMER = 2;
|
||||
@@ -142,12 +143,13 @@ public class Well {
|
||||
private double kFactor = 1.0;
|
||||
|
||||
// DATE & TIME PARAMETERS
|
||||
private LocalDate lastCheckedDate = null;
|
||||
private ZonedDateTime now = ZonedDateTime.now();
|
||||
|
||||
private boolean isNewDay(){
|
||||
LocalDate today = LocalDate.now();
|
||||
boolean ret = lastCheckedDate == null || today.isAfter(lastCheckedDate);
|
||||
lastCheckedDate = today;
|
||||
|
||||
ZonedDateTime today = ZonedDateTime.now();
|
||||
boolean ret = !(today.toLocalDate().equals(now.toLocalDate()));
|
||||
now = today;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -164,6 +166,7 @@ public class Well {
|
||||
private Measurement polishedRodHP;
|
||||
private Measurement pumpHP;
|
||||
private Measurement fluidProduced;
|
||||
private Measurement fluidProducedAdjusted;
|
||||
private Measurement oilProduced;
|
||||
private Measurement waterProduced;
|
||||
private Measurement gasProduced;
|
||||
@@ -192,6 +195,7 @@ public class Well {
|
||||
polishedRodHP = new Measurement("Polished Rod HP", true, db, 0.25, 600);
|
||||
pumpHP = new Measurement("Pump HP", true, db, 0.25, 600);
|
||||
fluidProduced = new Measurement("Fluid Produced", true, db, 1.0, 600);
|
||||
fluidProducedAdjusted = new Measurement("Fluid Produced (adjusted)", true, db, 1.0, 600);
|
||||
oilProduced = new Measurement("Oil Produced", true, db, 1.0, 600);
|
||||
waterProduced = new Measurement("Water Produced", true, db, 1.0, 600);
|
||||
gasProduced = new Measurement("Gas Produced", true, db, 1.0, 600);
|
||||
@@ -222,6 +226,7 @@ public class Well {
|
||||
polishedRodHP = new Measurement("Polished Rod HP", true, db, 0.25, 600);
|
||||
pumpHP = new Measurement("Pump HP", true, db, 0.25, 600);
|
||||
fluidProduced = new Measurement("Fluid Produced", true, db, 1.0, 600);
|
||||
fluidProducedAdjusted = new Measurement("Fluid Produced (adjusted)", true, db, 1.0, 600);
|
||||
oilProduced = new Measurement("Oil Produced", true, db, 1.0, 600);
|
||||
waterProduced = new Measurement("Water Produced", true, db, 1.0, 600);
|
||||
gasProduced = new Measurement("Gas Produced", true, db, 1.0, 600);
|
||||
@@ -377,6 +382,25 @@ public class Well {
|
||||
return runStatus;
|
||||
}
|
||||
|
||||
public String getRunStatusString(){
|
||||
switch(runStatus){
|
||||
case RUNSTATUS_STOPPED:
|
||||
return "Stopped";
|
||||
case RUNSTATUS_STARTING:
|
||||
return "Starting";
|
||||
case RUNSTATUS_RUNNING:
|
||||
return "Running";
|
||||
case RUNSTATUS_PUMPEDOFF:
|
||||
return "Pumped-Off";
|
||||
case RUNSTATUS_FAULTED:
|
||||
return "Faulted";
|
||||
case RUNSTATUS_LOCKEDOUT:
|
||||
return "Locked Out";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public int getRunMode() {
|
||||
return runMode;
|
||||
}
|
||||
@@ -902,7 +926,7 @@ public class Well {
|
||||
cardStorage[j + 1] = cardStorage[j];
|
||||
}
|
||||
cardStorage[0] = currentCard;
|
||||
currentCard.printCard("csv", true);
|
||||
currentCard.printCard("none", true);
|
||||
strokesSinceStart++;
|
||||
strokesToday++;
|
||||
strokesLifetime++;
|
||||
@@ -917,6 +941,7 @@ public class Well {
|
||||
polishedRodHP.update(currentCard.getPolishedRodHorsepower());
|
||||
pumpHP.update(currentCard.getPumpHorsepower());
|
||||
fluidProduced.update(currentCard.getFluidBBLMoved());
|
||||
fluidProducedAdjusted.update(currentCard.getFluidBBLMovedAdjusted());
|
||||
oilProduced.update(currentCard.getOilBBLMoved());
|
||||
waterProduced.update(currentCard.getWaterBBLMoved());
|
||||
gasProduced.update(currentCard.getGasMCFMoved());
|
||||
@@ -924,31 +949,12 @@ public class Well {
|
||||
surfaceStrokeLength.update(currentCard.getSurfaceStrokeLength());
|
||||
tubingMovement.update(currentCard.getTubingMovement());
|
||||
|
||||
db.newCard(currentCard);
|
||||
currentCard = new Card(strokesLifetime);
|
||||
pointCounter = -1;
|
||||
if (strokesSinceStart > startupStrokes){
|
||||
runStatus = RUNSTATUS_RUNNING;
|
||||
}
|
||||
if(isNewDay()){
|
||||
strokeSpeed.endOfDay();
|
||||
downholeGrossStroke.endOfDay();
|
||||
downholeNetStroke.endOfDay();
|
||||
fluidLevel.endOfDay();
|
||||
fluidLoad.endOfDay();
|
||||
inflowRate.endOfDay();
|
||||
peakPolishedRodLoad.endOfDay();
|
||||
minPolishedRodLoad.endOfDay();
|
||||
percentRun.endOfDay();
|
||||
polishedRodHP.endOfDay();
|
||||
pumpHP.endOfDay();
|
||||
fluidProduced.endOfDay();
|
||||
oilProduced.endOfDay();
|
||||
waterProduced.endOfDay();
|
||||
gasProduced.endOfDay();
|
||||
pumpIntakePressure.endOfDay();
|
||||
surfaceStrokeLength.endOfDay();
|
||||
tubingMovement.endOfDay();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -957,12 +963,16 @@ public class Well {
|
||||
currentSurfacePosition = inclinometer.readScaled();
|
||||
currentSurfaceLoad = loadCell.readScaled();
|
||||
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, currentSurfacePosition);
|
||||
currentCard.setSurfaceLoad(pointCounter, currentSurfaceLoad);
|
||||
currentCard.setDownholePosition(pointCounter, lastPoint.getPosition());
|
||||
currentCard.setDownholeLoad(pointCounter, lastPoint.getLoad());
|
||||
currentCard.setDownholePosition(pointCounter, currentDownholePosition);
|
||||
currentCard.setDownholeLoad(pointCounter, currentDownholeLoad);
|
||||
}
|
||||
|
||||
if (inclinometer.getHistory(0) > inclinometer.getHistory(1))
|
||||
@@ -971,47 +981,18 @@ 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, fluidWaterRatio, fluidOilRatio, fluidGasRatio);
|
||||
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++;
|
||||
|
||||
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());
|
||||
|
||||
currentCard = new Card(strokesLifetime);
|
||||
pointCounter = -1;
|
||||
if (strokesSinceStart > startupStrokes) {
|
||||
runStatus = RUNSTATUS_RUNNING;
|
||||
}
|
||||
endOfStroke();
|
||||
}
|
||||
lastDirection = direction;
|
||||
pointCounter++;
|
||||
}
|
||||
|
||||
if (runStatus == RUNSTATUS_RUNNING || runStatus == RUNSTATUS_STARTING){
|
||||
runCommand.write(1);
|
||||
} else {
|
||||
runCommand.write(0);
|
||||
}
|
||||
|
||||
if(isNewDay()){
|
||||
strokeSpeed.endOfDay();
|
||||
downholeGrossStroke.endOfDay();
|
||||
@@ -1025,6 +1006,7 @@ public class Well {
|
||||
polishedRodHP.endOfDay();
|
||||
pumpHP.endOfDay();
|
||||
fluidProduced.endOfDay();
|
||||
fluidProducedAdjusted.endOfDay();
|
||||
oilProduced.endOfDay();
|
||||
waterProduced.endOfDay();
|
||||
gasProduced.endOfDay();
|
||||
@@ -1071,6 +1053,28 @@ public class Well {
|
||||
} else {
|
||||
runCommand.write(0);
|
||||
}
|
||||
|
||||
if(isNewDay()){
|
||||
strokeSpeed.endOfDay();
|
||||
downholeGrossStroke.endOfDay();
|
||||
downholeNetStroke.endOfDay();
|
||||
fluidLevel.endOfDay();
|
||||
fluidLoad.endOfDay();
|
||||
inflowRate.endOfDay();
|
||||
peakPolishedRodLoad.endOfDay();
|
||||
minPolishedRodLoad.endOfDay();
|
||||
percentRun.endOfDay();
|
||||
polishedRodHP.endOfDay();
|
||||
pumpHP.endOfDay();
|
||||
fluidProduced.endOfDay();
|
||||
fluidProducedAdjusted.endOfDay();
|
||||
oilProduced.endOfDay();
|
||||
waterProduced.endOfDay();
|
||||
gasProduced.endOfDay();
|
||||
pumpIntakePressure.endOfDay();
|
||||
surfaceStrokeLength.endOfDay();
|
||||
tubingMovement.endOfDay();
|
||||
}
|
||||
}
|
||||
public void printTotals(){
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.henrypump.poc;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -8,13 +10,13 @@ import java.util.Date;
|
||||
*/
|
||||
public class WellTest {
|
||||
private double testHours;
|
||||
private Date testStart;
|
||||
private ZonedDateTime testStart;
|
||||
|
||||
private double totalFluidBBL, testOilBBL, testWaterBBL, testGasMCF;
|
||||
private double kFactor, oilRatio, waterRatio, gasMCFRatio;
|
||||
|
||||
|
||||
public WellTest(Date testStart, double testHours, double totalFluidBBL, double testOilBBL, double testWaterBBL, double testGasMCF, double prevDailyTotal) {
|
||||
public WellTest(ZonedDateTime testStart, double testHours, double totalFluidBBL, double testOilBBL, double testWaterBBL, double testGasMCF, double prevDailyTotal) {
|
||||
this.testStart = testStart;
|
||||
this.testHours = testHours;
|
||||
this.totalFluidBBL = totalFluidBBL;
|
||||
@@ -39,7 +41,7 @@ public class WellTest {
|
||||
return testHours;
|
||||
}
|
||||
|
||||
public Date getTestStart() {
|
||||
public ZonedDateTime getTestStart() {
|
||||
return testStart;
|
||||
}
|
||||
|
||||
@@ -75,4 +77,14 @@ public class WellTest {
|
||||
return gasMCFRatio;
|
||||
}
|
||||
|
||||
public void print(){
|
||||
System.out.println("Well Test started at " + testStart.toString() + " lasting " + testHours + " hours");
|
||||
System.out.println("Fluid BBL: " + totalFluidBBL);
|
||||
System.out.println("Oil BBL: " + testOilBBL);
|
||||
System.out.println("Water BBL: " + testWaterBBL);
|
||||
System.out.println("Gas MCF: " + testGasMCF);
|
||||
System.out.printf("New Ratio Oil/Water/Gas: %.2f/%.2f/%.2f\n", oilRatio, waterRatio, gasMCFRatio);
|
||||
System.out.println("New Correction Factor: " + kFactor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user