- Timestamp:
- 09/05/04 18:56:47 (20 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 5 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/caos/Led.h
r2278 r4865 40 40 } 41 41 42 void SetX(Double_t x) { fX=x; } 43 void SetY(Double_t y) { fY=y; } 44 42 45 Double_t GetX() const { return fX; } 43 46 Double_t GetY() const { return fY; } -
trunk/MagicSoft/Cosy/caos/Rings.cc
r2278 r4865 14 14 int nPoints = leds.GetEntries(); 15 15 16 if (nPoints< 5)16 if (nPoints<fMinNumberLeds) 17 17 return; 18 18 -
trunk/MagicSoft/Cosy/caos/Rings.h
r2278 r4865 16 16 private: 17 17 Ring fCenter; 18 Short_t fMinNumberLeds; 18 19 19 20 void CalcCenters(const Leds &leds, Float_t min, Float_t max); 20 21 21 22 public: 22 Rings() : TClonesArray("Ring", 1) {} 23 Rings() : TClonesArray("Ring", 1) 24 { 25 fMinNumberLeds=5; 26 } 27 28 void SetMinNumberLeds(Short_t n) { fMinNumberLeds=n; } 23 29 24 30 void CalcRings(Leds &leds, Float_t min=-1, Float_t max=-1); -
trunk/MagicSoft/Cosy/catalog/StarCatalog.cc
r4104 r4865 16 16 ClassImp(StarCatalog); 17 17 18 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), f Astro(0), /*fSao(NULL), fSrt(NULL), fEntries(0),*/ fSinAngle(0), fCosAngle(1)18 StarCatalog::StarCatalog(MObservatory::LocationName_t key) : SlaStars(key), fW(768), fH(576), fAstro(0), /*fSao(NULL), fSrt(NULL), fEntries(0),*/ fSinAngle(0), fCosAngle(1), fBox(768) 19 19 { 20 20 fAstro = new MAstroCatalog; … … 136 136 { 137 137 const int mag = (10 - (star->GetMag()>1 ? (int)star->GetMag() : 1))/2; 138 139 Double_t color = 0xf0; //0x0f; 140 DrawCircle(color, img, (int)star->GetX(), (int)star->GetY(), mag);138 Double_t color = 0xf0; //0x0f; 139 // DrawStars flips the picture in X defaultwise now 140 DrawCircle(color, img, 768-(int)star->GetX(), (int)star->GetY(), mag); 141 141 } 142 142 } 143 143 144 void StarCatalog::CalcStars(MStarList &list) const 145 { 144 void StarCatalog::CalcStars(MStarList &list) 145 { 146 // full FOV 147 fBox=768; 148 CalcStars(list, 0, 576, 0, 0); 149 } 150 151 void StarCatalog::CalcStars(MStarList &list, int xc, int yc, 152 int xo, int yo) const 153 { 154 155 // CalcStars flips the picture in X defaultwise now 156 int x0 = (768-xc)-fBox; 157 int x1 = (768-xc)+fBox; 158 int y0 = yc-fBox; 159 int y1 = yc+fBox; 160 161 if (x0<0) x0=0; 162 if (y0<0) y0=0; 163 if (x1>fW) x1=fW; 164 if (y1>fH) y1=fH; 165 146 166 // Align stars into telescope system 147 167 // (Move the telescope to pointing position) … … 196 216 Float_t yy = loc.X()*fSinAngle + loc.Y()*fCosAngle; 197 217 198 if (xx<0 || xx >=768 || yy<0 || yy>=576) 218 if (xx<(x0-768/2) || xx >=(x1-768/2) 219 || yy<(y0-(576/2+yo)) || yy>=(y1-(576/2+yo))) 199 220 continue; 200 221 201 222 // Store pixel coordinates of star in list 202 list.Add(xx+768/2, yy+576/2, -2.5*log10(mag)); 223 list.Add(xx+768/2+xo, yy+576/2+yo, -2.5*log10(mag)); 224 203 225 } 204 226 } -
trunk/MagicSoft/Cosy/catalog/StarCatalog.h
r4076 r4865 25 25 { 26 26 private: 27 28 int fW; 29 int fH; 30 31 27 32 MAstroCatalog *fAstro; 28 33 … … 41 46 void SetRaDec(const RaDec &radec); 42 47 void SetAltAz(const AltAz &altaz); 48 49 int fBox; 43 50 44 51 public: … … 69 76 } 70 77 71 void CalcStars(MStarList &list) const; 78 void CalcStars(MStarList &list, int xc, int yc, int xo, int yo) const; 79 void CalcStars(MStarList &list); 72 80 static void DrawStars(MStarList &list, byte *img); 81 82 void SetBox(int box) { fBox = box; } 73 83 74 84 ClassDef(StarCatalog, 0) -
trunk/MagicSoft/Cosy/gui/GuiLinkDef.h
r4104 r4865 14 14 #pragma link C++ class MGAccuracy+; 15 15 #pragma link C++ class MGSkyPosition+; 16 #pragma link C++ class MGStarg+; 16 17 17 18 #pragma link C++ class MGCosy+; -
trunk/MagicSoft/Cosy/gui/Makefile
r4104 r4865 38 38 MGEmbeddedCanvas.cc \ 39 39 MGAccuracy.cc \ 40 MGStarg.cc \ 40 41 MGSkyPosition.cc 41 42 42 43 SRCS = $(SRCFILES) 43 44 HEADERS = $(SRCFILES:.cc=.h) -
trunk/MagicSoft/Cosy/main/MCaos.cc
r4105 r4865 116 116 117 117 Rings r; 118 r.SetMinNumberLeds(fMinNumberLeds); 118 119 r.CalcRings(fPositions); 119 120 … … 159 160 fHistw[i] = new TH1F; 160 161 fHistw[i]->SetNameTitle(name, title); 161 fHistw[i]->SetBins( 721, -180.5, 180.5);162 fHistw[i]->SetXTitle("\\Phi [ deg]");162 fHistw[i]->SetBins(101, -50.5, 50.5); 163 fHistw[i]->SetXTitle("\\Phi [arcmin]"); 163 164 fHistw[i]->SetYTitle("counts"); 164 165 } … … 259 260 c2->Update(); 260 261 262 /* 261 263 c = new TCanvas("ctime", "Timedevelopement of Center", 800, 800); 262 264 c->Divide(1,3); … … 266 268 h->SetYTitle("x [pix]"); 267 269 h->DrawCopy(); 268 ((TPad*)gPad)->SetSelected(NULL);270 c->SetSelectedPad(NULL); 269 271 fGraphprx->DrawClone("ALP*")->SetBit(kCanDelete); 272 gPad->Modified(); 273 gPad->Update(); 270 274 c->cd(2); 271 275 h = fGraphpry->GetHistogram(); … … 273 277 h->SetYTitle("y [pix]"); 274 278 h->DrawCopy(); 275 ((TPad*)gPad)->SetSelected(NULL);276 fGraphpry->DrawClone("ALP*")->SetBit(kCanDelete);279 //((TPad*)gPad)->SetSelectedPad(NULL); 280 //fGraphpry->DrawClone("ALP*")->SetBit(kCanDelete); 277 281 c->cd(3); 278 282 h = fGraphr->GetHistogram(); … … 280 284 h->SetYTitle("r [pix]"); 281 285 h->DrawCopy(); 282 ((TPad*)gPad)->SetSelected(NULL);283 fGraphr->DrawClone("ALP*")->SetBit(kCanDelete);286 //((TPad*)gPad)->SetSelectedPad(NULL); 287 //fGraphr->DrawClone("ALP*")->SetBit(kCanDelete); 284 288 c->Modified(); 285 289 c->Update(); 290 */ 286 291 287 292 c = new TCanvas("crot", "rotation angle", 800, 600); … … 291 296 fHistallw->SetYTitle("counts"); 292 297 fHistallw->DrawCopy(); 298 /* 293 299 c->cd(2); 294 300 h = fGraphw->GetHistogram(); … … 298 304 ((TPad*)gPad)->SetSelected(NULL); 299 305 fGraphw->DrawClone("ALP*")->SetBit(kCanDelete); 300 306 */ 301 307 302 308 /* -------------------------------------------------------- … … 325 331 } 326 332 327 Ring MCaos::Run(byte *img, bool printl, bool printr, const ZdAz &pos, const MTime &t )333 Ring MCaos::Run(byte *img, bool printl, bool printr, const ZdAz &pos, const MTime &t, Double_t box, Double_t cut) 328 334 { 329 335 Leds &leds = *fLeds; … … 331 337 332 338 // img width height radius sigma 333 FilterLed f(img, 768, 576, 50, 3.0);339 FilterLed f(img, 768, 576, box, cut); 334 340 335 341 Int_t first=0; … … 365 371 366 372 Rings rings; 367 rings.CalcRings(leds, 265, 268); 373 rings.SetMinNumberLeds(fMinNumberLeds); 374 // rings.CalcRings(leds, 265, 268); 375 // rwagner 376 // rings.CalcRings(leds, 158, 164); 377 rings.CalcRings(leds, fMinRadius, fMaxRadius); 368 378 369 379 const Ring ¢er = rings.GetCenter(); 380 381 center.Print(); 370 382 371 383 // FIXME! … … 393 405 { 394 406 0, 395 396 397 398 399 407 0, 408 0, 409 0, 410 0, 411 0 400 412 }; 401 413 -
trunk/MagicSoft/Cosy/main/MCaos.h
r4105 r4865 45 45 TGraph *fGraphr; 46 46 47 Short_t fMinNumberLeds; 48 Double_t fMinRadius; 49 Double_t fMaxRadius; 50 47 51 public: 48 MCaos() : fFile(NULL), fHistpr(NULL) 52 MCaos() : fFile(NULL), fHistpr(NULL), fMinNumberLeds(5), fMinRadius(265), fMaxRadius(268) 49 53 { 50 54 fLeds = new Leds; 51 55 } 56 52 57 ~MCaos() 53 58 { … … 66 71 void OpenFile(); 67 72 void CloseFile(); 73 74 void SetMinNumberRings(Short_t n) 75 { 76 fMinNumberLeds = n; 77 } 78 79 void SetRadii(Double_t min, Double_t max) 80 { 81 fMinRadius=min; 82 fMaxRadius=max; 83 } 68 84 69 85 void InitHistograms(); … … 72 88 void ResetHistograms(); 73 89 74 Ring Run(byte *img, bool printl, bool printr, const ZdAz &pos, const MTime &t); 90 Ring Run(byte *img, bool printl, bool printr, const ZdAz &pos, 91 const MTime &t, Double_t box, Double_t cut); 75 92 }; 76 93 -
trunk/MagicSoft/Cosy/main/MCosy.h
r4255 r4865 203 203 MLog *GetOutRep() { return fOutRep; } 204 204 205 //rwagner 206 MDriveCom *GetDriveCom() { return fCom; } 207 205 208 // static ZdAz CorrectTarget(const ZdAz &src, const ZdAz &dst); 206 209 // static ZdAz RaDec2ZdAz(const double mjd, const RaDec &pos, const RaDec &pm=RaDec(0,0)); -
trunk/MagicSoft/Cosy/main/MStarguider.cc
r4549 r4865 1 #define EXPERT 2 1 3 #include "MStarguider.h" 2 4 … … 9 11 #include <TTimer.h> 10 12 #include <TSystem.h> 13 #include <TFile.h> // temp writeout of histos 14 #include "MAstro.h" 15 #include "MString.h" 11 16 12 17 #include <TGMenu.h> … … 15 20 #include <TGSplitter.h> // TGHorizontal3DLine 16 21 #include <TGTextEntry.h> 17 22 #include <TGLayout.h> 18 23 #include "MString.h" 19 24 20 25 #include "MCosy.h" 21 26 #include "MCaos.h" 27 // #include "MStargLeds.h" 28 #include "MStargHistograms.h" 29 #include "MDriveCom.h" 30 31 #include "MGStarg.h" 32 #include "TGFrame.h" 22 33 23 34 #include "MGImage.h" … … 91 102 IDM_kCaosWriteStart, 92 103 IDM_kCaosWriteStop, 93 IDM_kResetHistograms 104 IDM_kResetHistograms, 105 IDM_kStargHistograms, 106 IDM_kStargAnalysis, 107 IDM_kStargCaosFilter, 108 IDM_kStargLEDFilter, 109 IDM_kStargFindStar 110 94 111 }; 95 112 … … 105 122 fCosy->GetWin()->GetImage()->DoRedraw(); 106 123 124 fGStarg->Update(fPos, fD); 125 107 126 return kTRUE; 108 127 } … … 122 141 123 142 fChannel = new MGPopupMenu(p); 124 fChannel->AddEntry(" Channel #1", IDM_kChannel1);125 fChannel->AddEntry(" Channel #2", IDM_kChannel2);143 fChannel->AddEntry("Starfield Camera", IDM_kChannel1); 144 fChannel->AddEntry("TPoint Camera", IDM_kChannel2); 126 145 fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2); 127 146 fChannel->Associate(this); … … 134 153 fDisplay->AddEntry("&Filter", IDM_kFilter); 135 154 fDisplay->AddEntry("Find &Star", IDM_kFindStar); 136 fDisplay->AddEntry("C&aosFilter", IDM_kCaosFilter); 137 fDisplay->AddEntry("Sao &Catalog", IDM_kCatalog); 155 fDisplay->AddEntry("C&aos Filter", IDM_kCaosFilter); 156 fDisplay->AddEntry("SAO &Catalog", IDM_kCatalog); 157 fDisplay->AddEntry("Stretch", IDM_kStretch); 158 fDisplay->AddSeparator(); 138 159 fDisplay->AddEntry("Starguider", IDM_kStarguider); 139 fDisplay->AddEntry("Stretch", IDM_kStretch); 160 fDisplay->AddEntry("Starguider LED Filter", IDM_kStargCaosFilter); 161 fDisplay->AddEntry("Starguider Find Star", IDM_kStargFindStar); 162 fDisplay->AddEntry("Starguider Analysis", IDM_kStargAnalysis); 163 fDisplay->AddSeparator(); 140 164 if (channel>=0) 141 165 fDisplay->AddPopup("&Input", fChannel); 142 fDisplay->DisableEntry(IDM_kStarguider); 166 fDisplay->DisableEntry(IDM_kStargAnalysis); 167 fDisplay->DisableEntry(IDM_kStargFindStar); 143 168 fDisplay->CheckEntry(IDM_kStretch); 144 169 fDisplay->Associate(this); … … 218 243 { 219 244 fInterpol->CheckEntry(IDM_kInterpol5); 220 fIntRate = 5 ;245 fIntRate = 50; 221 246 } 222 247 else … … 247 272 248 273 fCaosAnalyse = new MGPopupMenu(p); 249 fCaosAnalyse->AddEntry("S&tart Analys e", IDM_kCaosAnalStart);250 fCaosAnalyse->AddEntry("St&op p Analyse", IDM_kCaosAnalStop);274 fCaosAnalyse->AddEntry("S&tart Analysis", IDM_kCaosAnalStart); 275 fCaosAnalyse->AddEntry("St&op Analysis", IDM_kCaosAnalStop); 251 276 fCaosAnalyse->DisableEntry(IDM_kCaosAnalStop); 252 277 // fCaosAnalyse->AddEntry("&Reset Histograms", IDM_kResetHistograms); … … 272 297 fList->Add(fCaOs); 273 298 299 TGLayoutHints *hints2a = 300 new TGLayoutHints(kLHintsCenterX|kLHintsCenterY| 301 kLHintsExpandX|kLHintsExpandY,1,1); 302 fList->Add(hints2a); 303 304 fGStarg = new MGStarg(this, 235); 305 fGStarg->Move(530,596+5); 306 fList->Add(fGStarg); 307 274 308 fCRaDec = new MGCoordinates(this, kETypeRaDec); 275 309 fCRaDec->Move(4, fMenu->GetDefaultHeight()+584); … … 278 312 279 313 fCZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 280 fCZdAz->Move(240+12+ 10, fMenu->GetDefaultHeight()+584);314 fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+581+12); 281 315 AddFrame(fCZdAz); 282 316 fList->Add(fCZdAz); 283 317 284 318 fPZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 285 fPZdAz->Move(240+12+ 10, fMenu->GetDefaultHeight()+630);319 fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+627+2*12); 286 320 AddFrame(fPZdAz); 287 321 fList->Add(fPZdAz); 288 322 323 fDZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 324 fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+673+3*12); 325 AddFrame(fDZdAz); 326 fList->Add(fDZdAz); 327 328 fSZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE); 329 fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+719+4*12); 330 AddFrame(fSZdAz); 331 fList->Add(fSZdAz); 332 289 333 fTPoint = new TGTextButton(this, "TPoint"); 290 fTPoint->Move(4, fMenu->GetDefaultHeight()+ 665);334 fTPoint->Move(4, fMenu->GetDefaultHeight()+722+3*12+25); 291 335 fTPoint->AllowStayDown(kTRUE); 292 336 AddFrame(fTPoint); … … 295 339 fFps = new TGLabel(this, "---fps"); 296 340 fFps->SetTextJustify(kTextRight); 297 fFps->Move(6 33, fMenu->GetDefaultHeight()+578);341 fFps->Move(650-440, fMenu->GetDefaultHeight()+619+13+60+20); 298 342 AddFrame(fFps); 299 343 fList->Add(fFps); … … 301 345 fPosZoom = new TGLabel(this, "----.--d/----.--d (----, ----)"); 302 346 fPosZoom->SetTextJustify(kTextRight); 303 fPosZoom->Move( 620, fMenu->GetDefaultHeight()+678);347 fPosZoom->Move(4, fMenu->GetDefaultHeight()+765); 304 348 AddFrame(fPosZoom); 305 349 fList->Add(fPosZoom); 306 350 307 TGLabel *l = new TGLabel(this, "Arb.-Sky Pos"); 351 fSkyBright = new TGLabel(this, "Sky Brightness: --- "); 352 fSkyBright->SetTextJustify(kTextLeft); 353 fSkyBright->Move(4, fMenu->GetDefaultHeight()+785); 354 AddFrame(fSkyBright); 355 fList->Add(fSkyBright); 356 357 TGLabel *l = new TGLabel(this, "arcsec/pix"); 308 358 l->SetTextJustify(kTextLeft); 309 l->Move( 480+32, fMenu->GetDefaultHeight()+590);359 l->Move(605-400, fMenu->GetDefaultHeight()+619+13+60); 310 360 AddFrame(l); 311 361 fList->Add(l); 312 362 313 l = new TGLabel(this, " arcsec/pix");363 l = new TGLabel(this, "deg"); 314 364 l->SetTextJustify(kTextLeft); 315 l->Move(605 , fMenu->GetDefaultHeight()+619+13);365 l->Move(605-410, fMenu->GetDefaultHeight()+619-10+60); 316 366 AddFrame(l); 317 367 fList->Add(l); 318 368 319 l = new TGLabel(this, " deg");369 l = new TGLabel(this, "Telescope pointing at"); 320 370 l->SetTextJustify(kTextLeft); 321 l->Move( 605, fMenu->GetDefaultHeight()+619-10);371 l->Move(240+12+20, fMenu->GetDefaultHeight()+584-5); 322 372 AddFrame(l); 323 373 fList->Add(l); 324 374 325 l = new TGLabel(this, " Pointing Pos");375 l = new TGLabel(this, "Starguider position"); 326 376 l->SetTextJustify(kTextLeft); 327 l->Move( 480+32, fMenu->GetDefaultHeight()+655);377 l->Move(240+12+20, fMenu->GetDefaultHeight()+630+12-5); 328 378 AddFrame(l); 329 379 fList->Add(l); 330 380 331 const Double_t pixsize = 23.4; 381 l = new TGLabel(this, "Misspointing"); 382 l->SetTextJustify(kTextLeft); 383 l->Move(240+12+20, fMenu->GetDefaultHeight()+676+2*12-5); 384 AddFrame(l); 385 fList->Add(l); 386 387 #ifdef EXPERT 388 l = new TGLabel(this, "Misspointing/FindStar (Experts Only!)"); 389 l->SetTextJustify(kTextLeft); 390 l->Move(240+12+20, fMenu->GetDefaultHeight()+722+3*12-5); 391 AddFrame(l); 392 fList->Add(l); 393 #endif 394 395 const Double_t pixsize = 48.8; // used to be 23.4 332 396 333 397 fSao->SetPixSize(pixsize); … … 339 403 fPixSize = new TGTextEntry(this, txt, IDM_kPixSize); 340 404 fPixSize->SetAlignment(kTextCenterX); 341 fPixSize->Move(547 , fMenu->GetDefaultHeight()+617+13);405 fPixSize->Move(547-410, fMenu->GetDefaultHeight()+617+13+60); 342 406 AddFrame(fPixSize); 343 407 fList->Add(fPixSize); … … 345 409 fAngle = new TGTextEntry(this, " 0", IDM_kAngle); 346 410 fAngle->SetAlignment(kTextCenterX); 347 fAngle->Move(547 , fMenu->GetDefaultHeight()+617-10);411 fAngle->Move(547-410, fMenu->GetDefaultHeight()+617-10+60); 348 412 AddFrame(fAngle); 349 413 fList->Add(fAngle); … … 357 421 // 358 422 fZoomImage = new MGImage(this, kZOOM, kZOOM); 359 fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2); 423 // fZoomImage->Move(768-kZOOM-2, 700-kZOOM-2); 424 fZoomImage->Move(4, 700-kZOOM-2+85); 360 425 AddFrame(fZoomImage); 361 426 fList->Add(fZoomImage); … … 374 439 MapSubwindows(); 375 440 fTPoint->UnmapWindow(); 441 fGStarg->UnmapWindow(); 442 fPZdAz->UnmapWindow(); 443 fDZdAz->UnmapWindow(); 444 fSZdAz->UnmapWindow(); 445 fSkyBright->UnmapWindow(); 376 446 MapWindow(); 377 447 378 IconifyWindow(); 448 449 //IconifyWindow(); 379 450 380 451 //------------------------------------------------------------ … … 386 457 387 458 MStarguider::MStarguider(MObservatory::LocationName_t obs, Int_t channel) 388 : TGMainFrame(gClient->GetRoot(), 768, 740), fCosy(NULL), fOutTp(0), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2) 389 { 459 : TGMainFrame(gClient->GetRoot(), 768, 840), fCosy(NULL), fOutTp(0), fDx((768-kZOOM)/2), fDy((512-kZOOM)/2), fStatus(MDriveCom::kStandby) 460 { 461 390 462 cout << " #### FIXME: Make MCaos Thread safe!" << endl; 391 463 … … 393 465 fRaDec = new RaDec(180, 40); 394 466 467 // fStargLeds = new MStargLeds; 468 // fStargLeds->ReadResources(); 469 395 470 fCaos = new MCaos; 396 471 fCaos->ReadResources(); 472 473 fStargCaos = new MCaos; 474 fStargCaos->ReadResources("stargleds.txt"); 475 fStargCaos->SetMinNumberRings(2); 476 fStargCaos->SetRadii(158,164); 477 478 fStargHistograms = new MStargHistograms(); 397 479 398 480 InitGui(channel); … … 427 509 428 510 delete fCaos; 511 delete fStargCaos; 512 // delete fStargLeds; 513 delete fStargHistograms; 429 514 delete fSao; 430 delete fRaDec; 515 delete fRaDec; 431 516 432 517 if (fOutTp) … … 491 576 case IDM_kCatalog: 492 577 Toggle(fDisplay, IDM_kCatalog); 493 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 494 fDisplay->EnableEntry(IDM_kStarguider); 495 else 496 { 497 fDisplay->UnCheckEntry(IDM_kStarguider); 498 fDisplay->DisableEntry(IDM_kStarguider); 499 } 578 // if (!fDisplay->IsEntryChecked(IDM_kCatalog)) 579 // { 580 // fDisplay->UnCheckEntry(IDM_kStarguider); 581 // fDisplay->DisableEntry(IDM_kStarguider); 582 // } else { 583 // fDisplay->EnableEntry(IDM_kStarguider); 584 // } 585 return kTRUE; 586 587 case IDM_kStargFindStar: 588 Toggle(fDisplay, IDM_kStargFindStar); 589 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) { 590 fSZdAz->MapWindow(); 591 } else { 592 fSZdAz->UnmapWindow(); 593 } 500 594 return kTRUE; 501 595 502 596 case IDM_kStarguider: 503 597 Toggle(fDisplay, IDM_kStarguider); 598 599 if (fDisplay->IsEntryChecked(IDM_kStarguider)) { 600 601 fLastBright = 0xff; 602 603 fDisplay->DisableEntry(IDM_kFindStar); 604 fDisplay->EnableEntry(IDM_kStargAnalysis); 605 606 fPZdAz->MapWindow(); 607 fDZdAz->MapWindow(); 608 fSkyBright->MapWindow(); 609 610 fSao->SetLimitMag(8.3); 611 fIntRate = 125; 612 613 fDisplay->CheckEntry(IDM_kCatalog); 614 fGStarg->MapWindow(); 615 616 const Int_t ch0 = 617 fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1; 618 const Int_t ch1 = 0; 619 620 if (ch0!=ch1) 621 { 622 623 delete fGetter; 624 usleep(150000); // FIX: Device or resource busy. 625 fGetter = new Camera(*this, ch1); 626 ((Camera*)fGetter)->Loop(0); 627 } 628 629 fChannel->CheckEntry(IDM_kChannel1); 630 fChannel->UnCheckEntry(IDM_kChannel2); 631 fChannel->DisableEntry(IDM_kChannel2); 632 633 } else { 634 635 fStatus = MDriveCom::kStandby; 636 637 fPZdAz->UnmapWindow(); 638 fDZdAz->UnmapWindow(); 639 fSkyBright->UnmapWindow(); 640 fGStarg->UnmapWindow(); 641 fChannel->EnableEntry(IDM_kChannel2); 642 fDisplay->EnableEntry(IDM_kFindStar); 643 fDisplay->DisableEntry(IDM_kStargAnalysis); 644 } 645 504 646 gSystem->Unlink("tracking_error.txt"); 647 648 return kTRUE; 649 650 case IDM_kStargAnalysis: 651 Toggle(fDisplay, IDM_kStargAnalysis); 652 if (fDisplay->IsEntryChecked(IDM_kStargAnalysis)) { 653 fStargHistograms->OpenFile(); 654 } else { 655 fStargHistograms->CloseFile(); 656 } 657 658 return kTRUE; 659 660 661 case IDM_kStargHistograms: 662 Toggle(fDisplay, IDM_kStargHistograms); 663 return kTRUE; 664 665 case IDM_kStargLEDFilter: 666 Toggle(fDisplay, IDM_kStargLEDFilter); 505 667 return kTRUE; 506 668 507 669 case IDM_kFilter: 508 Toggle(fDisplay, IDM_kFilter); 509 if (fDisplay->IsEntryChecked(IDM_kFilter)) 510 fDisplay->EnableEntry(IDM_kStarguider); 511 else 512 { 513 fDisplay->UnCheckEntry(IDM_kStarguider); 514 fDisplay->DisableEntry(IDM_kStarguider); 515 } 516 return kTRUE; 670 Toggle(fDisplay, IDM_kFilter); 671 return kTRUE; 672 673 // case IDM_kFilterStarg: 674 // Toggle(fDisplay, IDM_kFilterStarg); 675 // if (fDisplay->IsEntryChecked(IDM_kFilterStarg)) 676 // fDisplay->EnableEntry(IDM_kStarguider); 677 // else 678 // { 679 // fDisplay->UnCheckEntry(IDM_kStarguider); 680 // fDisplay->DisableEntry(IDM_kStarguider); 681 // } 682 // return kTRUE; 517 683 518 684 case IDM_kFindStar: … … 535 701 // fCaos->OpenFile(); 536 702 Toggle(fDisplay, IDM_kCaosFilter); 537 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 703 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) { 538 704 fMenu->AddPopup("&CaOs", fCaOs, NULL); 705 } 539 706 else 540 707 { … … 558 725 } 559 726 fMenu->Resize(fMenu->GetDefaultSize()); 560 MapSubwindows(); 727 MapSubwindows(); // maps everything, but we don't want that 728 fTPoint->UnmapWindow(); 729 fGStarg->UnmapWindow(); 730 fPZdAz->UnmapWindow(); 731 fDZdAz->UnmapWindow(); 732 fSZdAz->UnmapWindow(); 733 fSkyBright->UnmapWindow(); 561 734 MapWindow(); 562 735 return kTRUE; 736 737 case IDM_kStargCaosFilter: 738 Toggle(fDisplay, IDM_kStargCaosFilter); 739 if (fDisplay->IsEntryEnabled(IDM_kStargCaosFilter)) { 740 fDisplay->EnableEntry(IDM_kStargFindStar); 741 } else { 742 fDisplay->DisableEntry(IDM_kStargFindStar); 743 } 744 return kTRUE; 563 745 564 746 case IDM_kCaosPrintLeds: … … 665 847 const Int_t ch0 = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1; 666 848 const Int_t ch1 = mp1==IDM_kChannel1 ? 0 : 1; 667 if (ch0==ch1) 849 850 if (ch0==ch1) 668 851 return kTRUE; 669 852 … … 754 937 // Viewable area (FIXME: AZ) 755 938 // 756 TH2F h("Hist", "dX/dY", 77, -768/2-.5, 768/2+.5, 58, -576/2-.5, 576/2+.5); // 3 757 758 /* 939 // TH2F h("Hist", "dX/dY", 77, -768/2-.5, 768/2+.5, 58, -576/2-.5, 576/2+.5); // 3 940 // chose a bit coarser binning to enhance excess 941 // important: chose binning symmetrical around (0|0)! 942 TH2F h("Hist", "dX/dY", 49, -768/2-8, 768/2+8, 37, -576/2-8, 576/2+8); // 3 943 759 944 TH1F hmag("HistMag", "Mag", 19, 0, 100); 760 945 for (int i=0; i<mag.GetSize(); i++) 761 946 hmag.Fill(mag[i]); 762 */ 763 947 764 948 // 765 949 // Search for matching Magnitudes … … 772 956 773 957 // 774 // Se rach for an excess in the histogram958 // Search for an excess in the histogram 775 959 // 776 960 Int_t mx, my, dummy; … … 783 967 const double dy = h.GetYaxis()->GetBinWidth(my); 784 968 969 #ifdef EXPERT 785 970 cout << setprecision(3); 786 971 cout << "Cut-XY: " << xmax << " +- " << dx << " / " << ymax << " +- " << dy << endl; 972 #endif 787 973 788 974 TGraph g; … … 790 976 { 791 977 if (!(x[i]>xmax-dx && x[i]<xmax+dx && 792 y[i]>ymax-dy && y[i]<ymax+dy &&793 mag[i]>48-15 && mag[i]<48+15))978 y[i]>ymax-dy && y[i]<ymax+dy /*&& 979 mag[i]>48-15 && mag[i]<48+15*/)) 794 980 continue; 795 981 796 g.SetPoint(g.GetN(), x[i], y[i]); 797 } 798 982 g.SetPoint(g.GetN(), x[i], y[i]); 983 } 984 985 #ifdef EXPERT 799 986 cout << "Offset-XY: " << g.GetMean(1) << " +- " << g.GetRMS(1) << " / "; 800 987 cout << g.GetMean(2) << " +- " << g.GetRMS(2) << endl; 988 #endif 801 989 802 990 AltAz pos0 = fSao->CalcAltAzFromPix(768/2, 576/2)*kRad2Deg; … … 817 1005 fout2 << -pos1.Alt() << " " << pos1.Az() << endl; 818 1006 1007 // if (g.GetMean(1)>9 || g.GetMean(2)>9) { 1008 // TFile f1("sguider-highoffset.root","UPDATE"); 1009 // h.Write(); 1010 // hmag.Write(); 1011 // g.Write(); 1012 // f1.Close(); 1013 // } else { 1014 // TFile f1("sguider-niceoffset.root","UPDATE"); 1015 // h.Write(); 1016 // hmag.Write(); 1017 // g.Write(); 1018 // f1.Close(); 1019 1020 1021 // } 1022 819 1023 return ZdAz(-pos1.Alt(), pos1.Az()); 820 1024 } 821 1025 822 void MStarguider::CalcTrackingError(Leds &leds, MStarList &stars)1026 bool MStarguider::CalcTrackingError(Leds &leds, MStarList &stars, ZdAz &d, MTime &t) 823 1027 { 824 1028 const Int_t max = leds.GetEntries(); 825 826 if (stars.GetRealEntries() < 3) 827 { 828 cout << "Sorry, less than 3 stars in FOV!" << endl; 829 return; 830 } 831 832 if (max < 1) 833 { 834 cout << "Sorry, less than 1 detected spot in FOV!" << endl; 835 return; 836 } 1029 if (stars.GetRealEntries() < 3) 1030 { 1031 cout << "Sorry, less than 3 stars in FOV!" << endl; 1032 return kFALSE; 1033 } 1034 if (max < 3) //was 1 1035 { 1036 cout << "Sorry, less than 3 detected spot in FOV!" << endl; 1037 return kFALSE; 1038 } 837 1039 838 1040 stars.Sort(); // Sort by magnitude 839 1041 840 1042 TString str = "data/tracking_"; 841 str += fSao->GetMjd() -52000;1043 str += fSao->GetMjd(); 842 1044 str += ".txt"; 843 1045 … … 848 1050 Int_t num = 0; 849 1051 850 // FIXME: Is pred ifined value 3 a good idea?1052 // FIXME: Is predefined value 3 a good idea? 851 1053 852 1054 MStar *star; 853 1055 MStarListIter NextStar(&stars); 854 while ((star=NextStar()) && num++<max+3) 1056 while ((star=NextStar()) && num++<max+3) 855 1057 { 856 1058 TIter NextSp(&leds); 857 1059 Led *spot=NULL; 858 while ((spot=(Led*)NextSp())) 859 860 const XY dpos(spot->GetX()- star->GetX(), spot->GetY()-star->GetY());861 1060 while ((spot=(Led*)NextSp())) 1061 { 1062 const XY dpos(spot->GetX()-(768-star->GetX()), spot->GetY()-star->GetY()); 1063 862 1064 const Int_t idx = x.GetSize(); 863 1065 864 1066 x.Set(idx+1); 865 1067 y.Set(idx+1); 866 1068 mag.Set(idx+1); 867 1069 868 1070 x.AddAt(dpos.X(), idx); 869 1071 y.AddAt(dpos.Y(), idx); 870 1072 mag.AddAt(spot->GetMag()/star->GetMag(), idx); 871 1073 872 if (fout) 1074 if (fout) { 1075 fout << spot->GetX() << " " 1076 << spot->GetY() << " " 1077 << spot->GetMag() << " " 1078 << star->GetX() << " " 1079 << star->GetY() << " " 1080 << star->GetMag() << " "; 873 1081 fout << x[idx] << " " << y[idx] << " " << mag[idx] << endl; 1082 } 874 1083 } 875 } 876 877 ZdAz d = TrackingError(x, y, mag); 878 1084 } 1085 1086 d = TrackingError(x, y, mag); 1087 fDZdAz->SetCoordinates(d); 1088 879 1089 // 880 1090 // Calculated offsets 881 1091 // 882 1092 1093 #ifdef EXPERT 883 1094 // round= floor(x+.5) 884 1095 cout << "Offset-ZdAz: " << d.Zd()*60 << "' / " << d.Az()*60 << "'" << endl; 885 1096 cout << "Offset-ZdAz: " << d.Zd()/360*16384 << " / " << d.Az()/360*16384 << " (SE) " << endl; 1097 #endif 886 1098 887 1099 // … … 890 1102 ZdAz cpos = fSao->GetZdAz()-d; 891 1103 fPZdAz->SetCoordinates(cpos); 892 } 893 894 void MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t) 1104 1105 return kTRUE; 1106 1107 } 1108 1109 ZdAz MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t, Double_t cut, Double_t box, Double_t scalefactor = 1.0) 895 1110 { 896 1111 // Set search Paremeters (FIXME: Get them from user input!) 897 f.SetCut( 3.5);898 f.SetBox( 70);1112 f.SetCut(cut); // 3.5 1113 f.SetBox(box); // 70 899 1114 900 1115 // Try to find Led in this area … … 902 1117 f.FindStar(leds, (Int_t)center.GetX(), (Int_t)center.GetY()); 903 1118 904 // Check whet er star found1119 // Check whether star found 905 1120 Led *star = (Led*)leds.At(0); 906 1121 if (!star || leds.GetEntries()<1) 907 return ;1122 return ZdAz(.0,.0); 908 1123 909 1124 cout << "Found star @ " << flush; … … 932 1147 933 1148 // Convert from Pixel to millimeter (1pix=2.9mm) 934 x *= 2.58427;935 y *= 2.58427;1149 x *= (2.58427 * scalefactor); 1150 y *= (2.58427 * scalefactor); 936 1151 937 1152 // Correct for abberation. … … 945 1160 cout << "STAR-Offset: " << MTime(-1) << " dZd=" << dzd << "d dAz=" << daz << "d" << endl; 946 1161 1162 ZdAz zdaz(dzd,daz); 1163 947 1164 // Check TPoint data set request 948 1165 if (!fTPoint->IsDown()) 949 return ;1166 return zdaz; 950 1167 fTPoint->SetDown(kFALSE); 951 1168 … … 1011 1228 outrep.UnLock("MStarguider::FindStar"); 1012 1229 } 1230 1231 return zdaz; 1013 1232 } 1014 1233 … … 1042 1261 } 1043 1262 1044 void MStarguider::ProcessFrame(const unsigned long n, byte *img, struct timeval *tm) 1263 void MStarguider::ProcessFrame(const unsigned long n, byte *img, 1264 struct timeval *tm) 1045 1265 { 1046 1266 static unsigned long n0 = n; … … 1066 1286 FilterLed f(img, 768, 576, 2.5); // 2.5 1067 1287 FilterLed f2(cimg, 768, 576); // former color 0xb0 1068 1288 1069 1289 if (fDisplay->IsEntryChecked(IDM_kStretch)) 1070 1290 f.Stretch(); 1071 1291 1072 1292 if (!fWritePictures->IsEntryEnabled(IDM_kStart) && 1073 1293 (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce))) … … 1075 1295 if (fFileType->IsEntryChecked(IDM_kPNG)) 1076 1296 Writer::Png("pix/file", img, tm); 1077 1297 1078 1298 if (fFileType->IsEntryChecked(IDM_kPPM)) 1079 1299 Writer::Ppm("pix/file", img, tm); 1080 1300 1081 1301 if (fWriteType->IsEntryChecked(IDM_kOnce)) 1082 1302 ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStop, 0); 1083 1303 } 1084 1085 MStarList spots;1304 1305 // Visual Filter, whole FOV 1086 1306 if (fDisplay->IsEntryChecked(IDM_kFilter)) 1087 1307 f.Execute(); 1088 1308 1309 /* ---------------------------------- 1310 // Visual StarFilter for Starguider 1311 if (fDisplay->IsEntryChecked(IDM_kFilterStarg) && !fDisplay->IsEntryChecked(IDM_kStarguider)) { 1312 f.SetBox(230); 1313 f.AddIgnoreRegion(295,112,384,204); 1314 f.Execute(530, 292); 1315 } 1316 ------------------------------------- */ 1317 1318 // Find Center of Camera for Caos and Tpoints 1089 1319 Ring center(768/2, 576/2); 1090 1320 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) … … 1095 1325 if (fCosy) 1096 1326 pos = fCosy->GetPointingPos(); 1097 1098 center = fCaos->Run(img, printl, printr, pos, t);1099 } 1100 1327 center = fCaos->Run(img, printl, printr, pos, t, 50, 3.0); 1328 } 1329 1330 // Find Star at Center---for Tpoint Procedure 1101 1331 if (fDisplay->IsEntryChecked(IDM_kFindStar)) 1102 FindStar(f, f2, center, t);1332 ZdAz zdaz = FindStar(f, f2, center, t, 3.5, 70); 1103 1333 1104 1334 byte zimg[kZOOM*kZOOM]; … … 1111 1341 if (fCosy) 1112 1342 { 1113 byte simg[(768/2-1)*(576/2-1)]; 1114 for (int y=0; y<576/2-1; y++) 1115 for (int x=0; x<768/2-1; x++) 1116 simg[x+y*(768/2-1)] = ((unsigned int)img[2*x+2*y*768]+img[2*x+2*y*768+1]+img[2*x+2*(y+1)*768]+img[2*x+2*(y+1)*768+1])/4; 1117 1118 fCosy->GetWin()->GetImage()->DrawImg(simg); 1119 } 1120 1343 byte simg[(768/2-1)*(576/2-1)]; 1344 for (int y=0; y<576/2-1; y++) 1345 for (int x=0; x<768/2-1; x++) 1346 simg[x+y*(768/2-1)] = ((unsigned int)img[2*x+2*y*768]+img[2*x+2*y*768+1]+img[2*x+2*(y+1)*768]+img[2*x+2*(y+1)*768+1])/4; 1347 1348 fCosy->GetWin()->GetImage()->DrawImg(simg); 1349 } 1350 1351 // Find Center of Camera in Starfield Camera picture 1352 1353 Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px] 1354 ZdAz sgcenterzdaz(0, 0); // Center of camera in SG picture [deg] 1355 // (0,0)_deg is at (53.2, 293.6)_px 1356 ZdAz star(0, 0); // Star on curtain in [deg] 1357 1358 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 1359 { 1360 ZdAz pos; 1361 if (fCosy) 1362 pos = fCosy->GetPointingPos(); 1363 sgcenter = 1364 fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 30, 3.0); // [px] 1365 const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px] 1366 sgcenterzdaz.Zd((sgcenter.GetY()-293.6) * pixsize /3600 ); 1367 sgcenterzdaz.Az((sgcenter.GetX()-53.2) * pixsize /3600 ); 1368 #ifdef EXPERT 1369 cout << "- LEDs imply offset of Zd=" 1370 << sgcenter.GetX()-53.2 << "pix Az=" 1371 << sgcenter.GetY()-293.6<< "pix" << endl; 1372 #endif 1373 if (fDisplay->IsEntryChecked(IDM_kStargFindStar)) { 1374 star = FindStar(f, f2, sgcenter, t, 4.5, 30, 267/161.9); // [deg] 1375 #ifdef EXPERT 1376 cout << "- Star is found to be off Zd=" << star.Zd()*60 << "' Az=" 1377 << star.Az()*60 << "'" << endl; 1378 #endif 1379 fSZdAz->SetCoordinates(star); // Misspointing found from Camera 1380 } 1381 } 1382 1383 // we calculate the offset given by the three ETH Leds visible to 1384 // the guide camera 1385 // This is an (inferior, obsolete) alternative to the StarCaosFilter 1386 // Led offset; 1387 // if (fDisplay->IsEntryChecked(IDM_kStargLEDFilter)) 1388 // fStargLeds->Run(img,offset); 1389 1390 // Position corresponding to the camera center (53.2, 293.6) 1391 Ring skycenter(392, 318); 1392 // MStarList spots; 1393 1394 // we obtain a list of stars in the FOV from the SAO catalog 1121 1395 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1122 1396 { 1123 MTime time(*tm); 1124 1125 XY xy = fCRaDec->GetCoordinates(); 1126 fRaDec->Set(xy.X()*360/24, xy.Y()); 1127 1128 UpdatePosZoom(); 1129 1130 /* 1131 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 1132 { 1133 Leds leds; 1134 f.Execute(leds); 1135 1136 cout << "Found: " << leds.GetEntries() << " stars." << endl; 1137 1138 CalcTrackingError(leds, stars); 1139 } 1140 */ 1141 1142 // Always call SetMjd first! 1143 fSao->SetPointing(time.GetMjd(), *fRaDec); 1144 fCZdAz->SetCoordinates(fSao->GetZdAz()); 1145 1146 MStarList stars; 1147 fSao->CalcStars(stars); 1148 fSao->DrawStars(stars, cimg); 1149 } 1150 1397 MTime time(*tm); 1398 1399 XY xy = fCRaDec->GetCoordinates(); 1400 fRaDec->Set(xy.X()*360/24, xy.Y()); 1401 1402 UpdatePosZoom(); 1403 1404 // Always call SetMjd first! 1405 fSao->SetPointing(time.GetMjd(), *fRaDec); 1406 fCZdAz->SetCoordinates(fSao->GetZdAz()); 1407 1408 MStarList stars; 1409 fSao->SetBox(230); // Region of interest around center 1410 1411 // very careful: If center of camera cannot be determined 1412 // sgcenter jumps to (0,0) 1413 double sgcenteroffsetX = 0.0; 1414 double sgcenteroffsetY = 0.0; 1415 if ((double)sgcenter.GetX() > 0.0 && (double)sgcenter.GetY() > 0.0) { 1416 sgcenteroffsetX = sgcenter.GetX()-53.2; 1417 sgcenteroffsetY = sgcenter.GetY()-293.6; 1418 } 1419 1420 // we obtain stars in the effective star FOV and draw them. 1421 // coordinates are video frame coords. 1422 // We determine the ideal starfield using camera sagging info 1423 // from the LEDs 1424 1425 //cout << sgcenteroffsetX << " " << sgcenteroffsetY << endl; 1426 1427 fSao->CalcStars(stars, 530, 292, 1428 -8+2-3+sgcenteroffsetX, //x: star<spot =>subs 1429 31.5-3+sgcenteroffsetY); //y: star<spot =>subs? 1430 1431 fSao->DrawStars(stars, cimg); 1432 1433 // There are two corrections to the misspointing 1434 // - Sagging of the camera as measured with the LEDs 1435 // - Star not ideally centered on MAGIC Camera 1436 1437 // Next we evaluate the offset given by the LEDs. This we obtain 1438 // in Zd/Az and add it to the tracking error. 1439 1440 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 1441 { 1442 Leds spots; 1443 f.SetBox(230); 1444 double bright; 1445 f.ExecuteAndMark(spots, 530, 292, bright); 1446 MString txt; 1447 txt.Print("Sky Brightness: %.1f", bright); 1448 fSkyBright->SetText(txt); 1449 1450 ULong_t color; 1451 gClient->GetColorByName("Green", color); 1452 if (bright> 60) gClient->GetColorByName("Yellow", color); 1453 if (bright> 85) gClient->GetColorByName("Orange", color); 1454 if (bright> 95) gClient->GetColorByName("Red", color); 1455 fSkyBright->SetBackgroundColor(color); 1456 1457 bool rc = CalcTrackingError(spots, stars, fD, t); 1458 1459 if (rc && (bright <= 1.75* fLastBright) && (bright < 110)) { 1460 fStatus = MDriveCom::kMonitoring; 1461 } else { 1462 fStatus = MDriveCom::kError; 1463 } 1464 1465 if (fCosy) 1466 fPos = fCosy->GetPointingPos(); 1467 1468 if (fDisplay->IsEntryChecked(IDM_kStargAnalysis)) 1469 fStargHistograms->Fill(spots, stars, fD, 1470 fSao->GetZdAz(), sgcenter, sgcenterzdaz, 1471 star, bright, fPos, t); 1472 1473 fLastBright = bright; 1474 1475 } //kStarguider 1476 1477 f2.DrawCircle(skycenter, 2.0, 0x0a); 1478 1479 f2.DrawCircle(skycenter, 7.4, 0x0a); //0.1deg 1480 1481 f2.DrawCircle(skycenter, 2.06*.5*74.0, 0x0a); 1482 f2.DrawCircle(skycenter, 2.32*.5*74.0, 0x0a); 1483 f2.DrawCircle(skycenter, 3.50*.5*74.0, 0x0a); 1484 f2.DrawCircle(skycenter, 3.84*.5*74.0, 0x0a); 1485 1486 } //CalcStars 1487 1488 if (fCosy) { 1489 MDriveCom &com = *fCosy->GetDriveCom(); 1490 com.SendStargReport(fStatus, fD); // Report 1491 } 1492 1493 // Draw Circles around center of Camera 1151 1494 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 1152 1495 { 1153 1496 f2.DrawCircle(center, 0x0a); 1154 f2.DrawCircle(center, 5.0, fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0); 1497 f2.DrawCircle(center, 5.0, 1498 fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0); 1155 1499 f2.DrawCircle(center, 115.0, 0x0a); 1156 1500 f2.DrawCircle(center, 230.0, 0x0a); … … 1158 1502 } 1159 1503 1160 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1161 { 1162 fSao->PaintImg(cimg, 768, 576); 1163 1164 const float r = 60*60/fSao->GetPixSize(); 1165 1166 f2.DrawCircle(0.5*r, 0x0a); 1167 f2.DrawCircle(1.0*r, 0x0a); 1168 f2.DrawCircle(1.5*r, 0x0a); 1169 } 1504 if (fDisplay->IsEntryChecked(IDM_kStargCaosFilter)) 1505 { 1506 f2.DrawCircle(sgcenter, 0x0a); 1507 f2.DrawCircle(sgcenter, 5.0, 1508 fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0); 1509 } 1510 1511 // if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1512 // { 1513 // fSao->PaintImg(cimg, 768, 576); 1514 // const float r = 60*60/fSao->GetPixSize(); 1515 // f2.DrawCircle(0.5*r, 0x0a); 1516 // f2.DrawCircle(1.0*r, 0x0a); 1517 // f2.DrawCircle(1.5*r, 0x0a); 1518 // } 1170 1519 1171 1520 if (fDisplay->IsEntryChecked(IDM_kCaosFilter) || … … 1183 1532 { 1184 1533 // FIXME: Necessary? 1185 1534 fSao->Now(); 1186 1535 AltAz aa = fSao->CalcAltAzFromPix(fDx, fDy)*kRad2Deg; 1187 1188 1536 if (aa.Az()<0) 1189 1537 aa.Az(aa.Az()+360); 1190 1191 1538 txt.Print("%.1fd/%.1fd (%d, %d)", -aa.Alt(), aa.Az()-180, fDx, fDy); 1192 1539 } 1193 1540 else 1194 1541 txt.Print("(%d, %d)", fDx, fDy); 1195 1196 1542 fPosZoom->SetText(txt); 1197 1543 } … … 1221 1567 return kTRUE; 1222 1568 } 1569 1570 void MStarguider::Print(TString &str, Double_t deg) const 1571 { 1572 Char_t sgn; 1573 UShort_t d, m, s; 1574 1575 MAstro::Deg2Dms(deg, sgn, d, m, s); 1576 1577 MString txt; 1578 str += txt.Print("%c %03d %02d %03d ", sgn, d, m, s); 1579 } -
trunk/MagicSoft/Cosy/main/MStarguider.h
r4105 r4865 1 1 #ifndef COSY_MStarguider 2 2 #define COSY_MStarguider 3 4 #ifndef ROOT_TGFrame5 #include <TGFrame.h>6 #endif7 3 8 4 #include "PixClient.h" … … 23 19 class TGLabel; 24 20 class TGButton; 21 class TString; 25 22 26 23 class TTimer; … … 39 36 class MCosy; 40 37 class MCaos; 38 // class MStargLeds; 39 class MStargHistograms; 40 class MGStarg; 41 41 class FilterLed; 42 42 class Ring; … … 54 54 MGImage *fImage; 55 55 MGImage *fZoomImage; 56 57 MGStarg *fGStarg; 56 58 57 59 MGPopupMenu *fDisplay; … … 74 76 75 77 MGCoordinates *fPZdAz; 78 MGCoordinates *fDZdAz; 79 MGCoordinates *fSZdAz; 76 80 77 81 TGTextEntry *fPixSize; … … 80 84 TGLabel *fFps; 81 85 TGLabel *fPosZoom; 86 TGLabel *fSkyBright; 82 87 83 88 TGButton *fTPoint; 84 89 90 ZdAz fPos; 91 ZdAz fD; 92 85 93 StarCatalog *fSao; 86 94 MCosy *fCosy; 87 95 MCaos *fCaos; 88 96 MCaos *fStargCaos; 97 // MStargLeds *fStargLeds; 98 MStargHistograms *fStargHistograms; 99 89 100 RaDec *fRaDec; 90 101 … … 100 111 int fWrtRate; 101 112 113 UInt_t fStatus; 114 Double_t fLastBright; 115 102 116 void SetPixSize(const double pixsize); 103 117 void Toggle(MGPopupMenu *p, UInt_t id); 104 118 //void GetCoordinates(); 105 void CalcTrackingError(Leds &, MStarList &); 119 bool CalcTrackingError(Leds &, MStarList &, ZdAz &, MTime &); 120 //void CalcTrackingError(Leds &, MStarList &); 106 121 ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag) const; 107 122 bool Interpolate(const unsigned long n, byte *img) const; 108 void FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t); 123 ZdAz FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t, 124 Double_t cut, Double_t box, Double_t scalefactor); 109 125 110 126 //void InitHists(); … … 145 161 void ProcessFrame(const unsigned long n, byte *img, struct timeval *tm); 146 162 163 void Print(TString &str, Double_t deg) const; 164 147 165 ClassDef(MStarguider, 0) 148 166 }; 149 167 150 168 #endif 169 170 -
trunk/MagicSoft/Cosy/main/MainLinkDef.h
r4105 r4865 7 7 #pragma link C++ class MCosy; 8 8 #pragma link C++ class MStarguider+; 9 #pragma link C++ class MStargHistograms+; 9 10 10 11 #pragma link C++ class MBending; -
trunk/MagicSoft/Cosy/main/Makefile
r4105 r4865 34 34 SRCFILES = MBending.cc \ 35 35 MStarguider.cc \ 36 MStargHistograms.cc \ 36 37 MPointing.cc \ 37 38 MTracking.cc \ -
trunk/MagicSoft/Cosy/prepos_magic.txt
r2518 r4865 1 100.045 -8.869999999Camera Access1 98.30000000 -10.0133333 Camera Access 2 2 61.23817667 0 Celestial Pole 3 9 4.125 -9.23Park3 93.91666667 -10.0133333 Park 4 4 95.58527778 151.018055556 Roque Lamp 5 5 4 0 Zenith -
trunk/MagicSoft/Cosy/starg.cc
r4076 r4865 10 10 //VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; 11 11 12 TROOT root("GUI", "GUI test environ ement"); //, initfuncs);12 TROOT root("GUI", "GUI test environment"); //, initfuncs); 13 13 14 14 int main(int argc, char **argv) -
trunk/MagicSoft/Cosy/stars.txt
r4076 r4865 4 4 12 56 11 -05 47 22 3C279 (17.75) 5 5 12 54 02 55 57 35 Alioth (1.77) 6 19 30 43 27 57 34 Albiero (3.08) 6 7 00 08 23 29 05 26 Alpha Andromedae (2.1) 7 8 02 07 10 23 27 45 Alpha Aries (2.00) … … 33 34 05 55 10 07 24 25 Betelgeuse (0.5) 34 35 22 02 43 42 16 40 BL-Lac (14.5) 35 05 1 541 45 59 53 Capella (0.08)36 05 16 41 45 59 53 Capella (0.08) 36 37 00 09 11 59 08 59 Caph (2.27) 37 38 12 59 49 27 58 50 Coma Cluster (10.70) … … 69 70 06 33 54 17 46 48 Geminga 70 71 19 30 42 51 43 47 Iota2 Cygni (3.8) 72 22 07 00 25 20 42 Iota Pegasi (3.49) 71 73 19 17 06 53 22 07 Kappa Cygni (3.9) 72 74 18 24 10 -34 23 05 Kaus Australis (1.85) … … 88 90 15 02 22 -41 53 48 SN-1006 89 91 13 25 13 -11 09 41 Spica (0.98) 92 19 46 15 10 36 48 Tarazed (2.72) 90 93 20 11 18 -00 49 17 Theta Aquilae (3.2) 91 94 17 37 19 -42 59 52 Theta Scorpionis (1.87) 95 15 44 16 6 25 32 Unukalhay (2.65) 92 96 18 36 56 38 47 01 Vega (0.03) 93 97 19 05 25 13 51 48 Zeta Aquilae (3.0) -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
r4105 r4865 90 90 } 91 91 92 bool MCeCoCom::Send(const char *cmd, const char *str )92 bool MCeCoCom::Send(const char *cmd, const char *str, bool force=kFALSE) 93 93 { 94 94 MTime t; … … 113 113 str); 114 114 115 const bool rc = MTcpIpIO::Send(msg );115 const bool rc = MTcpIpIO::Send(msg, force); 116 116 fComStat = rc ? kNoCmdReceived : kComProblem; 117 117 return rc; -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h
r4105 r4865 49 49 } 50 50 51 bool Send(const char *cmd, const char *str );51 bool Send(const char *cmd, const char *str, bool force); 52 52 void SetStatus(Byte_t s) { fStatus=s; } 53 53 -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
r4105 r4865 182 182 str += txt.Print("%08.3f", er.Az()); 183 183 184 return Send("DRIVE-REPORT", str );184 return Send("DRIVE-REPORT", str, kFALSE); 185 185 } 186 186 187 187 bool MDriveCom::SendStatus(const char *stat) 188 188 { 189 return Send("DRIVE-STATUS", stat); 190 } 189 return Send("DRIVE-STATUS", stat, kFALSE); 190 } 191 192 bool MDriveCom::SendStargReport(UInt_t stat, ZdAz miss) 193 { 194 195 // miss [rad] 196 const MTime t(-1); 197 198 miss *= kRad2Deg; 199 200 // Set status flag 201 if (stat&kError) 202 SetStatus(0); 203 if (stat&kStopped) 204 SetStatus(1); 205 if (stat&kStandby) 206 SetStatus(2); 207 if (stat&kMonitoring) 208 SetStatus(4); 209 210 MString txt; 211 212 TString str; 213 str += txt.Print("%05.3f ", miss.Zd()); 214 str += txt.Print("%05.3f", miss.Az()); 215 216 return Send("STARG-REPORT", str, kTRUE); 217 218 } 219 220 221 222 223 -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.h
r4076 r4865 31 31 kTracking = 0x04, 32 32 kStopping = 0x08, 33 kStopped = 0x10 33 kStopped = 0x10, 34 kStandby = 0x20, 35 kMonitoring = 0x40 34 36 }; 35 37 36 38 MDriveCom(MsgQueue *q, MLog &out=gLog) : MCeCoCom("DRIVE-REPORT", out), fQueue(q) {} 37 39 38 40 bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er); 41 bool SendStargReport(UInt_t stat, ZdAz miss); 39 42 bool SendStatus(const char *stat); 40 43 }; 41 44 42 45 #endif 46 47 48 49 50 51 52 53 54 55 56 -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
r4256 r4865 67 67 } 68 68 69 bool MTcpIpIO::Send(const char *msg) 70 { 69 bool MTcpIpIO::Send(const char *msg, bool force=kFALSE) 70 { 71 71 72 const MTime t(-1); 72 73 73 if ((double)t-(double)fTime<0.001*fSendInterval) 74 return true; 74 if ((double)t-(double)fTime<0.001*fSendInterval && !force) 75 return true; 76 75 77 76 78 if (lout.Lock("MTcpIpIO::Send")) … … 103 105 cout << "Tx: " << msg << flush; 104 106 #endif 107 105 108 return true; 106 109 } -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h
r4076 r4865 32 32 ~MTcpIpIO(); 33 33 34 virtual bool Send(const char *msg );34 virtual bool Send(const char *msg, bool force); 35 35 virtual bool InterpreteStr(TString str); 36 36 -
trunk/MagicSoft/Cosy/videodev/FilterLed.cc
r4699 r4865 227 227 228 228 Execute(leds, xc, yc); 229 229 230 230 // Mark Stars in image 231 231 for (int i=first; i<leds.GetEntriesFast(); i++) … … 233 233 } 234 234 235 236 void FilterLed::ExecuteAndMark(Leds &leds, int xc, int yc, double &bright) const 237 { 238 const Int_t first = leds.GetEntriesFast(); 239 240 Execute(leds, xc, yc, bright); 241 242 // Mark Stars in image 243 for (int i=first; i<leds.GetEntriesFast(); i++) 244 MarkPoint(leds(i)); 245 } 246 235 247 void FilterLed::Execute(int xc, int yc) const 236 248 { … … 240 252 241 253 void FilterLed::Execute(Leds &leds, int xc, int yc) const 254 { 255 double bright; 256 Execute(leds, xc, yc, bright); 257 } 258 259 260 void FilterLed::Execute(Leds &leds, int xc, int yc, double &bright) const 242 261 { 243 262 int x0 = xc-fBox; … … 269 288 sq /= wx*hy; 270 289 290 bright=sum; 291 292 271 293 // 254 because b<=max and not b<max 272 294 const double sdev = sqrt(sq-sum*sum); … … 345 367 346 368 RemoveTwinsInterpol(leds, first, 5); 369 370 347 371 } 348 372 -
trunk/MagicSoft/Cosy/videodev/FilterLed.h
r4076 r4865 22 22 void GetMinMax(const int offset, byte *min, byte *max) const; 23 23 int GetMeanPosition(const int x, const int y, const int box) const; 24 int GetMeanPosition(const int x, const int y, const int box, float &mx, float &my, unsigned int &sum) const; 24 int GetMeanPosition(const int x, const int y, const int box, 25 float &mx, float &my, unsigned int &sum) const; 25 26 void RemoveTwinsInterpol(Leds &leds, Int_t first, Double_t radius) const; 26 27 void DrawBox(const int x1, const int y1, … … 30 31 public: 31 32 FilterLed(byte *img, int w, int h, double cut=2.5) 32 33 : fImg(img), fW(w), fH(h), fBox(w>h?w:h), fCut(cut) 33 34 { 34 35 } 35 36 36 37 FilterLed(byte *img, int w, int h, int box, double cut=2.5) 37 38 : fImg(img), fW(w), fH(h), fBox(box), fCut(cut) 38 39 { 39 40 } 40 41 41 42 void SetBox(int box) { fBox = box; } 42 void SetCut(float cut) { fCut = cut; } 43 43 void SetCut(float cut) { fCut = cut; } 44 44 void FindStar(Leds &leds, int xc, int yc) const; 45 45 void Execute(Leds &leds, int xc, int yc, double &bright) const; 46 46 void Execute(Leds &leds, int xc, int yc) const; 47 47 void Execute(Leds &leds) const { Execute(leds, fW/2, fH/2); } 48 48 void ExecuteAndMark(Leds &leds, int xc, int yc) const; 49 void ExecuteAndMark(Leds &leds, int xc, int yc, double &bright) const; 49 50 void ExecuteAndMark(Leds &leds) const { ExecuteAndMark(leds, fW/2, fH/2); } 50 51 void Execute(int xc, int yc) const;
Note:
See TracChangeset
for help on using the changeset viewer.