Changeset 4105 for trunk/MagicSoft/Cosy
- Timestamp:
- 05/20/04 05:01:03 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 2 deleted
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r4076 r4105 1 1 -*-*- END -*-*- 2 2004/05/15 - Thomas Bretz (La Palma) 3 4 * Makefile: 5 - added MGMenu links 6 7 * bending_magic.txt: 8 - last calculated pointing model (stil has the hysteresis 9 problem) 10 11 * cosy.cc: 12 - moved camera stuff to MStarguider 13 - added channel selection 14 15 * base/BaseLinkDef.h: 16 - updated 17 18 * base/MString.[h,cc]: 19 - removed (now in Mars) 20 21 * base/MThread.h, candrv/network.h, candrv/nodedrv.h, 22 candrv/vmodican.h, devdrv/macs.h, videodev/Camera.h: 23 - changed ifndef 24 25 * base/Makefile: 26 - updated 27 28 * candrv/nodedrv.cc: 29 - added cast to MTime 30 31 * candrv/vmodican.cc: 32 - changed priority from 10 to 1 33 34 * caos/Led.cc, caos/Ring.cc: 35 - changed Form to MString 36 37 * caos/Makefile: 38 - added include base 39 40 * caos/Ring.[h,cc]: 41 - added arguments to constructor 42 43 * catalog/CatalogLinkDef.h, catalog/Makefile: 44 - removed SaoFile 45 46 * catalog/Slalib.cc: 47 - removed some obsolete code 48 49 * catalog/StarCatalog.cc: 50 - added a size check for the bitmap 51 52 * devdrv/macs.cc: 53 - no guarding for the moment 54 55 * devdrv/shaftencoder.[h,cc]: 56 - added code to communicate with the Macs 57 58 * gui/GuiLinkDef.h, gui/Makefile: 59 - removed MGVelocity 60 61 * gui/MGCosy.[h,cc]: 62 - added weather data to display 63 - added image of the camera to window 64 - removed velocity from window 65 - replaced Form by MString 66 67 * main/MBending.cc: 68 - changed handling in GetAnAw - Hopefully correct??? 69 the old handling gave problems 70 71 * main/MCosy.[h,cc]: 72 - added SetTrackingPosRE 73 - display interpolated position when tracking 74 - added SetMotor calls 75 76 * main/MStarguider.[h,cc]: 77 - added code to find star in the display 78 - added corresponding menus 79 - added code to support more than one ccd channel 80 81 * main/MTracking.[h,cc]: 82 - complete change to the algorithm. The position which is 83 send to CC need still some investigations. For more information 84 look at the code. The main difference is that the motor 85 encoders are taken better into account which fixes the SE 86 handling on the elevation axis 87 88 * main/MainLinkDef.h, main/Makefile: 89 - added MPointing 90 - added MTracking 91 92 * tcpip/MCeCoCom.[h,cc]: 93 - added alarm counter 94 95 * tcpip/MTcpIpIO.cc: 96 - do not write to output file if stream is locked 97 98 * tpoint/gui.C: 99 - fixed display so that it perfectly shows north, east, ... 100 - added error for residual 101 - simplified residual algorithm 102 - read new files 103 - changed displaying deviations a bit 104 - display result in the display (preliminary) 105 - set gIgnoreLevel to suppress strange color warnings 106 107 * videodev/FilterLed.cc: 108 - use MGMap for drawing... 109 110 111 2 112 2004/05/15 - Thomas Bretz (La Palma) 3 113 -
trunk/MagicSoft/Cosy/Makefile
r4076 r4105 143 143 @ln -sf ../../Mars/mbase/MGMap.h base/MGMap.h 144 144 @ln -sf ../../Mars/mbase/MGMap.cc base/MGMap.cc 145 @ln -sf ../../Mars/mbase/MGMenu.h base/MGMenu.h 146 @ln -sf ../../Mars/mbase/MGMenu.cc base/MGMenu.cc 145 147 @ln -sf ../../Mars/mgeom/MGeomMirror.h base/MGeomMirror.h 146 148 @ln -sf ../../Mars/mgeom/MGeomMirror.cc base/MGeomMirror.cc -
trunk/MagicSoft/Cosy/base/BaseLinkDef.h
r2615 r4105 8 8 #pragma link C++ class MLog; 9 9 #pragma link C++ class MStar+; 10 #pragma link C++ class MGMap+; 10 11 #pragma link C++ class MGList+; 11 12 #pragma link C++ class MParContainer+; 13 12 14 #pragma link C++ class MObservatory+; 15 #pragma link C++ class MVector3+; 16 17 #pragma link C++ class MString+; 13 18 #pragma link C++ class MAstro+; 19 #pragma link C++ class MAstroSky2Local+; 20 #pragma link C++ class MAstroCatalog+; 21 #pragma link C++ class MAstroCamera+; 22 23 #pragma link C++ class MGeomPix+; 24 #pragma link C++ class MGeomCam+; 25 #pragma link C++ class MGeomCamMagic+; 26 #pragma link C++ class MGeomMirror+; 27 28 #pragma link C++ class MHCamera+; 29 #pragma link C++ class MH+; 30 #pragma link C++ class MBinning+; 31 #pragma link C++ class MCamEvent+; 32 #pragma link C++ class MHexagon+; 14 33 15 34 #pragma link C++ class MTime+; -
trunk/MagicSoft/Cosy/base/MThread.h
r1273 r4105 1 #ifndef MTHREAD_H2 #define MTHREAD_H1 #ifndef COSY_MThread 2 #define COSY_MThread 3 3 4 4 #ifdef __CINT__ -
trunk/MagicSoft/Cosy/base/Makefile
r2615 r4105 31 31 .SUFFIXES: .c .cc .cxx .h .hxx .o 32 32 33 SRCFILES = File.cc \ 34 MStopwatch.cc \ 33 SRCFILES = MStopwatch.cc \ 35 34 MParContainer.cc \ 36 35 MThread.cc \ 37 36 MTimeout.cc \ 38 37 MTime.cc \ 39 M Astro.cc \38 MString.cc \ 40 39 MStar.cc \ 41 40 MStarList.cc \ 41 MAstro.cc \ 42 MAstroCatalog.cc \ 43 MAstroCamera.cc \ 44 MAstroSky2Local.cc \ 45 MGeomMirror.cc \ 46 MGeomPix.cc \ 47 MGeomCam.cc \ 48 MGeomCamMagic.cc \ 49 MGMap.cc \ 50 MGMenu.cc \ 51 MH.cc \ 52 MBinning.cc \ 53 MHexagon.cc \ 54 MCamEvent.cc \ 55 MHCamera.cc \ 42 56 msgqueue.cc \ 43 57 MLog.cc \ … … 49 63 MGList.h \ 50 64 MTime.h \ 65 MString.h \ 51 66 MAstro.h \ 67 MAstroSky2Local.h \ 68 MAstroCatalog.h \ 69 MAstroCamera.h \ 70 MGeomMirror.h \ 71 MGeomPix.h \ 72 MGeomCam.h \ 73 MGeomCamMagic.h \ 74 MHCamera.h \ 75 MBinning.h \ 76 MH.h \ 77 MGMap.h \ 78 MGMenu.h \ 79 MHexagon.h \ 80 MCamEvent.h \ 52 81 MLog.h \ 53 82 MLogManip.h \ -
trunk/MagicSoft/Cosy/bending_magic.txt
r2751 r4105 1 MAGIC1 2003/12/29 19:15:38.4331 MAGIC1 15.05.2004 23:25:21.338 2 2 S 00 000000 000000 0000000 3 IA 502.5 2368 0.0343567964 IE -9.05 64239 0.0198958783 IA 502.51471 0.0072972921 4 IE -9.0539559 0.0050128431 5 5 FLOP 0 0 6 6 AN 0 0 7 AW 0 08 NPAE 0.077561439 0.0388244447 AW -0.066794332 0.005947689 8 NPAE 0 0 9 9 CA 0 0 10 10 TF 0 0 11 11 TX 0 0 12 12 ECES 0 0 13 ACES 0 013 ACES -0.021708338 0.0089723026 14 14 ECEC 0 0 15 ACEC 0 015 ACEC -0.072368751 0.011236351 16 16 NRX 0 0 17 17 NRY 0 0 -
trunk/MagicSoft/Cosy/candrv/network.h
r1727 r4105 1 #ifndef NETWORK_H2 #define NETWORK_H1 #ifndef COSY_Network 2 #define COSY_Network 3 3 4 #ifndef COSY_CanOpen 4 5 #include "canopen.h" 6 #endif 7 #ifndef COSY_NodeDrv 5 8 #include "nodedrv.h" 9 #endif 6 10 7 11 class Network : public CanOpen -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r2615 r4105 48 48 #include <iostream.h> 49 49 50 #include <TTimer.h>50 //#include <TTimer.h> 51 51 52 52 #include "MTime.h" … … 530 530 const Double_t t0 = t+fGuardTime; 531 531 532 while (!HasStopFlag() && t<t0 &&t<fTimeoutTime)532 while (!HasStopFlag() && (double)t<t0 && (double)t<fTimeoutTime) 533 533 { 534 534 usleep(5); … … 540 540 //cout << "-g-> " << (Long_t)((t-t0)*1000)<< endl; 541 541 542 if ( t<fTimeoutTime)542 if ((double)t<fTimeoutTime) 543 543 continue; 544 544 -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r2518 r4105 1 #ifndef NODEDRV_H2 #define NODEDRV_H1 #ifndef COSY_NodeDrv 2 #define COSY_NodeDrv 3 3 4 #ifndef ROOT_TString 4 5 #include <TString.h> 6 #endif 5 7 8 #ifndef COSY_Log 6 9 #include "log.h" 10 #endif 7 11 8 12 #ifdef __CINT__ -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r4076 r4105 934 934 // and switch the can bus communication on 935 935 // 936 VmodIcan::VmodIcan(const char *dev, const int baud, MLog &out) : Log(out), MThread(false, 1 0)//: CanDriver(dev, baud)936 VmodIcan::VmodIcan(const char *dev, const int baud, MLog &out) : Log(out), MThread(false, 1)//: CanDriver(dev, baud) 937 937 { 938 938 // -
trunk/MagicSoft/Cosy/candrv/vmodican.h
r1727 r4105 1 #ifndef VMODICAN_H2 #define VMODICAN_H1 #ifndef COSY_VmodIcan 2 #define COSY_VmodIcan 3 3 4 4 #include <pthread.h> … … 16 16 #endif 17 17 18 #ifndef COSY_MThread 18 19 #include "MThread.h" 20 #endif 19 21 20 22 class Message; -
trunk/MagicSoft/Cosy/cosy.cc
r4076 r4105 13 13 14 14 #define EXPERT 15 #define HAVE_CAMERA16 15 17 16 #define clog(txt) \ … … 42 41 if (arg=="-0") 43 42 channel = 0; 43 if (arg=="-c") 44 channel = -1; 44 45 } 45 46 … … 96 97 cosy->Start(); 97 98 98 clog("- Starting Camera."); 99 #ifdef HAVE_CAMERA 100 MStarguider *client=new MStarguider(MObservatory::kMagic1, channel); 99 MStarguider *client=0; 100 if (channel>=0) 101 { 102 clog("- Starting Camera."); 103 client=new MStarguider(MObservatory::kMagic1, channel); 104 cosy->SetStarguider(client); 105 client->SetCosy(cosy); 106 } 101 107 102 cosy->SetStarguider(client);103 client->SetCosy(cosy);104 #endif105 108 clog("- Starting mainloop."); 106 109 #ifndef EXPERT … … 108 111 #endif 109 112 app->Run(kTRUE); 110 #ifdef HAVE_CAMERA111 client->SetCosy(NULL);112 cosy->SetStarguider(NULL);113 113 114 clog("- Stopping starg."); 115 delete client; 116 #endif 114 if (channel>=0) 115 { 116 client->SetCosy(NULL); 117 cosy->SetStarguider(NULL); 118 clog("- Stopping starg."); 119 delete client; 120 } 121 117 122 clog("- Stopping cosy."); 118 123 cosy->Stop(); -
trunk/MagicSoft/Cosy/main/MBending.cc
r2615 r4105 317 317 318 318 // Vector in cartesian coordinates 319 TVector3 v (1., 1., 1.);319 TVector3 v1; 320 320 321 321 // Set Azimuth and Elevation 322 v.SetPhi(p.Az()); 323 v.SetTheta(TMath::Pi()/2-p.Alt()); 322 v1.SetMagThetaPhi(1, TMath::Pi()/2-p.Alt(), p.Az()); 323 324 325 TVector3 v2(v1); 326 // cout << sign << endl; 327 328 // cout << "v1: " << v1.Theta()*TMath::RadToDeg() << " " << v1.Phi()*TMath::RadToDeg() << endl; 324 329 325 330 // Rotate around the x- and y-axis 326 v.RotateY(sign*fAn); 327 v.RotateX(sign*fAw); 331 v1.RotateY(sign*fAn); 332 v1.RotateX(sign*fAw); 333 334 // cout << "v1: " << v1.Theta()*TMath::RadToDeg() << " " << v1.Phi()*TMath::RadToDeg() << endl; 335 // cout << "v2: " << v2.Theta()*TMath::RadToDeg() << " " << v2.Theta()*TMath::RadToDeg() << endl; 336 337 // cout << "dv: " << (v2.Theta()-v1.Theta())*TMath::RadToDeg() << " " << (v2.Phi()-v1.Phi())*TMath::RadToDeg() << endl; 338 339 Double_t dalt = v1.Theta()-v2.Theta(); 340 Double_t daz = v1.Phi() -v2.Phi(); 341 342 //cout << dalt*TMath::RadToDeg() << " " << daz*TMath::RadToDeg() << endl; 343 344 if (daz>TMath::Pi()) 345 daz -= TMath::TwoPi(); 346 if (daz<-TMath::Pi()) 347 daz += TMath::TwoPi(); 348 349 // if (daz>TMath::Pi()/2) 350 // { 351 // } 352 353 AltAz d(dalt, daz); 354 return d; 328 355 329 356 // Calculate Delta Azimuth and Delta Elevation 330 AltAz d(TMath::Pi()/2-v.Theta(), v.Phi()); 357 /* 358 AltAz d(TMath::Pi()/2-v1.Theta(), v1.Phi()); 359 360 cout << "p : " << p.Alt()*TMath::RadToDeg() << " " << p.Az()*TMath::RadToDeg() << endl; 361 cout << "d : " << d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl; 331 362 d -= p; 363 cout << "d-p: " << d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl; 332 364 d *= sign; 333 365 cout << "d* : " << d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl; 366 367 368 cout << "p2: " << 90-p.Alt()*TMath::RadToDeg() << " " << p.Az()*TMath::RadToDeg() << endl; 369 cout << "d2: " << 90-d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl; 370 371 Int_t s1 = 90-d.Alt()*TMath::RadToDeg() < 0 ? -1 : 1; 372 Int_t s2 = 90-p.Alt()*TMath::RadToDeg() < 0 ? -1 : 1; 373 374 375 if (s1 != s2) 376 { 377 //90-d.Alt() <-- -90+d.Alt() 378 379 d.Alt(d.Alt()-TMath::Pi()); 380 cout << "Alt-" << endl; 381 } 382 cout << "d': " << 90-d.Alt()*TMath::RadToDeg() << " " << d.Az()*TMath::RadToDeg() << endl; 383 /* 334 384 // Fix 'direction' of output depending on input vector 335 if (sign*p.Alt()>TMath::Pi()/2) 385 if (TMath::Pi()/2-sign*p.Alt()<0) 386 { 336 387 d.Alt(d.Alt()-TMath::Pi()); 388 cout << "Alt-" << endl; 389 } 390 //if (TMath::Pi()/2-sign*p.Alt()>TMath::Pi()) 391 //{ 392 // d.Alt(TMath::Pi()-d.Alt()); 393 // cout << "Alt+" << endl; 394 //} 337 395 338 396 // Align correction into [-180,180] 339 397 while (d.Az()>TMath::Pi()) 398 { 340 399 d.Az(d.Az()-TMath::Pi()*2); 400 cout << "Az-" << endl; 401 } 341 402 while (d.Az()<-TMath::Pi()) 403 { 342 404 d.Az(d.Az()+TMath::Pi()*2); 343 405 cout << "Az+" << endl; 406 } 407 */ 344 408 return d; 345 409 } … … 426 490 p += FLOP; 427 491 492 //const AltAz MAGIC1(fMagic1*sin(p.Az()), 0); 493 //p += MAGIC1; 494 428 495 const AltAz I(fIe, fIa); 429 496 p += I; … … 445 512 const AltAz I(fIe, fIa); 446 513 p -= I; 514 515 //const AltAz MAGIC1(fMagic1*sin(p.Az()), 0); 516 //p -= MAGIC1; 447 517 448 518 const AltAz FLOP(Sign(fFlop, p.Alt()), 0); -
trunk/MagicSoft/Cosy/main/MCaos.cc
r4076 r4105 167 167 fHistallw->SetNameTitle("allw","Rotation angel"); 168 168 fHistallw->SetBins(26, -25, 25); 169 fHistallw->SetXTitle("\\ Phi [arcmin]");169 fHistallw->SetXTitle("\\phi [arcmin]"); 170 170 fHistallw->SetYTitle("counts"); 171 171 172 172 fHistprxpry = new TH2F; 173 fHistprxpry->SetNameTitle("prx und pry","x- and y-coord niate of the ring-center");173 fHistprxpry->SetNameTitle("prx und pry","x- and y-coordinate of the ring-center"); 174 174 fHistprxpry->SetBins(xbin, xmin, xmax, ybin, ymin, ymax); 175 fHistprxpry->SetXTitle("x [ mm]");176 fHistprxpry->SetYTitle("y [ mm]");175 fHistprxpry->SetXTitle("x [pix]"); 176 fHistprxpry->SetYTitle("y [pix]"); 177 177 fHistprxpry->SetZTitle("counts"); 178 178 … … 183 183 fGraphpry->SetTitle("time-developement of the y-coordinate of the ring-center"); 184 184 185 fGraphw = new TGraph*[fPositions.GetEntriesFast()]; 186 for (int i=0; i<fPositions.GetEntriesFast(); i++) 187 { 188 TString title = "Time-developement of the angle "; 189 title += i; 190 191 fGraphw[i] = new TGraph; 192 fGraphw[i]->SetTitle(title); 193 } 185 fGraphw = new TGraph; 186 fGraphw->SetTitle("Time-developement of rotation angle"); 194 187 195 188 fHistpr = new TH1F("pr","Radius of the ring", rbin, rmin, rmax); … … 211 204 delete fGraphprx; 212 205 delete fGraphpry; 206 delete fGraphr; 213 207 214 208 for (int i=0; i<6; i++) … … 216 210 delete fHistled[i]; 217 211 delete fHistw[i]; 218 delete fGraphw [i];212 delete fGraphw; 219 213 } 220 214 delete fHistled; … … 265 259 c2->Update(); 266 260 267 c = new TCanvas("ctime", " timedevelopement of center", 800, 800);268 c->Divide(1, 2);261 c = new TCanvas("ctime", "Timedevelopement of Center", 800, 800); 262 c->Divide(1,3); 269 263 c->cd(1); 270 264 h = fGraphprx->GetHistogram(); … … 272 266 h->SetYTitle("x [pix]"); 273 267 h->DrawCopy(); 274 //fGraphprx->DrawClone("LP*")->SetBit(kCanDelete); 268 ((TPad*)gPad)->SetSelected(NULL); 269 fGraphprx->DrawClone("ALP*")->SetBit(kCanDelete); 275 270 c->cd(2); 276 271 h = fGraphpry->GetHistogram(); … … 278 273 h->SetYTitle("y [pix]"); 279 274 h->DrawCopy(); 280 //fGraphpry->DrawClone("LP*")->SetBit(kCanDelete); 275 ((TPad*)gPad)->SetSelected(NULL); 276 fGraphpry->DrawClone("ALP*")->SetBit(kCanDelete); 277 c->cd(3); 278 h = fGraphr->GetHistogram(); 279 h->SetXTitle("time [s]"); 280 h->SetYTitle("r [pix]"); 281 h->DrawCopy(); 282 ((TPad*)gPad)->SetSelected(NULL); 283 fGraphr->DrawClone("ALP*")->SetBit(kCanDelete); 281 284 c->Modified(); 282 285 c->Update(); 286 287 c = new TCanvas("crot", "rotation angle", 800, 600); 288 c->Divide(2,1); 289 c->cd(1); 290 fHistallw->SetXTitle("\\phi [arcmin]"); 291 fHistallw->SetYTitle("counts"); 292 fHistallw->DrawCopy(); 293 c->cd(2); 294 h = fGraphw->GetHistogram(); 295 h->SetXTitle("time [s]"); 296 h->SetYTitle("\\phi [arcmin]"); 297 h->DrawCopy(); 298 ((TPad*)gPad)->SetSelected(NULL); 299 fGraphw->DrawClone("ALP*")->SetBit(kCanDelete); 300 283 301 284 302 /* -------------------------------------------------------- … … 333 351 f.MarkPoint(l1.GetX(), l1.GetY(), l1.GetMag()); 334 352 353 //old 354 /* 335 355 // Fill values into Histogram 336 356 if (!fHistpr) … … 339 359 fHistled[i]->Fill(l1.GetX(), l1.GetY()); 340 360 fHistw[i]->Fill(l1.GetPhi()); 361 */ 341 362 } 342 363 first = leds.GetEntries(); … … 344 365 345 366 Rings rings; 346 rings.CalcRings(leds, 26 6, 268);367 rings.CalcRings(leds, 265, 268); 347 368 348 369 const Ring ¢er = rings.GetCenter(); … … 358 379 fGraphprx->SetPoint(fGraphprx->GetN(), fEvtTime, center.GetX()); 359 380 fGraphpry->SetPoint(fGraphpry->GetN(), fEvtTime, center.GetY()); 381 382 //new 383 //----- 384 Double_t sum = 0; 385 for (int j=0; j<leds.GetEntries(); j++) 386 { 387 Led &l1 = leds(j); 388 389 fHistled[j]->Fill(l1.GetX(), l1.GetY()); 390 //fHistw[j]->Fill(l1.GetPhi()); 391 392 Double_t phi[6] = 393 { 394 0, 395 0, 396 0, 397 0, 398 0, 399 0 400 }; 401 402 const Double_t w = (leds(j).GetPhi()-phi[j])*60; 403 sum += w; 404 405 fHistw[j]->Fill(w); 406 sum /= leds.GetEntries(); 407 } 408 fGraphw->SetPoint(fGraphw->GetN(), fEvtTime, sum); 409 fHistallw->Fill(sum/leds.GetEntries()); 410 //----- 360 411 } 361 412 -
trunk/MagicSoft/Cosy/main/MCaos.h
r4076 r4105 42 42 TGraph *fGraphprx; 43 43 TGraph *fGraphpry; 44 TGraph **fGraphw; 44 TGraph *fGraphw; 45 TGraph *fGraphr; 45 46 46 47 public: -
trunk/MagicSoft/Cosy/main/MCosy.cc
r4076 r4105 402 402 403 403 return point.SetPosition(dst, track); 404 } 405 406 void MCosy::SetTrackingPosRE(ZdAz za) 407 { 408 za /= kGearTot; // [U_tel] 409 za *= TMath::TwoPi(); // [rad] 410 //cout << "RE1: " << za.Zd()*180/3.1415 << " " << za.Az()*180/3.1415 << endl; 411 fTrackingPos = fBending.CorrectBack(za)*TMath::RadToDeg(); 412 //cout << "RE2: " << fTrackingPos.Zd() << " " << fTrackingPos.Az() << endl; 404 413 } 405 414 … … 828 837 829 838 cout << "Reading gear ratios..." << flush; 839 kGear.X(env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0)); 830 840 kGear.Y(env.GetValue("Az_GearRatio[U_mot/U_tel]", 1000.0)); 831 kGear.X(env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0));832 841 833 842 kResRE.Y(0); … … 1118 1127 SetStatus(MDriveCom::kError); 1119 1128 1120 ZdAz bendist = GetPointingPos(); 1129 1130 ZdAz bendist = fStatus&MDriveCom::kTracking ? fTrackingPos : GetPointingPos(); 1131 1132 //cout << (fStatus&MDriveCom::kTracking?"TRA: ":"POS: ") << bendist.Zd() << " " << bendist.Az() << endl; 1133 1121 1134 fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError); 1122 1135 … … 1328 1341 fAz->SetReport(fOutRep); 1329 1342 1343 fAz->SetMotor(fMac1); 1344 fZd1->SetMotor(fMac2); 1345 fZd2->SetMotor(fMac2); 1346 1330 1347 lout << "- Connecting devices to network." << endl; 1331 1348 -
trunk/MagicSoft/Cosy/main/MCosy.h
r4076 r4105 1 #ifndef MCOSY_H2 #define MCOSY_H1 #ifndef COSY_MCosy 2 #define COSY_MCosy 3 3 4 4 #include "coord.h" 5 5 #include "msgqueue.h" 6 #include "network.h"7 6 #include "MThread.h" 8 7 #include "MBending.h" 9 8 9 #ifndef COSY_Network 10 #include "network.h" 11 #endif 10 12 #ifndef MARS_MObservatory 11 13 #include "MObservatory.h" … … 84 86 MDriveCom *fCom; 85 87 86 TTimer *fUpdateGui;87 MTTalk *fTTalk;// should be outsourced, like the starguider.88 TTimer *fUpdateGui; 89 MTTalk *fTTalk; // should be outsourced, like the starguider. 88 90 // with a generic interface to both... 91 ZdAz fTrackingPos; // [deg] Current tracking position 89 92 90 93 TMutex fMutexGui; … … 185 188 MGCosy *GetWin() { return fWin; } 186 189 190 ZdAz GetTrackingPosDeg() const { return fTrackingPos; }; 191 void SetTrackingPosRE(ZdAz za); 192 187 193 AltAz GetAltAzDeg() const 188 194 { -
trunk/MagicSoft/Cosy/main/MPointing.cc
r4076 r4105 151 151 const ZdAz p=fCosy->GetSePos(); 152 152 153 // calculate control deviation and rounded cd153 // calculate control deviation 154 154 ZdAz rd = dest-p; // [se] 155 155 ZdAz cd = rd; // [se] 156 // Correct for having two SE available 157 cd.Zd(cd.Zd()*2); 158 // Round to check whether we are as near as possible 159 // to the value we expect 156 160 cd.Round(); 157 161 -
trunk/MagicSoft/Cosy/main/MStarguider.cc
r2615 r4105 8 8 #include <TGraph.h> 9 9 #include <TTimer.h> 10 #include <TSystem.h> 10 11 11 12 #include <TGMenu.h> 12 13 #include <TGLabel.h> 13 #include <T System.h>14 #include <TGButton.h> 14 15 #include <TGSplitter.h> // TGHorizontal3DLine 15 16 #include <TGTextEntry.h> 16 17 18 #include "MString.h" 19 17 20 #include "MCosy.h" 18 21 #include "MCaos.h" … … 22 25 23 26 #include "coord.h" 27 28 #include "Camera.h" 29 #include "PngReader.h" 24 30 25 31 #include "Led.h" … … 29 35 #include "CaosFilter.h" 30 36 #include "StarCatalog.h" 37 #include "MGeomCamMagic.h" 38 #include "MAstroCamera.h" 31 39 32 40 #include "MGMenu.h" 41 #include "MGCosy.h" 33 42 34 43 ClassImp(MStarguider); … … 36 45 enum { 37 46 IDM_kFilter, 47 IDM_kFindStar, 38 48 IDM_kCaosFilter, 39 49 IDM_kCatalog, … … 46 56 IDM_kOnce, 47 57 IDM_kStretch, 48 // IDM_kUseFileRaDec, 58 IDM_kInput, 59 IDM_kChannel1, 60 IDM_kChannel2, 49 61 IDM_kContinous, 50 62 IDM_kRate25ps, … … 65 77 IDM_kPixSize, 66 78 IDM_kAngle, 79 IDM_kInterpol250, 67 80 IDM_kInterpol125, 68 81 IDM_kInterpol50, … … 83 96 Bool_t MStarguider::HandleTimer(TTimer *t) 84 97 { 85 fImage->DoRedraw(); 86 fZoomImage->DoRedraw(); 98 if (IsMapped()) 99 { 100 fImage->DoRedraw(); 101 fZoomImage->DoRedraw(); 102 } 103 104 if (fCosy && fCosy->GetWin()->IsMapped()) 105 fCosy->GetWin()->GetImage()->DoRedraw(); 106 87 107 return kTRUE; 88 108 } … … 95 115 } 96 116 97 void MStarguider::InitGui( )117 void MStarguider::InitGui(Int_t channel) 98 118 { 99 119 fList = new MGList; 100 120 101 121 const TGWindow *p=gClient->GetRoot(); 122 123 fChannel = new MGPopupMenu(p); 124 fChannel->AddEntry("Channel #1", IDM_kChannel1); 125 fChannel->AddEntry("Channel #2", IDM_kChannel2); 126 fChannel->CheckEntry(channel==0?IDM_kChannel1:IDM_kChannel2); 127 fChannel->Associate(this); 128 fList->Add(fChannel); 102 129 103 130 // … … 106 133 fDisplay = new MGPopupMenu(p); 107 134 fDisplay->AddEntry("&Filter", IDM_kFilter); 135 fDisplay->AddEntry("Find &Star", IDM_kFindStar); 108 136 fDisplay->AddEntry("C&aosFilter", IDM_kCaosFilter); 109 137 fDisplay->AddEntry("Sao &Catalog", IDM_kCatalog); 110 138 fDisplay->AddEntry("Starguider", IDM_kStarguider); 111 139 fDisplay->AddEntry("Stretch", IDM_kStretch); 140 if (channel>=0) 141 fDisplay->AddPopup("&Input", fChannel); 112 142 fDisplay->DisableEntry(IDM_kStarguider); 113 143 fDisplay->CheckEntry(IDM_kStretch); … … 169 199 170 200 fInterpol = new MGPopupMenu(p); 201 fInterpol->AddEntry("250", IDM_kInterpol250); 171 202 fInterpol->AddEntry("125", IDM_kInterpol125); 172 203 fInterpol->AddEntry("50", IDM_kInterpol50); … … 242 273 243 274 fCRaDec = new MGCoordinates(this, kETypeRaDec); 244 fCRaDec->Move( 1, fMenu->GetDefaultHeight()+584);275 fCRaDec->Move(4, fMenu->GetDefaultHeight()+584); 245 276 AddFrame(fCRaDec); 246 277 fList->Add(fCRaDec); … … 255 286 AddFrame(fPZdAz); 256 287 fList->Add(fPZdAz); 288 289 fTPoint = new TGTextButton(this, "TPoint"); 290 fTPoint->Move(4, fMenu->GetDefaultHeight()+665); 291 fTPoint->AllowStayDown(kTRUE); 292 AddFrame(fTPoint); 293 fList->Add(fTPoint); 257 294 258 295 fFps = new TGLabel(this, "---fps"); … … 294 331 const Double_t pixsize = 23.4; 295 332 296 fSao->SetPixSize(pixsize /3600);333 fSao->SetPixSize(pixsize); 297 334 fSao->SetRotationAngle(0); 298 335 … … 336 373 337 374 MapSubwindows(); 375 fTPoint->UnmapWindow(); 338 376 MapWindow(); 377 378 IconifyWindow(); 339 379 340 380 //------------------------------------------------------------ … … 345 385 } 346 386 347 MStarguider::MStarguider(MObservatory::LocationName_t obs )348 : TGMainFrame(gClient->GetRoot(), 768, 740), fCosy(NULL), f Dx((768-kZOOM)/2), fDy((512-kZOOM)/2)387 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) 349 389 { 350 390 cout << " #### FIXME: Make MCaos Thread safe!" << endl; … … 356 396 fCaos->ReadResources(); 357 397 358 InitGui(); 359 360 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE); 398 InitGui(channel); 361 399 362 400 fTimer=new TTimer(this, 1000/25); // 40ms … … 364 402 365 403 fTime.Now(); 404 405 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kTRUE); 406 407 if (channel<0) 408 fGetter=new PngReader(*this); 409 else 410 { 411 fGetter = new Camera(*this, channel); 412 ((Camera*)fGetter)->Loop(0); 413 } 366 414 } 367 415 368 416 MStarguider::~MStarguider() 369 417 { 418 fGetter->ExitLoop(); 419 delete fGetter; 420 370 421 gVirtualX->GrabButton(fId, kButton2, 0, 0, 0, 0, kFALSE); 371 422 … … 378 429 delete fSao; 379 430 delete fRaDec; 431 432 if (fOutTp) 433 delete fOutTp; 380 434 381 435 cout << "Camera Display destroyed." << endl; … … 416 470 const Float_t pixsize = atof(fPixSize->GetText()); 417 471 cout << "Pixel Size changed to " << pixsize << "\"/pix" << endl; 418 fSao->SetPixSize(pixsize /3600);472 fSao->SetPixSize(pixsize); 419 473 return kTRUE; 420 474 } … … 459 513 fDisplay->UnCheckEntry(IDM_kStarguider); 460 514 fDisplay->DisableEntry(IDM_kStarguider); 515 } 516 return kTRUE; 517 518 case IDM_kFindStar: 519 Toggle(fDisplay, IDM_kFindStar); 520 if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy) 521 fTPoint->MapWindow(); 522 else 523 { 524 fTPoint->UnmapWindow(); 525 fTPoint->SetDown(kFALSE); 461 526 } 462 527 return kTRUE; … … 595 660 return kTRUE; 596 661 662 case IDM_kChannel1: 663 case IDM_kChannel2: 664 { 665 const Int_t ch0 = fChannel->IsEntryChecked(IDM_kChannel1) ? 0 : 1; 666 const Int_t ch1 = mp1==IDM_kChannel1 ? 0 : 1; 667 if (ch0==ch1) 668 return kTRUE; 669 670 fChannel->CheckEntry (ch1==0?IDM_kChannel1:IDM_kChannel2); 671 fChannel->UnCheckEntry(ch1==1?IDM_kChannel1:IDM_kChannel2); 672 delete fGetter; 673 usleep(150000); // FIX: Device or resource busy. 674 fGetter = new Camera(*this, ch1); 675 ((Camera*)fGetter)->Loop(0); 676 } 677 return kTRUE; 678 679 case IDM_kInterpol250: 597 680 case IDM_kInterpol125: 598 681 case IDM_kInterpol50: … … 602 685 case IDM_kInterpol2: 603 686 case IDM_kInterpol1: 604 for (int i=IDM_kInterpol 125; i<=IDM_kInterpol1; i++)687 for (int i=IDM_kInterpol250; i<=IDM_kInterpol1; i++) 605 688 if (mp1==i) 606 689 fInterpol->CheckEntry(i); … … 629 712 case IDM_kInterpol125: 630 713 fIntRate = 125; 714 return kTRUE; 715 case IDM_kInterpol250: 716 fIntRate = 250; 631 717 return kTRUE; 632 718 } … … 806 892 } 807 893 894 void MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t) 895 { 896 // Set search Paremeters (FIXME: Get them from user input!) 897 f.SetCut(3.0); 898 f.SetBox(70); 899 900 // Try to find Led in this area 901 Leds leds; 902 f.FindStar(leds, center.GetX(), center.GetY()); 903 904 // Check wheter star found 905 Led *star = (Led*)leds.At(0); 906 if (!star) 907 return; 908 909 cout << "Found star @ " << flush; 910 star->Print(); 911 f2.MarkPoint(star->GetX(), star->GetY(), 2<<2); 912 913 // Initialize Star Catalog on th camera plane 914 MGeomCamMagic geom; 915 MAstroCamera ac; 916 ac.SetMirrors("magic.def"); 917 ac.SetGeom(geom); 918 ac.SetRadiusFOV(3); 919 ac.SetObservatory(*fSao); 920 ac.SetTime(t); 921 922 // Get tracking coordinates 923 const XY xy = fCRaDec->GetCoordinates(); 924 const RaDec rd(xy.X()*TMath::DegToRad()*360/24, xy.Y()*TMath::DegToRad()); 925 926 ac.SetRaDec(rd.Ra(), rd.Dec()); 927 928 // Adapt coordinate system (GUI and humans are counting Y in different directions) 929 Double_t x = star->GetX()-center.GetX(); 930 Double_t y = center.GetY()-star->GetY(); 931 932 // Convert from Pixel to millimeter (1pix=2.9mm) 933 x *= 2.58427; 934 y *= 2.58427; 935 936 // Correct for abberation. 937 x /= 1.0713; 938 y /= 1.0713; 939 940 // Calculate Offset 941 Double_t dzd, daz; 942 ac.GetDiffZdAz(x, y, dzd, daz); 943 944 cout << "STAR-Offset: " << MTime(-1) << " dZd=" << dzd << "d dAz=" << daz << "d" << endl; 945 946 // Check TPoint data set request 947 if (!fTPoint->IsDown()) 948 return; 949 fTPoint->SetDown(kFALSE); 950 951 // If no file open: open new file 952 if (!fOutTp) 953 { 954 // 955 // open tpoint file 956 // 957 const TString name = MCosy::GetFileName("tpoint/starg_%s.txt"); 958 cout << "TPoint-Starg File ********* " << name << " ********** " << endl; 959 960 fOutTp = new ofstream(name); 961 *fOutTp << "Magic Model TPOINT data file" << endl; 962 *fOutTp << ": ALTAZ" << endl; 963 *fOutTp << "49 48 0 "; 964 *fOutTp << t << endl; 965 // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m) 966 } 967 968 // Output Ra/Dec the drive system thinks that it is currently tracking 969 cout << "TPoint Star: " << xy.X() << "h " << xy.Y() << "°" << endl; 970 971 // From the star position in the camera we calculate the Alt/Az 972 // position we are currently tracking (real pointing position) 973 fSao->SetMjd(t.GetMjd()); 974 AltAz za0 = fSao->CalcAltAz(rd)*kRad2Deg; 975 976 //ZdAz za0 = fSao->GetZdAz(); 977 za0 -= AltAz(-dzd, daz); 978 979 // From the Shaftencoders we get the current 'pointing' position 980 // as it is seen by the drive system (system pointing position) 981 const ZdAz za1 = fCosy->GetTrackingPosDeg(); 982 983 // Write real pointing position 984 cout << " Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl; 985 *fOutTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " "; 986 987 // Write system pointing position 988 cout << " SE-Pos: " << 90-za1.Zd() << "° " << za1.Az() << "°" << endl; 989 *fOutTp << fmod(za1.Az()+360, 360) << " " << 90-za1.Zd(); 990 991 *fOutTp << " " << xy.X() << " " << xy.Y(); 992 *fOutTp << " " << -dzd << " " << -daz; 993 *fOutTp << " " << setprecision(11) << t.GetMjd(); 994 *fOutTp << endl; 995 } 996 808 997 bool MStarguider::Interpolate(const unsigned long n, byte *img) const 809 998 { … … 844 1033 if (d>1) 845 1034 { 846 fFps->SetText(Form("%dfps", (int)((n-n0)/d+.5))); 1035 MString txt; 1036 txt.Print("%dfps", (int)((n-n0)/d+.5)); 1037 fFps->SetText(txt); 847 1038 fTime = t; 848 1039 n0 = n; … … 852 1043 return; 853 1044 854 FilterLed f(img, 768, 576, 2.5); // 2.5 1045 byte cimg[768*576]; 1046 memset(cimg, 0, 768*576); 1047 1048 FilterLed f(img, 768, 576, 2.5); // 2.5 1049 FilterLed f2(cimg, 768, 576); // former color 0xb0 855 1050 856 1051 if (fDisplay->IsEntryChecked(IDM_kStretch)) … … 874 1069 f.Execute(); 875 1070 1071 Ring center(768/2, 576/2); 876 1072 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 877 1073 { … … 882 1078 pos = fCosy->GetPointingPos(); 883 1079 884 fCaos->Run(img, printl, printr, pos, t); 885 } 1080 center = fCaos->Run(img, printl, printr, pos, t); 1081 } 1082 1083 if (fDisplay->IsEntryChecked(IDM_kFindStar)) 1084 FindStar(f, f2, center, t); 886 1085 887 1086 byte zimg[kZOOM*kZOOM]; … … 892 1091 fZoomImage->DrawImg(zimg); 893 1092 1093 if (fCosy) 1094 { 1095 byte simg[(768/2-1)*(576/2-1)]; 1096 for (int y=0; y<576/2-1; y++) 1097 for (int x=0; x<768/2-1; x++) 1098 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; 1099 1100 fCosy->GetWin()->GetImage()->DrawImg(simg); 1101 } 1102 894 1103 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 895 1104 { … … 901 1110 UpdatePosZoom(); 902 1111 903 MStarList stars; 904 fSao->GetStars(stars, time.GetMjd(), *fRaDec); 905 1112 /* 906 1113 if (fDisplay->IsEntryChecked(IDM_kStarguider)) 907 1114 { … … 913 1120 CalcTrackingError(leds, stars); 914 1121 } 915 916 byte cimg[768*576]; 917 fSao->GetImg(img, cimg, stars); 918 919 const float r = 60*60/fSao->GetPixSize()+1; 920 f.DrawCircle(0.5*r); 921 f.DrawCircle(1.0*r); 922 f.DrawCircle(1.5*r); 923 1122 */ 1123 1124 // Always call SetMjd first! 1125 fSao->SetPointing(time.GetMjd(), *fRaDec); 924 1126 fCZdAz->SetCoordinates(fSao->GetZdAz()); 925 1127 1128 MStarList stars; 1129 fSao->CalcStars(stars); 1130 fSao->DrawStars(stars, cimg); 1131 } 1132 1133 if (fDisplay->IsEntryChecked(IDM_kCaosFilter)) 1134 { 1135 f2.DrawCircle(center, 0x0a); 1136 f2.DrawCircle(center, 5.0, fDisplay->IsEntryChecked(IDM_kFindStar)?3:0xb0); 1137 f2.DrawCircle(center, 115.0, 0x0a); 1138 f2.DrawCircle(center, 230.0, 0x0a); 1139 f2.DrawCircle(center, 245.0, 0x0a); 1140 } 1141 1142 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 1143 { 1144 fSao->PaintImg(cimg, 768, 576); 1145 1146 const float r = 60*60/fSao->GetPixSize(); 1147 1148 f2.DrawCircle(0.5*r, 0x0a); 1149 f2.DrawCircle(1.0*r, 0x0a); 1150 f2.DrawCircle(1.5*r, 0x0a); 1151 } 1152 1153 if (fDisplay->IsEntryChecked(IDM_kCaosFilter) || 1154 fDisplay->IsEntryChecked(IDM_kCatalog) || 1155 fDisplay->IsEntryChecked(IDM_kFindStar)) 926 1156 fImage->DrawColImg(img, cimg); 927 }928 1157 else 929 1158 fImage->DrawImg(img); … … 932 1161 void MStarguider::UpdatePosZoom() 933 1162 { 1163 MString txt; 934 1164 if (fDisplay->IsEntryChecked(IDM_kCatalog)) 935 1165 { … … 940 1170 if (aa.Az()<0) 941 1171 aa.Az(aa.Az()+360); 942 fPosZoom->SetText(Form("%.1fd/%.1fd (%d, %d)", 943 -aa.Alt(), aa.Az()-180, fDx, fDy));1172 1173 txt.Print("%.1fd/%.1fd (%d, %d)", -aa.Alt(), aa.Az()-180, fDx, fDy); 944 1174 } 945 1175 else 946 fPosZoom->SetText(Form("(%d, %d)", fDx, fDy)); 1176 txt.Print("(%d, %d)", fDx, fDy); 1177 1178 fPosZoom->SetText(txt); 947 1179 } 948 1180 -
trunk/MagicSoft/Cosy/main/MStarguider.h
r2615 r4105 7 7 8 8 #include "PixClient.h" 9 #include "MGImage.h" 10 #include "coord.h" 9 11 10 12 #ifndef MARS_MObservatory 11 13 #include "MObservatory.h" 12 14 #endif 13 14 15 #ifndef MARS_MTime 15 16 #include "MTime.h" 16 17 #endif 17 18 #ifndef MARS_MGList 18 19 #include "MGList.h" 19 #include "MGImage.h" 20 21 #include "coord.h" 20 #endif 22 21 23 22 class TArrayF; 24 23 class TGLabel; 24 class TGButton; 25 25 26 26 class TTimer; … … 29 29 class MGPopupMenu; 30 30 class TGTextEntry; 31 32 class PixGetter; 31 33 32 34 class MGImage; … … 37 39 class MCosy; 38 40 class MCaos; 41 class FilterLed; 42 class Ring; 39 43 40 44 class Leds; … … 43 47 { 44 48 private: 49 PixGetter *fGetter; 50 45 51 MGList *fList; 46 52 … … 57 63 MGPopupMenu *fSetup; 58 64 MGPopupMenu *fLimMag; 65 MGPopupMenu *fChannel; 59 66 60 67 MGPopupMenu *fCaosWrite; … … 74 81 TGLabel *fPosZoom; 75 82 83 TGButton *fTPoint; 84 76 85 StarCatalog *fSao; 77 86 MCosy *fCosy; … … 82 91 TTimer *fTimer; 83 92 MTime fTime; 93 94 ofstream *fOutTp; 84 95 85 96 Int_t fDx; … … 95 106 ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag) const; 96 107 bool Interpolate(const unsigned long n, byte *img) const; 108 void FindStar(FilterLed &f, FilterLed &f2, Ring ¢er, MTime &t); 97 109 98 110 //void InitHists(); 99 111 //void InitGraphs(); 100 void InitGui( );112 void InitGui(Int_t channel); 101 113 102 114 //void OpenFile(); … … 110 122 111 123 public: 112 MStarguider(MObservatory::LocationName_t obs );124 MStarguider(MObservatory::LocationName_t obs, Int_t channel); 113 125 virtual ~MStarguider(); 114 126 … … 119 131 120 132 Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); 133 121 134 Bool_t HandleDoubleClick(Event_t *event); 135 //Bool_t HandleButton(Event_t *); 122 136 123 137 void SetPointingPosition(RaDec rd); -
trunk/MagicSoft/Cosy/main/MTracking.cc
r4076 r4105 73 73 return false; 74 74 75 fCosy->SetStatus(MDriveCom::kMoving | MDriveCom::kTracking);76 77 75 fCosy->fMac2->SetRpmMode(TRUE); 78 76 if (fCosy->fMac2->IsZombieNode()) … … 82 80 if (fCosy->fMac1->IsZombieNode()) 83 81 return false; 82 83 fCosy->SetStatus(MDriveCom::kMoving | MDriveCom::kTracking); 84 84 85 85 return true; … … 223 223 224 224 return kFALSE; 225 } 226 227 // -------------------------------------------------------------------- 228 // 229 // Return pointing position of the telescope based on the 230 // Shaftencoders with interpolation with motor encoders. 231 // 232 // GetPointingPos [re] 233 // 234 ZdAz MTracking::GetPointingPosRE(Bool_t pdo) const 235 { 236 // Conversion factor from se to re 237 const XY re = fCosy->kGearTot/fCosy->kResSE; //[re/se] 238 239 // Get current shaftencoder position of the telescope 240 Double_t seposzd1 = ((fCosy->fZd1->GetPos()+8192)%16384)*re.X(); 241 Double_t seposzd2 = ((fCosy->fZd2->GetPos()+8192)%16384)*re.X(); 242 Double_t seposaz = fCosy->fAz->GetPos() *re.Y(); 243 244 // distance between (To+dt) and To [re] 245 // position time difference < 5usec 246 // fRePos does the synchronization between the 247 // Shaft- and the rotary encoders 248 const ZdAz repos = pdo ? fCosy->GetRePosPdo() : fCosy->GetRePos(); 249 250 // Calculate the part of one SE which the motors moved 251 // since the last SE has changed its value 252 const Double_t offzd1 = repos.Zd() - fCosy->fZd1->GetOffset(); 253 const Double_t offzd2 = repos.Zd() - fCosy->fZd2->GetOffset(); 254 const Double_t offaz = repos.Az() - fCosy->fAz->GetOffset(); 255 256 // Correct for the direction in which the motor is moving 257 // (in which the shaftencoders should change its values) 258 if (offaz<0) 259 seposaz += re.Y(); 260 if (offzd1<0) 261 seposzd1 += re.X(); 262 if (offzd2<0) 263 seposzd2 += re.X(); 264 265 // and interpolate the shaftencoder steps using the motor 266 // encoder positon (Be carefull the minus-sign is important) 267 seposzd1 += offzd1; 268 seposzd2 -= offzd2; 269 seposaz += offaz; 270 271 return ZdAz((seposzd1-seposzd2)/2, seposaz); 225 272 } 226 273 … … 260 307 // calculate offset from present se position 261 308 // 262 const ZdAz sepos = fCosy->GetSePos()*fCosy->kGearTot/fCosy->kResSE; //[re]309 //const ZdAz sepos = fCosy->GetSePos()*fCosy->kGearTot/fCosy->kResSE; //[re] 263 310 if (!RequestRePos()) 264 311 return; 265 312 266 //267 313 // Estimate Offset before starting to track 268 // 269 fOffset = sepos-fCosy->GetRePos(); 270 271 /* 272 cout << "Sepos: " << sepos.Zd() << "re, " << sepos.Az() << "re" << endl; 273 cout << "Repos: " << repos.Zd() << "re, " << repos.Az() << "re" << endl; 274 cout << "Offset: " << fOffset.Zd() << "re, " << fOffset.Az() << "re" << endl; 275 */ 314 ZdAz repos = fCosy->GetRePos(); 315 fCosy->fZd1->SetOffset(repos.Zd()); 316 fCosy->fZd2->SetOffset(repos.Zd()); 317 fCosy->fAz->SetOffset(repos.Az()); 318 319 fCosy->SetTrackingPosRE(GetPointingPosRE()); 320 321 // Initialize Tracker (slalib or starguider) 322 fCosy->fRaDec = dst; 323 324 // StartThread 325 Start(); 276 326 277 327 // … … 283 333 return; 284 334 } 285 286 // Initialize Tracker (slalib or starguider)287 fCosy->fRaDec = dst;288 289 // StartThread290 Start();291 335 292 336 // Get current nominal local position … … 296 340 // Some output 297 341 XY xy(Rad2Deg(dst.Ra())*24/360, Rad2Deg(dst.Dec())); 298 lout << sla.GetTime() << " - Start Tracking: Ra=" << xy.X() << "h Dec=";342 lout << sla.GetTime() << " - Start Tracking: Ra=" << xy.X() << "h Dec="; 299 343 lout << xy.Y() << "\xb0 @ Zd=" << pos.Zd()*kRad2Deg <<"deg Az=" << pos.Az()*kRad2Deg <<"deg" << endl; 300 344 … … 331 375 break; 332 376 377 // Destination position at t+dt in re-units 333 378 dest *= fCosy->kGearTot/TMath::TwoPi(); // [re] 334 379 335 //*fCosy->fOutRep << "> ReqRePos1 " << endl;336 337 //338 380 // Request absolute position of rotary encoder from Macs 339 // 381 // Such that the RE position used in GetPointingPos is 382 // as up-to-date as possible. 383 // DO I NEED THIS OR IS THE PDOPOS ENOUGH? 340 384 if (!RequestRePos()) 341 385 break; 342 386 343 //*fCosy->fOutRep << "> ReqRePos2 " << fOffset.Zd() << " " << fOffset.Az() << endl; 344 345 // 387 // *NEW* offset handling 388 // Get current position of the telescope and 389 // forward this position to MCosy 390 ZdAz sepos = GetPointingPosRE(); //[re] 391 fCosy->SetTrackingPosRE(sepos); 392 346 393 // distance between (To+dt) and To [re] 347 394 // position time difference < 5usec 348 // f Offsetdoes the synchronization between the395 // fRePos does the synchronization between the 349 396 // Shaft- and the rotary encoders 350 397 repos = fCosy->GetRePos(); 351 dest -= repos + fOffset; //[re] 398 399 // Now calculate the distance to move from now 400 // to a time in t+dt. 401 dest -= sepos; 352 402 353 403 dtime = dt; … … 412 462 if (fOut) 413 463 { 414 fOut->Lock( );464 fOut->Lock("MTracking::TrackPosition"); 415 465 *fOut << "RE-REPORT " << MTime(-1) << " " << repos.Zd() << " " << repos.Az() <<" " << vt.Zd() << " " << vt.Az() << endl; 416 fOut->UnLock( );466 fOut->UnLock("MTracking::TrackPosition"); 417 467 } 418 468 … … 455 505 lout << "- Tracking Thread started..." << endl; 456 506 457 const XY re2se = fCosy->kGearTot/fCosy->kResSE; //[re/se]507 //const XY re2se = fCosy->kGearTot/fCosy->kResSE; //[re/se] 458 508 459 509 SlaStars sla(fCosy->fObservatory); … … 471 521 bool phcaz=false; 472 522 523 ZdAz wasse = fCosy->GetSePos(); 524 ZdAz oldse = fCosy->GetSePos(); 525 473 526 while (!HasStopFlag()) 474 527 { … … 476 529 // This is the time constant which defines how fast 477 530 // you correct for external influences (like wind) 478 const float weight = 1.; //0.3;531 //const float weight = 1.; //0.3; 479 532 480 533 // Check for changes of the shaftencoder values … … 492 545 } while (!phca1 && !phca2 && !phcaz && !HasStopFlag()); 493 546 494 //*fCosy->fOutRep << "> Do Calculation" << endl;495 496 // Get current position of motors (use last automatically sent497 // position (PDO) - requesting the position results in problems498 // with thread safty)499 ZdAz istre = fCosy->GetRePosPdo();500 501 // get current position of shaftencoders502 ZdAz istse = fCosy->GetSePos(); // [se]503 504 547 // Get time from last shaftencoder position change (position: ist) 505 548 // FIXME: Is this correct? 506 if (fCosy->fZd1->GetMjd()>fCosy->fZd2->GetMjd()) 507 time.Zd(fCosy->fZd1->GetMjd()); 508 else 509 time.Zd(fCosy->fZd2->GetMjd()); 510 511 time.Az(fCosy->fAz->GetMjd()); 549 // time.Az(fCosy->fMac1->GetMjd()); 550 // time.Zd(fCosy->fMac2->GetMjd()); 551 552 Double_t mjd1 = fCosy->fZd1->GetMjd(); 553 Double_t mjd2 = fCosy->fZd2->GetMjd(); 554 Double_t mjd0 = fCosy->fAz->GetMjd(); 555 556 // get current position of shaftencoders (interpolated 557 // using motor encoders) 558 const ZdAz istse = GetPointingPosRE(kTRUE)/fCosy->kGearTot*TMath::TwoPi(); 559 //const ZdAz istse = fCosy->GetSePosPdo(); 512 560 513 561 // calculate offset for both axis (only one is needed) 514 const ZdAz offset = (istse*re2se - istre)*weight + fOffset*(weight-1);515 562 // *NEW* offset handling 563 //.const ZdAz offset = istre; //(istse*re2se - istre)*weight + fRePos*(weight-1); 516 564 // if Shaftencoder changed position, calculate nominal position 517 565 if (phca1 || phca2) 518 566 { 519 const ZdAz dummy = sla.CalcZdAz(fCosy->fRaDec, time.Zd()); 567 ZdAz dummy = sla.CalcZdAz(fCosy->fRaDec, fCosy->fMac2->GetPdoMjd());//TMath::Max(mjd1, mjd2)); 568 dummy = fCosy->AlignTrackingPos(dummy); 569 dummy = fCosy->fBending(dummy); 520 570 soll.Zd(dummy.Zd()); // [rad] 521 fOffset.Zd(offset.Zd());522 571 } 523 572 if (phcaz) 524 573 { 525 const ZdAz dummy = sla.CalcZdAz(fCosy->fRaDec, time.Az()); 574 const Double_t mjd = fCosy->fMac1->GetMjd(); 575 ZdAz dummy = sla.CalcZdAz(fCosy->fRaDec, fCosy->fMac1->GetPdoMjd());//mjd0); 576 dummy = fCosy->AlignTrackingPos(dummy); 577 dummy = fCosy->fBending(dummy); 526 578 soll.Az(dummy.Az()); // [rad] 527 fOffset.Az(offset.Az());528 579 } 529 580 530 // After calculation of fOffset is done we need 'ist' in rad 531 istse /= fCosy->kResSE/TMath::TwoPi(); // [rad] 581 fCosy->fZdAzSoll = soll; 532 582 533 583 // Calculate the aligned tracking posotion from 'soll'-position 534 fCosy->fZdAzSoll = fCosy->AlignTrackingPos(soll); 535 536 /* --- OLD --- */ 537 //fCosy->fTrackingError = istse-fCosy->fBending(fCosy->fZdAzSoll); 538 /* --- NEW --- */ 539 fCosy->fTrackingError = fCosy->fBending.CorrectBack(istse)-fCosy->fZdAzSoll; 540 /* --- END --- */ 584 if (phca1 || phca2) 585 fCosy->fTrackingError.Zd(soll.Zd()-istse.Zd()); 586 if (phcaz) 587 fCosy->fTrackingError.Az(soll.Az()-istse.Az()); 541 588 } 542 589 -
trunk/MagicSoft/Cosy/main/MTracking.h
r4076 r4105 20 20 Float_t fTrackDec; 21 21 22 ZdAz fOffset; // Offset between se and re coordinate system [re] 22 //Int_t fSePosZd1; 23 //Int_t fSePosZd2; 24 //Int_t fSePosAz; 23 25 24 MLog *fOut; 26 //Int_t fRePosZd1; 27 //Int_t fRePosZd2; 28 //Int_t fRePosAz; 29 30 //ZdAz fRePos; // Offset between se and re coordinate system [re] 31 //ZdAz fSePos; // Shaftencoder Position 32 33 MLog *fOut; 25 34 26 35 bool RequestRePos(); … … 28 37 bool LimitSpeed(ZdAz *vt, const SlaStars &sla) const; 29 38 bool InitTracking(); 30 //void StopTracking();39 ZdAz GetPointingPosRE(Bool_t pdo=kFALSE) const; 31 40 32 41 void *Thread(); … … 39 48 40 49 void SetOut(MLog *fout) { fOut = fout; } 41 //void TalkThreadTracking(); 42 50 43 51 ClassDef(MTracking, 0) 44 52 }; -
trunk/MagicSoft/Cosy/main/MainLinkDef.h
r2278 r4105 10 10 #pragma link C++ class MBending; 11 11 12 #pragma link C++ class MPointing; 13 #pragma link C++ class MTracking; 14 12 15 #endif -
trunk/MagicSoft/Cosy/main/Makefile
r2384 r4105 34 34 SRCFILES = MBending.cc \ 35 35 MStarguider.cc \ 36 MPointing.cc \ 37 MTracking.cc \ 36 38 MCaos.cc \ 37 39 MCosy.cc -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
r4076 r4105 59 59 fSolarRadiation = solar; 60 60 fWindSpeed = wind; 61 62 if (fWindSpeed>30) 63 fAlarmCounter++; 64 else 65 fAlarmCounter=0; 61 66 62 67 cout << "Zd/Az: " << zd << "/" << az << " "; … … 131 136 if (fHumidity>80) 132 137 rc++; 138 if (fWindSpeed>10) 139 rc++; 133 140 if (fWindSpeed>20) 134 141 rc++; 135 142 if (fWindSpeed>30) 136 143 rc++; 137 if (fWindSpeed>50)138 rc++;139 144 140 145 return rc; -
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h
r4076 r4105 31 31 ComStatus_t fComStat; // communication status 32 32 33 Float_t fHumidity; // [%] 34 Float_t fTemperature; // [deg] celsius 35 Float_t fWindSpeed; // [km/h] 36 Float_t fSolarRadiation; // [W/m^2] IR-Radiation 33 Float_t fHumidity; // [%] 34 Float_t fTemperature; // [deg] celsius 35 Float_t fWindSpeed; // [km/h] 36 Float_t fSolarRadiation; // [W/m^2] IR-Radiation 37 38 Int_t fAlarmCounter; // Counter for alarm cases 37 39 38 40 virtual bool InterpreteCmd(TString cmd, TString str); … … 56 58 TString GetWeather() const; 57 59 Int_t GetWeatherStatus() const; 60 61 Bool_t HasAlarm() const { return fAlarmCounter>3; } 58 62 }; 59 63 -
trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc
r4076 r4105 156 156 er *= kRad2Deg; 157 157 158 rd.Ra(rd.Ra() *24/360);158 rd.Ra(rd.Ra()/15); 159 159 160 160 // Set status flag -
trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
r4076 r4105 74 74 return true; 75 75 76 const Int_t rc = lout.IsOutputDeviceEnabled(MLog::eGui); 77 lout.DisableOutputDevice(MLog::eGui); 78 lout.Lock(); 79 lout << msg << flush; 80 lout.UnLock(); 81 if (rc) 82 lout.EnableOutputDevice(MLog::eGui); 76 if (lout.Lock("MTcpIpIO::Send")) 77 { 78 const Int_t rc = lout.IsOutputDeviceEnabled(MLog::eGui); 79 lout.DisableOutputDevice(MLog::eGui); 80 lout << msg << flush; 81 lout.UnLock("MTcpIpIO::Send"); 82 if (rc) 83 lout.EnableOutputDevice(MLog::eGui); 84 } 83 85 84 86 fTime = t; -
trunk/MagicSoft/Cosy/videodev/Camera.h
r4076 r4105 1 #ifndef C AMERA_H2 #define C AMERA_H1 #ifndef COSY_Camera 2 #define COSY_Camera 3 3 4 4 #ifndef ROOT_TMutex -
trunk/MagicSoft/Cosy/videodev/FilterLed.cc
r4076 r4105 8 8 #include "Ring.h" 9 9 10 #include "MGMap.h" 11 10 12 ClassImp(FilterLed); 11 12 void FilterLed::DrawCircle(float cx, float cy, float rpix, byte col) const13 {14 if (cx-rpix<1 || cy-rpix<1 || cx+rpix>fW-2 || cy+rpix>fH-2)15 return;16 17 for (int dx=-(int)(rpix*0.7); dx<(int)(rpix*0.7); dx+=2)18 {19 const int dy = (int)sqrt(rpix*rpix-dx*dx);20 fImg[(int)(cx+dx) + (int)(cy-dy)*fW] = col;21 fImg[(int)(cx+dx) + (int)(cy+dy)*fW] = col;22 fImg[(int)(cx-dy) + (int)(cy+dx)*fW] = col;23 fImg[(int)(cx+dy) + (int)(cy+dx)*fW] = col;24 }25 }26 27 void FilterLed::DrawCircle(const Ring &l, byte col=0x40) const28 {29 DrawCircle(l.GetX(), l.GetY(), l.GetR(), col);30 }31 32 void FilterLed::DrawCircle(const Ring &l, double r, byte col=0x40) const33 {34 DrawCircle(l.GetX(), l.GetY(), r, col);35 }36 13 37 14 void FilterLed::DrawBox(const int x1, const int y1, … … 39 16 const int col) const 40 17 { 41 for (int x=x1; x<x2+1; x++) 42 for (int y=y1; y<y2+1; y++) 43 if (x>=0 && x<fW-1 && y>=0 && y<fH-1) 44 fImg[y*fW+x] = col; 45 } 46 47 void FilterLed::MarkPoint(const Led &led) const 48 { 49 const int x = (int)(led.GetX()+.5); 50 const int y = (int)(led.GetY()+.5); 51 const int m = (int)(led.GetMag()); 52 53 MarkPoint(x, y, m); 18 MGMap::DrawBox(fImg, 768, 576, x1, y1, x2, y2, col); 54 19 } 55 20 … … 64 29 DrawBox(x+5, y, x+8, y, m); 65 30 DrawBox(x, y-8, x, y-5, m); 31 } 32 33 void FilterLed::MarkPoint(const Led &led) const 34 { 35 const int x = (int)(led.GetX()+.5); 36 const int y = (int)(led.GetY()+.5); 37 const int m = (int)(led.GetMag()); 38 39 MarkPoint(x, y, m); 40 } 41 42 void FilterLed::DrawCircle(float cx, float cy, float r, byte col) const 43 { 44 MGMap::DrawCircle(fImg, 768, 576, cx, cy, r, col); 45 } 46 47 void FilterLed::DrawCircle(const Ring &l, byte col) const 48 { 49 DrawCircle(l.GetX(), l.GetY(), l.GetR(), col); 50 } 51 52 void FilterLed::DrawCircle(const Ring &l, double r, byte col) const 53 { 54 DrawCircle(l.GetX(), l.GetY(), r, col); 66 55 } 67 56
Note:
See TracChangeset
for help on using the changeset viewer.