Changeset 8869 for trunk/MagicSoft/Cosy/tcpip
- Timestamp:
- 02/21/08 22:03:06 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy/tcpip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h
r8862 r8869 48 48 49 49 public: 50 MCeCoCom(const char *addr, MLog *out)51 : MTcpIpIO(addr, 7304, 7404), fOut(out), fStatus(0), fComStat(kNoCmdReceived),50 MCeCoCom(const char *addr, const int tx=7304, const int rx=7404, MLog *out=NULL) 51 : MTcpIpIO(addr, tx, rx), fOut(out), fStatus(0), fComStat(kNoCmdReceived), 52 52 fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1), 53 53 fAlarmCounter(0) … … 55 55 } 56 56 //virtual bool SendMsg(const char *msg, bool force); 57 58 void SetOutRep(MLog *out) { fOut = out; } 57 59 58 60 bool SendRep(const char *cmd, const char *str, bool force); -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
r8847 r8869 61 61 62 62 //cout << "MDriveCom - TRACK... start." << endl; 63 fQueue->PostMsg(WM_TRACK, &rd, sizeof(rd)); 63 if (fQueue) 64 fQueue->PostMsg(WM_TRACK, &rd, sizeof(rd)); 64 65 //cout << "MDriveCom - TRACK... done." << endl; 65 66 return true; … … 87 88 88 89 //cout << "MDriveCom - TRACK... start." << endl; 89 fQueue->PostMsg(WM_GRB, &rd, sizeof(rd)); 90 if (fQueue) 91 fQueue->PostMsg(WM_GRB, &rd, sizeof(rd)); 90 92 //cout << "MDriveCom - TRACK... done." << endl; 91 93 return true; … … 112 114 113 115 //cout << "MDriveCom - POSITION... start." << endl; 114 fQueue->PostMsg(WM_POSITION, &za, sizeof(za)); 116 if (fQueue) 117 fQueue->PostMsg(WM_POSITION, &za, sizeof(za)); 115 118 //cout << "MDriveCom - POSITION... done." << endl; 116 119 return true; … … 136 139 137 140 //cout << "MDriveCom - TRACK... start." << endl; 138 fQueue->PostMsg(WM_PREPS, (void*)str.Data(), str.Length()+1); 141 if (fQueue) 142 fQueue->PostMsg(WM_PREPS, (void*)str.Data(), str.Length()+1); 139 143 //cout << "MDriveCom - TRACK... done." << endl; 144 return true; 145 } 146 147 bool MDriveCom::CommandTPOINT(TString &str) 148 { 149 cout << "CC-COMMAND " << MTime(-1) << " TPOIN " << str << endl; 140 150 return true; 141 151 } … … 166 176 bool lock = str=="lock"; 167 177 168 fQueue->PostMsg(WM_ARM, &lock, sizeof(lock)); 178 if (fQueue) 179 fQueue->PostMsg(WM_ARM, &lock, sizeof(lock)); 169 180 return true; 170 181 } … … 176 187 //cout << "MDriveCom - WAIT... start." << endl; 177 188 cout << "CC-COMMAND " << MTime(-1) << " WAIT" << endl; 178 fQueue->PostMsg(WM_WAIT); 189 if (fQueue) 190 fQueue->PostMsg(WM_WAIT); 179 191 //cout << "MDriveCom - WAIT... done." << endl; 180 192 return true; … … 185 197 //cout << "MDriveCom - STOP!... start." << endl; 186 198 cout << "CC-COMMAND " << MTime(-1) << " STOP!" << endl; 187 fQueue->PostMsg(WM_STOP); 199 if (fQueue) 200 fQueue->PostMsg(WM_STOP); 188 201 //cout << "MDriveCom - STOP!... done." << endl; 189 202 return true; … … 202 215 return CommandPREPS(str); 203 216 217 if (cmd==(TString)"TPOIN") 218 return CommandTPOINT(str); 219 220 if (cmd==(TString)"ARM") 221 return CommandARM(str); 222 204 223 if (cmd.IsNull() && str.IsNull()) 205 224 { … … 223 242 } 224 243 225 bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er )244 bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed) 226 245 { 227 246 // rd [rad] … … 259 278 Print(str, is.Az()); 260 279 str += txt.Print("%08.3f ", er.Zd()); 261 str += txt.Print("%08.3f", er.Az()); 280 str += txt.Print("%08.3f ", er.Az()); 281 str += armed ? "1 " : "0 "; 262 282 263 283 return SendRep("DRIVE-REPORT", str, kFALSE); … … 303 323 return SendRep("STARG-REPORT", str, kTRUE); 304 324 } 325 326 bool MDriveCom::SendTPoint(UInt_t stat) 327 { 328 /* 329 // miss [deg] 330 // nompos [deg] 331 const MTime t(-1); 332 333 miss *= 60; // [arcmin] 334 335 // Set status flag 336 if (stat&kError) 337 SetStatus(0); 338 if (stat&kStandby) 339 SetStatus(2); 340 if (stat&kMonitoring) 341 SetStatus(4); 342 343 MString txt; 344 345 TString str; 346 str += txt.Print("%05.3f ", miss.Zd()); //[arcmin] 347 str += txt.Print("%05.3f ", miss.Az()); //[arcmin] 348 Print(str, nompos.Zd()); //[deg] 349 Print(str, nompos.Az()); //[deg] 350 str += txt.Print("%05.1f ", center.GetX()); //number 351 str += txt.Print("%05.1f ", center.GetY()); //number 352 str += txt.Print("%04d ", n); //number of correleated stars 353 str += txt.Print("%03.1f ", bright); 354 str += txt.Print("%12.6f ", t.GetMjd()); // mjd 355 str += txt.Print("%.1f ", x); 356 str += txt.Print("%.1f ", y); 357 str += txt.Print("%04d ", num); //number of detected stars 358 */ 359 360 return SendRep("TPOINT-REPORT", "", kTRUE); 361 } -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.h
r8862 r8869 28 28 bool CommandPREPS(TString &str); 29 29 bool CommandARM(TString &str); 30 bool CommandTPOINT(TString &str); 30 31 31 32 public: … … 41 42 }; 42 43 43 MDriveCom(MsgQueue *q, const char *addr, MLog *out) : MCeCoCom(addr, out), fQueue(q) {} 44 MDriveCom(MsgQueue *q, const char *addr, const int tx, const int rx, MLog *out=NULL) : MCeCoCom(addr, tx, rx, out), fQueue(q) {} 45 MDriveCom(const char *addr, const int tx, const int rx, MLog *out=NULL) : MCeCoCom(addr, tx, rx, out), fQueue(NULL) {} 44 46 45 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er); 47 void SetMsgQueue(MsgQueue *q) { fQueue = q; } 48 49 50 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed); 46 51 bool SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t num, Int_t n, Double_t bright, Double_t mjd, Double_t x, Double_t y); 52 bool SendTPoint(UInt_t stat); 47 53 bool SendStatus(const char *stat); 48 54 }; -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
r8865 r8869 217 217 if (!ReadSocket(sock)) 218 218 { 219 gLog << warn << "WARNING - Connection lost to " << MTcpIpO::GetSocketAddress(sock) << endl;219 gLog << warn << MTime(-1) << " WARNING - Connection lost to " << MTcpIpO::GetSocketAddress(sock) << endl; 220 220 return kFALSE; 221 221 } … … 228 228 if (timeout.HasTimedOut()) 229 229 { 230 gLog << warn << "WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out." << endl;230 gLog << warn << MTime(-1) << " WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out." << endl; 231 231 return kFALSE; 232 232 } … … 245 245 void MTcpIpI::WaitForConnection(TServerSocket &server) 246 246 { 247 gLog << all << " Wait for connection" << endl;248 249 247 while (!IsThreadCanceled()) 250 248 { 251 gLog << all << "Listening for new connection on port " << fPortRx << "..." << endl;249 gLog << all << MTime(-1) << " Listening for new connection on port " << fPortRx << "..." << endl; 252 250 253 251 // Check for a connection request (reminder: we are in non-blocking mode) … … 256 254 while (!IsThreadCanceled()) 257 255 { 256 //cout << (int) IsThreadCanceled() << endl; 258 257 // Wait for a new connection on RX port 259 258 socket = server.Accept(); … … 281 280 return; 282 281 283 gLog << all << "Connection established to " << MTcpIpO::GetSocketAddress(*socket) << "..." << endl;282 gLog << all << MTime(-1) << " Connection established to " << MTcpIpO::GetSocketAddress(*socket) << "..." << endl; 284 283 285 284 if (!WaitForData(*socket)) … … 296 295 while (!IsThreadCanceled()) 297 296 { 298 TServerSocket *server=new TServerSocket(fPortRx, kTRUE );297 TServerSocket *server=new TServerSocket(fPortRx, kTRUE, 0); 299 298 server->SetOption(kNoBlock, 1); 300 299
Note:
See TracChangeset
for help on using the changeset viewer.