From 0c6e09a6a4f441bfd3f4f84168c77d7db70dd5b8 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Fri, 10 Feb 2017 13:46:49 -0600 Subject: [PATCH] A few fixes for keeping things private --- src/main/java/com/henrypump/poc/AnalogIn.java | 28 ++++++++----------- .../java/com/henrypump/poc/FluidShot.java | 15 ++++++++++ src/main/java/com/henrypump/poc/WellTest.java | 2 +- 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/henrypump/poc/FluidShot.java diff --git a/src/main/java/com/henrypump/poc/AnalogIn.java b/src/main/java/com/henrypump/poc/AnalogIn.java index d7aa258..d2bfa06 100644 --- a/src/main/java/com/henrypump/poc/AnalogIn.java +++ b/src/main/java/com/henrypump/poc/AnalogIn.java @@ -40,47 +40,43 @@ public class AnalogIn { this.euMin = euMin; } - public double getHistory(int pointIndex) { + double getHistory(int pointIndex) { return history[pointIndex]; } - public long readRaw(){ + private long readRaw(){ return gpioPin.read(); } - public double readScaled(){ - double pv = ((euMax - euMin)/(rawMax - rawMin)) * gpioPin.read() + (euMax - ((euMax - euMin)/(rawMax - rawMin)) * rawMax); + double readScaled(){ + double pv = ((euMax - euMin)/(rawMax - rawMin)) * readRaw() + (euMax - ((euMax - euMin)/(rawMax - rawMin)) * rawMax); lastValue = pv; - for(int i = 98; i >= 0; i--){ - history[i+1] = history[i]; - } + System.arraycopy(history, 0, history,1, history.length - 1); history[0] = lastValue; return pv; } - public double readScaledSim(double simRaw){ + double readScaledSim(double simRaw){ double pv = ((euMax - euMin)/(rawMax - rawMin)) * simRaw + (euMax - ((euMax - euMin)/(rawMax - rawMin)) * rawMax); lastValue = pv; - for(int i = 98; i >= 0; i--){ - history[i+1] = history[i]; - } + System.arraycopy(history, 0, history,1, history.length - 1); history[0] = lastValue; return pv; } public static void main(String[] args){ System.out.println("Testing Analog Inputs Inputs..."); - boolean forceEnd = false; AnalogIn testIn0 = new AnalogIn(0, 0, 1020, 0, 4.6); - - do { - try{ + int loops = 0; + while(loops < 60) { + try { System.out.println("Raw = " + testIn0.readRaw()); System.out.println("Scaled = " + testIn0.readScaled()); sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } - } while (!forceEnd); + loops++; + } } } diff --git a/src/main/java/com/henrypump/poc/FluidShot.java b/src/main/java/com/henrypump/poc/FluidShot.java new file mode 100644 index 0000000..31ff8e7 --- /dev/null +++ b/src/main/java/com/henrypump/poc/FluidShot.java @@ -0,0 +1,15 @@ +package com.henrypump.poc; + +/** + * Created by patrickjmcd on 2/10/17. + */ +public class FluidShot { + private double fluidLevel; + private double frictionEstimate; + private double pumpIntakePressure; + + + FluidShot(double fluidLevel){ + + } +} diff --git a/src/main/java/com/henrypump/poc/WellTest.java b/src/main/java/com/henrypump/poc/WellTest.java index 95e2372..c053625 100644 --- a/src/main/java/com/henrypump/poc/WellTest.java +++ b/src/main/java/com/henrypump/poc/WellTest.java @@ -16,7 +16,7 @@ public class WellTest { private double kFactor, oilRatio, waterRatio, gasMCFRatio; - public WellTest(ZonedDateTime testStart, double testHours, double totalFluidBBL, double testOilBBL, double testWaterBBL, double testGasMCF, double prevDailyTotal) { + WellTest(ZonedDateTime testStart, double testHours, double totalFluidBBL, double testOilBBL, double testWaterBBL, double testGasMCF, double prevDailyTotal) { this.testStart = testStart; this.testHours = testHours; this.totalFluidBBL = totalFluidBBL;