Changeset 1793 for trunk/MagicSoft/Cosy/main
- Timestamp:
- 02/25/03 21:07:13 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.