80 lines
1.3 KiB
C++
80 lines
1.3 KiB
C++
/*
|
|
* GrowControl.h
|
|
*
|
|
* Created on: 14.06.2014
|
|
* Author: matzman
|
|
*/
|
|
|
|
#ifndef GROWCONTROL_H_
|
|
#define GROWCONTROL_H_
|
|
|
|
#include <TfCPPsimple.h>
|
|
#include "GCException.h"
|
|
#include <log4cpp/Category.hh>
|
|
#include <mutex>
|
|
#include "LCD.h"
|
|
|
|
using namespace tfcppsimple;
|
|
|
|
namespace growcontrol {
|
|
|
|
|
|
template<class T>
|
|
struct CGSensorValue {
|
|
T value;
|
|
bool valid = false;
|
|
GCException error;
|
|
};
|
|
|
|
struct GCSensorsInfo {
|
|
CGSensorValue<double> temp1;
|
|
CGSensorValue<double> temp2;
|
|
CGSensorValue<double> hum1;
|
|
CGSensorValue<int> fan1;
|
|
};
|
|
|
|
|
|
class GrowControl : public TfConnectionListener {
|
|
private:
|
|
|
|
static log4cpp::Category& logger;
|
|
|
|
LCD lcd;
|
|
|
|
TfConnection tfConnection;
|
|
TfMasterBrick* rootBrick = nullptr;
|
|
TfTemperatureBricklet* temp1Bricklet = nullptr;
|
|
TfTemperatureBricklet* temp2Bricklet = nullptr;
|
|
TfHumidityBricklet* hum1Bricklet = nullptr;
|
|
TfIO16Bricklet* io16Bricklet = nullptr;
|
|
|
|
std::mutex controlMutex;
|
|
unsigned int sleepDuration = 1;
|
|
bool mainLoopFlag = true;
|
|
|
|
|
|
|
|
public:
|
|
GrowControl();
|
|
virtual ~GrowControl();
|
|
|
|
bool connect(std::string host , uint16_t port, bool retry = true);
|
|
|
|
void newDeviceCallback(TfConnection& conn, TfDevice& device);
|
|
void shutdownCallback();
|
|
|
|
void mainLoop();
|
|
|
|
double getTemp1();
|
|
|
|
double getTemp2();
|
|
|
|
double getHum1();
|
|
|
|
int getFan1();
|
|
};
|
|
|
|
} /* namespace growcontrol */
|
|
|
|
#endif /* GROWCONTROL_H_ */
|