/* * GrowControl.h * * Created on: 14.06.2014 * Author: matzman */ #ifndef GROWCONTROL_H_ #define GROWCONTROL_H_ #include #include "GCException.h" #include #include #include "LCD.h" using namespace tfcppsimple; namespace growcontrol { template struct CGSensorValue { T value; bool valid = false; GCException error; }; struct GCSensorsInfo { CGSensorValue temp1; CGSensorValue temp2; CGSensorValue hum1; CGSensorValue 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_ */