Changeset 1793 for trunk/MagicSoft/Cosy
- Timestamp:
- 02/25/03 21:07:13 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r1784 r1793 1 1 -*-*- END -*-*- 2 2003/02/25 - Thomas Bretz (La Palma): 3 4 * Makefile 5 - changed order of binaries 6 7 * base/timer.cc: 8 - corrected calculation of fMs (/1000 missing) 9 10 * gui/MGCosy.cc: 11 - added new tab Gear 12 13 * gui/MGSkyPosition.[h,cc]: 14 - fixed memory leak by not changing positions or having object 15 outside 16 - removed fake-statics 17 18 * main/MCosy.[h,cc]: 19 - adapted GetSePos to present shaftencoders 20 - changed speed to 0.15 and acc to 0.4 in positioning 21 - changed tracking cycle from 0.05s to 0.25s 22 - added WM_GEAR 23 - added WM_DISPLAY 24 - fixed displaying the SE offsets 25 - added TalkThreadGear 26 - changed DisplayHistTestSe 27 - added DisplayHistGear 28 - added check for second Zd-SE 29 - removed lout.SetOutputGui(NULL, kFALSE) because it crashes 30 when closing the spplication while tracking 31 32 33 2 34 2003/02/21 - Thomas Bretz (La Palma): 3 35 … … 10 42 * catalog/Slalib.h: 11 43 - added Hms2DegRad and Dms2Rad 44 12 45 13 46 -
trunk/MagicSoft/Cosy/Makefile
r1757 r1793 20 20 # 21 21 22 PROGRAMS = testse cosy starg22 PROGRAMS = testse starg cosy 23 23 SOLIB = 24 24 CINT = M -
trunk/MagicSoft/Cosy/base/timer.cc
r1760 r1793 104 104 fSec = (int)fmod(mjd, 60); 105 105 106 fMs = fmod(mjd * 1000, 1000) ;106 fMs = fmod(mjd * 1000, 1000)/1000; 107 107 } 108 108 -
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r1760 r1793 48 48 kPB_TPOINT, 49 49 kPB_START, 50 kPB_DISPLAY1, 51 kPB_DISPLAY2, 50 52 kPB_RAp, 51 53 kPB_RAm, … … 345 347 TGCompositeFrame *tf1 = fTab->AddTab("Position"); 346 348 TGCompositeFrame *tf2 = fTab->AddTab("Track"); 347 TGCompositeFrame *tf4 = fTab->AddTab("Calib ration");349 TGCompositeFrame *tf4 = fTab->AddTab("Calib"); 348 350 TGCompositeFrame *tf5 = fTab->AddTab("Test SE"); 351 TGCompositeFrame *tf6 = fTab->AddTab("Gear"); 349 352 /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo"); 350 353 … … 418 421 fList->Add(l3); 419 422 fList->Add(l4); 423 424 l1 = new TGLabel(tf6, "FIXME Text missing / Only one axis?"); 425 l1->Move(x, y); 426 fList->Add(l1); 420 427 421 428 // … … 465 472 fList->Add(but); 466 473 474 but = new TGTextButton(tf5, "Display", kPB_DISPLAY1); 475 but->Resize(80, 25); 476 but->Move(160, 197); 477 but->SetToolTipText("Display Histogram."); 478 but->Associate(this); 479 fList->Add(but); 480 481 but = new TGTextButton(tf6, "Display", kPB_DISPLAY2); 482 but->Resize(80, 25); 483 but->Move(160, 197); 484 but->SetToolTipText("Display Histogram."); 485 but->Associate(this); 486 fList->Add(but); 487 467 488 but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ); 468 489 but->Resize(80, 25); … … 1190 1211 return kTRUE; 1191 1212 case 4: 1213 fQueue->Proc(WM_GEAR, (void*)1); 1214 return kTRUE; 1215 case 5: 1192 1216 StartDemo(); 1193 1217 return kTRUE; … … 1201 1225 if (fTab->GetCurrent()==3) 1202 1226 fQueue->Proc(WM_TESTSE, NULL); 1227 if (fTab->GetCurrent()==4) 1228 fQueue->Proc(WM_GEAR, NULL); 1203 1229 cout << "PostMsg (WM_Stop) returned." << endl; 1204 1230 return kTRUE; … … 1256 1282 fQueue->PostMsg(WM_HOME, 0, 0); 1257 1283 return kTRUE; 1284 case kPB_DISPLAY1: 1285 case kPB_DISPLAY2: 1286 fQueue->PostMsg(WM_DISPLAY, 0, 0); 1287 return kTRUE; 1258 1288 1259 1289 default: -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc
r1784 r1793 97 97 // Reset 'static' positions of planets 98 98 // 99 /* 99 100 for (int i=0; i<9; i++) 100 101 { 101 fX[i] = ~0; 102 fY[i] = ~0; 103 } 102 fPlanetX[i] = ~0; 103 fPlanetY[i] = ~0; 104 } 105 for (int i=0; i<13; i++) 106 { 107 fStarX[i] = ~0; 108 fStarY[i] = ~0; 109 }*/ 104 110 } 105 111 … … 253 259 const float c = cos(zdaz.Az()); 254 260 255 const float x = s*zdaz.Zd()*kRad2Deg; // [deg] 256 const float y = c*zdaz.Zd()*kRad2Deg; // [deg] 261 float x = s*zdaz.Zd()*kRad2Deg; // [deg] 262 float y = c*zdaz.Zd()*kRad2Deg; // [deg] 263 264 if (x>95 || x<-95 || y>95 || y<-95) 265 { 266 if (arc->GetX1()==10 && arc->GetY1()==100) 267 return; 268 269 x=-100; 270 y= 100; 271 } 272 273 const int pixx = (int)(x/fPix); 274 const int pixy = (int)(y/fPix); 275 276 const int oldx = (int)(arc->GetX1()/fPix); 277 const int oldy = (int)(arc->GetY1()/fPix); 278 279 if (pixx==oldx && pixy==oldy) 280 return; 257 281 258 282 arc->SetX1(x); 259 283 arc->SetY1(y); 260 284 261 //SetModified();***MEMORY LEAK!!!***285 SetModified(); //***MEMORY LEAK!!!*** 262 286 } 263 287 … … 302 326 SetLin2(x+dy, y-dx, x-dy, y+dx); 303 327 304 if (zd<80)305 {328 //if (zd<80) 329 //{ 306 330 for(int i=0; i<3; i++) 307 331 SetDot(fDot[i], radec, i-3); 308 332 for(int i=3; i<6; i++) 309 333 SetDot(fDot[i], radec, i-2); 310 }334 //} 311 335 312 336 SetModified(); … … 363 387 364 388 RaDec radec = fSlaStar->CalcRaDecFast(pos*kDeg2Rad); 365 366 389 UpdatePosition(radec, pos.Zd(), pos.Az()); 367 390 UpdateText(pos.Zd(), pos.Az()); … … 387 410 const float deg = zdaz.Zd()*kRad2Deg; 388 411 389 const float x = s*deg; 390 const float y = c*deg; 412 float x = s*deg; 413 float y = c*deg; 414 415 if (x>95 || x<-95 || y>95 || y<-95) 416 { 417 if (arc->GetX1()==10 && arc->GetY1()==100) 418 return; 419 420 x=-100; 421 y= 100; 422 } 391 423 392 424 const int pixx = (int)(x/fPix); 393 425 const int pixy = (int)(y/fPix); 394 426 395 if (fX[planet]==pixx && fY[planet]==pixy) 427 const int oldx = (int)(arc->GetX1()/fPix); 428 const int oldy = (int)(arc->GetY1()/fPix); 429 430 if (oldx==pixx && oldy==pixy) 396 431 return; 397 398 fX[planet] = pixx;399 fY[planet] = pixy;400 432 401 433 // -
trunk/MagicSoft/Cosy/gui/MGSkyPosition.h
r1784 r1793 54 54 const MObservatory::LocationName_t fObservatory; 55 55 56 Int_t fX[9]; 57 Int_t fY[9]; 56 // Int_t fStarX[13]; 57 // Int_t fStarY[13]; 58 59 // Int_t fPlanetX[9]; 60 // Int_t fPlanetY[9]; 58 61 59 62 void InitArc(TArc *arc, Int_t fillstyle, Int_t fillcolor, Int_t linecolor); -
trunk/MagicSoft/Cosy/main/MCosy.cc
r1760 r1793 167 167 // Get the values 168 168 // 169 const int p1 = fZd1->GetPos();170 const int p2 = -fZd2->GetPos();169 int p1 = (fZd1->GetPos()+8192)%16384; 170 int p2 = -(fZd2->GetPos()+8192)%16384; 171 171 172 172 if (fZd1->IsZombieNode()) … … 180 180 float p = (float)(p1+p2)/2; 181 181 182 //183 // calculate 'regelabweichung'184 //185 182 return ZdAz(p, pa); 186 183 } … … 506 503 lout << "SetVelocity" << endl; 507 504 if (i) 508 SetPosVelocity(1.0, 0.1, 0.1); 509 else 510 SetPosVelocity(fabs(rd.Ratio()), 0.1, 0.3); 505 SetPosVelocity(1.0, 0.05, 0.1); 506 else // vel(0.6) acc(0.5) 507 SetPosVelocity(fabs(rd.Ratio()), 0.15, 0.4); 508 // SetPosVelocity(fabs(rd.Ratio()), 0.1, 0.3); 511 509 512 510 rd.Round(); … … 859 857 // (This is important on fast machines >500MHz) 860 858 // 861 usleep(50000); // 0. 05s862 //usleep(50000 0); // 0.5s859 usleep(50000); // 0.25s 860 //usleep(50000); // 0.05s 863 861 } 864 862 … … 907 905 bool MCosy::CheckNetwork() 908 906 { 909 return kTRUE;907 //return kTRUE; 910 908 //CheckConnections(); 911 909 … … 1030 1028 cout << "WM_TestSe: done. (return 0x1e51)" << endl; 1031 1029 return (void*)0x1e51; 1030 1031 case WM_GEAR: 1032 cout << "WM_Gear: start." << endl; 1033 fBackground = mp ? kBgdGear : kBgdNone; 1034 cout << "WM_Gear: done. (return 0xfeaf)" << endl; 1035 return (void*)0xfeaf; 1036 1037 case WM_DISPLAY: 1038 cout << "WM_Display: start." << endl; 1039 fTriggerDisplay = kTRUE; 1040 cout << "WM_Disply: done. (return 0xd1e1)" << endl; 1041 return (void*)0xd1e1; 1032 1042 1033 1043 case WM_TRACK: … … 1265 1275 { 1266 1276 phca1 = fZd1->PosHasChanged(); 1267 //phca2 = fZd2->PosHasChanged();1277 phca2 = fZd2->PosHasChanged(); 1268 1278 phcaz = fAz->PosHasChanged(); 1269 1279 usleep(1); … … 1293 1303 // 1294 1304 // FIXME 1295 time.Zd(fZd1->GetMjd());1296 /* OLD* 1305 //time.Zd(fZd1->GetMjd()); 1306 /* OLD* */ 1297 1307 if (fZd1->GetMjd()>fZd2->GetMjd()) 1298 1308 time.Zd(fZd1->GetMjd()); 1299 1309 else 1300 1310 time.Zd(fZd2->GetMjd()); 1301 */ 1311 1302 1312 //time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0); 1303 1313 time.Az(fAz->GetMjd()); … … 1338 1348 //--- fout << setprecision(5) << setw(7) << fTrackingError.Az() << endl; 1339 1349 } 1350 1351 lout << "Tracking Thread done." << endl; 1352 1340 1353 //--- fout << endl << endl; 1341 1354 } … … 1346 1359 // return; 1347 1360 1348 if (fHist TestSe)1361 if (fHist) 1349 1362 { 1350 1363 lout << "You are much too fast... try again." << endl; … … 1352 1365 } 1353 1366 1354 fHist TestSe= new TH2F("Diff", "Difference of SE values",1355 201, fMin.Zd(), fMax.Zd(), 101, -50, 50);1356 fHist TestSe->SetXTitle("ZA [\\circ]");1357 fHist TestSe->SetYTitle("\\Delta SE");1367 fHist = new TH2F("Diff", "Difference of SE values", 1368 201, fMin.Zd(), fMax.Zd(), 41, -10.5, 10.5); 1369 fHist->SetXTitle("ZA [\\circ]"); 1370 fHist->SetYTitle("\\Delta SE"); 1358 1371 1359 1372 Double_t offset = 0; … … 1372 1385 usleep(1); 1373 1386 1374 const Double_t pos[3] = { fZd1->GetPos(), fZd2->GetPos(), fAz->GetPos() }; 1387 const Double_t pos[3] = { 1388 (fZd1->GetPos()+8192)%16384, 1389 (fZd2->GetPos()+8192)%16384, 1390 fAz->GetPos() }; 1375 1391 1376 1392 // … … 1378 1394 // 1379 1395 if (cnt++<10) 1396 { 1380 1397 offset += pos[0]+pos[1]; 1381 if (cnt++==10) 1398 continue; 1399 } 1400 if (cnt==11) 1401 { 1382 1402 offset /= 10; 1383 if (cnt<11) 1403 cnt++; 1404 } 1405 1406 Double_t apos = (pos[0]-pos[1])/2 * TMath::Pi()*2 / 16384; 1407 1408 ZdAz bend = fBending.CorrectBack(ZdAz(apos, pos[2]))*kRad2Deg; 1409 fHist->Fill(bend.Zd(), pos[0]+pos[1]-offset); 1410 } 1411 1412 lout << "Shaftencoder Test Stopped... displaying Histogram." << endl; 1413 1414 fBackground=kBgdSeTestDispl; 1415 } 1416 1417 void MCosy::TalkThreadGear() 1418 { 1419 // if (fZd1->IsZombieNode() || fZd2->IsZombieNode()) 1420 // return; 1421 1422 if (fHist) 1423 { 1424 lout << "You are much too fast... try again." << endl; 1425 return; 1426 } 1427 1428 // fHist = new TH2F("Gear", "Gear Ratio Re/Se", 1429 // 201, fMin.Zd(), fMax.Zd(), 61, 349.5, 500.5); 1430 fHist = new TH2F("Gear", "Gear Ratio Re/Se", 1431 201, fMin.Az(), fMax.Az(), 61, 419.5, 570.5); 1432 fHist->SetXTitle("ZA [\\circ]"); 1433 fHist->SetYTitle("Re/Se"); 1434 1435 lout << "Starting Gear determination..." << endl; 1436 1437 ZdAz se0 = GetSePos(); 1438 ZdAz re0 = GetRePosPdo(); 1439 1440 while (fBackground==kBgdGear) 1441 { 1442 fZd1->ResetPosHasChanged(); 1443 fZd2->ResetPosHasChanged(); 1444 fAz->ResetPosHasChanged(); 1445 1446 while (!fZd1->PosHasChanged() && !fZd2->PosHasChanged() && 1447 !fAz->PosHasChanged() && fBackground==kBgdGear) 1448 usleep(1); 1449 1450 ZdAz se = GetSePos(); 1451 ZdAz re = GetRePosPdo(); 1452 1453 ZdAz dse = se-se0; 1454 ZdAz dre = re-re0; 1455 1456 if (fabs(dse.Zd())*144>16384) // Each 2.5deg 1457 { 1458 se0.Zd(se.Zd()); 1459 re0.Zd(re.Zd()); 1460 1461 ZdAz bend = fBending.CorrectBack(se*2*TMath::Pi()/16384)*kRad2Deg; 1462 fHist->Fill(bend.Zd(), dre.Zd()/dse.Zd()); 1463 } 1464 1465 if (fabs(dse.Az())*144>16384) // Each 2.5deg 1466 { 1467 se0.Az(se.Az()); 1468 re0.Az(re.Az()); 1469 1470 ZdAz bend = fBending.CorrectBack(se*2*TMath::Pi()/16384)*kRad2Deg; 1471 fHist->Fill(bend.Az(), dre.Az()/dse.Az()); 1472 1473 cout << bend.Az() << ": " << dre.Az()/dse.Az() << endl; 1474 } 1475 1476 /* 1477 const Double_t pos[3] = { 1478 (fZd1->GetPos()+8192)%16384, 1479 (fZd2->GetPos()+8192)%16384, 1480 fAz->GetPos() }; 1481 1482 // 1483 // Estimate Offset from the first ten positions 1484 // 1485 if (cnt++<10) 1486 { 1487 offset += pos[0]+pos[1]; 1384 1488 continue; 1489 } 1490 if (cnt==11) 1491 { 1492 offset /= 10; 1493 cnt++; 1494 } 1385 1495 1386 1496 Double_t apos = (pos[0]-pos[1])/2 * TMath::Pi()*2 / 16384; 1387 1497 1388 ZdAz bend = fBending(ZdAz(apos, pos[2]))*kRad2Deg; 1389 1498 ZdAz bend = fBending.CorrectBack(ZdAz(apos, pos[2]))*kRad2Deg; 1390 1499 fHistTestSe->Fill(bend.Zd(), pos[0]+pos[1]-offset); 1391 } 1392 1393 lout << "Shaftencoder Test Stopped... displaying Histogram." << endl; 1500 */ 1501 } 1502 lout << "Gear Test Stopped... displaying Histogram." << endl; 1503 1504 fBackground=kBgdGearDispl; 1394 1505 } 1395 1506 … … 1436 1547 case kBgdSeTest: 1437 1548 TalkThreadSeTest(); 1549 continue; 1550 1551 case kBgdGear: 1552 TalkThreadGear(); 1553 continue; 1554 1555 default: 1438 1556 continue; 1439 1557 } … … 1479 1597 */ 1480 1598 1481 if (fBackground==kBgdSeTest || fHistTestSe==NULL) 1482 return kTRUE; 1483 1484 DisplayHistTestSe(); 1599 const Bool_t trigger = fTriggerDisplay; 1600 fTriggerDisplay = kFALSE; 1601 1602 if (fBackground==kBgdSeTestDispl || (trigger&&fBackground==kBgdSeTest)) 1603 DisplayHistTestSe(!trigger); 1604 1605 if (fBackground==kBgdGearDispl || (trigger&&fBackground==kBgdGear)) 1606 DisplayHistGear(!trigger); 1485 1607 1486 1608 return kTRUE; 1487 1609 } 1488 1610 1489 void MCosy::DisplayHistTestSe() 1490 { 1491 TH2F &hist = *fHistTestSe; 1492 fHistTestSe = NULL; 1611 void MCosy::DisplayHistTestSe(Bool_t del) 1612 { 1613 lout << "Displaying histogram..." << endl; 1614 1615 TH2F &hist = *fHist; 1616 1617 if (del) 1618 { 1619 fHist = NULL; 1620 fBackground = kBgdNone; 1621 } 1493 1622 1494 1623 TCanvas *c=new TCanvas("c1", "", 1000, 1000); … … 1514 1643 p2.DrawCopy(); 1515 1644 1516 delete &hist; 1645 if (del) 1646 delete &hist; 1647 } 1648 1649 void MCosy::DisplayHistGear(Bool_t del) 1650 { 1651 lout << "Displaying histogram..." << endl; 1652 1653 TH2F &hist = *fHist; 1654 1655 if (del) 1656 { 1657 fHist = NULL; 1658 fBackground = kBgdNone; 1659 } 1660 1661 TCanvas *c=new TCanvas("c1", "", 1000, 1000); 1662 c->Divide(1,2); 1663 1664 c->cd(1); 1665 TH2 *h=(TH2*)hist.DrawCopy(); 1666 1667 TProfile *p = h->ProfileX("_pfx", -1, 9999, "s"); 1668 p->SetLineColor(kBlue); 1669 p->Draw("same"); 1670 p->SetBit(kCanDelete); 1671 1672 c->cd(2); 1673 1674 TH1F p2("spread", "Spread of the gear [16384/1500/4*U/U]", hist.GetNbinsX(), hist.GetBinLowEdge(1), 1675 hist.GetBinLowEdge(hist.GetNbinsX()+1)); 1676 p2.SetXTitle("ZA [\\circ]"); 1677 for (int i=0; i<hist.GetNbinsX(); i++) 1678 p2.SetBinError(i, p->GetBinError(i)); 1679 p2.SetLineColor(kRed); 1680 p2.SetStats(0); 1681 p2.DrawCopy(); 1682 1683 if (del) 1684 delete &hist; 1517 1685 } 1518 1686 … … 1549 1717 void MCosy::Stop() 1550 1718 { 1551 1552 1719 lout << "- Stopping GUI update." << endl; 1553 1720 fUpdateGui->TurnOff(); … … 1653 1820 bool MCosy::HasZombie() const 1654 1821 { 1655 bool ses = fZd1->IsZombieNode() &fZd2->IsZombieNode();1822 bool ses = fZd1->IsZombieNode() | fZd2->IsZombieNode(); 1656 1823 1657 1824 return fMac1->IsZombieNode() | fMac2->IsZombieNode() | fAz->IsZombieNode() | ses; … … 1729 1896 1730 1897 lout.DisableOutputDevice(MLog::eGui); 1731 lout.SetOutputGui(NULL, kFALSE); 1898 // FIXME: WHY DOES THIS CRASH THE APPLICATIOn WHILE TRAKING? 1899 // lout.SetOutputGui(NULL, kFALSE); 1732 1900 1733 1901 gApplication->Terminate(0); -
trunk/MagicSoft/Cosy/main/MCosy.h
r1760 r1793 27 27 #define WM_HOME 0x100a 28 28 #define WM_TESTSE 0x100b 29 #define WM_GEAR 0x100c 30 #define WM_DISPLAY 0x100d 29 31 30 32 … … 87 89 kBgdNone, 88 90 kBgdTracking, 89 kBgdSeTest 91 kBgdSeTest, 92 kBgdSeTestDispl, 93 kBgdGear, 94 kBgdGearDispl 90 95 }; 91 96 … … 101 106 ZdAz fMax; 102 107 103 TH2F *fHistTestSe; 108 TH2F *fHist; 109 Bool_t fTriggerDisplay; 104 110 105 111 XY kGearRatio; // describing the gear of the system [re/se] … … 138 144 void TalkThreadTracking(); 139 145 void TalkThreadSeTest(); 146 void TalkThreadGear(); 140 147 141 void DisplayHistTestSe(); 148 void DisplayHistTestSe(Bool_t del=kTRUE); 149 void DisplayHistGear(Bool_t del=kTRUE); 142 150 143 151 int SetPosition(const ZdAz &dst);
Note:
See TracChangeset
for help on using the changeset viewer.