Changeset 1691 for trunk/MagicSoft


Ignore:
Timestamp:
12/18/02 20:35:52 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/base/BaseLinkDef.h

    r1531 r1691  
    88#pragma link C++ class MLog;
    99#pragma link C++ class MStar+;
     10#pragma link C++ class MGList+;
    1011
    1112#endif
  • trunk/MagicSoft/Cosy/base/Makefile

    r1531 r1691  
    4040           MLog.cc \
    4141           MLogManip.cc \
     42           MGList.cc \
    4243           timer.cc
    4344
    4445CINTHEADERS = MStar.h \
     46              MGList.h \
    4547              MLog.h \
    4648              MLogManip.h
  • trunk/MagicSoft/Cosy/catalog/SlaStars.cc

    r1275 r1691  
    4040    slaMappa(2000.0, mjd, fAmprms);
    4141    slaAoppa(mjd, 0,                    // mjd, UT1-UTC
    42              GetElong(), GetPhi(), 148, // göttingen long, lat, height
     42             // GetElong(), GetPhi(), 148, // göttingen long, lat, height
     43             GetElong(), GetPhi(), 300, // göttingen long, lat, height
    4344             0, 0,                      // polar motion x, y-coordinate (radians)
    44              273.155, 1013.25, 0.5,     // temp, pressure, humidity
    45              0.2, 0.0065,               // wavelength, tropo lapse rate
     45             // 273.155, 1013.25, 0.5,     // temp, pressure, humidity
     46             273.155+20, 1013.25, 0.5,     // temp, pressure, humidity
     47             // 0.2, 0.0065,               // wavelength, tropo lapse rate
     48             0.55, 0.0065,               // wavelength, tropo lapse rate
    4649             fAoprms);
    4750}
  • trunk/MagicSoft/Cosy/main/MCosy.cc

    r1275 r1691  
    2626typedef struct tm tm_t;
    2727
    28 #define GEAR_RATIO_ALT  75.55 // 75.25 VERY IMPORTANT! unit=RE/SE
    29 #define GEAR_RATIO_AZ  179.8  // VERY IMPORTANT! unit=RE/SE
    30 
    31 const XY kGearRatio(GEAR_RATIO_ALT, GEAR_RATIO_AZ);
    32 const XY kGearRatio2(GEAR_RATIO_ALT*16384.0/360.0, GEAR_RATIO_AZ*16384.0/360.0);
    33 
    34 double Rad2SE(double rad)
     28/*
     29#define GEAR_RATIO_ALT  2475.6 // [U_mot/U_tel(360deg)]
     30#define GEAR_RATIO_AZ   5891.7 // [U_mot/U_tel(360deg)]
     31
     32#define RES_RE           500   // [re/U_mot]
     33#define RES_SE         16384   // [se/U_tel(360deg)]
     34*/
     35/*
     36 #define GEAR_RATIO_ALT (75.55*16384/1500) // 75.25 VERY IMPORTANT! unit=U_mot/U_tel
     37 #define GEAR_RATIO_AZ  (179.8*16384/1500)  // VERY IMPORTANT! unit=U_mot/U_tel
     38*/
     39
     40//const XY kGearRatio (GEAR_RATIO_ALT*RES_RE/RES_SE, GEAR_RATIO_AZ*RES_RE/RES_SE);   //[re/se]
     41//const XY kGearRatio2(GEAR_RATIO_ALT*RES_RE/360.0,  GEAR_RATIO_AZ*RES_RE/360.0);    //[re/deg]
     42
     43double MCosy::Rad2SE(double rad) const
    3544{
    3645    return 16384.0/k2Pi*rad;
    3746}
    3847
    39 double Rad2ZdRE(double rad)
     48double MCosy::Rad2ZdRE(double rad) const
    4049{
    4150    return 16384.0/k2Pi*rad*kGearRatio.X();
    4251}
    4352
    44 double Rad2AzRE(double rad)
     53double MCosy::Rad2AzRE(double rad) const
    4554{
    4655    return 16384.0/k2Pi*rad*kGearRatio.Y();
    4756}
    4857
    49 double Deg2ZdRE(double rad)
     58double MCosy::Deg2ZdRE(double rad) const
    5059{
    5160    return rad*kGearRatio2.X();
    5261}
    5362
    54 double Deg2AzRE(double rad)
     63double MCosy::Deg2AzRE(double rad) const
    5564{
    5665    return rad*kGearRatio2.Y();
     
    7281    ZdAz dest   = dst * kRad2Deg;
    7382
     83    if (dest.Zd()>-3 && dest.Zd()<3)
     84        dest.Zd(dest.Zd()<0?-3:3);
     85
    7486    if (dest.Zd()>-1e-6 && dest.Zd()<1e-6)
    7587        return dst*(16384.0/k2Pi);
     
    138150    // Get the values
    139151    //
    140     const int p0 = fZd1->GetPos();
    141     const int p1 = fZd2->GetPos();
    142     const int p2 = fAz->GetPos();
     152    const int p0 = fZd1 ? fZd1->GetPos() : 0;
     153    const int p1 = fZd2 ? fZd2->GetPos() : 0;
     154    const int p2 = fAz  ? fAz->GetPos()  : 0;
    143155
    144156    const int a0 = p0; //p0>8192?p0-16384:p0;
     
    165177Bool_t MCosy::RequestRePos()
    166178{
     179    if (!(fMac1 && fMac2))
     180        return kTRUE;
     181
    167182    //
    168183    // Send request
     
    201216ZdAz MCosy::GetRePos()
    202217{
    203     return ZdAz(fMac2->GetPos(), fMac1->GetPos());
     218    return fMac1 && fMac2 ? ZdAz(fMac2->GetPos(), fMac1->GetPos()) : ZdAz(0,0);
    204219}
    205220
     
    363378    // FIXME: Correct by fOffset ?
    364379
     380    if (!(fMac1 && fMac2 && fMac3))
     381    {
     382        cout << "SetPosition: No MACS!" << endl;
     383        return TRUE;
     384    }
     385
    365386    //
    366387    // Calculate new target position (shortest distance to go)
    367388    //
    368     const ZdAz src  = GetSePos();
    369     const ZdAz dest = CorrectTarget(src, dst);
     389    const ZdAz src = GetSePos();//*TMath::Pi()*2/16384;;
     390
     391    //
     392    // Because we agreed on I don't search for the shortest move
     393    // anymore
     394    //
     395    // const ZdAz dest = CorrectTarget(src, dst);
     396    //
     397    const ZdAz dest = fBending(dst)*16384/2/TMath::Pi();
    370398
    371399    lout << "Positioning to Target..." << endl;
    372400    //cout << "Source        Zd: " << src.Zd()  << "se  Az:" << src.Az()  << "se" << endl;
    373401    //cout << "Destination   Zd: " << Rad2SE(dst.Zd()) << "se  Az:" << Rad2SE(dst.Az())  << "se" << endl;
    374     //cout << "Shortest Dest Zd: " << dest.Zd() << "se  Az:" << dest.Az() << "se" << endl;
     402    cout << "Shortest Dest Zd: " << dest.Zd() << "se  Az:" << dest.Az() << "se" << endl;
    375403
    376404    for (int i=0; i<10 && !StopWaitingForSDO(); i++)
     
    484512void MCosy::InitTracking()
    485513{
     514    if (!(fMac1 && fMac2))
     515        return;
     516
    486517    //
    487518    // Start revolution mode
     
    608639    InitTracking();
    609640
     641    XY xy(Rad2Deg(dst.Ra())*24/360, Rad2Deg(dst.Dec()));
     642
    610643    lout << "Start tracking:";
    611     lout << " Ra: " << Rad2Deg(dst.Ra())  << "\xb0  ";
    612     lout << "Dec: " << Rad2Deg(dst.Dec()) << "\xb0" << endl;
     644    lout << " Ra: " << xy.X() << "h  " << "Dec: " << xy.Y() << "\xb0" << endl;
     645
     646    ofstream fout("coordinates.txt");
     647    fout << xy;
     648    fout.close();
    613649
    614650    //
    615651    // Initialize Tracker (slalib or starguider)
    616652    //
    617     fRaDec    = dst;
     653    fRaDec = dst;
     654
     655    if (!(fMac1 && fMac2 && fMac3))
     656        return;
     657
    618658    fTracking = kTRUE;
    619659
    620     ofstream fout("log/cosy.pos");
    621     fout << "Tracking:";
    622     fout << " Ra: " << Rad2Deg(dst.Ra())  << "\x9c  ";
    623     fout << "Dec: " << Rad2Deg(dst.Dec()) << "\x9c" << endl << endl;
    624     fout << "     Mjd/10ms    V/re/min/4" << endl;
     660//---    ofstream fout("log/cosy.pos");
     661//---    fout << "Tracking:";
     662//---    fout << " Ra: " << Rad2Deg(dst.Ra())  << "\x9c  ";
     663//---    fout << "Dec: " << Rad2Deg(dst.Dec()) << "\x9c" << endl << endl;
     664//---    fout << "     Mjd/10ms    V/re/min/4" << endl;
    625665
    626666    //
     
    646686        //
    647687        sla.SetMjd(sla.CalcMjd()+dt/(60*60*24));
    648         dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst)); // [se]
    649 
    650         ZdAz vcalc = sla.GetApproxVel(dst) * kGearRatio2*4./60.;  // [re/min]
     688        ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
     689        dest = CorrectTarget(GetSePos(), dummy); // [se]
    651690
    652691        //
     
    676715        //
    677716        ZdAz vt = v/4;
     717        ZdAz vcalc = sla.GetApproxVel(fRaDec) * kGearRatio2*4./60.;  // [re/min]
    678718        LimitSpeed(&vt, vcalc);
    679719        vt.Round();
     
    700740        fVelocity = vt/kGearRatio2*4;
    701741
    702         const double mjd = fMac2->GetMjd();
    703         fout << setprecision(15) << setw(17) << mjd*60.*60.*24. << " ";
    704         fout << setw(4) << vt.Zd() << " ";
    705         fout << setw(4) << vt.Az() << endl;
     742//---        const double mjd = fMac2->GetMjd();
     743//---        fout << setprecision(15) << setw(17) << mjd*60.*60.*24. << " ";
     744//---        fout << setw(4) << vt.Zd() << " ";
     745//---        fout << setw(4) << vt.Az() << endl;
    706746        //
    707747        // FIXME? Calculate an accuracy for the tracking system?
     
    716756        // update time
    717757        //
    718         // usleep(50000); // 0.05s
     758        usleep(50000); // 0.05s
    719759    }
    720760
     
    733773void MCosy::StopMovement()
    734774{
     775    if (!fMac1 || !fMac2)
     776        return;
    735777    //
    736778    // Set status to stopped
     
    780822    case WM_PRESET:
    781823        cout << "WM_Preset: start." << endl;
    782         fZd1->SetPreset();
    783         fZd2->SetPreset();
    784         fAz->SetPreset();
     824        if (fZd1) fZd1->SetPreset();
     825        if (fZd2) fZd2->SetPreset();
     826        if (fAz)  fAz->SetPreset();
    785827        cout << "WM_Preset: done. (return 0xaffe)" << endl;
    786828        return (void*)0xaffe;
    787829
    788     case WM_POLARIS:
     830    case WM_CALIB:
    789831        {
    790             cout << "WM_Polaris: start." << endl;
     832            cout << "WM_Calib: start." << endl;
    791833            SlaStars sla;
    792834            sla.SetMjd2Now();
    793835
    794             RaDec rd(37.94, 89.2644);
     836            RaDec rd = *((RaDec*)mp);
     837
     838            //RaDec rd(37.94, 89.2644);      // POLARIS
     839            //RaDec rd(213.915417, 19.1825); // ACTURUS
     840
     841            cout << "Calibrating to: " << rd.Ra()*24/360 << "h " << rd.Dec() << "°" << endl;
     842
    795843            ZdAz za=sla.CalcZdAz(rd*kDeg2Rad)*16384.0/k2Pi;
    796844
     
    800848            cout << "Got  Zd: " << sepos.Zd() << " Az: " << sepos.Az() << endl;
    801849
    802             fZd1->SetPreset(za.Zd());
    803             fZd2->SetPreset(-za.Zd());
    804             fAz->SetPreset(za.Az());
     850            if (fZd1)
     851                fZd1->SetPreset(za.Zd());
     852            if(fZd2)
     853                fZd2->SetPreset(-za.Zd());
     854            if(fAz)
     855                fAz->SetPreset(za.Az());
    805856
    806857            cout << "WM_Polaris: done. (return 0xaffe)" << endl;
    807858        }
    808859        return (void*)0xaffe;
     860
     861    case WM_TPOINT:
     862        {
     863            cout << "WM_TPoint: start." << endl;
     864            SlaStars sla;
     865            sla.SetMjd2Now();
     866
     867            RaDec rd = *((RaDec*)mp);
     868            cout << "TPoint Star: " << rd.Ra()/15 << "h " << rd.Dec() << "°" << endl;
     869
     870            AltAz za=sla.CalcAltAz(rd*kDeg2Rad)*kRad2Deg;
     871
     872            cout << "     Alt/Az: " << za.Alt() << "° " << za.Az() << "°" << endl;
     873            *tpout << za.Az() << " " << za.Alt() << " ";
     874
     875            ZdAz sepos = GetSePos()*TMath::Pi()*2/16384;;
     876            za.Set(TMath::Pi()/2-sepos.Zd(), sepos.Az());
     877            za *= kRad2Deg;
     878
     879            cout << "     SE-Pos: " << za.Alt() << "° " << za.Az() << "°" << endl;
     880            *tpout << fmod(za.Az()+360, 360) << " " << za.Alt() << endl;
     881
     882            cout << "WM_TPoint: done. (return 0xaffe)" << endl;
     883        }
     884        return (void*)0xca1b;
    809885
    810886    case WM_POSITION:
     
    827903        return (void*)0x8888;
    828904
     905    case WM_NEWTRACK:
     906        cout << "WM_NewTrack: START" << endl;
     907        fRaDec = *((RaDec*)mp);
     908        cout << "WM_NewTrack: done. (return 0x9999)" << endl;
     909        return (void*)0x9999;
     910
     911    case WM_LOADBENDING:
     912        cout << "WM_LoadBending: START" << endl;
     913        fBending.Load("bending.txt");
     914        cout << "WM_LoadBending: done. (return 0xbe0d)" << endl;
     915        return (void*)0xbe0d;
     916
     917    case WM_CALCALTAZ:
     918        {
     919            cout << endl;
     920
     921            SlaStars sla;
     922            sla.SetMjd2Now();
     923
     924            XY xy = *((XY*)mp);
     925            RaDec rd(xy.X()*15., xy.Y());
     926
     927            ZdAz a0 = sla.CalcZdAz(rd*kDeg2Rad);
     928            ZdAz a1 = fBending(a0);
     929            ZdAz se = CorrectTarget(GetSePos(), a1);
     930            a0 *= kRad2Deg;
     931            a1 *= kRad2Deg;
     932            ZdAz a2 = a1*16384/360;
     933            cout << "Ra/Dec source: " << xy.X()  << "h " << xy.Y()  << "°" << endl;
     934            cout << "Zd/Az source:  " << a0.Zd() << "° " << a0.Az() << "°" << endl;
     935            cout << "Zd/Az bended:  " << a1.Zd() << "° " << a1.Az() << "°" << endl;
     936            cout << "SE bended:     " << a2.Zd() << "  " << a2.Az() << endl;
     937            cout << "SE target:     " << se.Zd() << "  " << se.Az() << endl;
     938        }
     939        return (void*)0xa17a;
     940
    829941    case WM_QUIT:
    830942        cout << "WM_Quit: now." << endl;
    831943        TerminateApp();
    832944        cout << "WM_Quit: done." << endl;
    833         return (void*)0x9999;
     945        return (void*)0xaaaa;
    834946    }
    835947    cout << "Unknown Msg" << endl;
     
    843955}
    844956
     957void MCosy::ReadConfig()
     958{
     959    cout << "Reading configuration file..." << flush;
     960    TEnv env(".cosyrc");
     961    cout << "done." << endl;
     962
     963    cout << "Reading gear ratios..." << flush;
     964    const Double_t gaz = env.GetValue("Az_GearRatio[U_mot/U_tel]", 1000.0);
     965    const Double_t gzd = env.GetValue("Zd_GearRatio[U_mot/U_tel]", 1000.0);
     966
     967    Double_t resreaz = 0;
     968    if (fMac1)
     969        resreaz = fMac1->GetRes();
     970    else
     971        if (fMac3)
     972            resreaz = fMac3->GetRes();
     973        else
     974            resreaz = env.GetValue("Az_ResRE[re/U_mot]", 1500);
     975
     976    Double_t resrezd = 0;
     977    if (fMac2)
     978        resrezd = fMac2->GetRes();
     979    else
     980        resrezd = env.GetValue("Zd_ResRE[re/U_mot]", 1500);
     981
     982    Double_t ressezd = 0;
     983    if (fZd1)
     984        ressezd = fZd1->GetPhysRes();
     985    else
     986        if (fZd2)
     987            ressezd = fZd2->GetPhysRes();
     988        else
     989            ressezd = env.GetValue("Zd_ResSE[se/U_mot]", 16384);
     990
     991    Double_t resseaz = 0;
     992    if (fAz)
     993        resseaz = fAz->GetPhysRes();
     994    else
     995        resseaz = env.GetValue("Az_ResSE[se/U_mot]", 16384);
     996
     997    kGearRatio.Set (gzd*resrezd/ressezd, gaz*resreaz/resseaz);  //[re/se]
     998    kGearRatio2.Set(gzd*resrezd/360.0,   gaz*resreaz/360.0);    //[re/deg]
     999    cout << "done." << endl;
     1000}
     1001
    8451002void MCosy::TalkThread()
    8461003{
     1004    if (!(fMac1 && fMac2 && fMac3))
     1005        return;
     1006
     1007    fMac1->ReqPos();
     1008    fMac2->ReqPos();
     1009
     1010    const int res = fMac3->GetVelRes();
     1011
     1012    fMac3->SetVelocity(res);
     1013    fMac3->SetAcceleration(res);
     1014    fMac3->SetDeceleration(res);
     1015
     1016    fMac1->EnableTimeout(kTRUE, 500);
     1017    fMac2->EnableTimeout(kTRUE, 500);
     1018
     1019    if (!(fZd1 && fZd2 && fAz))
     1020        return;
     1021
     1022    /*
    8471023    //
    8481024    // Start the Network
     
    8721048    //cout << "APOS: " << repos.Zd() << "re, " << repos.Az() << "re" << endl;
    8731049
    874     /*
    875      cout << Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0)) << " < Az < "
    876      << Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0)) << "RE" << endl;
    877      cout << env.GetValue("MinAz[Deg]", -1.0) << " < Az < "
    878      << env.GetValue("MaxAz[Deg]", +1.0) << kDEG << endl;
    879      cout << Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)) << "RE < Zd < "
    880      << Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl;
    881      */
    882 
     1050    //cout << Deg2AzRE(env.GetValue("MinAz[Deg]", -1.0)) << " < Az < "
     1051    //</< Deg2AzRE(env.GetValue("MaxAz[Deg]", +1.0)) << "RE" << endl;
     1052    //cout << env.GetValue("MinAz[Deg]", -1.0) << " < Az < "
     1053    //<< env.GetValue("MaxAz[Deg]", +1.0) << kDEG << endl;
     1054    //cout << Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)) << "RE < Zd < "
     1055    //<< Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)) << "RE" << endl;
    8831056
    8841057    cout << "Setting up software endswitch..." << flush;
     
    8931066    fMac2->EnableTimeout(kTRUE, 500);
    8941067
    895 /*
    896     fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)));
    897     fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)));
    898 */
    899 //    fMac3->StartVelSync();
    900 /*
    901     cout << "PostMsg(WM_PRESET)" << endl;
    902     void *rc =
    903     cout << hex << "WM_PRESET: ret=" << rc << endl;
    904 
    905     RaDec dest = RaDec(45.0, 30.0)*D2PI/360.0;
    906 
    907     cout << "PostMsg(WM_TRACK)" << endl;
    908     cout << sizeof(RaDec) << "==" << sizeof(dest) << endl;
    909     rc=PostMsg(WM_TRACK, &dest, sizeof(dest));
    910     cout << "DEST killed." << endl;
    911 */
     1068    const Double_t gaz = env.GetValue("Az_GearRatio[U_mot/U_tel]");
     1069    const Double_t gzd = env.GetValue("Zd_GearRatio[U_mot/U_tel]");
     1070
     1071    const Double_t resreaz = env.GetValue("Az_ResRE[re/U_mot]");
     1072    const Double_t resrezd = env.GetValue("Zd_ResRE[re/U_mot]");
     1073
     1074    kGearRatio.Set (gzd*resrezd/RES_SE, gaz*resreaz/RES_SE);   //[re/se]
     1075    kGearRatio2.Set(gzd*resrezd/360.0,  gaz*resreaz/360.0);    //[re/deg]
     1076
     1077    //fMac2->SetNegEndswitch(Deg2ZdRE(env.GetValue("MinZd[Deg]", -1.0)));
     1078    //fMac2->SetPosEndswitch(Deg2ZdRE(env.GetValue("MaxZd[Deg]", +1.0)));
     1079    //    fMac3->StartVelSync();
     1080
     1081    //cout << "PostMsg(WM_PRESET)" << endl;
     1082    //void *rc =
     1083    //cout << hex << "WM_PRESET: ret=" << rc << endl;
     1084
     1085    //RaDec dest = RaDec(45.0, 30.0)*D2PI/360.0;
     1086
     1087    //cout << "PostMsg(WM_TRACK)" << endl;
     1088    //cout << sizeof(RaDec) << "==" << sizeof(dest) << endl;
     1089    //rc=PostMsg(WM_TRACK, &dest, sizeof(dest));
     1090    //cout << "DEST killed." << endl;
     1091
    9121092    // AltAz dest = AltAz(45.0, 30.0);
    9131093    // double ra, dec;
     
    9181098    // dest = AltAz(-46.0, 210);
    9191099    // SetPosition(dest);
    920 
     1100    */
    9211101    SlaStars sla;
    9221102    while (1)
     
    9281108            usleep(1);
    9291109
    930         ofstream fout("log/cosy.err");
    931         fout << "Tracking:";
    932         fout << " Ra: " << Rad2Deg(fRaDec.Ra())  << "\x9c  ";
    933         fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl;
    934         fout << "     MjdZd/10ms    ErrZd/re";
    935         fout << "     MjdAz/10ms    ErrAd/re" << endl;
     1110//---        ofstream fout("log/cosy.err");
     1111//---        fout << "Tracking:";
     1112//---        fout << " Ra: " << Rad2Deg(fRaDec.Ra())  << "\x9c  ";
     1113//---        fout << "Dec: " << Rad2Deg(fRaDec.Dec()) << "\x9c" << endl << endl;
     1114//---        fout << "     MjdZd/10ms    ErrZd/re";
     1115//---        fout << "     MjdAz/10ms    ErrAd/re" << endl;
    9361116
    9371117        ZdAz old;
     
    10051185            {
    10061186                sla.SetMjd(time.Zd());
    1007                 sollzd = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se]
     1187
     1188                ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
     1189                sollzd = CorrectTarget(ist, dummy); // [se]
    10081190
    10091191                fOffset.Zd(fOffset.Zd()*(1.-weight)+(ist.Zd()*kGearRatio.X()-istre.Zd())*weight);
     
    10131195            {
    10141196                sla.SetMjd(time.Az());
    1015                 sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec)); // [se]
     1197
     1198                ZdAz dummy = fBending(sla.CalcZdAz(fRaDec));
     1199                sollaz = CorrectTarget(ist, dummy); // [se]
    10161200
    10171201                fOffset.Az(fOffset.Az()*(1.-weight)+(ist.Az()*kGearRatio.Y()-istre.Az())*weight);
     
    10211205                               (ist.Az()-sollaz.Az())*kGearRatio.Y());
    10221206
    1023             fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " ";
    1024             fout << setprecision(5)  << setw(7)  << fTrackingError.Zd() << "  ";
    1025             fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " ";
    1026             fout << setprecision(5)  << setw(7)  << fTrackingError.Az() << endl;
     1207//---            fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " ";
     1208//---            fout << setprecision(5)  << setw(7)  << fTrackingError.Zd() << "  ";
     1209//---            fout << setprecision(15) << setw(17) << time.Az()*60.*60.*24. << " ";
     1210//---            fout << setprecision(5)  << setw(7)  << fTrackingError.Az() << endl;
    10271211        }
    10281212
    1029         fout << endl << endl;
     1213//---        fout << endl << endl;
    10301214    }
    10311215}
     
    10361220    // Update Gui, foremer MTGui.
    10371221    //
    1038     fZd1->DisplayVal();
    1039     fZd2->DisplayVal();
    1040     fAz->DisplayVal();
     1222    if (fZd1) fZd1->DisplayVal();
     1223    if (fZd2) fZd2->DisplayVal();
     1224    if (fAz)  fAz->DisplayVal();
    10411225
    10421226    ZdAz ist = GetSePos()*(360.0/16384.0); // [se]
     
    10631247    Network::Start();
    10641248
     1249    if (fMac1)
     1250        if (fMac1->IsZombieNode()) { delete fMac1; fMac1=NULL; }
     1251    if (fMac2)
     1252        if (fMac2->IsZombieNode()) { delete fMac2; fMac2=NULL; }
     1253    if (fMac3)
     1254        if (fMac3->IsZombieNode()) { delete fMac3; fMac3=NULL; }
     1255
     1256    if (fZd1)
     1257        if (fZd1->IsZombieNode())  { delete fZd1;  fZd1=NULL; }
     1258        else fZd1->SetDisplay(fWin->GetLabel2());
     1259
     1260    if (fZd2)
     1261        if (fZd2->IsZombieNode())  { delete fZd2;  fZd2=NULL; }
     1262        else fZd2->SetDisplay(fWin->GetLabel3());
     1263
     1264    if (fAz)
     1265        if (fAz->IsZombieNode())   { delete fAz;   fAz=NULL; }
     1266        else fAz->SetDisplay(fWin->GetLabel1());
     1267
     1268    ReadConfig();
     1269
    10651270    lout << "- Starting TX Thread." << endl;
    10661271    fTTalk = new MTTalk(this);
     
    10921297}
    10931298
    1094 MCosy::MCosy(const char *dev, const int baud, MLog &out)
    1095 : Network(dev, baud, out), fTracking(kFALSE)
     1299void MCosy::Constructor()
    10961300{
    10971301    //
     
    11011305
    11021306    fMac1=new Macs(1, "Mac.1/Az",      lout);
    1103     fMac2=new Macs(2, "Mac.2/Zd",      lout);
    1104     fMac3=new Macs(3, "Mac.3/Az-Sync", lout);
    1105 
    1106     fZd1=new ShaftEncoder(4, "SE.4/Zd1", lout);
    1107     fZd2=new ShaftEncoder(5, "SE.5/Zd2", lout);
    1108     fAz =new ShaftEncoder(6, "SE.6/Az",  lout);
     1307    fMac3=new Macs(2, "Mac.3/Az-Sync", lout);
     1308    fMac2=new Macs(3, "Mac.2/Zd",      lout);
     1309
     1310    fZd1=new ShaftEncoder(5, "SE.5/Zd1", lout);
     1311    fZd2=new ShaftEncoder(6, "SE.6/Zd2", lout);
     1312    fAz =new ShaftEncoder(7, "SE.7/Az",  lout);
     1313
     1314    lout << "- Connecting devices to network." << endl;
    11091315
    11101316    //
     
    11321338
    11331339    lout.SetOutputGui(fWin->GetLog(), kTRUE);
     1340}
     1341
     1342void MCosy::ConstructorSE()
     1343{
     1344    //
     1345    // Create Nodes
     1346    //
     1347    lout << "- Setting up network." << endl;
     1348
     1349    fZd1=new ShaftEncoder(5, "SE.5/Zd1", lout);
     1350    fZd2=new ShaftEncoder(6, "SE.6/Zd2", lout);
     1351    fAz =new ShaftEncoder(7, "SE.7/Az",  lout);
     1352
     1353    lout << "- Connecting devices to network." << endl;
     1354
     1355    //
     1356    // Connect the devices to the network
     1357    //
     1358    SetNode(fZd1);
     1359    SetNode(fZd2);
     1360    SetNode(fAz);
     1361
     1362    //
     1363    // Create Gui Event timer and Gui
     1364    //
     1365    lout << "- Initializing GUI Timer." << endl;
     1366    fUpdateGui = new TTimer(this, 100); // 100ms
     1367
     1368    lout << "- Starting GUI." << endl;
     1369    fWin=new MGCosy(this, gClient->GetRoot(), 1, 1);
     1370
     1371    fAz->SetDisplay(fWin->GetLabel1());
     1372    fZd1->SetDisplay(fWin->GetLabel2());
     1373    fZd2->SetDisplay(fWin->GetLabel3());
     1374
     1375    lout.SetOutputGui(fWin->GetLog(), kTRUE);
     1376}
     1377
     1378void MCosy::ConstructorDemo()
     1379{
     1380    //
     1381    // Create Nodes
     1382    //
     1383    lout << "- Setting up network." << endl;
     1384
     1385    /*
     1386    fMac1=new Macs(1, "Mac.1/Az",      lout);
     1387    fMac2=new Macs(2, "Mac.2/Zd",      lout);
     1388    fMac3=new Macs(3, "Mac.3/Az-Sync", lout);
     1389
     1390    fZd1=new ShaftEncoder(4, "SE.4/Zd1", lout);
     1391    fZd2=new ShaftEncoder(5, "SE.5/Zd2", lout);
     1392    fAz =new ShaftEncoder(6, "SE.6/Az",  lout);
     1393
     1394    lout << "- Connecting devices to network." << endl;
     1395
     1396    //
     1397    // Connect the devices to the network
     1398    //
     1399    SetNode(fMac1);
     1400    SetNode(fMac2);
     1401    SetNode(fMac3);
     1402    SetNode(fZd1);
     1403    SetNode(fZd2);
     1404    SetNode(fAz);
     1405    */
     1406    //
     1407    // Create Gui Event timer and Gui
     1408    //
     1409    lout << "- Initializing GUI Timer." << endl;
     1410    fUpdateGui = new TTimer(this, 100); // 100ms
     1411
     1412    lout << "- Starting GUI." << endl;
     1413    fWin=new MGCosy(this, gClient->GetRoot(), 1, 1);
     1414    /*
     1415    fAz->SetDisplay(fWin->GetLabel1());
     1416    fZd1->SetDisplay(fWin->GetLabel2());
     1417    fZd2->SetDisplay(fWin->GetLabel3());
     1418    */
     1419    lout.SetOutputGui(fWin->GetLog(), kTRUE);
     1420}
     1421
     1422MCosy::MCosy(int mode, const char *dev, const int baud, MLog &out)
     1423: Network(dev, baud, out), fTracking(kFALSE)
     1424{
     1425    lout << "- Program in ";
     1426    switch (mode)
     1427    {
     1428    case 0:
     1429        lout << "<<Stanard mode>>" << endl;
     1430        Constructor();
     1431        break;
     1432    case 1:
     1433        lout << "<<SE mode>>" << endl;
     1434        ConstructorSE();
     1435        break;
     1436    default:
     1437        lout << "<<Demo mode>>" << endl;
     1438        ConstructorDemo();
     1439    }
     1440
     1441    int i=0;
     1442    char name[100];
     1443    while (1)
     1444    {
     1445        sprintf(name, "/home/tbretz/TPoint/tpoint%03d.txt", i++);
     1446        cout << "Testing: " << name << endl;
     1447        if (gSystem->AccessPathName(name, kFileExists))
     1448            break;
     1449    }
     1450
     1451    Timer time;
     1452    time.Now();
     1453
     1454    tpout = new ofstream(name);
     1455    *tpout << "Magic Model  TPOINT data file" << endl;
     1456    *tpout << ": ALTAZ" << endl;
     1457    *tpout << "49 48 0 ";
     1458    *tpout << time.Year() << " " << time.Month() << " " << time.Day() << " ";
     1459    *tpout << /*"20 1013.25 300 0.5 0.55 0.0065" <<*/ endl;
     1460    // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m)
    11341461}
    11351462
     
    11551482MCosy::~MCosy()
    11561483{
     1484    *tpout << "END" << endl;
     1485    delete tpout;
     1486
    11571487    cout << "Deleting GUI timer." << endl;
    11581488
     
    11611491    cout << "Deleting Nodes." << endl;
    11621492
    1163     delete fAz;
    1164     delete fZd2;
    1165     delete fZd1;
    1166     delete fMac1;
    1167     delete fMac2;
    1168     delete fMac3;
     1493    if (fAz)   delete fAz;
     1494    if (fZd1)  delete fZd1;
     1495    if (fZd2)  delete fZd2;
     1496    if (fMac1) delete fMac1;
     1497    if (fMac2) delete fMac2;
     1498    if (fMac3) delete fMac3;
    11691499
    11701500    cout << "Deleting MGCosy." << endl;
  • trunk/MagicSoft/Cosy/main/MCosy.h

    r1275 r1691  
    66#include "network.h"
    77#include "MThread.h"
     8#include "MBending.h"
    89
    910#define kDEG ((char)0x9c)  // Linux 'ø'
    1011
    11 #define WM_WAIT      WM_NULL
    12 #define WM_PRESET    0x1000
    13 #define WM_POSITION  0x1001
    14 #define WM_TRACK     0x1002
    15 #define WM_STOP      0x1003
    16 #define WM_POLARIS   0x1004
     12#define WM_WAIT        WM_NULL
     13#define WM_PRESET      0x1000
     14#define WM_POSITION    0x1001
     15#define WM_TRACK       0x1002
     16#define WM_STOP        0x1003
     17#define WM_CALIB       0x1004
     18#define WM_TPOINT      0x1005
     19#define WM_NEWTRACK    0x1006
     20#define WM_LOADBENDING 0x1007
     21#define WM_CALCALTAZ   0x1008
    1722
    1823class ShaftEncoder;
     
    7580    ZdAz  fVelocity;      // Actual velocity of Tracking
    7681
     82    XY kGearRatio;        // describing the gear of the system [re/se]
     83    XY kGearRatio2;       // describing the gear of the system [re/deg]
     84
     85    MBending fBending;
     86
    7787    UInt_t fStatus;
     88
     89    ofstream *tpout;
     90
     91    double Rad2SE(double rad) const;
     92    double Rad2ZdRE(double rad) const;
     93    double Rad2AzRE(double rad) const;
     94    double Deg2ZdRE(double rad) const;
     95    double Deg2AzRE(double rad) const;
    7896
    7997    void SetStatus(UInt_t stat) { fStatus = stat; }
     
    107125    void WaitForEndMovement();
    108126
     127    void Constructor();
     128    void ConstructorSE();
     129    void ConstructorDemo();
     130
     131    void ReadConfig();
     132
    109133public:
    110     MCosy(const char *dev, const int baud, MLog &out=gLog);
     134    MCosy(int mode, const char *dev, const int baud, MLog &out=gLog);
    111135    ~MCosy();
    112136
  • trunk/MagicSoft/Cosy/starg.cc

    r924 r1691  
    77
    88/* ---------------------------------------------------------------------- */
    9 
    109//extern void InitGui();
    1110//VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
    1211
     12TROOT root("GUI", "GUI test environement"); //, initfuncs);
     13
    1314int main(int argc, char **argv)
    1415{
    15     TROOT root("GUI", "GUI test environement"); //, initfuncs);
    16 
    17     TApplication app("Starguider", &argc, argv);
     16    TApplication *app=new TApplication("Starguider", &argc, argv);
    1817
    1918    MGStarguider starg;
     
    2120    starg.Loop(0);
    2221
    23     app.Run();
     22    app->Run(kTRUE);
    2423
    2524    cout << "Exit." << endl;
  • trunk/MagicSoft/Cosy/videodev/Makefile

    r1111 r1691  
    3333SRCFILES = Camera.cc \
    3434           Filter.cc \
     35           Filter2.cc \
    3536           Writer.cc
    3637
  • trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h

    r1111 r1691  
    77#pragma link C++ class Writer+;
    88#pragma link C++ class Filter+;
     9#pragma link C++ class Filter2+;
    910
    1011#pragma link C++ class Camera+;
Note: See TracChangeset for help on using the changeset viewer.