Changeset 2384 for trunk/MagicSoft/Cosy
- Timestamp:
- 10/15/03 17:28:35 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Makefile
r1953 r2384 39 39 SUBDIRS = \ 40 40 main \ 41 tcpip \ 41 42 gui \ 42 43 catalog \ … … 114 115 @cd videodev; make mrproper; cd .. 115 116 @echo "cd .." 117 @echo "cd tcpip" 118 @cd tcpip; make mrproper; cd .. 119 @echo "cd .." 116 120 @echo "cd catalog" 117 121 @cd catalog; make mrproper; cd .. -
trunk/MagicSoft/Cosy/base/log.h
r920 r2384 1 #ifndef LOG_H2 #define LOG_H1 #ifndef COSY_Log 2 #define COSY_Log 3 3 4 4 #include <ostream.h> 5 5 6 #ifndef MARS_MLog 6 7 #include "MLog.h" 8 #endif 7 9 8 10 //#ifndef __CINT__ -
trunk/MagicSoft/Cosy/base/timer.h
r2278 r2384 10 10 friend ostream &operator<<(ostream &out, Timer &t); 11 11 private: 12 double fMs; 13 double fDiv;12 double fMs; // Microsec in units of sec as returned by gettimeofday 13 int fSecs; // Seconds as returned by gettimeofday 14 14 15 int fSec; 16 int fSecs; 17 int fMin; 18 int fHor; 19 int fDay; 20 int fMon; 21 int fYea; 15 int fSec; // Sec of time 16 int fMin; // Min of time 17 int fHor; // Hor of time 18 int fDay; // Day of time 19 int fMon; // Mon of time 20 int fYea; // Yea of time 22 21 23 double fMjd; 22 double fDiv; // Division of day 23 double fMjd; // MJD 24 24 25 25 char fDateStr[30]; … … 28 28 29 29 public: 30 Timer() : fMs(0), fSec(0), fSecs(0), fMin(0), fHor(0), fDay(0), fMon(0), fYea(0), fMjd(0) {} 30 Timer(int d, int m, int y, int h, int min, int s, double ms) 31 : fMs(ms), fSecs(0), fSec(s), fMin(m), fHor(h), fDay(d), fMon(m), fYea(y), fDiv(0), fMjd(0) {} 32 Timer() : fMs(0), fSecs(0), fSec(0), fMin(0), fHor(0), fDay(0), fMon(0), fYea(0), fDiv(0), fMjd(0) {} 31 33 Timer(double t); 32 34 Timer(struct timeval *tv); … … 35 37 void SetTimer(int tv_sec, double tv_usec); 36 38 void SetTimer(const struct timeval *tv); 39 void SetTimer(int y, int m, int d, int h, int min, int s, double ms) 40 { 41 fMs = ms; 42 fSec = s; 43 fMin = min; 44 fHor = h; 45 fDay = d; 46 fMon = m; 47 fYea = y; 48 } 37 49 38 50 void GetTimeval(struct timeval *tv) const; … … 52 64 int M() const { return fMin; } 53 65 int S() const { return fSec; } 66 int MilliSec() const { return (int)(fMs*1000); } 67 double MicroSec() const { return fMs; } 54 68 55 69 const char *GetTimeStr(); -
trunk/MagicSoft/Cosy/cosy.cc
r2278 r2384 15 15 #include "MStarguider.h" 16 16 17 #define EXPERT 17 //#define EXPERT 18 #define HAVE_CAMERA 18 19 19 20 #define clog(txt) \ … … 100 101 101 102 clog("- Starting Camera."); 103 #ifdef HAVE_CAMERA 102 104 MStarguider *client=new MStarguider(MObservatory::kMagic1); 103 105 Camera *cam = new Camera(*client); … … 106 108 cosy->SetStarguider(client); 107 109 client->SetCosy(cosy); 108 110 #endif 109 111 clog("- Starting mainloop."); 110 112 #ifndef EXPERT … … 112 114 #endif 113 115 app->Run(kTRUE); 114 116 #ifdef HAVE_CAMERA 115 117 client->SetCosy(NULL); 116 118 cosy->SetStarguider(NULL); … … 120 122 delete cam; 121 123 delete client; 122 124 #endif 123 125 clog("- Stopping cosy."); 124 126 cosy->Stop(); -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r2280 r2384 26 26 #include "MCosy.h" 27 27 #include "MGList.h" 28 #include "MDriveCom.h" 28 29 #include "MGAccuracy.h" 29 30 #include "MGCoordinates.h" … … 34 35 35 36 #undef DEBUG 36 #define EXPERT 37 //#define EXPERT 38 //#define HAS_DEMO 37 39 38 40 ClassImp(MGCosy); … … 41 43 #define IDM_TEXT 2 42 44 #define IDM_ASPECT 3 45 43 46 44 47 enum … … 386 389 TGCompositeFrame *tf6 = fTab->AddTab("Gear"); 387 390 #endif 388 /*TGCompositeFrame *tf3 =*/// fTab->AddTab("Demo"); 391 #ifdef HAS_DEMO 392 /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo"); 393 #endif 389 394 390 395 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 984 989 void MGCosy::UpdateZdAz(ZdAz &soll) 985 990 { 986 soll *= 360/2/TMath::Pi();991 soll *= kRad2Deg; 987 992 988 993 static Int_t zd=~0; … … 1055 1060 UpdateZdAz(soll); 1056 1061 1057 #define kError 0x01 1058 #define kMoving 0x02 1059 #define kTracking 0x04 1060 #define kStopping 0x08 1061 #define kStopped 0x10 1062 1063 EnableLabel(fError, stat&kError); 1064 EnableLabel(fMoving, stat&kMoving); 1065 EnableLabel(fTracking, stat&kTracking); 1066 EnableLabel(fStopping, stat&kStopping); 1067 EnableLabel(fStopped, stat&kStopped); 1068 EnableLabel(fRaSoll, stat&kTracking); 1069 EnableLabel(fDecSoll, stat&kTracking); 1070 EnableLabel(fZdSoll, stat&kMoving); 1071 EnableLabel(fAzSoll, stat&kMoving); 1062 EnableLabel(fError, stat&MDriveCom::kError); 1063 EnableLabel(fMoving, stat&MDriveCom::kMoving); 1064 EnableLabel(fTracking, stat&MDriveCom::kTracking); 1065 EnableLabel(fStopping, stat&MDriveCom::kStopping); 1066 EnableLabel(fStopped, stat&MDriveCom::kStopped); 1067 EnableLabel(fRaSoll, stat&MDriveCom::kTracking); 1068 EnableLabel(fDecSoll, stat&MDriveCom::kTracking); 1069 EnableLabel(fZdSoll, stat&MDriveCom::kMoving); 1070 EnableLabel(fAzSoll, stat&MDriveCom::kMoving); 1072 1071 1073 1072 SetLabelColor(fAvailMac1, stat2&0x01); … … 1078 1077 SetLabelColor(fAvailSe3, stat2&0x20); 1079 1078 1080 if (stat& kTracking)1079 if (stat&MDriveCom::kTracking) 1081 1080 { 1082 1081 fAccuracy->Update(pos, acc); … … 1187 1186 // ************************** For demo purpose ********************** 1188 1187 // 1189 /* 1188 #ifdef HAS_DEMO 1189 1190 1190 #include <TRandom.h> 1191 1191 class MDemo : public MThread … … 1200 1200 void SetQueue(MsgQueue *q) { fQueue = q; } 1201 1201 1202 bool Wait(int s, int m) 1203 { 1204 int i = 0; 1205 while (!HasStopFlag() && i++<m) 1206 usleep(s); 1207 if (HasStopFlag()) 1208 return false; 1209 return true; 1210 } 1211 1212 bool Move(float zd, float az, int s, int m) 1213 { 1214 ZdAz dest1(zd, az); 1215 fQueue->PostMsg(WM_POSITION1, &dest1, sizeof(dest1)); 1216 return Wait(s, m); // 30s? 1217 } 1218 1202 1219 virtual void *Thread() 1203 1220 { 1204 while (1) 1221 if (!Move(90, -65, 1000000, 27)) 1222 return NULL; 1223 1224 Int_t i=1; 1225 while (i-->0) 1205 1226 { 1206 1227 Timer tm; 1207 1228 tm.Now(); 1208 1229 1209 //fQueue->PostMsg(WM_STOP, 0, 0); 1210 1211 ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90); 1212 1213 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; 1214 1215 fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1)); 1216 1217 int i = 0; 1218 while (!HasStopFlag() && i++<5) // 30s 1219 usleep(1000000); 1220 if (HasStopFlag()) 1230 if (!Move(75, -80, 1000000, 13)) 1221 1231 break; 1222 1223 //ZdAz dest2(5, 30); 1224 //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2)); 1225 //if (HasStopFlag()) 1226 // break; 1232 if (!Move(60, -65, 1000000, 13)) 1233 break; 1234 if (!Move(75, -50, 1000000, 13)) 1235 break; 1236 if (!Move(90, -65, 1000000, 13)) 1237 break; 1227 1238 } 1239 if (!Move(60, -65, 1000000, 17)) 1240 return NULL; 1241 if (!Move(90, -65, 1000000, 19)) 1242 return NULL; 1243 if (!Move(90, -10, 1000000, 28)) 1244 return NULL; 1245 1228 1246 cout << "Demo Thread: done." << endl; 1229 1247 return NULL; … … 1248 1266 demo.Stop(); 1249 1267 } 1250 */ 1268 #endif //HAS_DEMO 1269 1251 1270 /* 1252 1271 void MGCosy::StartCalib() … … 1344 1363 fQueue->Proc(WM_GEAR, (void*)1); 1345 1364 return kTRUE; 1346 /* 1365 #ifdef HAS_DEMO 1347 1366 case 5: 1348 1367 StartDemo(); 1349 1368 return kTRUE; 1350 */ 1369 #endif 1351 1370 } 1352 1371 return kTRUE; … … 1354 1373 case kPB_STOP: 1355 1374 cout << "Sending stop movement msg." << endl; 1356 //StopDemo(); 1375 #ifdef HAS_DEMO 1376 StopDemo(); 1377 #endif 1357 1378 fQueue->PostMsg(WM_STOP, 0, 0); 1358 1379 if (fTab->GetCurrent()==3) -
trunk/MagicSoft/Cosy/gui/MGImage.cc
r2278 r2384 52 52 fDefGC = gVirtualX->CreateGC(fId, 0); 53 53 fImage = (XImage*)gVirtualX->CreateImage(fWidth, fHeight); 54 55 cout << "Detected Color Depth: " << gVirtualX->GetDepth() << endl; 54 56 } 55 57 … … 82 84 } 83 85 84 void MGImage::DrawImg (const byte *buffer)86 void MGImage::DrawImg32(char *d, char *s, char *e) 85 87 { 86 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 87 return; 88 89 char *d = fImage->data; 90 char *e = (char*)(buffer+fWidth*fHeight); 91 char *s = (char*)buffer; 92 93 // FIXME: This loop depends on the screen color depth 88 // d=destination, s=source, e=end 94 89 while (s<e) 95 90 { … … 99 94 d++; 100 95 } 101 102 SetBit(kNeedRedraw);103 104 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);105 96 } 106 97 107 void MGImage::DrawColImg (const byte *gbuf, const byte *cbuf)98 void MGImage::DrawColImg32(char *d, char *s1, char *s2, char *e) 108 99 { 109 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 110 return; 111 112 char *d = fImage->data; 113 char *e = (char*)(gbuf+fWidth*fHeight); 114 char *s1 = (char*)gbuf; 115 char *s2 = (char*)cbuf; 116 117 // FROM libAfterImage: 118 // ------------------- 119 //#define ALPHA_TRANSPARENT 0x00 120 //#define ALPHA_SEMI_TRANSPARENT 0x7F 121 //#define ALPHA_SOLID 0xFF 122 // * Lowermost 8 bits - Blue channel 123 // * bits 8 to 15 - Green channel 124 // * bits 16 to 23 - Red channel 125 // * bits 24 to 31 - Alpha channel 126 //#define ARGB32_White 0xFFFFFFFF 127 //#define ARGB32_Black 0xFF000000 128 129 // FIXME: This loop depends on the screen color depth 100 // d=destination, s1=source1, s2=source2, e=end 130 101 while (s1<e) 131 102 { … … 147 118 } 148 119 } 120 } 121 122 void MGImage::DrawImg(const byte *buffer) 123 { 124 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 125 return; 126 127 switch (gVirtualX->GetDepth()) 128 { 129 case 32: 130 DrawImg32(fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight)); 131 break; 132 default: 133 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl; 134 } 149 135 150 136 SetBit(kNeedRedraw); … … 152 138 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 153 139 } 140 141 void MGImage::DrawColImg(const byte *gbuf, const byte *cbuf) 142 { 143 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 144 return; 145 146 // FROM libAfterImage: 147 // ------------------- 148 //#define ALPHA_TRANSPARENT 0x00 149 //#define ALPHA_SEMI_TRANSPARENT 0x7F 150 //#define ALPHA_SOLID 0xFF 151 // * Lowermost 8 bits - Blue channel 152 // * bits 8 to 15 - Green channel 153 // * bits 16 to 23 - Red channel 154 // * bits 24 to 31 - Alpha channel 155 //#define ARGB32_White 0xFFFFFFFF 156 //#define ARGB32_Black 0xFF000000 157 158 // FIXME: This loop depends on the screen color depth 159 switch (gVirtualX->GetDepth()) 160 { 161 case 32: 162 DrawColImg32(fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight)); 163 break; 164 default: 165 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl; 166 } 167 168 SetBit(kNeedRedraw); 169 170 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 171 } -
trunk/MagicSoft/Cosy/gui/MGImage.h
r2278 r2384 35 35 enum { kNeedRedraw = BIT(17) }; 36 36 37 void DrawImg32(char *d, char *s, char *e); 38 void DrawColImg32(char *d, char *s1, char *s2, char *e); 39 37 40 public: 38 41 MGImage(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options = kSunkenFrame, ULong_t back = fgDefaultFrameBackground); -
trunk/MagicSoft/Cosy/gui/Makefile
r2278 r2384 21 21 22 22 INCLUDES = -I. -I.. -I../base -I../slalib -I../candrv -I../incl \ 23 -I../catalog -I../videodev -I../main -I../caos 23 -I../catalog -I../videodev -I../main -I../caos -I../tcpip 24 24 25 25 # @code -
trunk/MagicSoft/Cosy/main/MCosy.cc
r2278 r2384 18 18 19 19 #include "MGCosy.h" 20 #include "MDriveCom.h" 20 21 #include "MStarguider.h" 21 22 #include "SlaStars.h" … … 52 53 53 54 #define EXPERT 55 //#undef EXPERT 54 56 55 57 double MCosy::Rad2SE(double rad) const … … 296 298 return; 297 299 298 SetStatus(M Cosy::kMoving);300 SetStatus(MDriveCom::kMoving); 299 301 300 302 if (axe1) fMac2->StartRelPos(rd.Zd()); … … 364 366 if (!HasError()) 365 367 { 366 SetStatus(M Cosy::kStopped);368 SetStatus(MDriveCom::kStopped); 367 369 return; 368 370 } … … 371 373 // If there is an error, the error status is set to Error. 372 374 // 373 SetStatus(M Cosy::kError);375 SetStatus(MDriveCom::kError); 374 376 375 377 /* … … 391 393 // Set motor status to stopped 392 394 // 393 SetStatus(M Cosy::kStopped);395 SetStatus(MDriveCom::kStopped); 394 396 */ 395 397 } … … 471 473 472 474 int i; 473 for (i=0; i< 10&& !(Break() || HasError() || HasZombie()); i++)475 for (i=0; i<(track?1:10) && !(Break() || HasError() || HasZombie()); i++) 474 476 { 475 477 … … 511 513 t.Now(); 512 514 lout << t << " - Positioning done in " << i << (i==1?" step.":" steps.") << endl; 513 SetStatus(M Cosy::kStopped);515 SetStatus(MDriveCom::kStopped); 514 516 return TRUE; 515 517 } … … 560 562 fMac2->SetAcceleration(0.4*vr);// 0.4 561 563 fMac2->SetDeceleration(0.4*vr);// 0.4 562 SetPosVelocity(fabs(rd.Ratio()), 0.2); // 0.175564 SetPosVelocity(fabs(rd.Ratio()), 0.2); // fast: 0.6, slow: 0.2 563 565 #else 564 566 fMac2->SetAcceleration(0.2*vr); … … 592 594 StopMovement(); 593 595 else 594 SetStatus(M Cosy::kStopped);596 SetStatus(MDriveCom::kStopped); 595 597 596 598 t.Now(); … … 662 664 return false; 663 665 664 SetStatus(M Cosy::kMoving | MCosy::kTracking);666 SetStatus(MDriveCom::kMoving | MDriveCom::kTracking); 665 667 666 668 fMac2->SetRpmMode(TRUE); … … 1042 1044 // Set status to Stopping 1043 1045 // 1044 SetStatus(M Cosy::kStopping);1046 SetStatus(MDriveCom::kStopping); 1045 1047 1046 1048 // … … 1095 1097 // Set status to Stopping 1096 1098 // 1097 SetStatus(M Cosy::kStopping);1099 SetStatus(MDriveCom::kStopping); 1098 1100 1099 1101 // … … 1281 1283 return (void*)0x7777; 1282 1284 1285 case WM_POSITION1: 1286 cout << "WM_Position1: start." << endl; 1287 { 1288 if (!CheckNetwork()) 1289 return (void*)0xebb0; 1290 1291 ZdAz dest = *((ZdAz*)mp); 1292 SetPosition(dest*kDeg2Rad, kTRUE); 1293 } 1294 cout << "WM_Position: done. (return 0x7777)" << endl; 1295 return (void*)0x7777; 1296 1283 1297 case WM_TESTSE: 1284 1298 cout << "WM_TestSe: start." << endl; … … 1341 1355 TEnv env(".cosyrc"); 1342 1356 1343 SetStatus(M Cosy::kMoving);1357 SetStatus(MDriveCom::kMoving); 1344 1358 1345 1359 fMac1->SetHome(250000, env.GetValue("Az_MaxTime2ReachHome[s]", 100)); … … 1348 1362 lout << "SETHOME DONE" << endl; 1349 1363 1350 SetStatus(HasError() ? M Cosy::kError : MCosy::kStopped);1364 SetStatus(HasError() ? MDriveCom::kError : MDriveCom::kStopped); 1351 1365 1352 1366 fAz->SetPreset(); … … 1833 1847 1834 1848 if (HasError()) 1835 SetStatus(M Cosy::kError);1849 SetStatus(MDriveCom::kError); 1836 1850 1837 1851 lout.UpdateGui(); … … 1849 1863 DisplayHistGear(!trigger); 1850 1864 1865 // FIXME: Not thread safe! 1866 static int i=0; 1867 if (i++==8) 1868 { 1869 fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError); 1870 i=0; 1871 } 1851 1872 return kTRUE; 1852 1873 } … … 2103 2124 2104 2125 MCosy::MCosy(int mode, const char *dev, const int baud, MLog &out) 2105 : Network(dev, baud, out), fObservatory(MObservatory::kMagic1), fStarguider(NULL), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone), fStatus( kStopped)2126 : Network(dev, baud, out), fObservatory(MObservatory::kMagic1), fStarguider(NULL), fZd1(0), fZd2(0), fAz(0), fMac1(0), fMac2(0), fMac3(0), fBackground(kBgdNone), fStatus(MDriveCom::kStopped) 2106 2127 { 2107 2128 TEnv env(".cosyrc"); … … 2158 2179 *tpout << /*"20 1013.25 300 0.5 0.55 0.0065" <<*/ endl; 2159 2180 // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m) 2181 2182 fCom = new MDriveCom(out); 2183 fCom->Start(); 2160 2184 } 2161 2185 … … 2189 2213 2190 2214 delete fUpdateGui; 2215 delete fCom; 2191 2216 2192 2217 cout << "Deleting Nodes." << endl; -
trunk/MagicSoft/Cosy/main/MCosy.h
r2278 r2384 30 30 #define WM_DISPLAY 0x100d 31 31 #define WM_TRACKPOS 0x100e 32 #define WM_POSITION1 0x100f 32 33 33 34 class ShaftEncoder; … … 37 38 class TH1; 38 39 class MStarguider; 40 class MDriveCom; 39 41 40 42 class MTTalk : public MThread … … 61 63 62 64 private: 63 enum64 {65 kError = 0x01,66 kMoving = 0x02,67 kTracking = 0x04,68 kStopping = 0x08,69 kStopped = 0x1070 };71 72 65 const MObservatory::LocationName_t fObservatory; 73 66 … … 82 75 Macs *fMac3; 83 76 84 MGCosy *fWin; 77 MGCosy *fWin; 78 MDriveCom *fCom; 85 79 86 80 TTimer *fUpdateGui; -
trunk/MagicSoft/Cosy/main/Makefile
r2278 r2384 21 21 22 22 INCLUDES = -I. -I../base -I.. -I../gui -I../catalog -I../devdrv \ 23 -I../candrv -I../incl -I../videodev -I../caos 23 -I../candrv -I../incl -I../videodev -I../caos -I../tcpip 24 24 25 25 # @code -
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.