Changeset 1531
- Timestamp:
- 09/24/02 14:35:10 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Starguider.cc
r921 r1531 38 38 IDM_kLimMag7, 39 39 IDM_kLimMag8, 40 IDM_kLimMag9 40 IDM_kLimMag9, 41 IDM_kInterpol125, 42 IDM_kInterpol25, 43 IDM_kInterpol10, 44 IDM_kInterpol5, 45 IDM_kInterpol2, 46 IDM_kInterpol1 41 47 }; 42 48 … … 84 90 85 91 fWrtRate = 25*60; 92 93 fInterpol = new TGPopupMenu(p); 94 fInterpol->AddEntry("125", IDM_kInterpol125); 95 fInterpol->AddEntry("25", IDM_kInterpol25); 96 fInterpol->AddEntry("10", IDM_kInterpol10); 97 fInterpol->AddEntry("5", IDM_kInterpol5); 98 fInterpol->AddEntry("2", IDM_kInterpol2); 99 fInterpol->AddEntry("Off", IDM_kInterpol1); 100 fInterpol->CheckEntry(IDM_kInterpol0); 101 fInterpol->Associate(this); 102 fList.Add(fInterpol); 103 104 fIntRate = 1; 86 105 87 106 fWrite = new TGPopupMenu(p); … … 268 287 return kTRUE; 269 288 289 case IDM_kInterpol125: 290 case IDM_kInterpol25: 291 case IDM_kInterpol10: 292 case IDM_kInterpol5: 293 case IDM_kInterpol2: 294 case IDM_kInterpol1: 295 for (int i=IDM_kInterpol125; i<=IDM_kInterpol1; i++) 296 if (mp1==i) 297 fWriteRate->CheckEntry(i); 298 else 299 fWriteRate->UnCheckEntry(i); 300 switch (mp1) 301 { 302 case IDM_kInterpol1: 303 fWrtRate = 1; 304 return kTRUE; 305 case IDM_kInterpol2: 306 fWrtRate = 2; 307 return kTRUE; 308 case IDM_kInterpol5: 309 fWrtRate = 5; 310 return kTRUE; 311 case IDM_kInterpol10: 312 fWrtRate = 10; 313 return kTRUE; 314 case IDM_kInterpol25: 315 fWrtRate = 25; 316 return kTRUE; 317 case IDM_kInterpol125: 318 fWrtRate = 125; 319 return kTRUE; 320 } 321 return kTRUE; 322 270 323 case IDM_kLimMag3: 271 324 case IDM_kLimMag4: … … 318 371 } 319 372 320 if (!(n% 25))373 if (!(n%fIntRate)) 321 374 { 322 375 cout << "Img: " << n << endl; … … 331 384 XY xy = fCRaDec->GetCoordinates(); 332 385 333 fRaDec.Set(xy.X() , xy.Y());386 fRaDec.Set(xy.X()*360/24, xy.Y()); 334 387 335 388 Timer time(tm); -
trunk/MagicSoft/Cosy/Starguider.h
r909 r1531 32 32 TGPopupMenu *fWriteType; 33 33 TGPopupMenu *fWriteRate; 34 TGPopupMenu *fInterpol; 34 35 TGPopupMenu *fSetup; 35 36 TGPopupMenu *fLimMag; … … 43 44 44 45 int fWrtRate; 46 int fIntRate; 45 47 46 48 void SetPixSize(const double pixsize); -
trunk/MagicSoft/Cosy/base/BaseLinkDef.h
r920 r1531 7 7 //#pragma link C++ global gLog; 8 8 #pragma link C++ class MLog; 9 #pragma link C++ class MStar+; 9 10 10 11 #endif -
trunk/MagicSoft/Cosy/base/Makefile
r920 r1531 35 35 MThread.cc \ 36 36 MTimeout.cc \ 37 MStar.cc \ 38 MStarList.cc \ 37 39 msgqueue.cc \ 38 40 MLog.cc \ … … 40 42 timer.cc 41 43 42 CINTHEADERS = MLog.h \ 44 CINTHEADERS = MStar.h \ 45 MLog.h \ 43 46 MLogManip.h 44 47 -
trunk/MagicSoft/Cosy/base/timer.h
r1109 r1531 18 18 int fYea; 19 19 20 char fDateStr[ 27];20 char fDateStr[30]; 21 21 22 22 public: … … 29 29 void SetTimer(const struct timeval *tv); 30 30 31 32 31 int GetSecs() { return fSecs; } 33 32 double Now(); //[s] 34 33 double CalcMjd(); 34 35 int Day() const { return fDay; } 36 int Month() const { return fMon; } 37 int Year() const { return fYea; } 35 38 36 39 int H() const { return fHor; } -
trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
r1109 r1531 9 9 #include "slamac.h" 10 10 #include "File.h" 11 12 #include "MStarList.h" 11 13 12 14 ClassImp(StarCatalog); … … 319 321 } 320 322 321 void StarCatalog::DrawSCAltAz(byte *img, const int color) 323 void StarCatalog::DrawSCAltAz(byte *img, const int color) const 322 324 { 323 325 // … … 353 355 } 354 356 355 void StarCatalog::DrawSCRaDec(byte *img, const int color) 357 void StarCatalog::DrawSCRaDec(byte *img, const int color) const 356 358 { 357 359 // … … 396 398 } 397 399 400 void StarCatalog::GetImg(byte *img, byte *cimg, MStarList &list) const 401 { 402 memset(cimg, 0, 768*576); 403 404 DrawSCAltAz(cimg, 2<<4); 405 DrawSCRaDec(cimg, 2); 406 407 DrawStars(list, cimg); 408 DrawCross(img, 768/2, 576/2); 409 } 410 398 411 void StarCatalog::GetImg(byte *img, byte *cimg, const double utc, 399 412 const RaDec &radec) 400 413 { 401 // memset(img, 0, 768*576); 402 memset(cimg, 0, 768*576); 403 404 SetMjd(utc); 405 //fAlpha = sla.GetAlpha(); 406 SetRaDec(radec); 407 408 DrawSCAltAz(cimg, 2<<4); 409 DrawSCRaDec(cimg, 2); 410 411 CalcImg(img); 412 413 DrawCross(img, 768/2, 576/2); 414 MStarList list; 415 GetStars(list, utc, radec); 416 GetImg(img, cimg, list); 417 /* 418 // memset(img, 0, 768*576); 419 SetMjd(utc); 420 //fAlpha = sla.GetAlpha(); 421 SetRaDec(radec); 422 //CalcImg(cimg); 423 */ 414 424 } 415 425 … … 417 427 const AltAz &altaz) 418 428 { 419 // memset(img, 0, 768*576); 420 memset(cimg, 0, 768*576); 421 429 MStarList list; 430 GetStars(list, utc, altaz); 431 GetImg(img, cimg, list); 432 /* 433 // memset(img, 0, 768*576); 434 435 SetMjd(utc); 436 //fAlpha = sla.GetAlpha(); 437 SetAltAz(altaz); 438 439 CalcRaDecRange(); 440 441 //CalcImg(img); 442 */ 443 444 } 445 446 void StarCatalog::GetStars(MStarList &list, const double utc, const RaDec &radec) 447 { 422 448 SetMjd(utc); 423 //fAlpha = sla.GetAlpha(); 449 SetRaDec(radec); 450 451 CalcStars(list); 452 } 453 454 void StarCatalog::GetStars(MStarList &list, const double utc, const AltAz &altaz) 455 { 456 SetMjd(utc); 424 457 SetAltAz(altaz); 425 458 426 459 CalcRaDecRange(); 427 DrawSCRaDec(cimg, 2); 428 DrawSCAltAz(cimg, 2<<4); 429 CalcImg(img); 430 431 DrawCross(img, 768/2, 576/2); 460 CalcStars(list); 432 461 } 433 462 … … 453 482 } 454 483 455 Bool_t StarCatalog::DrawAltAz(const int color, byte *img, double alt, double az, int size) 484 Bool_t StarCatalog::DrawAltAz(const int color, byte *img, double alt, double az, int size) const 456 485 { 457 486 // … … 492 521 } 493 522 523 /* 494 524 Bool_t StarCatalog::Draw(const int color, byte *img, const SaoFile *sao) 495 525 { 496 //497 // ---- mean to observed ---498 //499 AltAz altaz=CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;500 501 526 if (sao->MagV() > fLimitMag) 502 527 return kFALSE; 503 528 529 // 530 // ---- mean to observed --- 531 // 532 AltAz altaz=CalcAltAz(sao->GetRaDec()) * 360.0/D2PI; 533 504 534 const int mag = (10 - (sao->MagV()>1 ? (int)sao->MagV() : 1))/2; 505 535 … … 509 539 return DrawAltAz(color, img, altaz.Alt(), altaz.Az(), mag); 510 540 } 511 512 Bool_t StarCatalog::DrawRaDec(const int color, byte *img, double ra, double dec, int size) 541 */ 542 543 Bool_t StarCatalog::DrawRaDec(const int color, byte *img, double ra, double dec, int size) const 513 544 { 514 545 // … … 542 573 return DrawRaDec(color, img, radec.Ra(), radec.Dec()); 543 574 } 544 575 /* 545 576 void StarCatalog::CalcImg(byte *img) 546 577 { … … 574 605 575 606 // 576 // Try to draw star into the image (white) 577 // 578 if (!Draw(0xff, img, fSao)) 607 // Try to draw star into the image 608 // white = 0xff 609 // 610 if (!Draw(0x0f, img, fSao)) 579 611 deleted++; 580 612 … … 586 618 cout << " " << count << "-" << deleted << "=" << count-deleted << " " << flush; 587 619 } 588 620 */ 621 void StarCatalog::DrawStars(MStarList &list, byte *img) 622 { 623 MStarListIter Next(&list); 624 625 MStar *star; 626 while ((star=Next())) 627 { 628 const int mag = (10 - (star->GetMag()>1 ? (int)star->GetMag() : 1))/2; 629 630 Double_t color = 0x0f; 631 632 DrawCircle(color, img, (int)star->GetX(), (int)star->GetY(), mag); 633 } 634 } 635 636 void StarCatalog::CalcStars(MStarList &list) const 637 { 638 // 639 // --------- search for stars in catalog ---------- 640 // 641 int count = 0; 642 int deleted = 0; 643 644 int idx = 0; 645 646 while (fSrt[idx].dec<fDecMin) 647 idx++; 648 649 idx--; 650 while (++idx<fEntries && fSrt[idx].dec<fDecMax+1) 651 { 652 const int ra = fSrt[idx].ra; 653 654 if (!fRa0[ra]) 655 continue; 656 657 int nr = fSrt[idx].nr; 658 do 659 { 660 // 661 // Get entry from catalog 662 // 663 fSao->GetEntry(nr++); 664 665 if (fSao->MagV() > fLimitMag) 666 continue; 667 668 // 669 // ---- mean to observed --- 670 // 671 AltAz altaz=CalcAltAz(fSao->GetRaDec()); 672 673 // 674 // alt/az[rad] -> alt/az[pix] 675 // 676 double dx, dy; 677 slaDe2h(altaz.Az()-fAltAz.Az(), -altaz.Alt(), 678 DPI/2-fAltAz.Alt(), &dx, &dy); 679 680 // 681 // Align alt/az[pix] 682 // 683 const float xx = 768.0 - (fWidth -dx+DPI)/fPixSize; 684 const float yy = (fHeight+dy) /fPixSize; 685 686 // 687 // Range Check, add stars to the list 688 // 689 if (!(0<=xx && xx<768 && 0<=yy && yy<576)) 690 { 691 deleted++; 692 continue; 693 } 694 695 list.Add(xx, yy, fSao->MagV()); 696 count++; 697 } 698 while ((int)(360.0/D2PI*fSao->Ra())==ra); 699 } 700 701 cout << " " << count+deleted << "-" << deleted << "=" << count << " " << endl; 702 } 703 704 AltAz StarCatalog::CalcAltAzFromPix(Double_t pixx, Double_t pixy) const 705 { 706 Double_t dx = (pixx-768.0)*fPixSize + fWidth+DPI; 707 Double_t dy = pixy*fPixSize - fHeight; 708 709 double ha, dec; 710 slaDh2e(dx, dy, DPI/2-fAltAz.Alt(), &ha, &dec); 711 712 return AltAz(-dec, ha+fAltAz.Az()); 713 } -
trunk/MagicSoft/Cosy/catalog/StarCatalog.h
r1111 r1531 15 15 16 16 typedef unsigned char byte; 17 18 class MStarList; 17 19 18 20 class StarCatalog : public SlaStars … … 41 43 int fDecMax; 42 44 43 void DrawCross(byte *img, const int x, const int y);44 void DrawCircle(int color, byte *img, int xx, int yy, int size);45 static void DrawCross(byte *img, const int x, const int y); 46 static void DrawCircle(int color, byte *img, int xx, int yy, int size); 45 47 46 Bool_t DrawAltAz(const int color, byte *img, double alt, double az, int size=0) ;47 Bool_t DrawRaDec(const int color, byte *img, double ra, double dec, int size=0) ;48 Bool_t DrawAltAz(const int color, byte *img, double alt, double az, int size=0) const; 49 Bool_t DrawRaDec(const int color, byte *img, double ra, double dec, int size=0) const; 48 50 49 51 Bool_t Draw(const int color, byte *img, const AltAz &altaz); 50 52 Bool_t Draw(const int color, byte *img, const RaDec &radec); 51 Bool_t Draw(const int color, byte *img, const SaoFile *sao);52 53 53 void CalcImg(byte *); 54 //Bool_t Draw(const int color, byte *img, const SaoFile *sao); 55 //void CalcImg(byte *); 56 57 void CalcStars(MStarList &list) const; 58 59 static void DrawStars(MStarList &list, byte *img); 54 60 55 61 void SetRaDec(const RaDec &radec); 56 62 void SetAltAz(const AltAz &altaz); 57 void DrawSCAltAz(byte *img, const int color) ;58 void DrawSCRaDec(byte *img, const int color) ;63 void DrawSCAltAz(byte *img, const int color) const; 64 void DrawSCRaDec(byte *img, const int color) const; 59 65 60 66 void CalcRaDecRange(); … … 68 74 virtual ~StarCatalog(); 69 75 70 void GetImg(byte *img, byte *cimg, const double utc, 71 const RaDec &radec); 72 void GetImg(byte *img, byte *cimg, const double utc, 73 const AltAz &altaz); 76 void GetImg(byte *img, byte *cimg, MStarList &list) const; 77 void GetImg(byte *img, byte *cimg, const double utc, const RaDec &radec); 78 void GetImg(byte *img, byte *cimg, const double utc, const AltAz &altaz); 79 80 void GetStars(MStarList &list, const double utc, const RaDec &radec); 81 void GetStars(MStarList &list, const double utc, const AltAz &altaz); 74 82 75 83 const AltAz GetAltAz() const { return fAltAz*kRad2Deg; } … … 78 86 79 87 void SetPixSize(const double pixsize); 80 void SetLimitMag(const float mag) { fLimitMag = mag; }; 88 void SetLimitMag(const float mag) { fLimitMag = mag; } 89 90 AltAz CalcAltAzFromPix(Double_t pixx, Double_t pixy) const; 81 91 82 92 ClassDef(StarCatalog, 0) -
trunk/MagicSoft/Cosy/cosy.cc
r1266 r1531 19 19 } 20 20 21 TROOT root("Cosy", "Magic Control System"); 22 21 23 int main(int argc, char **argv) 22 24 { … … 27 29 // this must move to MGCosy !!!! (or MApplication) 28 30 // 29 MLog lout("log/cosy.log", kTRUE); 31 MLog *l = new MLog("log/cosy.log", kTRUE); 32 MLog &lout = *l; 30 33 lout.EnableOutputDevice(MLog::eStdout); 31 34 … … 37 40 clog("- Initialising Root environment."); 38 41 39 TROOT root("Cosy", "Magic Control System"); 40 TApplication app("App", &argc, argv); 42 TApplication* app = new TApplication("App", &argc, argv); 41 43 42 44 // … … 44 46 // 45 47 clog("- Constructing MCosy."); 46 MCosy *cosy = new MCosy("/dev/dpm_00", 500, lout); 48 49 // 50 // check for the right usage of the program 51 // 52 int mode = 2; 53 if (argc==2 && (argv[1][0]=='-' || argv[1][1]=='m')) 54 switch (argv[1][2]) 55 { 56 case '0': // standard 57 mode = 0; 58 break; 59 case '1': // SE mode 60 mode = 1; 61 break; 62 } 63 64 MCosy *cosy = new MCosy(mode, "/dev/dpm_00", 500, lout); 47 65 48 66 clog("- Starting MCosy."); … … 50 68 51 69 clog("- Starting mainloop."); 52 app .Run(kTRUE);70 app->Run(kTRUE); 53 71 54 72 clog("- Stopping cosy."); … … 59 77 60 78 clog("- Terminating Program."); 79 80 delete l; 81 61 82 cout << "The End." << endl; 83 62 84 } -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r1140 r1531 93 93 char text[21]; 94 94 95 if (fPos!=fUpdPos )95 if (fPos!=fUpdPos && fLabel[0]) 96 96 { 97 97 sprintf(text, "%ld", fPos); … … 100 100 } 101 101 102 if (fVel!=fUpdVel )102 if (fVel!=fUpdVel && fLabel[1]) 103 103 { 104 104 sprintf(text, "%d", fVel); … … 107 107 } 108 108 109 if (fAcc!=fUpdAcc )109 if (fAcc!=fUpdAcc && fLabel[2]) 110 110 { 111 111 sprintf(text, "%d", fAcc); … … 279 279 void ShaftEncoder::StopDevice() 280 280 { 281 lout << "- St artNode " << GetNodeName() << endl;281 lout << "- Stop Node " << GetNodeName() << endl; 282 282 SendNMT(kNMT_STOP); 283 283 } -
trunk/MagicSoft/Cosy/gui/MGCoordinate.cc
r1111 r1531 28 28 const Bool_t flag, const char *txt, 29 29 const Int_t deg, const UInt_t min, const UInt_t sec) 30 : TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), f Deg(deg), fMin(min), fSec(sec)30 : TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), fSign('+'), fDeg(deg), fMin(min), fSec(sec) 31 31 { 32 32 fList = new MGList; … … 139 139 Double_t MGCoordinate::GetVal() const 140 140 { 141 const Int_t deg = fDeg<0 ? -fDeg : fDeg; 142 const Int_t sgn = fDeg<0 ? -1 : 1; 143 144 return (Double_t)sgn*(60*(60*deg+fMin)+fSec)/3600; 141 const Int_t sgn = fSign=='-' ? -1 : 1; 142 143 return (Double_t)sgn*(60*(60*fDeg+fMin)+fSec)/3600; 145 144 } 146 145 147 146 void MGCoordinate::Print() 148 147 { 149 cout << fLabel->GetText()->GetString() << " " << f Deg << "\xb0 " << fMin << "' " << fSec << "\"" << endl;148 cout << fLabel->GetText()->GetString() << " " << fSign << fDeg << "\xb0 " << fMin << "' " << fSec << "\"" << endl; 150 149 } 151 150 … … 154 153 char txt[20]; 155 154 156 sprintf(txt, "% d", val);155 sprintf(txt, "%s%d", label == fLabelDeg && fSign=='-'?"-":"", val); 157 156 158 157 label->SetText(new TGString(txt)); … … 163 162 char txt[20]; 164 163 165 sprintf(txt, "% d", val);164 sprintf(txt, "%s%d", entry == fTextEntryDeg && fSign=='-'?"-":"", val); 166 165 167 166 entry->SetText(txt); … … 180 179 slaDr2af(0, d*D2PI/360.0, &sign, dms); 181 180 182 183 fDeg = sign=='-'?-dms[0]:dms[0];181 fSign = sign; 182 fDeg = dms[0]; 184 183 fMin = dms[1]; 185 184 fSec = dms[2]; … … 197 196 Bool_t MGCoordinate::Set(TGLabel *label, Int_t &val, TGTextEntry *entry) 198 197 { 199 Int_t newval = atoi(entry->GetText()); 198 TString text = entry->GetText(); 199 200 Int_t newval = abs(atoi(text)); 200 201 201 202 Bool_t ok = (entry == fTextEntryDeg || (newval>=0 && newval<60)); 203 204 if (entry==fTextEntryDeg) 205 fSign = text.Contains("-") ? '-' : '+'; 202 206 203 207 if (ok) -
trunk/MagicSoft/Cosy/gui/MGCoordinate.h
r1111 r1531 25 25 class MGCoordinate : public TGFrame 26 26 { 27 Char_t fSign; 28 27 29 Int_t fDeg; 28 30 Int_t fMin; -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1275 r1531 15 15 #include <TGListBox.h> // TGListBox 16 16 #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter) 17 #include <TGTextEntry.h> // TGTextEntry 17 18 #include <TGFrame.h> // TGGroupFrame 18 19 #include <TApplication.h> // gApplication … … 34 35 #define IDM_TEXT 2 35 36 36 #define kPB_POSITION 0x1001 37 #define kPB_TRACK 0x1002 38 #define kPB_STOP 0x1003 39 #define kPB_CALCALTAZ 0x1004 40 #define kPB_POLARIS 0x1005 41 #define kPB_START 0x1006 42 43 #define kEF_A 0x1010 44 #define kEF_B 0x1011 37 enum 38 { 39 kPB_POSITION, 40 kPB_TRACK, 41 kPB_STOP, 42 kPB_CALCALTAZ, 43 kPB_TPOINT, 44 kPB_START, 45 kPB_RAp, 46 kPB_RAm, 47 kPB_DECp, 48 kPB_DECm, 49 kPB_LoadBending, 50 kPB_CALIBSE 51 }; 45 52 46 53 void MGCosy::CreateMenu() … … 81 88 TGLabel *l; 82 89 83 l = new TGLabel(f, " SE-Az:");90 l = new TGLabel(f, "UTC:"); 84 91 l->Move(x-60, y); 85 92 fList->Add(l); 86 93 87 l = new TGLabel(f, " SE-Zd1:");94 l = new TGLabel(f, "Mjd:"); 88 95 l->Move(x-60, y+20); 89 96 fList->Add(l); 90 97 98 fUtc = new TGLabel(f, "0000/00/00 00:00:00.0"); 99 fMjd = new TGLabel(f, "00000.000000"); 100 fUtc->Move(x-25, y); 101 fMjd->Move(x-25, y+20); 102 fList->Add(fUtc); 103 fList->Add(fMjd); 104 105 l = new TGLabel(f, "SE-Az:"); 106 l->Move(x-60, y+60); 107 fList->Add(l); 108 109 l = new TGLabel(f, "SE-Zd1:"); 110 l->Move(x-60, y+80); 111 fList->Add(l); 112 91 113 l = new TGLabel(f, "SE-Zd2:"); 92 l->Move(x-60, y+ 40);114 l->Move(x-60, y+100); 93 115 fList->Add(l); 94 95 116 96 117 fLabel1 = new TGLabel*[3]; … … 101 122 fLabel1[1]->SetTextJustify(kTextRight); 102 123 fLabel1[2]->SetTextJustify(kTextRight); 103 fLabel1[0]->Move(x, y );104 fLabel1[1]->Move(x+43, y );105 fLabel1[2]->Move(x+70, y );124 fLabel1[0]->Move(x, y+60); 125 fLabel1[1]->Move(x+43, y+60); 126 fLabel1[2]->Move(x+70, y+60); 106 127 fList->Add(fLabel1[0]); 107 128 fList->Add(fLabel1[1]); … … 118 139 fLabel2[1]->SetTextJustify(kTextRight); 119 140 fLabel2[2]->SetTextJustify(kTextRight); 120 fLabel2[0]->Move(x, y+ 20);121 fLabel2[1]->Move(x+43, y+ 20);122 fLabel2[2]->Move(x+70, y+ 20);141 fLabel2[0]->Move(x, y+80); 142 fLabel2[1]->Move(x+43, y+80); 143 fLabel2[2]->Move(x+70, y+80); 123 144 fList->Add(fLabel2[0]); 124 145 fList->Add(fLabel2[1]); … … 135 156 fLabel3[1]->SetTextJustify(kTextRight); 136 157 fLabel3[2]->SetTextJustify(kTextRight); 137 fLabel3[0]->Move(x, y+ 40);138 fLabel3[1]->Move(x+43, y+ 40);139 fLabel3[2]->Move(x+70, y+ 40);158 fLabel3[0]->Move(x, y+100); 159 fLabel3[1]->Move(x+43, y+100); 160 fLabel3[2]->Move(x+70, y+100); 140 161 fList->Add(fLabel3[0]); 141 162 fList->Add(fLabel3[1]); … … 146 167 147 168 l = new TGLabel(f, "Offset-Zd:"); 148 l->Move(x-60, y+ 80);169 l->Move(x-60, y+140); 149 170 fList->Add(l); 150 171 151 172 l = new TGLabel(f, "Offset-Az:"); 152 l->Move(x-60, y+1 00);173 l->Move(x-60, y+160); 153 174 fList->Add(l); 154 175 … … 157 178 fOffsetZd->SetTextJustify(kTextRight); 158 179 fOffsetAz->SetTextJustify(kTextRight); 159 fOffsetZd->Move(x, y+ 80);160 fOffsetAz->Move(x, y+1 00);180 fOffsetZd->Move(x, y+140); 181 fOffsetAz->Move(x, y+160); 161 182 fList->Add(fOffsetZd); 162 183 fList->Add(fOffsetAz); … … 204 225 void MGCosy::CreateTabs(TGTab *fTab) 205 226 { 206 TGCompositeFrame *tf1 = fTab->AddTab("Position Zd/Az"); 207 TGCompositeFrame *tf2 = fTab->AddTab("Track Ra/Dec"); 208 TGCompositeFrame *tf3 = fTab->AddTab("Demo Mode"); 227 TGCompositeFrame *tf1 = fTab->AddTab("Position"); 228 TGCompositeFrame *tf2 = fTab->AddTab("Track"); 229 TGCompositeFrame *tf4 = fTab->AddTab("Calibration"); 230 TGCompositeFrame *tf3 = fTab->AddTab("Demo"); 209 231 210 232 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 216 238 fList->Add(fCRaDec); 217 239 240 fCCalib = new MGCoordinates(tf4, kETypeRaDec); 241 fCCalib->Move(27, 105); 242 fList->Add(fCCalib); 218 243 219 244 const int x=15; … … 239 264 l1 = new TGLabel(tf2, "Track a position given in sky coordinates."); 240 265 l2 = new TGLabel(tf2, "Right Ascension and declination must be given"); 241 l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system ");266 l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system."); 242 267 l1->Move(x, y); 243 268 l2->Move(x, y+h); … … 246 271 fList->Add(l2); 247 272 fList->Add(l3); 273 274 l1 = new TGLabel(tf4, "Start the calibration using the Start button."); 275 l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using"); 276 l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset"); 277 l4 = new TGLabel(tf4, "use the Calib SE button."); 278 l1->Move(x, y); 279 l2->Move(x, y+h); 280 l3->Move(x, y+2*h); 281 l4->Move(x, y+3*h); 282 fList->Add(l1); 283 fList->Add(l2); 284 fList->Add(l3); 285 fList->Add(l4); 248 286 249 287 // … … 261 299 TGTextButton *but; 262 300 263 but= new TGTextButton(this, "Calc Zd/Az", kPB_CALCALTAZ); 301 but= new TGTextButton(tf2, "Ra -", kPB_RAm); 302 but->Resize(50, 25); 303 but->Move(25, 210); 304 but->SetToolTipText("Right ascension -= 1'"); 305 but->Associate(this); 306 fList->Add(but); 307 but= new TGTextButton(tf2, "RA +", kPB_RAp); 308 but->Resize(50, 25); 309 but->Move(90, 210); 310 but->SetToolTipText("Right ascension += 1'"); 311 but->Associate(this); 312 fList->Add(but); 313 but= new TGTextButton(tf2, "DEC +", kPB_DECp); 314 but->Resize(50, 25); 315 but->Move(55, 185); 316 but->SetToolTipText("Declination += 1'"); 317 but->Associate(this); 318 fList->Add(but); 319 but= new TGTextButton(tf2, "DEC -", kPB_DECm); 320 but->Resize(50, 25); 321 but->Move(55, 235); 322 but->SetToolTipText("Declination -= 1'"); 323 but->Associate(this); 324 fList->Add(but); 325 326 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 264 327 but->Resize(80, 25); 265 but->Move( 37, 257);328 but->Move(165, 197); 266 329 but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec."); 330 but->Associate(this); 267 331 fList->Add(but); 268 332 269 but = new TGTextButton(t his, "Set Polaris", kPB_POLARIS);333 but = new TGTextButton(tf4, "TPoint", kPB_TPOINT); 270 334 but->Resize(80, 25); 271 but->Move(37, 288); 272 but->SetToolTipText("Set the actual position as the position of Polaris."); 335 but->Move(25, 197); 336 but->SetToolTipText("Trigger writing a tpoint coordinate pair."); 337 but->Associate(this); 338 fList->Add(but); 339 340 but = new TGTextButton(tf4, "Calib SE", kPB_CALIBSE); 341 but->Resize(80, 25); 342 but->Move(160, 197); 343 but->SetToolTipText("Set SE to given coordinates."); 344 but->Associate(this); 345 fList->Add(but); 346 347 but = new TGTextButton(tf4, "Load", kPB_LoadBending); 348 but->Resize(80, 25); 349 but->Move(25, 227); 350 but->SetToolTipText("Load bending corrections from file 'bending.txt'"); 351 but->Associate(this); 273 352 fList->Add(but); 274 353 … … 278 357 gClient->GetColorByName("Green", color); 279 358 but->SetBackgroundColor(color); 280 but->Move(147, 2 75);359 but->Move(147, 295); 281 360 but->Resize(62, 25); 282 361 but->SetToolTipText("Start a telescope movement."); … … 287 366 gClient->GetColorByName("Red", color); 288 367 but->SetBackgroundColor(color); 289 but->Move(212, 2 75);368 but->Move(212, 295); 290 369 but->Resize(62, 25); 291 370 but->SetToolTipText("Stop any movement of telescope."); 292 371 fList->Add(but); 293 372 373 /* 374 const Double_t ca = 0; // Left-Right Collimation Error 375 const Double_t an = 0; // Azimuth Axis Misalignment (N-S) 376 const Double_t aw = 0; // Azimuth Axis Misalignment (E-W) 377 const Double_t npae = 0; // Az-El Nonperpendicularity 378 const Double_t nrx = 0; // Nasmyth rotator displacement, horizontan 379 const Double_t nry = 0; // Nasmyth rotator displacement, vertical 380 const Double_t crx = 0; // Alt/Az Coude Displacement (N-S) 381 const Double_t cry = 0; // Alt/Az Coude Displacement (E-W) 382 l1 = new TGLabel(tf5, "CA"); 383 l1->SetTextJustify(kTextLeft); 384 l1->Move(x, y+2*h*1.5); 385 l1->MapWindow(); 386 fList->Add(l1); 387 l1 = new TGLabel(tf5, "AN"); 388 l1->SetTextJustify(kTextLeft); 389 l1->Move(x, y+3*h*1.5); 390 l1->MapWindow(); 391 fList->Add(l1); 392 l1 = new TGLabel(tf5, "AW"); 393 l1->SetTextJustify(kTextLeft); 394 l1->Move(x, y+4*h*1.5); 395 l1->MapWindow(); 396 fList->Add(l1); 397 l1 = new TGLabel(tf5, "NPAE"); 398 l1->SetTextJustify(kTextLeft); 399 l1->Move(x, y+5*h*1.5); 400 l1->MapWindow(); 401 fList->Add(l1); 402 l1 = new TGLabel(tf5, "NRX"); 403 l1->SetTextJustify(kTextLeft); 404 l1->Move(x, y+6*h*1.5); 405 l1->MapWindow(); 406 fList->Add(l1); 407 l1 = new TGLabel(tf5, "NRY"); 408 l1->SetTextJustify(kTextLeft); 409 l1->Move(x, y+7*h*1.5); 410 l1->MapWindow(); 411 fList->Add(l1); 412 l1 = new TGLabel(tf5, "CRX"); 413 l1->SetTextJustify(kTextLeft); 414 l1->Move(x, y+8*h*1.5); 415 l1->MapWindow(); 416 fList->Add(l1); 417 l1 = new TGLabel(tf5, "CRY"); 418 l1->SetTextJustify(kTextLeft); 419 l1->Move(x, y+9*h*1.5); 420 l1->MapWindow(); 421 fList->Add(l1); 422 const Double_t ie = 0; // Index Error in Elevation 423 const Double_t ia = 0; // Index Error in Azimuth 424 const Double_t eces = 0; // Elevation Centering Error (sin) 425 const Double_t ecec = 0; // Elevation Centering Error (cos) 426 const Double_t aces = 0; // Azimuth Centering Error (sin) 427 const Double_t acec = 0; // Azimuth Centering Error (cos) 428 l1 = new TGLabel(tf5, "IE"); 429 l1->SetTextJustify(kTextLeft); 430 l1->Move(x+150, y+3*h*1.5); 431 l1->MapWindow(); 432 fList->Add(l1); 433 l1 = new TGLabel(tf5, "IA"); 434 l1->SetTextJustify(kTextLeft); 435 l1->Move(x+150, y+4*h*1.5); 436 l1->MapWindow(); 437 fList->Add(l1); 438 l1 = new TGLabel(tf5, "ECES"); 439 l1->SetTextJustify(kTextLeft); 440 l1->Move(x+150, y+5*h*1.5); 441 l1->MapWindow(); 442 fList->Add(l1); 443 l1 = new TGLabel(tf5, "ECEC"); 444 l1->SetTextJustify(kTextLeft); 445 l1->Move(x+150, y+6*h*1.5); 446 l1->MapWindow(); 447 fList->Add(l1); 448 l1 = new TGLabel(tf5, "ACES"); 449 l1->SetTextJustify(kTextLeft); 450 l1->Move(x+150, y+4*h*1.5); 451 l1->MapWindow(); 452 fList->Add(l1); 453 l1 = new TGLabel(tf5, "IA"); 454 l1->SetTextJustify(kTextLeft); 455 l1->Move(x+150, y+4*h*1.5); 456 l1->MapWindow(); 457 fList->Add(l1); 458 459 460 TGTextEntry *entry = new TGTextEntry(tf5, "****", kEF_BendIE); 461 entry->Associate(this); 462 entry->Move(x+50, y+2*h*1.5); 463 entry->MapWindow(); 464 fList->Add(entry); 465 466 entry = new TGTextEntry(tf5, "*****", kEF_BendIA); 467 entry->Associate(this); 468 entry->Move(x+50, y+3*h*1.5); 469 entry->MapWindow(); 470 fList->Add(entry); 471 */ 294 472 } 295 473 … … 423 601 } 424 602 603 double MGCosy::UpdateTime() 604 { 605 Timer time; 606 time.Now(); 607 608 char text[256]; 609 610 strcpy(text, time.GetTimeStr()); 611 612 char *dot = strrchr(text, '.'); 613 614 if (dot) 615 dot[2] = 0; 616 617 fUtc->SetText(new TGString(text)); 618 619 double mjd = time.CalcMjd(); 620 621 sprintf(text, "%12.6f", mjd); 622 fMjd->SetText(new TGString(text)); 623 624 return mjd; 625 } 626 425 627 void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, ZdAz off, UInt_t stat) 426 628 { 427 fSkyPosition->Update(pos); 629 double mjd = UpdateTime(); 630 fSkyPosition->Update(pos, mjd); 428 631 fAccuracy->Update(pos, acc); 429 632 fVelocity->Update(vel); 430 633 UpdateOffset(off); 634 431 635 432 636 #define kError 0x01 … … 522 726 tm.Now(); 523 727 524 Float_t h = 2.+tm.H()+( 8.+tm.M())/60.;525 RaDec dest(h*15, 1 30);728 Float_t h = 2.+tm.H()+(10.7+tm.M())/60.; 729 RaDec dest(h*15, 129.7); 526 730 527 731 cout << dest.Ra()/15 << "h " << dest.Dec() << "°" << endl; … … 530 734 531 735 int i = 0; 532 while (!HasStopFlag() && i++< 130) // 2.5min736 while (!HasStopFlag() && i++<60) // 2.5min 533 737 usleep(1000000); 534 738 if (HasStopFlag()) … … 537 741 //fQueue->PostMsg(WM_STOP, 0, 0); 538 742 539 ZdAz dest1(fRand.Integer( 56)+5, fRand.Integer(360));743 ZdAz dest1(fRand.Integer(36)+25, fRand.Integer(360)); 540 744 541 745 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; … … 544 748 545 749 i = 0; 546 while (!HasStopFlag() && i++< 30) // 30s750 while (!HasStopFlag() && i++<15) // 30s 547 751 usleep(1000000); 548 752 if (HasStopFlag()) … … 581 785 demo.Stop(); 582 786 } 787 788 void MGCosy::StartCalib() 789 { 790 cout << "Start Calibration." << endl; 791 792 XY xy = fCCalib->GetCoordinates(); 793 RaDec pos(xy.X()*360/24, xy.Y()); 794 795 fQueue->PostMsg(WM_CALIB, &pos, sizeof(pos)); 796 797 cout << "PostMsg (WM_Calib) returned." << endl; 798 } 799 800 void MGCosy::StartTPoint() 801 { 802 cout << "Start writing tpoint pair." << endl; 803 804 XY xy = fCCalib->GetCoordinates(); 805 RaDec pos(xy.X()*360/24, xy.Y()); 806 807 //fQueue->PostMsg(WM_TPOINT, &pos, sizeof(pos)); 808 fQueue->Proc(WM_TPOINT, &pos); 809 810 cout << "PostMsg (WM_TPoint) returned." << endl; 811 } 583 812 // 584 813 // ****************************************************************** … … 622 851 return kTRUE; 623 852 case 2: 853 fCRaDec->SetCoordinates(fCCalib->GetCoordinates()); 854 return kTRUE; 855 case 3: 624 856 StartDemo(); 625 857 return kTRUE; … … 637 869 case kPB_CALCALTAZ: 638 870 { 639 SlaStars sla;640 sla.SetMjd2Now();641 642 871 XY xy = fCRaDec->GetCoordinates(); 643 RaDec rd(xy.X()*15., xy.Y()); 644 645 cout << "Ra/Dec: " << rd.Ra() << kDEG << " " << rd.Dec() << kDEG << endl; 646 ZdAz aa=sla.CalcZdAz(rd*kDeg2Rad)*kRad2Deg; 647 cout << "Zd/Az: " << aa.Zd() << kDEG << " " << aa.Az() << kDEG << endl; 872 fQueue->Proc(WM_CALCALTAZ, &xy); 648 873 } 649 874 return kTRUE; 650 875 651 case kPB_POLARIS: 652 fQueue->PostMsg(WM_POLARIS, 0, 0); 876 case kPB_RAp: 877 case kPB_RAm: 878 case kPB_DECp: 879 case kPB_DECm: 880 { 881 XY xy = fCRaDec->GetCoordinates(); 882 switch (mp1) 883 { 884 case kPB_RAp: 885 xy.X(xy.X()+1./60); 886 break; 887 case kPB_RAm: 888 xy.X(xy.X()-1./60); 889 break; 890 case kPB_DECp: 891 xy.Y(xy.Y()+1./60); 892 break; 893 case kPB_DECm: 894 xy.Y(xy.Y()-1./60); 895 break; 896 } 897 RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø] 898 fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest)); 899 //fQueue->Proc(WM_NEWTRACK, &dest); 900 fCRaDec->SetCoordinates(xy); 901 902 cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl; 903 } 904 return kTRUE; 905 906 case kPB_TPOINT: 907 StartTPoint(); 908 return kTRUE; 909 case kPB_CALIBSE: 910 StartCalib(); 911 return kTRUE; 912 case kPB_LoadBending: 913 fQueue->Proc(WM_LOADBENDING, NULL); 653 914 return kTRUE; 654 915 -
trunk/MagicSoft/Cosy/gui/MGCosy.h
r1275 r1531 47 47 TGLabel *fOffsetAz; 48 48 49 TGLabel *fUtc; 50 TGLabel *fMjd; 51 49 52 MGCoordinates *fCZdAz; 50 53 MGCoordinates *fCRaDec; 54 MGCoordinates *fCCalib; 51 55 52 56 MGSkyPosition *fSkyPosition; … … 74 78 void StartTrack(); 75 79 void StartDemo(); 80 void StartCalib(); 81 void StartTPoint(); 76 82 77 83 void EnableLabel(TGLabel *label, Bool_t stat); 78 84 void UpdateOffset(ZdAz &off); 85 double UpdateTime(); 79 86 80 87 public: -
trunk/MagicSoft/Cosy/gui/MGStarguider.cc
r1111 r1531 1 1 #include "MGStarguider.h" 2 2 3 #include <iostream.h> // cout 4 3 #include <fstream.h> // ifstream 4 #include <iostream.h> // cout 5 # 5 6 #include <TGMenu.h> 6 7 #include <TSystem.h> 7 8 #include <TGSplitter.h> // TGHorizontal3DLine 9 #include <TGTextEntry.h> 8 10 9 11 #include "MGImage.h" … … 15 17 16 18 #include "Filter.h" 19 #include "Filter2.h" 17 20 #include "Writer.h" 18 21 #include "base/timer.h" 22 23 #include "MStarList.h" 19 24 20 25 ClassImp(MGStarguider); … … 23 28 IDM_kFilter, 24 29 IDM_kCatalog, 30 IDM_kStarguider, 25 31 IDM_kStart, 26 32 IDM_kStop, … … 29 35 IDM_kPNG, 30 36 IDM_kOnce, 37 IDM_kUseFileRaDec, 31 38 IDM_kContinous, 32 39 IDM_kRate25ps, … … 44 51 IDM_kLimMag7, 45 52 IDM_kLimMag8, 46 IDM_kLimMag9 53 IDM_kLimMag9, 54 IDM_kPixSize, 55 IDM_kInterpol125, 56 IDM_kInterpol25, 57 IDM_kInterpol10, 58 IDM_kInterpol5, 59 IDM_kInterpol2, 60 IDM_kInterpol1 47 61 }; 48 62 63 #define kZOOM 96 64 49 65 MGStarguider::MGStarguider() 50 : Camera(), TGMainFrame(gClient->GetRoot(), 768, 700) 51 { 66 : Camera(), TGMainFrame(gClient->GetRoot(), 768, 700), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 67 { 68 gVirtualX->GrabButton(fId, kButton2, /*kButtonPressMask|kButtonReleaseMask|*/kNone, kNone, kNone, kNone); 69 70 52 71 fList = new MGList; 53 72 … … 65 84 fDisplay->AddEntry("&Filter", IDM_kFilter); 66 85 fDisplay->AddEntry("Sao &Catalog", IDM_kCatalog); 86 fDisplay->AddEntry("Starguider", IDM_kStarguider); 67 87 fDisplay->Associate(this); 68 88 fList->Add(fDisplay); … … 121 141 fSao->SetLimitMag(8.0); 122 142 143 fInterpol = new TGPopupMenu(p); 144 fInterpol->AddEntry("125", IDM_kInterpol125); 145 fInterpol->AddEntry("25", IDM_kInterpol25); 146 fInterpol->AddEntry("10", IDM_kInterpol10); 147 fInterpol->AddEntry("5", IDM_kInterpol5); 148 fInterpol->AddEntry("2", IDM_kInterpol2); 149 fInterpol->AddEntry("Off", IDM_kInterpol1); 150 fInterpol->CheckEntry(IDM_kInterpol25); 151 fInterpol->Associate(this); 152 fList->Add(fInterpol); 153 154 fIntRate = 25; 155 123 156 fSetup = new TGPopupMenu(p); 124 fSetup->AddPopup("Lim. &Magnitude", fLimMag); 157 fSetup->AddPopup("Lim. &Magnitude", fLimMag); 158 fSetup->AddPopup("Disp. &Interpolation", fInterpol); 159 fSetup->AddEntry("Use Ra/Dec from file", IDM_kUseFileRaDec); 125 160 fSetup->Associate(this); 126 161 fList->Add(fSetup); … … 140 175 141 176 fCZdAz = new MGCoordinates(this, kETypeZdAz); 142 fCZdAz->Move(240+12 , fMenu->GetDefaultHeight()+584);177 fCZdAz->Move(240+12+10, fMenu->GetDefaultHeight()+584); 143 178 AddFrame(fCZdAz); 144 179 fList->Add(fCZdAz); 180 181 const Double_t pixsize = 23.4; 182 183 fSao->SetPixSize(pixsize/3600); 184 185 TString txt; 186 txt += pixsize; 187 188 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 189 fPixSize->SetAlignment(kTextCenterX); 190 fPixSize->Move(600, fMenu->GetDefaultHeight()+584); 191 AddFrame(fPixSize); 192 fList->Add(fPixSize); 145 193 146 194 // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this); … … 156 204 fList->Add(fImage); 157 205 206 fZoomImage = new MGImage(this, kZOOM, kZOOM); 207 fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2); 208 AddFrame(fZoomImage); 209 fList->Add(fZoomImage); 210 158 211 // 159 212 // Make everything visible … … 164 217 MapSubwindows(); 165 218 MapWindow(); 166 167 fSao->SetPixSize(0.006);168 219 } 169 220 … … 191 242 } 192 243 244 void MGStarguider::Toggle(TGPopupMenu *p, UInt_t id) 245 { 246 if (p->IsEntryChecked(id)) 247 p->UnCheckEntry(id); 248 else 249 p->CheckEntry(id); 250 251 } 252 193 253 Bool_t MGStarguider::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2) 194 254 { 195 255 switch (GET_MSG(msg)) 196 256 { 257 case kC_TEXTENTRY: 258 if (GET_SUBMSG(msg)==kTE_ENTER) 259 { 260 const Float_t pixsize = atof(fPixSize->GetText()); 261 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 262 fSao->SetPixSize(pixsize/3600); 263 } 264 return kTRUE; 265 197 266 case kC_COMMAND: 198 267 switch (GET_SUBMSG(msg)) … … 202 271 { 203 272 case IDM_kCatalog: 273 Toggle(fDisplay, IDM_kCatalog); 204 274 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 205 fDisplay-> UnCheckEntry(IDM_kCatalog);275 fDisplay->EnableEntry(IDM_kStarguider); 206 276 else 207 fDisplay->CheckEntry(IDM_kCatalog); 277 { 278 fDisplay->UnCheckEntry(IDM_kStarguider); 279 fDisplay->DisableEntry(IDM_kStarguider); 280 } 281 return kTRUE; 282 283 case IDM_kStarguider: 284 Toggle(fDisplay, IDM_kStarguider); 208 285 return kTRUE; 209 286 210 287 case IDM_kFilter: 288 Toggle(fDisplay, IDM_kFilter); 211 289 if (fDisplay->IsEntryChecked(IDM_kFilter)) 212 fDisplay-> UnCheckEntry(IDM_kFilter);290 fDisplay->EnableEntry(IDM_kStarguider); 213 291 else 214 fDisplay->CheckEntry(IDM_kFilter); 292 { 293 fDisplay->UnCheckEntry(IDM_kStarguider); 294 fDisplay->DisableEntry(IDM_kStarguider); 295 } 296 return kTRUE; 297 298 case IDM_kUseFileRaDec: 299 Toggle(fSetup, IDM_kUseFileRaDec); 215 300 return kTRUE; 216 301 … … 283 368 return kTRUE; 284 369 370 case IDM_kInterpol125: 371 case IDM_kInterpol25: 372 case IDM_kInterpol10: 373 case IDM_kInterpol5: 374 case IDM_kInterpol2: 375 case IDM_kInterpol1: 376 for (int i=IDM_kInterpol125; i<=IDM_kInterpol1; i++) 377 if (mp1==i) 378 fInterpol->CheckEntry(i); 379 else 380 fInterpol->UnCheckEntry(i); 381 switch (mp1) 382 { 383 case IDM_kInterpol1: 384 fIntRate = 1; 385 return kTRUE; 386 case IDM_kInterpol2: 387 fIntRate = 2; 388 return kTRUE; 389 case IDM_kInterpol5: 390 fIntRate = 5; 391 return kTRUE; 392 case IDM_kInterpol10: 393 fIntRate = 10; 394 return kTRUE; 395 case IDM_kInterpol25: 396 fIntRate = 25; 397 return kTRUE; 398 case IDM_kInterpol125: 399 fIntRate = 125; 400 return kTRUE; 401 } 402 return kTRUE; 403 285 404 case IDM_kLimMag3: 286 405 case IDM_kLimMag4: … … 303 422 break; 304 423 } 424 305 425 return kTRUE; 306 426 } 307 427 428 void MGStarguider::GetCoordinates() 429 { 430 XY xy = fCRaDec->GetCoordinates(); 431 432 if (fSetup->IsEntryChecked(IDM_kUseFileRaDec)) 433 { 434 ifstream fin("coordinates.txt"); 435 if (!fin) 436 cout << "Error: Cannot open 'coordinates.txt' using fall back solution." << endl; 437 else 438 fin >> xy; 439 } 440 441 fCRaDec->SetCoordinates(xy); 442 fRaDec->Set(xy.X()*360/24, xy.Y()); 443 } 444 445 void MGStarguider::CalcTrackingError(MStarList &spots, MStarList &stars) 446 { 447 if (stars.GetRealEntries() < 3) 448 { 449 cout << "Sorry, less than 3 stars in FOV!" << endl; 450 return; 451 } 452 453 if (spots.GetRealEntries() < 1) 454 { 455 cout << "Sorry, less than 1 detected spot in FOV!" << endl; 456 return; 457 } 458 459 Int_t idx = 0; 460 461 MStarList sortedspots; 462 463 MStar *star; 464 MStar *spot; 465 MStarListIter NextStar(&stars); 466 MStarListIter NextSpot(&spots); 467 468 while ((spot=NextSpot())) 469 { 470 AltAz aa = fSao->CalcAltAzFromPix(spot->GetX(), spot->GetY()); 471 spot->Set(aa.Az(), aa.Alt()); 472 } 473 474 while ((star=NextStar())) 475 { 476 AltAz aa = fSao->CalcAltAzFromPix(star->GetX(), star->GetY()); 477 star->Set(aa.Az(), aa.Alt()); 478 479 const double aaz = star->GetX(); 480 const double dphi2 = aaz/2.; 481 const double cos2 = cos(dphi2)*cos(dphi2); 482 const double sin2 = sin(dphi2)*sin(dphi2); 483 484 Double_t min = 800; 485 486 NextSpot.Reset(); 487 while ((spot=NextSpot())) 488 { 489 const double pzd = TMath::Pi()/2-spot->GetY(); 490 const double azd = TMath::Pi()/2-star->GetY(); 491 492 const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2; 493 494 const Double_t dist = acos(d); 495 496 if (dist>=min) 497 continue; 498 499 min = dist; 500 sortedspots.AddAt(idx, spot->GetX(), spot->GetY(), spot->GetMag()); 501 } 502 if (min>768) 503 { 504 cout << "ERROR!!!!!!!!" << endl; 505 return; 506 } 507 idx++; 508 } 509 510 // 511 // Now we have in sortedspots the entries with the shortest distances 512 // to the corresponding ones in stars. 513 // Now calculate the tracking error. 514 // 515 NextStar.Reset(); 516 MStarListIter NextSpot2(&sortedspots); 517 518 Double_t meanx=0; 519 Double_t meany=0; 520 521 while ((star=NextStar())) 522 { 523 spot = NextSpot2(); 524 525 meanx += star->GetX() - spot->GetX(); 526 meany += star->GetY() - spot->GetY(); 527 } 528 529 meanx /= idx; 530 meany /= idx; 531 532 cout << "Tracking Error: dAlt=" << meany*180/TMath::Pi(); 533 cout << "° dAz=" << meanx*180/TMath::Pi() << "° (calculated"; 534 cout << " with " << idx << " stars/spots)" << endl; 535 } 536 308 537 void MGStarguider::ProcessFrame(const unsigned long n, byte *img, struct timeval *tm) 309 538 { 310 311 539 if (!fWrite->IsEntryEnabled(IDM_kStart) && 312 540 (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce))) … … 315 543 { 316 544 static int num = 0; 317 318 545 char name[80]; 319 sprintf(name, "pix/file%04d.png", num );546 sprintf(name, "pix/file%04d.png", num++); 320 547 Writer::Png(name, img, tm); 321 548 } … … 325 552 static int num = 0; 326 553 char name[80]; 327 sprintf(name, "pix/file%04d.ppm", num );554 sprintf(name, "pix/file%04d.ppm", num++); 328 555 Writer::Ppm(name, img); 329 556 } … … 333 560 } 334 561 335 if (!(n%25)) 336 { 337 cout << "Img: " << n << endl; 338 562 static float myimg[768*576]; 563 564 for (int i=0; i<768*576; i++) 565 myimg[i] += img[i]; 566 567 if (n%fIntRate) 568 return; 569 570 cout << "Img: " << n << endl; 571 572 byte c[768*576]; 573 for (int i=0; i<768*576; i++) 574 c[i] = (byte)(myimg[i]/fIntRate+.5); 575 576 MStarList spots; 577 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 578 Filter2::Execute(spots, c); 579 else 339 580 if (fDisplay->IsEntryChecked(IDM_kFilter)) 340 Filter::Execute(img); 341 342 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 343 { 344 byte cimg[768*576]; 345 346 XY xy = fCRaDec->GetCoordinates(); 347 348 fRaDec->Set(xy.X(), xy.Y()); 349 350 Timer time(tm); 351 fSao->GetImg(img, cimg, time.CalcMjd(), *fRaDec); 352 fImage->DrawColImg(img, cimg); 353 354 fCZdAz->SetCoordinates(fSao->GetZdAz()); 355 } 356 else 357 fImage->DrawImg(img); 358 } 359 360 } 581 Filter::Execute(c); 582 583 byte zimg[kZOOM*kZOOM]; 584 for (int y=0; y<kZOOM; y++) 585 for (int x=0; x<kZOOM; x++) 586 zimg[x+y*kZOOM] = c[(fDx+(x-kZOOM/2)/2)+(fDy+(y-kZOOM/2)/2)*768]; 587 588 fZoomImage->DrawImg(zimg); 589 590 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 591 { 592 byte cimg[768*576]; 593 594 GetCoordinates(); 595 596 Timer time(tm); 597 598 MStarList stars; 599 fSao->GetStars(stars, time.CalcMjd(), *fRaDec); 600 fSao->GetImg(c, cimg, stars); 601 //fSao->GetImg(c, cimg, time.CalcMjd(), *fRaDec); 602 603 fImage->DrawColImg(c, cimg); 604 605 fCZdAz->SetCoordinates(fSao->GetZdAz()); 606 607 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 608 CalcTrackingError(spots, stars); 609 } 610 else 611 fImage->DrawImg(c); 612 613 memset(myimg, 0, 768*576*sizeof(float)); 614 } 615 616 Bool_t MGStarguider::HandleDoubleClick(Event_t *event) 617 { 618 const Int_t w = fImage->GetWidth(); 619 const Int_t h = fImage->GetHeight(); 620 const Int_t x = fImage->GetX(); 621 const Int_t y = fImage->GetY(); 622 623 if (!(event->fX>x && event->fX<x+w && event->fY>y && event->fY<y+h)) 624 return kTRUE; 625 626 Int_t dx = event->fX-x; 627 Int_t dy = event->fY-y; 628 629 if (dx<kZOOM/4) dx=kZOOM/4; 630 if (dy<kZOOM/4) dy=kZOOM/4; 631 if (dx>766-kZOOM/2) dx=766-kZOOM/4; 632 if (dy>510-kZOOM/2) dy=510-kZOOM/4; 633 634 fDx = dx; 635 fDy = dy; 636 637 cout << "New coordinates for zoom: " << fDx << " " << fDy << endl; 638 639 return kTRUE; 640 } -
trunk/MagicSoft/Cosy/gui/MGStarguider.h
r1111 r1531 12 12 #include "MGImage.h" 13 13 14 class AltAz; 14 15 class RaDec; 15 16 16 17 class TGMenuBar; 17 18 class TGPopupMenu; 19 class TGTextEntry; 18 20 19 21 class MGImage; … … 21 23 22 24 class StarCatalog; 25 class MStarList; 23 26 24 27 class MGStarguider : public Camera, public TGMainFrame … … 29 32 TGMenuBar *fMenu; 30 33 MGImage *fImage; 34 MGImage *fZoomImage; 31 35 32 36 TGPopupMenu *fDisplay; … … 35 39 TGPopupMenu *fWriteType; 36 40 TGPopupMenu *fWriteRate; 41 TGPopupMenu *fInterpol; 37 42 TGPopupMenu *fSetup; 38 43 TGPopupMenu *fLimMag; … … 41 46 MGCoordinates *fCZdAz; 42 47 48 TGTextEntry *fPixSize; 49 43 50 StarCatalog *fSao; 44 51 45 52 RaDec *fRaDec; 46 53 54 Int_t fDx; 55 Int_t fDy; 56 57 int fIntRate; 47 58 int fWrtRate; 48 59 49 60 void SetPixSize(const double pixsize); 61 void Toggle(TGPopupMenu *p, UInt_t id); 62 void GetCoordinates(); 63 void CalcTrackingError(MStarList &, MStarList &); 50 64 51 65 public: … … 59 73 60 74 Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); 75 Bool_t HandleDoubleClick(Event_t *event); 61 76 62 77 // -
trunk/MagicSoft/Cosy/main/Makefile
r1393 r1531 33 33 34 34 SRCFILES = MCosy.cc \ 35 MBending.cc 35 MBending.cc \ 36 36 MStarguider.cc 37 37 -
trunk/MagicSoft/Cosy/videodev/Camera.cc
r1266 r1531 161 161 cout << "OK." << endl; 162 162 163 cout << "Buffer Offset " << buffers.offsets[1] << endl; 164 cout << "grab: use: 768x576 24 bit TrueColor (LE: bgr)" << endl; 163 cout << "Buffer Address: " << (void*)pMapBuffer << endl; 164 cout << "Buffer Offset 1: " << (void*)iOffsets[0] << endl; 165 cout << "Buffer Offset 2: " << (void*)iOffsets[1] << endl; 166 cout << "Buffer Size: " << (void*)iBufferSize << endl; 167 cout << "grab: use: 768x576 24 bit TrueColor (LE: bgr) = " << (void*)(768*576*3) << "b" << endl; 165 168 } 166 169 … … 207 210 } 208 211 209 210 212 void Camera::LoopStep(const unsigned long n) 211 213 { … … 248 250 if (!StartGrab(i&1)) 249 251 break; 252 250 253 ProcessFrame(i, (byte*)fImg, &fTime); 251 254 i++; -
trunk/MagicSoft/Cosy/videodev/Filter.cc
r1111 r1531 107 107 const float sdev = SDev(img, offset, mean); 108 108 109 const float cut = mean + 3*sdev;109 const float cut = mean + 2.5*sdev; 110 110 111 111 //
Note:
See TracChangeset
for help on using the changeset viewer.