| 1 | #ifndef COSY_MCeCoCom
|
|---|
| 2 | #define COSY_MCeCoCom
|
|---|
| 3 |
|
|---|
| 4 | #ifndef ROOT_TString
|
|---|
| 5 | #include <TString.h>
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | #ifndef COSY_MTcpIpIO
|
|---|
| 9 | #include "MTcpIpIO.h"
|
|---|
| 10 | #endif
|
|---|
| 11 |
|
|---|
| 12 | #ifndef MARS_MTime
|
|---|
| 13 | #include "MTime.h"
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | class MCeCoCom : public MTcpIpIO
|
|---|
| 17 | {
|
|---|
| 18 | private:
|
|---|
| 19 | enum ComStatus_t
|
|---|
| 20 | {
|
|---|
| 21 | kCmdReceived,
|
|---|
| 22 | kNoCmdReceived,
|
|---|
| 23 | kComProblem
|
|---|
| 24 | };
|
|---|
| 25 |
|
|---|
| 26 | MLog *fOut; // Stream to which reports are written in addition
|
|---|
| 27 |
|
|---|
| 28 | // Int_t fSendInterval; // [ms]
|
|---|
| 29 | // MTime fTime;
|
|---|
| 30 |
|
|---|
| 31 | MTime fT; // time of last report received
|
|---|
| 32 | char fStatus; // current status of this system
|
|---|
| 33 | int fCCStatus; // global status of CC
|
|---|
| 34 |
|
|---|
| 35 | ComStatus_t fComStat; // communication status
|
|---|
| 36 |
|
|---|
| 37 | Float_t fHumidity; // [%]
|
|---|
| 38 | Float_t fTemperature; // [deg] celsius
|
|---|
| 39 | Float_t fWindSpeed; // [km/h]
|
|---|
| 40 | Float_t fSolarRadiation; // [W/m^2] IR-Radiation
|
|---|
| 41 |
|
|---|
| 42 | Int_t fAlarmCounter; // Counter for alarm cases
|
|---|
| 43 |
|
|---|
| 44 | virtual bool InterpreteCmd(TString cmd, TString str);
|
|---|
| 45 |
|
|---|
| 46 | bool InterpreteReport(TString &str);
|
|---|
| 47 | bool InterpreteStr(TString str);
|
|---|
| 48 |
|
|---|
| 49 | public:
|
|---|
| 50 | MCeCoCom(const char *addr, MLog *out)
|
|---|
| 51 | : MTcpIpIO(addr, 7304, 7404), fOut(out), fStatus(0), fComStat(kNoCmdReceived),
|
|---|
| 52 | fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1),
|
|---|
| 53 | fAlarmCounter(0)
|
|---|
| 54 | {
|
|---|
| 55 | }
|
|---|
| 56 | //virtual bool SendMsg(const char *msg, bool force);
|
|---|
| 57 |
|
|---|
| 58 | bool SendRep(const char *cmd, const char *str, bool force);
|
|---|
| 59 | void SetStatus(Byte_t s) { fStatus=s; }
|
|---|
| 60 |
|
|---|
| 61 | Float_t GetHumidity() const { return fHumidity; }
|
|---|
| 62 | Float_t GetTemperature() const { return fTemperature; }
|
|---|
| 63 | Float_t GetWindSpeed() const { return fWindSpeed; }
|
|---|
| 64 |
|
|---|
| 65 | TString GetWeather() const;
|
|---|
| 66 | Int_t GetWeatherStatus() const;
|
|---|
| 67 |
|
|---|
| 68 | Bool_t HasAlarm() const { return fAlarmCounter>3; }
|
|---|
| 69 | };
|
|---|
| 70 |
|
|---|
| 71 | #endif
|
|---|