Ignore:
Timestamp:
05/09/09 13:48:12 (15 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/main/MCaos.cc

    r9435 r9439  
    354354
    355355    //          img  width height radius sigma
    356     FilterLed f(img, 768, 576, fSizeBox, fCut);
     356    FilterLed f(img, 768, 576, fSizeBox, fSizeBox, fCut);
    357357
    358358    Int_t first=0;
     
    506506
    507507    if (IsEnvDefined(env, prefix, "MinNumberLeds", print))
    508         fMaxRadius = GetEnvValue(env, prefix, "MinNumberLeds", fMinNumberLeds);
     508        fMinNumberLeds = GetEnvValue(env, prefix, "MinNumberLeds", fMinNumberLeds);
    509509
    510510    if (IsEnvDefined(env, prefix, "SizeBox", print))
  • trunk/MagicSoft/Cosy/main/MCosy.cc

    r9435 r9439  
    219219    if (d.Zd()<fMin.Zd())
    220220    {
    221         gLog << err << "ERROR: Requested Zenith Angle below negative endswitch." << endl;
     221        gLog << err << "ERROR: Requested Zenith Angle " << d.Zd()*TMath::RadToDeg() << " below negative endswitch " << fMin.Zd()*TMath::RadToDeg() << endl;
    222222        return kFALSE;
    223223    }
     
    225225    if (d.Zd()>fMax.Zd())
    226226    {
    227         gLog << err << "ERROR: Requested Zenith Angle behind positive endswitch." << endl;
     227        gLog << err << "ERROR: Requested Zenith Angle " << d.Zd()*TMath::RadToDeg() << " behind positive endswitch " << fMax.Zd()*TMath::RadToDeg() << endl;
    228228        return kFALSE;
    229229    }
     
    231231    if (d.Az()<fMin.Az())
    232232    {
    233         gLog << err << "ERROR: Requested Azimuth Angle below negative endswitch." << endl;
     233        gLog << err << "ERROR: Requested Azimuth Angle " << d.Az()*TMath::RadToDeg() << " below negative endswitch " << fMin.Az()*TMath::RadToDeg() << endl;
     234        if (TMath::Abs(d.Zd())<1)
     235            gLog << "       Remember that there is a small inaccessible region around zenith!" << endl;
     236
    234237        return kFALSE;
    235238    }
     
    237240    if (d.Az()>fMax.Az())
    238241    {
    239         gLog << err << "ERROR: Requested Azimuth Angle behind positive endswitch." << endl;
     242        gLog << err << "ERROR: Requested Azimuth Angle " << d.Az()*TMath::RadToDeg() << " behind positive endswitch " << fMax.Az()*TMath::RadToDeg() << endl;
     243        if (TMath::Abs(d.Zd())<1)
     244            gLog << "       Remember that there is a small inaccessible region around zenith!" << endl;
    240245        return kFALSE;
    241246    }
     
    336341
    337342    // Default: point.SetPointAcc(0.03, 0.01);
     343    // Default: point.SetPointVelocity(0.3);
    338344    point.SetPointAcc(0.03, 0.01);
    339345    point.SetPointVelocity(0.3);
     346
     347    //point.SetPointAcc(0.09, 0.03);
     348    //point.SetPointVelocity(1.0);
    340349
    341350    return point.SetPosition(dst, track);
     
    513522    case WM_STARGTPOINT:
    514523        if (fStarguider)
    515             fStarguider->StartTPoint();
     524            fStarguider->StartTPoint((char*)mp);
    516525        return 0xca1c;
    517526
    518527    case WM_STARGMODE:
    519528        if (fStarguider)
    520             fStarguider->StartStarguider();
     529            fStarguider->StartStarguider(*((bool*)mp));
    521530        return 0xca1c;
    522531
     
    594603            cout << "Preposition command to " << preps << " received." << endl;
    595604
    596             ifstream fin("prepos.txt");
     605            ifstream fin(fFilePrepos);
    597606            if (!fin)
    598607            {
    599                 cout << "ERROR: cannot open prepos.txt." << endl;
     608                cout << "ERROR: cannot open " << fFilePrepos << endl;
    600609                return 0xebb1;
    601610            }
     
    817826    {
    818827        tout.Start(999);
    819         fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError, armed);
     828        fCom->SendReport(fStatus, fRaDec, fZdAzSoll, bendist, fTrackingError, armed,
     829                         fStarguider ? fStarguider->GetStarguiderMode() : 0);
    820830    }
    821831
     
    876886}
    877887
    878 // --------------------------------------------------------------------------
    879 //
    880 // Disable the synchronization by using a negative CAN Id for id2.
    881 //
    882 void MCosy::Constructor(Int_t id1, Int_t id2)
    883 {
    884     //
    885     // Create Nodes
    886     //
    887     gLog << inf << "- Setting up network." << endl;
    888 
    889     fMac1=new Dkc(id1, "DKC/Az");
    890     fMac2=new Dkc(id2, "DKC/Zd");
    891 
    892     fMac1->SetReport(fOutRep);
    893     fMac2->SetReport(fOutRep);
    894 
    895     gLog << inf << "- Connecting devices to network." << endl;
    896 
    897     //
    898     // Connect the devices to the network
    899     //
    900     SetNode(fMac1);
    901     SetNode(fMac2);
    902 
    903     //
    904     // Create Gui Event timer and Gui
    905     //
    906     gLog << inf << "- Initializing GUI Timer." << endl;
    907     fUpdateGui = new TTimer(this, 100); // 100ms
    908 
    909     gLog << all << "- Starting GUI." << endl;
    910     fWin=new MGCosy(fObservatory, this);
    911 }
    912 
    913 /*
    914 void MCosy::ConstructorDemo()
    915 {
    916     //
    917     // Create Nodes
    918     //
    919     gLog << "- Setting up network." << endl;
    920 
    921     //
    922     // Create Gui Event timer and Gui
    923     //
    924     gLog << "- Initializing GUI Timer." << endl;
    925     fUpdateGui = new TTimer(this, 100); // 100ms
    926 
    927     gLog << "- Starting GUI." << endl;
    928     fWin=new MGCosy(fObservatory, this, gClient->GetRoot(), 1, 1);
    929 }
    930 */
    931 
    932888TString MCosy::GetFileName(const char *path, const char *name, const char *ext)
    933889{
     
    963919}
    964920
    965 MCosy::MCosy(MEnv &env, MDriveCom *com, const char *pointing)
     921MCosy::MCosy(MEnv &env, MDriveCom *com)
    966922: Network(), fObservatory(MObservatory::kMagic1), fStarguider(NULL),
    967923fMac1(0), fMac2(0), fStatus(MDriveCom::kStopped), fOutTp(0), fOutRep(0)
     
    969925    const Int_t id1 = env.GetValue("Az_Id", 1);
    970926    const Int_t id2 = env.GetValue("Zd_Id", 3);
     927
     928    fFilePrepos = env.GetValue("FilePredefinedPositions", "prepos.txt");
    971929
    972930    TString name = GetFileName("rep", "cosy", "rep");
     
    978936    *fOutRep << "[Reports]" << endl;
    979937
    980 /*
    981     gLog << "- Program in ";
    982     switch (mode)
    983     {
    984     case 0:
    985     gLog << "<<Standard mode>>" << endl;*/
    986         gLog << all << "Reading pointing model from " << pointing << "..." << endl;
    987         if (fBending.Load(pointing))
    988             gLog << all << "Reading pointing model from " << pointing << " successfull." << endl;
    989         else
    990             gLog << err << "ERROR - Reading pointing model from " << pointing << endl;
    991         Constructor(id1, id2);/*
    992         break;
    993     case 1:
    994         gLog << "<<SE mode>>" << endl;
    995         fBending.Load("bending.txt");
    996         ConstructorSE(id4, id5, id6);
    997         break;
    998     default:
    999         gLog << "<<Demo mode>>" << endl;
    1000         ConstructorDemo();
    1001     }
    1002 */
     938    const TString pointing = env.GetValue("PointingModel", "bending.txt");
     939
     940    gLog << all << "Reading pointing model from " << pointing << "..." << endl;
     941    if (fBending.Load(pointing))
     942        gLog << all << "Reading pointing model from " << pointing << " successfull." << endl;
     943    else
     944        gLog << err << "ERROR - Reading pointing model from " << pointing << endl;
     945
     946    //
     947    // Create Nodes
     948    //
     949    gLog << inf << "- Setting up network." << endl;
     950
     951    fMac1=new Dkc(id1, "DKC/Az");
     952    fMac2=new Dkc(id2, "DKC/Zd");
     953
     954    fMac1->SetReport(fOutRep);
     955    fMac2->SetReport(fOutRep);
     956
     957    gLog << inf << "- Connecting devices to network." << endl;
     958
     959    //
     960    // Connect the devices to the network
     961    //
     962    SetNode(fMac1);
     963    SetNode(fMac2);
     964
     965    //
     966    // Create Gui Event timer and Gui
     967    //
     968    gLog << inf << "- Initializing GUI Timer." << endl;
     969    fUpdateGui = new TTimer(this, 100); // 100ms
     970
     971    gLog << all << "- Starting GUI." << endl;
     972    fWin=new MGCosy(fObservatory, fFilePrepos, this);
    1003973
    1004974    gLog.SetOutputGui(fWin->GetLog(), kTRUE);
  • trunk/MagicSoft/Cosy/main/MCosy.h

    r9435 r9439  
    9191    MLog     *fOutRep;
    9292
     93    TString fFilePrepos;
     94
    9395    ZdAz AlignTrackingPos(ZdAz pointing) const;
    9496    Bool_t CheckRange(const ZdAz &d) const;
     
    122124
    123125public:
    124     MCosy(MEnv &env, MDriveCom *com, const char *pointing);
     126    MCosy(MEnv &env, MDriveCom *com);
    125127    ~MCosy();
    126128
  • trunk/MagicSoft/Cosy/main/MStarguider.cc

    r9435 r9439  
    1 #undef EXPERT
    21#undef EXPERT
    32
     
    307306
    308307    fGStarg = new MGStarg(this, 235);
    309     fGStarg->DrawText("0.75'", "1.50'", "3.00'", "Mispointing [min]");
    310     fGStarg->DrawHexagon();
    311308    fGStarg->Move(530,596+5);
    312309    fList->Add(fGStarg);
     
    342339
    343340    fTPoint = new TGTextButton(this, "TPoint");
    344     fTPoint->Move(4, fMenu->GetDefaultHeight()+785);
     341    //fTPoint->Move(4, fMenu->GetDefaultHeight()+785);
     342    fTPoint->Move(170, fMenu->GetDefaultHeight()+785);
    345343    fTPoint->AllowStayDown(kTRUE);
    346344    AddFrame(fTPoint);
    347 
    348     fStargTPoint = new TGTextButton(this, "StargTPoint");
    349     fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785);
    350     fStargTPoint->AllowStayDown(kTRUE);
    351     AddFrame(fStargTPoint);
     345    /*
     346     fStargTPoint = new TGTextButton(this, "StargTPoint");
     347     fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785);
     348     fStargTPoint->AllowStayDown(kTRUE);
     349     AddFrame(fStargTPoint);
     350    */
    352351
    353352    fFps = new TGLabel(this, "---fps");
     
    448447    MapSubwindows();
    449448    fTPoint->UnmapWindow();
    450     fStargTPoint->UnmapWindow();
     449    //fStargTPoint->UnmapWindow();
    451450    fGStarg->UnmapWindow();
    452451    fGNumStars->UnmapWindow();
     
    479478      fOutTp(0),
    480479      fOutStargTp(0),
    481       fOutRq(0),
     480//      fOutRq(0),
    482481      fDx((768-kZOOM)/2),
    483482      fDy((512-kZOOM)/2),
    484483      fStatus(MDriveCom::kStandby),
    485484      fRadius(200),
    486       fTPointFromCC(0)
     485      fTPointFromCC(-1),
     486      fFindStarCut(3.0), fFindStarBox(70)
    487487{
    488488    gLog << warn << " #### FIXME: Make MCaos Thread safe!" << endl;
     
    557557
    558558    fRadius = env.GetValue("Leds.Radius", fRadius);
     559
     560    fStarguiderW = env.GetValue("Starguider.Width",  fStarguiderW);
     561    fStarguiderH = env.GetValue("Starguider.Height", fStarguiderH);
     562    fStarguiderX = env.GetValue("Starguider.X",      fStarguiderX);
     563    fStarguiderY = env.GetValue("Starguider.Y",      fStarguiderY);
     564
     565    fSkyOffsetX = env.GetValue("Starguider.SkyOffsetX", fSkyOffsetX);
     566    fSkyOffsetY = env.GetValue("Starguider.SkyOffsetY", fSkyOffsetY);
     567
     568    fFindStarBox = env.GetValue("FindStar.SizeBox",       fFindStarBox);
     569    fFindStarCut = env.GetValue("FindStar.CleaningLevel", fFindStarCut);
    559570}
    560571
     
    583594        delete fOutStargTp;
    584595
    585     if (fOutRq)
    586         delete fOutRq;
     596//    if (fOutRq)
     597//        delete fOutRq;
    587598
    588599    gLog << inf2 << "Camera Display destroyed." << endl;
     
    649660}
    650661
     662/*
    651663void MStarguider::ToggleFindStar()
    652664{
    653665    if (fDisplay->IsEntryChecked(IDM_kFindStar) && fCosy)
    654         fTPoint->MapWindow();
     666    fTPoint->MapWindow();
    655667    else
    656668    {
     
    659671    }
    660672}
    661 
     673*/
    662674void MStarguider::ToggleStarguider()
    663675{
     
    671683        fOperations->EnableEntry(IDM_kStargAnalysis);
    672684
    673         fStargTPoint->MapWindow();
     685        //fStargTPoint->MapWindow();
    674686
    675687        fPZdAz->MapWindow();
     
    703715        SwitchOff(fChannel, IDM_kChannel2);
    704716        fChannel->CheckEntry(IDM_kChannel1);
    705 
    706717    }
    707718    else
     
    709720        fStatus = MDriveCom::kStandby;
    710721
    711         fStargTPoint->UnmapWindow();
    712         fStargTPoint->SetDown(kFALSE);
     722        //fStargTPoint->UnmapWindow();
     723        //fStargTPoint->SetDown(kFALSE);
    713724
    714725        fPZdAz->UnmapWindow();
     
    772783    MapSubwindows(); // maps everything, but we don't want that
    773784    fTPoint->UnmapWindow();
    774     fStargTPoint->UnmapWindow();
     785    //fStargTPoint->UnmapWindow();
    775786    fGStarg->UnmapWindow();
    776787    fGNumStars->UnmapWindow();
     
    863874                    //tpoint
    864875                    SwitchOff(fDisplay, IDM_kFindStar);
    865                     ToggleFindStar();
    866876                    SwitchOff(fDisplay, IDM_kCaosFilter);
    867877                    ToggleCaosFilter();
     
    874884
    875885                    //check needed items
    876                     fDisplay->CheckEntry(IDM_kStretch);
     886                    fDisplay->UnCheckEntry(IDM_kStretch);
    877887                    fDisplay->CheckEntry(IDM_kStargCaosFilter);
    878888                    fDisplay->CheckEntry(IDM_kStarguider);
    879889                    ToggleStarguider();
     890
     891                    fTPoint->MapWindow();
    880892                }
    881893                else
     
    885897                    fDisplay->UnCheckEntry(IDM_kStargCaosFilter);
    886898                    fDisplay->UnCheckEntry(IDM_kStarguider);
     899                    fTPoint->UnmapWindow();
    887900                    ToggleStarguider();
    888901
     
    922935
    923936                    //checking needed items
    924                     fDisplay->CheckEntry(IDM_kStretch);
     937                    fDisplay->UnCheckEntry(IDM_kStretch);
    925938                    fDisplay->CheckEntry(IDM_kCaosFilter);
    926939                    ToggleCaosFilter();
    927940                    fDisplay->CheckEntry(IDM_kFindStar);
    928                     ToggleFindStar();
     941                    fTPoint->MapWindow();
    929942                }
    930943                else
     
    946959                    ToggleCaosFilter();
    947960                    fDisplay->UnCheckEntry(IDM_kFindStar);
    948                     ToggleFindStar();
     961                    fTPoint->UnmapWindow();
    949962                }
    950963                return kTRUE;
     
    956969            case IDM_kFindStar:
    957970                Toggle(fDisplay, IDM_kFindStar);
    958                 ToggleFindStar();
     971                //ToggleFindStar();
    959972                return kTRUE;
    960973
     
    12931306#endif
    12941307
     1308    return fSao->CalcDeltaZdAzFromPix(mx, my)*TMath::RadToDeg();
     1309/*
    12951310    AltAz pos0 = fSao->CalcAltAzFromPix(768/2,    576/2)*kRad2Deg;
    12961311    AltAz pos1 = fSao->CalcAltAzFromPix(768/2+mx, 576/2+my)*kRad2Deg;
     
    12981313    pos1 -= pos0;
    12991314
    1300     return ZdAz(-pos1.Alt(), pos1.Az());
    1301 }
    1302 
    1303 Int_t MStarguider::CalcTrackingError(Leds &leds, MStarList &stars,
    1304                                      ZdAz &d, MTime &t, double &bright, Int_t &num)
    1305 {
     1315    ZdAz res2 = ZdAz(-pos1.Alt(), pos1.Az());
     1316
     1317    return res1;
     1318*/
     1319}
     1320
     1321Int_t MStarguider::CalcTrackingError(const Leds &leds, MStarList &stars,
     1322                                     ZdAz &d, const MTime &t, const double &bright,
     1323                                     Int_t &num, const Ring &center, Int_t numleds, Int_t numrings)
     1324{
     1325    // Get tracking coordinates
     1326    const XY xy = fCRaDec->GetCoordinates();
     1327
    13061328    num = leds.GetEntries();
    13071329    if (num < 3) //was 1
    13081330    {
    13091331        gLog << warn << "Sorry, less than 3 detected spot in FOV!" << endl;
    1310         fStargTPoint->SetDown(kFALSE);
     1332        if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
     1333            fCosy->GetDriveCom()->SendTPoint(false, 'S', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings, num);    // Report
     1334        fTPoint->SetDown(kFALSE);
    13111335        return 0;
    13121336    }
     
    13151339    {
    13161340        gLog << warn << "Sorry, less than 3 stars in FOV!" << endl;
    1317         fStargTPoint->SetDown(kFALSE);
     1341        if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
     1342            fCosy->GetDriveCom()->SendTPoint(false, 'S', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings, num);    // Report
     1343        fTPoint->SetDown(kFALSE);
    13181344        return 0;
    13191345    }
     
    13751401    if (numcor<1)
    13761402    {
    1377         fStargTPoint->SetDown(kFALSE);
     1403        fTPoint->SetDown(kFALSE);
     1404        if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
     1405            fCosy->GetDriveCom()->SendTPoint(false, 'S', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings, num, numcor);    // Report
    13781406        return 0;
    13791407    }
     
    13881416
    13891417    // Check StargTPoint data set request
    1390     if (!fStargTPoint->IsDown())
     1418    if (!fDisplay->IsEntryChecked(IDM_kStarguiderMode) || !fTPoint->IsDown())
    13911419        return numcor;
    1392     fStargTPoint->SetDown(kFALSE);
     1420    fTPoint->SetDown(kFALSE);
    13931421
    13941422    // If no file open: open new file
     
    14061434    }
    14071435
    1408     // Get tracking coordinates
    1409     const XY    xy = fCRaDec->GetCoordinates();
    14101436    const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());
    14111437
     
    14301456
    14311457    // Write real pointing position
    1432     //cout << "     Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
    14331458    *fOutStargTp << setprecision(7) << za0.Az() << " " << za0.Alt() << " ";
    14341459
    14351460    // Write system pointing position
    1436     //cout << "     SE-Pos: " << 90-cpos.Zd() << "° " << cpos.Az() << "°" << endl;
    14371461    *fOutStargTp << fmod(cpos.Az()+360, 360) << " " << 90-cpos.Zd();
    14381462
     
    14401464    *fOutStargTp << " " << d.Zd() << " " << d.Az();
    14411465    *fOutStargTp << " " << setprecision(11) << t.GetMjd();
    1442     *fOutStargTp << " " << num;
    1443     *fOutStargTp << " " << bright;
     1466    *fOutStargTp << " " << setprecision(4) << center.GetMag();
     1467    *fOutStargTp << " " << star->GetMag();
     1468    *fOutStargTp << " " << center.GetX() << " " << center.GetY();
     1469    *fOutStargTp << " 0 0";
     1470    *fOutStargTp << " " << numleds << " " << numrings;
     1471    *fOutStargTp << " " << num << " " << numcor << " " << bright;
    14441472    *fOutStargTp << endl;
    14451473
     1474    gLog << all << "Starguider TPoint successfully taken." << endl;
     1475
    14461476    fTimeFromTp.Clear();
    14471477
     1478    if (!fCosy)
     1479        return numcor;
     1480
     1481    MDriveCom *com = fCosy->GetDriveCom();
     1482    if (!com)
     1483        return numcor;
     1484
     1485    com->SendTPoint(true, 'S', fTPointStarMag, fTPointStarName, za0, cpos, xy, d.Zd(), d.Az(), t, center, Led(), numleds, numrings, num, numcor);    // Report
     1486
    14481487    return numcor;
    14491488}
    14501489
    1451 void MStarguider::FindStar(FilterLed &f, FilterLed &f2, Ring &center, MTime &t)
    1452 {
     1490void MStarguider::FindStar(const FilterLed &f, const FilterLed &f2, const Ring &center, const MTime &t, Int_t numleds, Int_t numrings)
     1491{
     1492    // Get tracking coordinates
     1493    const XY xy = fCRaDec->GetCoordinates();  // [h, deg]
     1494
     1495    if (center.GetX()<=0 && center.GetY()<=0)
     1496    {
     1497        gLog << warn << "Couldn't determine center of the camera." << endl;
     1498        if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
     1499            fCosy->GetDriveCom()->SendTPoint(false, 'T', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings);    // Report
     1500        return;
     1501    }
     1502
    14531503    // Try to find the star
    14541504    Leds leds;
     
    14591509    if (!star)
    14601510    {
    1461         if (fTPoint->IsDown())
    1462         {
    1463             fTPoint->SetDown(kFALSE);
    1464             gLog << warn << "No star found. Couldn't take a tpoint." << endl;
    1465         }
     1511        gLog << warn << "No star found." << endl;
     1512        if (fTPoint->IsDown() && fCosy && fCosy->GetDriveCom())
     1513            fCosy->GetDriveCom()->SendTPoint(false, 'T', fTPointStarMag, fTPointStarName, AltAz(), ZdAz(), xy, 0, 0, t, center, Led(), numleds, numrings);    // Report
    14661514        return;
    14671515    }
     
    14701518    star->Print();
    14711519    f2.MarkPoint(star->GetX(), star->GetY(), 2<<2);
     1520
     1521    const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());
    14721522
    14731523    // Initialize Star Catalog on the camera plane
     
    14781528    ac.SetObservatory(*fSao);
    14791529    ac.SetTime(t);
    1480 
    1481     // Get tracking coordinates
    1482     const XY xy = fCRaDec->GetCoordinates();  // [h, deg]
    1483     const RaDec rd(xy.X()*MAstro::HorToRad(), xy.Y()*TMath::DegToRad());
    1484 
    14851530    ac.SetRaDec(rd.Ra(), rd.Dec());
    14861531
     
    15001545
    15011546    // Check TPoint data set request
    1502     if (!fTPoint->IsDown())
     1547    if (!fDisplay->IsEntryChecked(IDM_kTpointMode) || !fTPoint->IsDown())
    15031548        return;
    1504 
    1505     fTPoint->SetDown(kFALSE);
    15061549
    15071550    // If no file open: open new file
     
    15391582    const ZdAz za1 = fCosy->GetSePos()*360; // [deg]
    15401583
     1584
    15411585    // Write real pointing position
    15421586    //cout << "     Alt/Az: " << za0.Alt() << "° " << za0.Az() << "°" << endl;
     
    15521596    *fOutTp << " " << setprecision(4) << center.GetMag();
    15531597    *fOutTp << " " << star->GetMag();
     1598    *fOutTp << " " << center.GetX() << " " << center.GetY();
     1599    *fOutTp << " " << star->GetX() << " " << star->GetY();
     1600    *fOutTp << " " << numleds << " " << numrings;
     1601    *fOutTp << " 0 0 0";
    15541602    *fOutTp << endl;
     1603
     1604    gLog << all << "TPoint successfully taken." << endl;
    15551605/*
    15561606    MLog &outrep = *fCosy->GetOutRep();
     
    15701620   
    15711621//    return zdaz;
     1622
     1623    if (!fCosy)
     1624        return;
     1625
     1626    MDriveCom *com = fCosy->GetDriveCom();
     1627    if (!com)
     1628        return;
     1629
     1630    com->SendTPoint(true, 'T', fTPointStarMag, fTPointStarName, za0, za1, xy, -dzd, -daz, t, center, *star, numleds, numrings);    // Report
    15721631}
    15731632
     
    16241683}
    16251684
    1626 void MStarguider::StartStarguider()
     1685void MStarguider::StartTPoint(char *cmd)
     1686{
     1687    fTPointStarName = "Dummy";
     1688    fTPointStarMag  = 0;
     1689
     1690    TString str(cmd);
     1691
     1692    TObjArray *arr = str.Tokenize(' ');
     1693
     1694    if (arr->GetEntries()==2)
     1695    {
     1696        fTPointStarName = (*arr)[0]->GetName();
     1697        fTPointStarMag  = atof((*arr)[1]->GetName());
     1698    }
     1699
     1700    delete arr;
     1701
     1702    if (fTPointFromCC<0)
     1703        fTPointFromCC=0;
     1704}
     1705
     1706void MStarguider::StartStarguider(bool on)
    16271707{
    16281708    // Switch to starguider mode
    1629     cout << " * Switching to Starguider mode" << endl;
    1630     fMode->UnCheckEntry(IDM_kStarguiderMode);
    1631     ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0);
     1709    if (on)
     1710    {
     1711        cout << " * Switching Starguider mode on" << endl;
     1712        fMode->UnCheckEntry(IDM_kStarguiderMode);
     1713        ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0);
     1714    }
     1715    else
     1716    {
     1717        cout << " * Switching Starguider mode off" << endl;
     1718        fMode->CheckEntry(IDM_kStarguiderMode);
     1719        ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kStarguiderMode, 0);
     1720    }
     1721}
     1722
     1723Int_t MStarguider::GetStarguiderMode() const
     1724{
     1725    return fMode->IsEntryChecked(IDM_kStarguiderMode) ? 1 : 2;
     1726
    16321727}
    16331728
    16341729Bool_t MStarguider::DoTPoint()
    16351730{
     1731    if (fTPoint->IsDown() && fTPointFromCC<0)
     1732    {
     1733        fTPointFromCC = 0;
     1734        fTPoint->SetDown(kFALSE);
     1735    }
     1736
    16361737    if (fTPointFromCC<0)
    16371738        return kTRUE;
     
    16501751
    16511752    case 2:
     1753    case 3:
    16521754        cout << " * Waiting one frame" << endl;
    16531755        // Wait one frame
    16541756        return kFALSE;
    16551757
    1656     case 3:
     1758    case 4:
    16571759        cout << " * Taking TPoint" << endl;
    16581760        fTPoint->SetDown(); // kTRUE
    16591761        return kTRUE;
    16601762
    1661     case 4:
     1763    case 5:
    16621764        if (!fTimeFromTp) // TPoint failed
    16631765            break;
     
    16691771        return kFALSE;
    16701772
    1671     case 5:
     1773    case 6:
     1774    case 7:
    16721775        cout << " * Waiting one frame" << endl;
    16731776        // Wait one frame
    16741777        return kFALSE;
    16751778
    1676     case 6:
     1779    case 8:
    16771780        cout << " * Taking Starguider TPoint" << endl;
    1678         fStargTPoint->SetDown(); // kTRUE
     1781        fTPoint->SetDown(); // kTRUE
    16791782        return kTRUE;
    16801783
    1681     case 7:
    1682         cout << " * Send Report" << endl;
     1784//    case 9:
     1785//        cout << " * Send Report" << endl;
     1786//        return kTRUE;
     1787
     1788    case 9:
     1789        cout << " * Switching to TPoint mode" << endl;
     1790        // Switch to tpoint mode
     1791        fMode->UnCheckEntry(IDM_kTpointMode);
     1792        ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU), IDM_kTpointMode, 0);
    16831793        break;
    16841794    }
     
    16861796    // Send report
    16871797    fTPointFromCC = -1;
    1688 
     1798/*
    16891799    if (!fCosy)
    16901800        return kTRUE;
     
    17021812    //fNumStarsCorrelated = rc;
    17031813    com->SendTPoint(fNumStarsCorrelated>0);
    1704 
     1814*/
    17051815    return kTRUE;
    17061816}
     
    17361846    if (!fWritePictures->IsEntryEnabled(IDM_kStart) &&
    17371847        (!(n%fWrtRate) || fWriteType->IsEntryChecked(IDM_kOnce)))
    1738     {     
     1848    {
    17391849
    17401850        if (fFileType->IsEntryChecked(IDM_kPNG))
     
    17521862        f.Execute();
    17531863
    1754     DoTPoint();
     1864    if (!DoTPoint())
     1865        return;
    17551866
    17561867    Int_t numleds = 0;
     
    17581869
    17591870    // Find Center of Camera for Caos and Tpoints
    1760     Ring center(768/2, 576/2);
     1871//    Ring center;//(-1, -1);
     1872    Ring center(5, 5);//(-1, -1);
    17611873    if (fDisplay->IsEntryChecked(IDM_kCaosFilter))
    17621874    {
     
    17741886
    17751887    // Find Star at Center---for Tpoint Procedure
    1776     if (fDisplay->IsEntryChecked(IDM_kFindStar) &&
    1777         center.GetX()>0 && center.GetY()>0)
     1888    if (fDisplay->IsEntryChecked(IDM_kFindStar))
    17781889    {
    17791890        // Set search Paremeters (FIXME: Get them from user input!)
    1780         f.SetCut(3.0);
    1781         f.SetBox(70);
    1782 
    1783         FindStar(f, f2, center, t);
     1891        f.SetCut(fFindStarCut);
     1892        f.SetBox(fFindStarBox);
     1893
     1894        FindStar(f, f2, center, t, numleds, numrings);
    17841895    }
    17851896
     
    17881899
    17891900    // Position corresponding to the camera center (53.2, 293.6)
    1790     Ring sgcenter(53.2, 293.6); // Center of camera in SG picture [px]
     1901    Ring sgcenter;//(-1, -1); // Center of camera in SG picture [px]
    17911902
    17921903    // Find Center of Camera in Starfield Camera picture
     
    18171928        fCZdAz->SetCoordinates(fSao->GetZdAz());
    18181929
    1819         fSao->SetBox(230); // Region of interest around center
     1930        fSao->SetBox(fStarguiderW, fStarguiderH); // 280 Region of interest around center
    18201931
    18211932        // If center of camera cannot be determined sgcenter is (0,0)
    18221933        const Bool_t centerisvalid = sgcenter.GetX()>0 && sgcenter.GetY()>0;
    1823 //        if (centerisvalid)
    1824 //            skycenter.SetXY(sgcenter.GetX() -  53.2,
    1825 //                            sgcenter.GetY() - 293.6);
    18261934
    18271935        // We determine the ideal starfield using camera sagging info
     
    18301938        // 53.2 and 293.6 are the "preliminary" camera center
    18311939        // -9 and 28.5 are the offsets of the pointing position in the sky
    1832         const XY off(sgcenter.GetX()- 53.2-9,
    1833                      sgcenter.GetY()-293.6+28.5);
    1834 
    1835         // we obtain stars in the effective star FOV and draw them.
    1836         // coordinates are video frame coords.
    1837         MStarList stars;
    1838         fSao->CalcStars(stars, 530, 292, TMath::FloorNint(off.X()), TMath::FloorNint(off.Y()));
    1839         fSao->DrawStars(stars, cimg);
    1840 
    1841         // Position around which the circles are drawn.
    1842         const Ring skycenter(768/2-off.X(), 576/2+off.Y());
     1940        //const XY off(sgcenter.GetX()- 53.2-9,
     1941        //             sgcenter.GetY()-293.6+28.5);
     1942
     1943        // Skycenter
     1944        const XY off(sgcenter.GetX() + fSkyOffsetX,
     1945                     sgcenter.GetY() + fSkyOffsetY);
     1946
     1947        MStarList stars;
     1948        if (centerisvalid)
     1949        {
     1950            // we obtain stars in the effective star FOV and draw them.
     1951            // coordinates are video frame coords.
     1952            fSao->CalcStars(stars, fStarguiderX, fStarguiderY, off.X(), off.Y());
     1953            fSao->DrawStars(stars, cimg);
     1954        }
    18431955
    18441956        // There are two corrections to the mispointing
     
    18531965
    18541966            Leds spots;
    1855             f.SetBox(230);
     1967            f.SetBox(fStarguiderW, fStarguiderH); // 280
    18561968            f.SetCut(cut);
    18571969
    18581970            double bright;
    1859             f.ExecuteAndMark(spots, 530, 292, bright);
     1971            f.ExecuteAndMark(spots, fStarguiderX, fStarguiderY, bright);
    18601972
    18611973            ULong_t color;
     
    18781990
    18791991            Int_t numstars = 0;
    1880             const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars);
     1992            const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars, sgcenter, numleds, numrings);
    18811993
    18821994            const Bool_t monitoring = brightnessisvalid && centerisvalid && fNumStarsCorrelated>2;
     
    19072019        if (centerisvalid && fNumStarsCorrelated>2)
    19082020        {
     2021            // Position around which the circles are drawn.
     2022            const Ring skycenter(off.X(), off.Y());
     2023
    19092024            f2.DrawCircle(skycenter,   2.0,     0x0a);
    19102025
     
    19172032
    19182033    } //CalcStars
     2034
     2035    if (fTPoint->IsDown())
     2036        fTPoint->SetDown(kFALSE);
    19192037
    19202038    // Draw Circles around center of Camera
     
    19482066void MStarguider::UpdatePosZoom()
    19492067{
    1950     MString txt;
     2068    MString txt;/*
    19512069    if (fDisplay->IsEntryChecked(IDM_kCatalog))
    19522070    {
     
    19582076        txt.Form("(%d, %d) %.1fd/%.1fd", fDx, fDy, -aa.Alt(), aa.Az()-180);
    19592077    }
    1960     else
     2078    else*/
    19612079        txt.Form("(%d, %d)", fDx, fDy);
    19622080    fPosZoom->SetText(txt);
  • trunk/MagicSoft/Cosy/main/MStarguider.h

    r9435 r9439  
    9898
    9999    TGButton      *fTPoint;
    100     TGButton      *fStargTPoint;
     100//    TGButton      *fStargTPoint;
    101101
    102102    ZdAz          fPos;
     
    121121    ofstream *fOutTp;
    122122    ofstream *fOutStargTp;
    123     ofstream *fOutRq;
     123//    ofstream *fOutRq;
    124124
    125125    Int_t fDx;
     
    135135
    136136    Int_t fTPointFromCC;
     137
     138    Int_t fStarguiderW;
     139    Int_t fStarguiderH;
     140    Int_t fStarguiderX;
     141    Int_t fStarguiderY;
     142
     143    Float_t fSkyOffsetX;  // Offset between camera center and sky position
     144    Float_t fSkyOffsetY;  // Offset between camera center and sky position
     145
     146    Float_t fFindStarCut;
     147    Int_t   fFindStarBox;
     148
     149    TString fTPointStarName;
     150    Float_t fTPointStarMag;
    137151
    138152    void Toggle(TGPopupMenu *p, UInt_t id);
    139153    void SwitchOff(TGPopupMenu *p, UInt_t id);
    140154    void ToggleStargAnalysis();
    141     void ToggleFindStar();
     155//    void ToggleFindStar();
    142156    void ToggleStarguider();
    143157    void ToggleCaosFilter();
    144158    void SetChannel();
    145     Int_t CalcTrackingError(Leds &, MStarList &, ZdAz &, MTime &, double &bright, Int_t &num);
     159    Int_t CalcTrackingError(const Leds &, MStarList &, ZdAz &, const MTime &, const double &bright, Int_t &num, const Ring &center, Int_t numleds, Int_t numrings);
    146160    ZdAz TrackingError(TArrayF &alt, TArrayF &az, TArrayF &mag, Int_t &num) const;
    147161    bool Interpolate(const unsigned long n, byte *img) const;
    148     void FindStar(FilterLed &f, FilterLed &f2, Ring &center, MTime &t);
     162    void FindStar(const FilterLed &f, const FilterLed &f2, const Ring &center, const MTime &t, Int_t numleds, Int_t numrings);
    149163
    150164    void InitGui(Int_t channel);
     
    188202    void Print(Option_t *o) const { }
    189203
    190     void StartTPoint() { if (fTPointFromCC<0) fTPointFromCC=0; }
    191     void StartStarguider();
     204    void StartTPoint(char *cmd=0);// { if (fTPointFromCC<0) fTPointFromCC=0; }
     205    void StartStarguider(bool on);
     206
     207    Int_t GetStarguiderMode() const;
    192208
    193209    ClassDef(MStarguider, 0)
  • trunk/MagicSoft/Cosy/main/MTracking.cc

    r9435 r9439  
    3333    // Send the new velocities for both axes.
    3434    //
    35     fCosy->fMac2->SendSDO(0x3006, 1, (LWORD_t)(v.Zd()*vrzd));  // SetRpmVelocity [re/min]
    36     fCosy->fMac1->SendSDO(0x3006, 1, (LWORD_t)(v.Az()*vraz));  // SetRpmVelocity [re/min]
     35    fCosy->fMac2->SendSDO(0x3007, (LWORD_t)(v.Zd()*vrzd));  // SetRpmVelocity [re/min]
     36    fCosy->fMac1->SendSDO(0x3007, (LWORD_t)(v.Az()*vraz));  // SetRpmVelocity [re/min]
    3737
    3838    //
    3939    // Wait for the objects to be acknoledged.
    4040    //
    41     fCosy->fMac2->WaitForSdo(0x3006, 1, 100);
    42     fCosy->fMac1->WaitForSdo(0x3006, 1, 100);
     41    fCosy->fMac2->WaitForSdo(0x3007, 0, 100);
     42    fCosy->fMac1->WaitForSdo(0x3007, 0, 100);
    4343
    4444    //
     
    272272    {
    273273        /*
    274         sla.Now(1);
     274         // Code for position control mode
     275         // Set: S-0-0001
     276         // Set: S-0-0002
     277         // Set: P-0-0099
     278         // Set: P-0-0187 (Spline)
     279         // Replace S-0-0258 by S-0-0047 in communication
     280
     281        sla.Now();
    275282        const ZdAz pointing = sla.CalcZdAz(fCosy->fRaDec); // [rad]
    276283        ZdAz dest = fCosy->AlignTrackingPos(pointing);     // fix ambiguity
     
    279286            break;
    280287        dest *= 1./TMath::TwoPi(); //[rev]
    281         fCosy->fMac2->SendSDO(0x6004, 0, (LWORD_t)(dest.Zd()*fCosy->fMac2->GetPosRes()+.5), false);
    282         fCosy->fMac1->SendSDO(0x6004, 0, (LWORD_t)(dest.Az()*fCosy->fMac1->GetPosRes()+.5), false);
    283         usleep(100000); // 1s
     288        fCosy->fMac2->SendSDO(0x6004, (LWORD_t)(dest.Zd()*fCosy->fMac2->GetPosRes()+.5), false);
     289        fCosy->fMac1->SendSDO(0x6004, (LWORD_t)(dest.Az()*fCosy->fMac1->GetPosRes()+.5), false);
     290        usleep(10000); // 10ms
    284291        continue;
    285292        */
Note: See TracChangeset for help on using the changeset viewer.