Changeset 2384 for trunk/MagicSoft/Cosy/tcpip
- Timestamp:
- 10/15/03 17:28:35 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy/tcpip
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
r2379 r2384 41 41 42 42 // skip solar_irr_Wm2, wind_speed, UPS 43 43 float zd, az, dec, ra, temp, hum; 44 44 n=sscanf(str.Data(), 45 45 "%f %f %f %f %f %*f %*f %f %*f %n", -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h
r2379 r2384 34 34 35 35 bool InterpreteStr(TString str); 36 bool Send(const char *str);37 36 38 37 public: 39 MCeCoCom::MCeCoCom(const char *cmd )40 : MTcpIpIO( ), fCommand(cmd), fStatus(0), fComStat(kNoCmdReceived)38 MCeCoCom::MCeCoCom(const char *cmd, MLog &out=gLog) 39 : MTcpIpIO(out), fCommand(cmd), fStatus(0), fComStat(kNoCmdReceived) 41 40 { 42 41 } 43 42 43 bool Send(const char *str); 44 44 void SetStatus(Byte_t s) { fStatus=s; } 45 45 }; -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
r2379 r2384 2 2 3 3 #include <iostream> 4 5 #include "coord.h" 6 #include "Slalib.h" 4 7 5 8 using namespace std; … … 31 34 return false; 32 35 } 36 37 void MDriveCom::Print(TString &str, Double_t deg) const 38 { 39 Char_t sgn; 40 UShort_t d, m, s; 41 42 Slalib::Deg2Dms(deg, sgn, d, m, s); 43 44 str += Form("%c %03d %02d %03d ", sgn, d, m, s); 45 } 46 47 bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er) 48 { 49 // so [rad] 50 // is [deg] 51 // er [rad] 52 53 so *= kRad2Deg; 54 er *= kRad2Deg; 55 56 // Set status flag 57 if (stat&kError) 58 SetStatus(0); 59 if (stat&kStopped) 60 SetStatus(1); 61 if (stat&kStopping || stat&kMoving) 62 SetStatus(3); 63 if (stat&kTracking) 64 SetStatus(4); 65 66 Timer t; 67 t.Now(); 68 69 TString str; 70 Print(str, rd.Ra()); // Ra 71 Print(str, rd.Dec()); // Dec 72 Print(str, 0); // HA 73 str += Form("%12.6f ", t.GetMjd()); // mjd 74 Print(str, so.Zd()); 75 Print(str, so.Az()); 76 Print(str, is.Zd()); 77 Print(str, is.Az()); 78 str += Form("%08.3f ", er.Zd()); 79 str += Form("%08.3f", er.Az()); 80 81 return Send(str); 82 } -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.h
r2379 r2384 6 6 #endif 7 7 8 class RaDec; 9 class ZdAz; 10 8 11 class MDriveCom : public MCeCoCom 9 12 { 10 13 private: 11 14 bool InterpreteCmd(TString cmd, TString str); 15 void Print(TString &str, Double_t deg) const; 12 16 13 17 public: 14 MDriveCom() : MCeCoCom("DRIVE-REPORT") {} 18 enum 19 { 20 kError = 0x01, 21 kMoving = 0x02, 22 kTracking = 0x04, 23 kStopping = 0x08, 24 kStopped = 0x10 25 }; 26 27 MDriveCom(MLog &out=gLog) : MCeCoCom("DRIVE-REPORT", out) {} 28 29 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er); 15 30 }; 16 31 -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
r2379 r2384 31 31 */ 32 32 33 MTcpIpIO::MTcpIpIO( ) : MThread(false), fRxSocket(NULL), fServSock(NULL)33 MTcpIpIO::MTcpIpIO(MLog &out) : MThread(false), Log(out), fRxSocket(NULL), fServSock(NULL) 34 34 { 35 35 fTxSocket = new TSocket("ceco", 7304); … … 38 38 MTcpIpIO::~MTcpIpIO() 39 39 { 40 cout << "Delete TxSocket..." << flush; 40 41 delete fTxSocket; 42 cout << "Done." << endl; 43 if (fServSock) 44 { 45 cout << "Delete ServSock..." << flush; 46 delete fServSock; 47 cout << "Done." << endl; 48 } 49 if (fRxSocket) 50 { 51 cout << "Delete RxSocket..." << flush; 52 delete fRxSocket; 53 cout << "Done." << endl; 54 } 41 55 } 42 56 … … 68 82 } 69 83 84 void MTcpIpIO::Clear() 85 { 86 char c; 87 while (fRxSocket->RecvRaw(&c, 1)>0 && !HasStopFlag()) 88 usleep(1); 89 } 90 70 91 void *MTcpIpIO::Thread() 71 92 { … … 87 108 } 88 109 delete fServSock; 110 fServSock=NULL; 89 111 usleep(5000000); 90 112 continue; … … 105 127 { 106 128 delete fServSock; 129 fServSock=NULL; 107 130 continue; 108 131 } … … 113 136 delete fServSock; 114 137 delete fRxSocket; 138 fServSock = NULL; 139 fRxSocket = NULL; 115 140 continue; 116 141 } … … 119 144 120 145 fRxSocket->SetOption(kNoBlock, 1); 146 147 Clear(); 121 148 122 149 TString str; … … 160 187 delete fServSock; 161 188 delete fRxSocket; 189 fServSock = NULL; 190 fRxSocket = NULL; 162 191 } 163 192 -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h
r2379 r2384 5 5 #include "MThread.h" 6 6 #endif 7 #ifndef COSY_Log 8 #include "log.h" 9 #endif 7 10 8 11 class TString; … … 10 13 class TServerSocket; 11 14 12 class MTcpIpIO : public MThread 15 class MTcpIpIO : public MThread, public Log 13 16 { 14 17 private: … … 17 20 TServerSocket *fServSock; 18 21 22 void Clear(); 23 19 24 public: 20 MTcpIpIO( );25 MTcpIpIO(MLog &out=gLog); 21 26 ~MTcpIpIO(); 22 27 -
trunk/MagicSoft/Cosy/tcpip/Makefile
r2379 r2384 20 20 # @endcode 21 21 22 INCLUDES = -I. -I../base 22 INCLUDES = -I. -I../base -I../catalog 23 23 24 24 # @code
Note:
See TracChangeset
for help on using the changeset viewer.