Compare commits
1 Commits
master
...
arduino-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba5b2d5baa |
@@ -23,7 +23,6 @@
|
|||||||
C568AEFC1F13EA5000524D66 /* LPPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEEA1F13EA5000524D66 /* LPPair.cpp */; };
|
C568AEFC1F13EA5000524D66 /* LPPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEEA1F13EA5000524D66 /* LPPair.cpp */; };
|
||||||
C568AEFD1F13EA5000524D66 /* LPStatus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEEC1F13EA5000524D66 /* LPStatus.cpp */; };
|
C568AEFD1F13EA5000524D66 /* LPStatus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEEC1F13EA5000524D66 /* LPStatus.cpp */; };
|
||||||
C568AEFE1F13EA5000524D66 /* Measurement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEEE1F13EA5000524D66 /* Measurement.cpp */; };
|
C568AEFE1F13EA5000524D66 /* Measurement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEEE1F13EA5000524D66 /* Measurement.cpp */; };
|
||||||
C568AEFF1F13EA5000524D66 /* MuxSetup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEF01F13EA5000524D66 /* MuxSetup.cpp */; };
|
|
||||||
C568AF001F13EA5000524D66 /* Well.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEF21F13EA5000524D66 /* Well.cpp */; };
|
C568AF001F13EA5000524D66 /* Well.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEF21F13EA5000524D66 /* Well.cpp */; };
|
||||||
C568AF011F13EA5000524D66 /* WellTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEF41F13EA5000524D66 /* WellTest.cpp */; };
|
C568AF011F13EA5000524D66 /* WellTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C568AEF41F13EA5000524D66 /* WellTest.cpp */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
@@ -72,8 +71,6 @@
|
|||||||
C568AEED1F13EA5000524D66 /* LPStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LPStatus.h; path = src/LPStatus.h; sourceTree = "<group>"; };
|
C568AEED1F13EA5000524D66 /* LPStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LPStatus.h; path = src/LPStatus.h; sourceTree = "<group>"; };
|
||||||
C568AEEE1F13EA5000524D66 /* Measurement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Measurement.cpp; path = src/Measurement.cpp; sourceTree = "<group>"; };
|
C568AEEE1F13EA5000524D66 /* Measurement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Measurement.cpp; path = src/Measurement.cpp; sourceTree = "<group>"; };
|
||||||
C568AEEF1F13EA5000524D66 /* Measurement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Measurement.h; path = src/Measurement.h; sourceTree = "<group>"; };
|
C568AEEF1F13EA5000524D66 /* Measurement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Measurement.h; path = src/Measurement.h; sourceTree = "<group>"; };
|
||||||
C568AEF01F13EA5000524D66 /* MuxSetup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MuxSetup.cpp; path = src/MuxSetup.cpp; sourceTree = "<group>"; };
|
|
||||||
C568AEF11F13EA5000524D66 /* MuxSetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuxSetup.h; path = src/MuxSetup.h; sourceTree = "<group>"; };
|
|
||||||
C568AEF21F13EA5000524D66 /* Well.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Well.cpp; path = src/Well.cpp; sourceTree = "<group>"; };
|
C568AEF21F13EA5000524D66 /* Well.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Well.cpp; path = src/Well.cpp; sourceTree = "<group>"; };
|
||||||
C568AEF31F13EA5000524D66 /* Well.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Well.h; path = src/Well.h; sourceTree = "<group>"; };
|
C568AEF31F13EA5000524D66 /* Well.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Well.h; path = src/Well.h; sourceTree = "<group>"; };
|
||||||
C568AEF41F13EA5000524D66 /* WellTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WellTest.cpp; path = src/WellTest.cpp; sourceTree = "<group>"; };
|
C568AEF41F13EA5000524D66 /* WellTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WellTest.cpp; path = src/WellTest.cpp; sourceTree = "<group>"; };
|
||||||
@@ -154,8 +151,6 @@
|
|||||||
C568AEED1F13EA5000524D66 /* LPStatus.h */,
|
C568AEED1F13EA5000524D66 /* LPStatus.h */,
|
||||||
C568AEEE1F13EA5000524D66 /* Measurement.cpp */,
|
C568AEEE1F13EA5000524D66 /* Measurement.cpp */,
|
||||||
C568AEEF1F13EA5000524D66 /* Measurement.h */,
|
C568AEEF1F13EA5000524D66 /* Measurement.h */,
|
||||||
C568AEF01F13EA5000524D66 /* MuxSetup.cpp */,
|
|
||||||
C568AEF11F13EA5000524D66 /* MuxSetup.h */,
|
|
||||||
C568AEF21F13EA5000524D66 /* Well.cpp */,
|
C568AEF21F13EA5000524D66 /* Well.cpp */,
|
||||||
C568AEF31F13EA5000524D66 /* Well.h */,
|
C568AEF31F13EA5000524D66 /* Well.h */,
|
||||||
C568AEF41F13EA5000524D66 /* WellTest.cpp */,
|
C568AEF41F13EA5000524D66 /* WellTest.cpp */,
|
||||||
@@ -225,7 +220,6 @@
|
|||||||
files = (
|
files = (
|
||||||
C568AEF61F13EA5000524D66 /* AnalogIn.cpp in Sources */,
|
C568AEF61F13EA5000524D66 /* AnalogIn.cpp in Sources */,
|
||||||
C568AEFE1F13EA5000524D66 /* Measurement.cpp in Sources */,
|
C568AEFE1F13EA5000524D66 /* Measurement.cpp in Sources */,
|
||||||
C568AEFF1F13EA5000524D66 /* MuxSetup.cpp in Sources */,
|
|
||||||
C568AEF81F13EA5000524D66 /* Database.cpp in Sources */,
|
C568AEF81F13EA5000524D66 /* Database.cpp in Sources */,
|
||||||
C568AEFA1F13EA5000524D66 /* DigitalOut.cpp in Sources */,
|
C568AEFA1F13EA5000524D66 /* DigitalOut.cpp in Sources */,
|
||||||
C568AEF71F13EA5000524D66 /* Card.cpp in Sources */,
|
C568AEF71F13EA5000524D66 /* Card.cpp in Sources */,
|
||||||
|
|||||||
Binary file not shown.
@@ -10,12 +10,7 @@
|
|||||||
AnalogIn::AnalogIn(int channel, double rawMin, double rawMax, double euMin, double euMax) {
|
AnalogIn::AnalogIn(int channel, double rawMin, double rawMax, double euMin, double euMax) {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
this->channel = channel;
|
this->channel = channel;
|
||||||
if (channel != 99){
|
|
||||||
channelMux[0] = MUX_VALUES[channel][0];
|
|
||||||
channelMux[1] = MUX_VALUES[channel][1];
|
|
||||||
channelMux[2] = MUX_VALUES[channel][2];
|
|
||||||
}
|
|
||||||
badReads = 0;
|
|
||||||
this->rawMax = rawMax;
|
this->rawMax = rawMax;
|
||||||
this->rawMin = rawMin;
|
this->rawMin = rawMin;
|
||||||
this->euMax = euMax;
|
this->euMax = euMax;
|
||||||
@@ -52,10 +47,6 @@ int AnalogIn::getRawValue(){
|
|||||||
return rawValue;
|
return rawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
long AnalogIn::getBadReads(){
|
|
||||||
return badReads;
|
|
||||||
}
|
|
||||||
|
|
||||||
double AnalogIn::setValue(int value){
|
double AnalogIn::setValue(int value){
|
||||||
rawValue = value;
|
rawValue = value;
|
||||||
double pv = m * rawValue + b;
|
double pv = m * rawValue + b;
|
||||||
@@ -66,25 +57,6 @@ double AnalogIn::setValue(int value){
|
|||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
double AnalogIn::read(MuxSetup *mux){
|
|
||||||
mux->set(channelMux[0], channelMux[1], channelMux[2]);
|
|
||||||
int rawIn = mux->readAnalog();
|
|
||||||
if (rawIn != -1){
|
|
||||||
badReads = 0;
|
|
||||||
return setValue(rawIn);
|
|
||||||
} else {
|
|
||||||
badReads++;
|
|
||||||
}
|
|
||||||
if (badReads > 10){
|
|
||||||
std::cout <<"Too many bad reads" << std::endl;
|
|
||||||
|
|
||||||
// mux->preAnalogWrite();
|
|
||||||
// mux->postAnalogWrite();
|
|
||||||
}
|
|
||||||
return lastValue;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnalogIn::setRawScaling(int rawMin, int rawMax){
|
void AnalogIn::setRawScaling(int rawMin, int rawMax){
|
||||||
this->rawMin = rawMin;
|
this->rawMin = rawMin;
|
||||||
this->rawMax = rawMax;
|
this->rawMax = rawMax;
|
||||||
@@ -93,23 +65,3 @@ void AnalogIn::setRawScaling(int rawMin, int rawMax){
|
|||||||
AnalogIn::~AnalogIn() {
|
AnalogIn::~AnalogIn() {
|
||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_AnalogIn(){
|
|
||||||
MuxSetup mux;
|
|
||||||
double a1val, a2val;
|
|
||||||
|
|
||||||
AnalogIn aI1(1, 32560, 65535, 0, 100);
|
|
||||||
AnalogIn aI2(2, 0, 65535, 0, 50000);
|
|
||||||
|
|
||||||
for(int i = 0; i< 50; i++){
|
|
||||||
a1val = aI1.read(&mux);
|
|
||||||
a2val = aI2.read(&mux);
|
|
||||||
|
|
||||||
std::cout << "Input 1: " << a1val << ", badReads: " << aI1.getBadReads() << std::endl;
|
|
||||||
std::cout << "Input 2: " << a2val << ", badReads: " << aI2.getBadReads() << std::endl;
|
|
||||||
std::cout << "--" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#ifndef ANALOGIN_H_
|
#ifndef ANALOGIN_H_
|
||||||
#define ANALOGIN_H_
|
#define ANALOGIN_H_
|
||||||
|
|
||||||
#include "MuxSetup.h"
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -17,11 +16,8 @@ public:
|
|||||||
AnalogIn(int ch, double rawMinI, double rawMaxI, double euMinI, double euMaxI);
|
AnalogIn(int ch, double rawMinI, double rawMaxI, double euMinI, double euMaxI);
|
||||||
int getRawValue();
|
int getRawValue();
|
||||||
double getLastValue();
|
double getLastValue();
|
||||||
long getBadReads();
|
|
||||||
double getHistory(int index);
|
double getHistory(int index);
|
||||||
double setValue(int value);
|
double setValue(int value);
|
||||||
double read(MuxSetup *mux);
|
|
||||||
double readSim(double simRaw);
|
|
||||||
void setRawScaling(int rawMin, int rawMax);
|
void setRawScaling(int rawMin, int rawMax);
|
||||||
virtual ~AnalogIn();
|
virtual ~AnalogIn();
|
||||||
|
|
||||||
@@ -31,9 +27,7 @@ private:
|
|||||||
double lastValue;
|
double lastValue;
|
||||||
double rawMin, rawMax, euMin, euMax;
|
double rawMin, rawMax, euMin, euMax;
|
||||||
double m, b;
|
double m, b;
|
||||||
int channelMux[3];
|
|
||||||
double history[100];
|
double history[100];
|
||||||
long badReads;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ANALOGIN_H_ */
|
#endif /* ANALOGIN_H_ */
|
||||||
|
|||||||
@@ -10,14 +10,10 @@
|
|||||||
DigitalIn::DigitalIn(int channel) {
|
DigitalIn::DigitalIn(int channel) {
|
||||||
this->channel = channel;
|
this->channel = channel;
|
||||||
value = -1;
|
value = -1;
|
||||||
channelMux[0] = MUX_VALUES[channel][0];
|
|
||||||
channelMux[1] = MUX_VALUES[channel][1];
|
|
||||||
channelMux[2] = MUX_VALUES[channel][2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DigitalIn::read(MuxSetup *mux){
|
int DigitalIn::setValue(int val){
|
||||||
mux->set(channelMux[0], channelMux[1], channelMux[2]);
|
value = val;
|
||||||
value = mux->readDigital();
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,36 +21,3 @@ DigitalIn::~DigitalIn() {
|
|||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
int test(){
|
|
||||||
MuxSetup mux;
|
|
||||||
|
|
||||||
DigitalIn dI1(1);
|
|
||||||
DigitalIn dI2(2);
|
|
||||||
DigitalIn dI3(3);
|
|
||||||
DigitalIn dI4(4);
|
|
||||||
DigitalIn dI5(5);
|
|
||||||
DigitalIn dI6(6);
|
|
||||||
DigitalIn dI7(7);
|
|
||||||
DigitalIn dI8(8);
|
|
||||||
|
|
||||||
int d1v = dI1.read(&mux);
|
|
||||||
int d2v = dI2.read(&mux);
|
|
||||||
int d3v = dI3.read(&mux);
|
|
||||||
int d4v = dI4.read(&mux);
|
|
||||||
int d5v = dI5.read(&mux);
|
|
||||||
int d6v = dI6.read(&mux);
|
|
||||||
int d7v = dI7.read(&mux);
|
|
||||||
int d8v = dI8.read(&mux);
|
|
||||||
|
|
||||||
std::cout << "DigIn 1: " << d1v << std::endl;
|
|
||||||
std::cout << "DigIn 2: " << d2v << std::endl;
|
|
||||||
std::cout << "DigIn 3: " << d3v << std::endl;
|
|
||||||
std::cout << "DigIn 4: " << d4v << std::endl;
|
|
||||||
std::cout << "DigIn 5: " << d5v << std::endl;
|
|
||||||
std::cout << "DigIn 6: " << d6v << std::endl;
|
|
||||||
std::cout << "DigIn 7: " << d7v << std::endl;
|
|
||||||
std::cout << "DigIn 8: " << d8v << std::endl;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,14 @@
|
|||||||
#ifndef DIGITALIN_H_
|
#ifndef DIGITALIN_H_
|
||||||
#define DIGITALIN_H_
|
#define DIGITALIN_H_
|
||||||
|
|
||||||
#include "MuxSetup.h"
|
|
||||||
|
|
||||||
class DigitalIn {
|
class DigitalIn {
|
||||||
private:
|
private:
|
||||||
int channel;
|
int channel;
|
||||||
int value;
|
int value;
|
||||||
int channelMux[3];
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DigitalIn(int channel);
|
DigitalIn(int channel);
|
||||||
int read(MuxSetup *mux);
|
int setValue(int val);
|
||||||
virtual ~DigitalIn();
|
virtual ~DigitalIn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,53 +39,17 @@ DigitalOut::DigitalOut(int chan) {
|
|||||||
// std::cout << "Cannot setup channel " << chan;
|
// std::cout << "Cannot setup channel " << chan;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pin = new mraa::Gpio(channel);
|
value = 0;
|
||||||
pin->dir(mraa::DIR_OUT);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DigitalOut::write(int value){
|
void DigitalOut::write(int value){
|
||||||
pin->write(value);
|
this->value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
DigitalOut::~DigitalOut() {
|
DigitalOut::~DigitalOut() {
|
||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
pin->write(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_DigitalOut(){
|
|
||||||
DigitalOut dO1(1);
|
|
||||||
DigitalOut dO2(2);
|
|
||||||
DigitalOut dO3(3);
|
|
||||||
DigitalOut dO4(4);
|
|
||||||
DigitalOut dO5(5);
|
|
||||||
DigitalOut dO6(6);
|
|
||||||
|
|
||||||
dO1.write(1);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO2.write(1);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO3.write(1);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO4.write(1);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO5.write(1);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO6.write(1);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO6.write(0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO5.write(0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO4.write(0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO3.write(0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO2.write(0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
dO1.write(0);
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#ifndef DIGITALOUT_H_
|
#ifndef DIGITALOUT_H_
|
||||||
#define DIGITALOUT_H_
|
#define DIGITALOUT_H_
|
||||||
|
|
||||||
#include "mraa.hpp"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -17,7 +16,7 @@
|
|||||||
class DigitalOut {
|
class DigitalOut {
|
||||||
private:
|
private:
|
||||||
int channel;
|
int channel;
|
||||||
mraa::Gpio* pin;
|
int value;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DigitalOut(int chan);
|
DigitalOut(int chan);
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* MuxSetup.cpp
|
|
||||||
*
|
|
||||||
* Created on: Jun 27, 2017
|
|
||||||
* Author: patrickjmcd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "MuxSetup.h"
|
|
||||||
|
|
||||||
int PIN_MUX_1 = 21;
|
|
||||||
int PIN_MUX_2 = 22;
|
|
||||||
int PIN_MUX_3 = 23;
|
|
||||||
int PIN_DIGITAL_READ = 24;
|
|
||||||
int PIN_ANOUT_TRIGGER = 4;
|
|
||||||
|
|
||||||
int SPI_CHANNEL = 0;
|
|
||||||
|
|
||||||
MuxSetup::MuxSetup() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
|
|
||||||
mux1value = 0;
|
|
||||||
mux2value = 0;
|
|
||||||
mux3value = 0;
|
|
||||||
|
|
||||||
pinMux1 = new mraa::Gpio(PIN_MUX_1);
|
|
||||||
mraa::Result response = pinMux1->dir(mraa::DIR_OUT);
|
|
||||||
|
|
||||||
pinMux2 = new mraa::Gpio(PIN_MUX_2);
|
|
||||||
response = pinMux2->dir(mraa::DIR_OUT);
|
|
||||||
|
|
||||||
pinMux3 = new mraa::Gpio(PIN_MUX_3);
|
|
||||||
response = pinMux3->dir(mraa::DIR_OUT);
|
|
||||||
|
|
||||||
pinDigitalRead = new mraa::Gpio(PIN_DIGITAL_READ);
|
|
||||||
response = pinDigitalRead->dir(mraa::DIR_OUT);
|
|
||||||
|
|
||||||
pinAnOutTrigger = new mraa::Gpio(PIN_ANOUT_TRIGGER);
|
|
||||||
response = pinAnOutTrigger->dir(mraa::DIR_OUT);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
spi = new mraa::Spi(SPI_CHANNEL);
|
|
||||||
|
|
||||||
pinAnOutTrigger->write(1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int MuxSetup::apply(){
|
|
||||||
pinMux1->write(mux1value);
|
|
||||||
pinMux2->write(mux2value);
|
|
||||||
pinMux3->write(mux3value);
|
|
||||||
|
|
||||||
return mux1value + mux2value * 2 + mux3value * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MuxSetup::set(int v1, int v2, int v3){
|
|
||||||
|
|
||||||
mux1value = v1;
|
|
||||||
mux2value = v2;
|
|
||||||
mux3value = v3;
|
|
||||||
return apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
int MuxSetup::readDigital(){
|
|
||||||
return pinDigitalRead->read();
|
|
||||||
}
|
|
||||||
|
|
||||||
int MuxSetup::readAnalog(){
|
|
||||||
|
|
||||||
uint8_t zero[] = {0x00, 0x00, 0x000};
|
|
||||||
uint8_t* recv = spi->write(zero, 3);
|
|
||||||
int a = recv[0];
|
|
||||||
int b = recv[1];
|
|
||||||
int c = recv[2];
|
|
||||||
std::cout << a << " - " << b << " - " << c << std::endl;
|
|
||||||
|
|
||||||
if (c == 13){
|
|
||||||
int x = a * 256;
|
|
||||||
x = x + b;
|
|
||||||
return x;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MuxSetup::preAnalogWrite(){
|
|
||||||
pinAnOutTrigger->write(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MuxSetup::postAnalogWrite(){
|
|
||||||
pinAnOutTrigger->write(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
MuxSetup::~MuxSetup() {
|
|
||||||
// TODO Auto-generated destructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* MuxSetup.h
|
|
||||||
*
|
|
||||||
* Created on: Jun 27, 2017
|
|
||||||
* Author: patrickjmcd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MUXSETUP_H_
|
|
||||||
#define MUXSETUP_H_
|
|
||||||
|
|
||||||
#include "mraa.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
|
|
||||||
const int MUX_VALUES[9][3] = {
|
|
||||||
{0,0,0},
|
|
||||||
{0,0,0},
|
|
||||||
{1,0,0},
|
|
||||||
{0,1,0},
|
|
||||||
{1,1,0},
|
|
||||||
{0,0,1},
|
|
||||||
{1,0,1},
|
|
||||||
{0,1,1},
|
|
||||||
{1,1,1},
|
|
||||||
};
|
|
||||||
|
|
||||||
class MuxSetup {
|
|
||||||
public:
|
|
||||||
|
|
||||||
MuxSetup();
|
|
||||||
int set(int v1, int v2, int v3);
|
|
||||||
void preAnalogWrite();
|
|
||||||
void postAnalogWrite();
|
|
||||||
int readAnalog();
|
|
||||||
int readDigital();
|
|
||||||
int writeDigital(int val);
|
|
||||||
virtual ~MuxSetup();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
int apply();
|
|
||||||
int mux1value, mux2value, mux3value;
|
|
||||||
mraa::Gpio* pinMux1;
|
|
||||||
mraa::Gpio* pinMux2;
|
|
||||||
mraa::Gpio* pinMux3;
|
|
||||||
mraa::Gpio* pinDigitalRead;
|
|
||||||
mraa::Gpio* pinAnOutTrigger;
|
|
||||||
mraa::Spi* spi;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MUXSETUP_H_ */
|
|
||||||
70
src/Well.cpp
70
src/Well.cpp
@@ -747,22 +747,43 @@ double lookupRodWeightPerFoot(double i_ym, double i_diam) {
|
|||||||
return wtPerFt;
|
return wtPerFt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool fileExists (const std::string& name) {
|
||||||
|
std::ifstream f(name.c_str());
|
||||||
|
return f.good();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Well::getWellSetup(){
|
void Well::getWellSetup(){
|
||||||
std::string jsonFilename = "wellSetup.json";
|
std::string jsonFilename = "wellSetup.json";
|
||||||
|
std::string renamedFilename = "wellSetup.json.bak";
|
||||||
std::ifstream i(jsonFilename);
|
std::ifstream i(jsonFilename);
|
||||||
json jsonData;
|
json jsonData;
|
||||||
i >> jsonData;
|
i >> jsonData;
|
||||||
|
|
||||||
try {
|
if (fileExists(jsonFilename)){
|
||||||
wellName = jsonData["wellName"];
|
|
||||||
dt = jsonData["dt"];
|
try {
|
||||||
setPumpDiameter(jsonData["pumpDiameter"]);
|
wellName = jsonData["wellName"];
|
||||||
fluidGradient = jsonData["fluidGradient"];
|
dt = jsonData["dt"];
|
||||||
setTubingInnerDiameter(jsonData["tubingID"]);
|
setPumpDiameter(jsonData["pumpDiameter"]);
|
||||||
setTubingOuterDiameter(jsonData["tubingOD"]);
|
fluidGradient = jsonData["fluidGradient"];
|
||||||
tubingAnchorDepth = jsonData["]
|
setTubingInnerDiameter(jsonData["tubingID"]);
|
||||||
|
setTubingOuterDiameter(jsonData["tubingOD"]);
|
||||||
|
|
||||||
|
auto tapers = jsonData["tapers"];
|
||||||
|
|
||||||
|
for (int i = 0; i < tapers.size(); i++){
|
||||||
|
setRodLength(i, tapers[i]["length"]);
|
||||||
|
setRodDiameter(i, tapers[i]["diameter"]);
|
||||||
|
setRodYM(i, tapers[i]["material"]);
|
||||||
|
setDampingFactor(i, tapers[i]["dampingFactor"]);
|
||||||
|
}
|
||||||
|
rename(jsonFilename.c_str(), renamedFilename.c_str());
|
||||||
|
// updateTapers(true);
|
||||||
|
|
||||||
|
} catch (std::exception){
|
||||||
|
std::cout << "Error in JSON" << std::endl;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -771,36 +792,7 @@ void Well::getWellSetup(){
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Object newTubingAnchorDepth = well.get("tubingAnchorDepth");
|
|
||||||
if (newTubingAnchorDepth != null) tubingAnchorDepth = (Double) newTubingAnchorDepth;
|
|
||||||
|
|
||||||
Object newStructuralRating = well.get("structuralRating");
|
|
||||||
if (newStructuralRating != null) structuralRating = (Double) newStructuralRating;
|
|
||||||
|
|
||||||
Object newStuffingBoxFriction = well.get("stuffingBoxFriction");
|
|
||||||
if (newStuffingBoxFriction != null) setSbfriction((Double) newStuffingBoxFriction);
|
|
||||||
|
|
||||||
Object newTubingHeadPressure = well.get("tubingOD");
|
|
||||||
if (newTubingHeadPressure != null) setTubingOD((Double) newTubingHeadPressure);
|
|
||||||
|
|
||||||
JSONArray tapers = (JSONArray) well.get("tapers");
|
|
||||||
numTapers = tapers.size();
|
|
||||||
for (int i = 0; i < numTapers; i++){
|
|
||||||
int currentTaperNum = i + 1;
|
|
||||||
JSONObject taperObj = (JSONObject) tapers.get(i);
|
|
||||||
|
|
||||||
Object newLength = taperObj.get("length");
|
|
||||||
if (newLength != null) setRodLength(currentTaperNum, (Double) newLength);
|
|
||||||
|
|
||||||
Object newDiameter = taperObj.get("diameter");
|
|
||||||
if (newDiameter != null) setRodDiameter(currentTaperNum, (Double) newDiameter);
|
|
||||||
|
|
||||||
Object newMaterial = taperObj.get("material");
|
|
||||||
if (newMaterial != null) setRodYM(currentTaperNum, (String) newMaterial);
|
|
||||||
|
|
||||||
Object newDampingFactor = taperObj.get("dampingFactor");
|
|
||||||
if (newDampingFactor != null) setDampingFactor(currentTaperNum, (Double) newDampingFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Path fromFile = Paths.get(jsonFilename);
|
Path fromFile = Paths.get(jsonFilename);
|
||||||
Path toFile = Paths.get(jsonFilename + ".bak");
|
Path toFile = Paths.get(jsonFilename + ".bak");
|
||||||
|
|||||||
Reference in New Issue
Block a user