| 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 = 1,
|
|---|
| 22 | kComProblem = 2
|
|---|
| 23 | };
|
|---|
| 24 |
|
|---|
| 25 | MLog *fOut; // Stream to which reports are written in addition
|
|---|
| 26 |
|
|---|
| 27 | // Int_t fSendInterval; // [ms]
|
|---|
| 28 | // MTime fTime;
|
|---|
| 29 |
|
|---|
| 30 | MTime fT; // time of last report received
|
|---|
| 31 | char fStatus; // current status of this system
|
|---|
| 32 | int fCCStatus; // global status of CC
|
|---|
| 33 |
|
|---|
| 34 | Byte_t fTelescope;
|
|---|
| 35 |
|
|---|
| 36 | ComStatus_t fComStat; // communication status
|
|---|
| 37 |
|
|---|
| 38 | Float_t fHumidity; // [%]
|
|---|
| 39 | Float_t fTemperature; // [deg] celsius
|
|---|
| 40 | Float_t fWindSpeed; // [km/h]
|
|---|
| 41 | Float_t fSolarRadiation; // [W/m^2] IR-Radiation
|
|---|
| 42 |
|
|---|
| 43 | Int_t fAlarmCounter; // Counter for alarm cases
|
|---|
| 44 |
|
|---|
| 45 | virtual bool InterpreteCmd(TString cmd, TString str);
|
|---|
| 46 |
|
|---|
| 47 | bool InterpreteReport(TString &str);
|
|---|
| 48 | bool InterpreteStr(TString str);
|
|---|
| 49 |
|
|---|
| 50 | public:
|
|---|
| 51 | MCeCoCom(const char *addr, const int tx=7304, const int rx=7404, MLog *out=NULL)
|
|---|
| 52 | : MTcpIpIO(addr, tx, rx, 15000), fOut(out), fStatus(0),
|
|---|
| 53 | fTelescope(1), fComStat(kComProblem),
|
|---|
| 54 | fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1),
|
|---|
| 55 | fAlarmCounter(0)
|
|---|
| 56 | {
|
|---|
| 57 | }
|
|---|
| 58 | //virtual bool SendMsg(const char *msg, bool force);
|
|---|
| 59 |
|
|---|
| 60 | void SetOutRep(MLog *out) { fOut = out; }
|
|---|
| 61 |
|
|---|
| 62 | bool SendRep(const char *cmd, const char *str, bool force);
|
|---|
| 63 | void SetStatus(Byte_t s) { fStatus=s; }
|
|---|
| 64 |
|
|---|
| 65 | void SetTelescope(Byte_t tel) { fTelescope = tel; }
|
|---|
| 66 |
|
|---|
| 67 | Float_t GetHumidity() const { return fHumidity; }
|
|---|
| 68 | Float_t GetTemperature() const { return fTemperature; }
|
|---|
| 69 | Float_t GetWindSpeed() const { return fWindSpeed; }
|
|---|
| 70 |
|
|---|
| 71 | TString GetWeather() const;
|
|---|
| 72 | Int_t GetWeatherStatus() const;
|
|---|
| 73 |
|
|---|
| 74 | Bool_t HasAlarm() const { return fAlarmCounter>3; }
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | #endif
|
|---|