Changeset 2019


Ignore:
Timestamp:
04/28/03 11:04:17 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/.cosyrc_magic

    r1814 r2019  
    1 #
    2 # -85.0 , +310.0
    3 #
    4 Az_MaxTime2ReachHome[s]: 150
    5 
    6 #
    7 #
    8 #
    9 Zd_MaxTime2ReachHome[s]: 150
    10 
    11 # Model: Az_GearRatio[U_mot/U_tel]: 5891.7/4
    12 # Model: Zd_GearRatio[U_mot/U_tel]: 2475.6/4
    13 
    14 #Az_GearRatio[U_mot/U_tel]: 5353.2
    15 #Zd_GearRatio[U_mot/U_tel]: 4600
    161
    172Az_GearRatio[U_mot/U_tel]: 1338.8
    183# 1338.3
    194Zd_GearRatio[U_mot/U_tel]: 1165.2
     5# old value: 1165.2, try: 1211.8
    206#1149.5
    217#1208.29
    22 
    23 #Az_ResRE[re/U_mot]: 500
    24 #Zd_ResRE[re/U_mot]: 500
    25 
    26 #Az_Min[deg]: -90
    27 #Az_Max[deg]: 318
    28 
    29 #Zd_Min[deg]: -74.5
    30 #Zd_Max[deg]: 100.5
    318
    329Az_Id-MAC1:  1
  • trunk/MagicSoft/Cosy/Changelog

    r1959 r2019  
    11                                                                  -*-*- END -*-*-
     2 2003/04/28 - Thomas Bretz
     3
     4   * .cosyrc_magic:
     5     - removed Time2ReachHome
     6     - changed Gear Ratio
     7   
     8   * bending_magic.txt:
     9     - added bening model calculated in March
     10     
     11   * cosy.cc:
     12     - added disable output to screen
     13
     14   * prepos_magic.txt:
     15     - made positions fit the present bending model
     16   
     17   * candrv/nodedrv.[h,cc]:
     18     - added posibility to implement fake guarding (eg. check a
     19       PDO frequence)
     20
     21   * devdrv/macs.cc:
     22     - added HandleNodeguard to handling of PDO
     23   
     24   * main/MCosy.[h,cc]:
     25     - GetSePos declared const
     26     - AlignTrackingPos declared const
     27     - define EXPERT
     28     - implemented EXPERT mode
     29     - implemented Gear while positioning for Elevation axes
     30     - fixed some bugs in LimitSpeed - to be chacked again!
     31     - implemented preliminary version of starguider
     32     - some small changes to the tracking
     33     - changed default end positions
     34     - fixed display of fZdAzSoll and fTrackingError
     35   
     36   * videodev/Filter.cc:
     37     fixed dealing with values above max and below min when stretching
     38
     39
     40
    241 2003/04/13 - Thomas Bretz
    342
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r1959 r2019  
    490490// least one Nodeguard message was answered.
    491491//
    492 void NodeDrv::StartGuarding()
     492void NodeDrv::StartGuarding(Bool_t real=kTRUE)
    493493{
    494494    if (fTimerOn)
    495495        return;
    496496
    497     SendNodeguard();
     497    if (!real)
     498        SendNodeguard();
    498499
    499500    fTimerOn = kTRUE;
     
    512513}
    513514
    514 void NodeDrv::StartGuarding(Int_t ms, Int_t ltf)
     515void NodeDrv::StartGuarding(Int_t ms, Int_t ltf, Bool_t real)
    515516{
    516517    if (fTimerOn)
     
    522523    fLifeTimeFactor = ltf;
    523524
    524     StartGuarding();
     525    StartGuarding(real);
    525526}
    526527
  • trunk/MagicSoft/Cosy/candrv/nodedrv.h

    r1727 r2019  
    109109    void EnableCanMsg(BYTE_t fcode);
    110110
    111     void StartGuarding();
    112     void StartGuarding(Int_t ms, Int_t ltf);
     111    void StartGuarding(Bool_t real=kTRUE);
     112    void StartGuarding(Int_t ms, Int_t ltf, Bool_t real=kTRUE);
    113113    void StopGuarding();
    114114
  • trunk/MagicSoft/Cosy/cosy.cc

    r1953 r2019  
    7979
    8080    clog("- Starting mainloop.");
     81    lout.DisableOutputDevice(MLog::eStdout);
    8182    app->Run(kTRUE);
    8283
  • trunk/MagicSoft/Cosy/devdrv/macs.cc

    r1959 r2019  
    153153        case 1:
    154154            //lout << ddev(MLog::eGui);
    155             lout << "- " << GetNodeName() << ": Decceleration set." << endl;
     155            lout << "- " << GetNodeName() << ": Deceleration set." << endl;
    156156            //lout << edev(MLog::eGui);
    157157            return;
     
    278278    SetNoWait(TRUE);
    279279
     280//    StartGuarding(200, 2, kFALSE); // Using PDO1 @ 100ms
     281
    280282//    StartGuarding(250, 4);
    281283//    StartHostGuarding();
     
    448450void Macs::HandlePDO1(BYTE_t *data, timeval_t *tv)
    449451{
     452    // FIXME!!!!
     453    HandleNodeguard(tv);
     454/*
     455    Timer t(tv);
     456    cout << GetNodeName()<< " " <<t.GetTimeStr() << endl;
     457*/
    450458    fPdoPos    = (data[4]<<24) | (data[5]<<16) | (data[6]<<8) | data[7];
    451459
  • trunk/MagicSoft/Cosy/main/MCosy.cc

    r1953 r2019  
    2525#include "base/timer.h"
    2626#include "shaftencoder.h"
    27 
    28 //#include <sys/resource.h>  // PRIO_PROCESS
    2927
    3028ClassImp(MCosy);
     
    5250*/
    5351
     52#define EXPERT
     53
    5454double MCosy::Rad2SE(double rad) const
    5555{
     
    161161//  sending all changes immediatly.
    162162//
    163 ZdAz MCosy::GetSePos()
     163ZdAz MCosy::GetSePos() const
    164164{
    165165    const int pa = fAz->GetPos();
     
    206206    fMac1->WaitForSdo(0x6004);
    207207
    208     // FIXME, what when waiting times out (Zombie)
    209     // WaitForSdos();
    210 
    211208    //
    212209    // If waiting was not interrupted everything is ok. return.
    213210    //
    214     if (!(Break() || HasError()) && !HasZombie())
     211    if (!(Break() || HasError() || HasZombie()))
    215212        return kTRUE;
    216213
     
    302299    if (axe1) fMac2->StartRelPos(rd.Zd());
    303300    if (axe2) fMac1->StartRelPos(rd.Az());
    304 
     301#ifdef EXPERT
    305302    cout << "Waiting for positioning..." << flush;
    306 
     303#endif
    307304    if (axe1) fMac2->WaitForSdo(0x6004, 1);
    308305    if (axe2) fMac1->WaitForSdo(0x6004, 1);
    309306
    310307    WaitForEndMovement();
    311 
     308#ifdef EXPERT
    312309    cout << "done." << endl;
     310#endif
    313311}
    314312
     
    400398    if (d.Zd()<fMin.Zd() || d.Zd()>fMax.Zd())
    401399    {
    402         lout << "ERROR: Requested Zenith Angle (" << d.Zd() << "deg) not ";
    403         lout << "inside allowed range." << endl;
     400        lout << "ERROR: Requested Zenith Angle (" << d.Zd() << "deg, Az=";
     401        lout << d.Az() << ") not inside allowed range." << endl;
    404402        return kFALSE;
    405403    }
     
    407405    if (d.Az()<fMin.Az() || d.Az()>fMax.Az())
    408406    {
    409         lout << "ERROR: Requested Azimuth Angle (" << d.Az() << "deg) not ";
    410         lout << "inside allowed range." << endl;
     407        lout << "ERROR: Requested Azimuth Angle (" << d.Az() << "deg, Zd=";
     408        lout << d.Zd() << ") not inside allowed range." << endl;
    411409        return kFALSE;
    412410    }
     
    428426int MCosy::SetPosition(const ZdAz &dst, Bool_t track) // [rad]
    429427{
    430     // FIXME: Correct by fOffset ?
    431 
    432428    const ZdAz d = dst*kRad2Deg;
    433429
     
    441437    //
    442438    const ZdAz src = GetSePos(); // [se]
    443 
    444     /*
    445     if (fMac1->IsZombieNode() || fMac2->IsZombieNode())
    446     {
    447         cout << "SetPosition: No connection to at least one of the MACS!" << endl;
    448         return TRUE;
    449     }
    450     */
    451439
    452440    //
     
    457445    //if (fMac3->IsZombieNode())
    458446    //    return false;
    459 
    460     // ====================================
    461     RequestRePos();
    462     ZdAz before = GetRePos();
    463     // ====================================
    464447
    465448    //
     
    477460    cout << "Shortest Dest Zd: " << dest.Zd() << "se  Az:" << dest.Az() << "se" << endl;
    478461
    479     /*
    480      * re(se) = -28.1*cos(x*360/16384/se - 14.4) + 443.2*re/se
    481      *
    482      * int(re) = -1278.86*sin(0.021972656   *x/se - 14.4    )re + 443.2re x/se
    483      * int(re) = -73273.4*sin(0.000383495197*x/se - .2513274)re + 443.2re x/se
    484      *
    485      * int (-75deg..95deg) = 3.28343e7 re
    486      *
    487      */
    488 
    489462    //
    490463    // Set velocities
     
    493466
    494467    int i;
    495     for (i=0; i<10 && !(Break() || HasError()) && !HasZombie(); i++)
     468    for (i=0; i<10 && !(Break() || HasError() || HasZombie()); i++)
    496469    {
    497470
     
    506479        //
    507480        ZdAz rd = dest-p; // [se]
    508 /*
    509         if (rd.Az()>0 && rd.Az()<0.5)
    510             rd.Az(1);
    511         if (rd.Az()<0 && rd.Az()>-0.5)
    512             rd.Az(-1);
    513 */
    514         cout << "Deviation: " << rd.Zd() << "se  Az:" << rd.Az() << "se" << endl;
    515 
    516481
    517482        // ===========================================
    518         Float_t k1 = dest.Zd()*360/16384 - 14.3979; //[deg]
    519         Float_t k0 = p.Zd()*360/16384    - 14.3979; //[deg]
    520 
    521         //
    522         // -28re/se*cos((x/deg-14.4)*pi/180) + 443.2re/se     x
    523         // 28re/se*2*pi/360*sin((x/deg-14.4)*pi/180)*deg + 443.2re/se*x/deg
    524         //
    525 
    526         Float_t dk = 443.152*(dest.Zd()-p.Zd());
    527         Float_t dx = 28.0148/2/TMath::Pi()*(sin(k1/kRad2Deg)-sin(k0/kRad2Deg));
    528 
    529         cout << "Using: " << rd.Zd()*kGearRatio.X() << endl; // [re]
    530         cout << "Estimated1: " << 16384*dx + dk << endl;
    531         cout << "Estimated2: " << (16384*dx + dk)/1.085949688 << endl;
    532         cout << "Estimated3: " << rd.Zd()*432 << endl;
     483        const ZdAz ist = dst-rd*TMath::Pi()/8192;
     484
     485        const double p1 = ist.Zd()-19.0605/kRad2Deg;
     486        const double p2 = dst.Zd()-19.0605/kRad2Deg;
     487
     488        const double f1 = (-26.0101*sin(p1)+443.761*ist.Zd())*8192/TMath::Pi();
     489        const double f2 = (-26.0101*sin(p2)+443.761*dst.Zd())*8192/TMath::Pi();
    533490        // ===========================================
    534 
    535491
    536492        ZdAz cd = rd;     // [se]
    537493        cd.Round();
    538 /*
    539         if (rd.Az()>0 && rd.Az()<0.5)
    540             rd.Az(0.5);
    541         if (rd.Az()<0 && rd.Az()>-0.5)
    542             rd.Az(-0.5);
    543 */
     494
    544495        //
    545496        // Check if there is a control deviation on the axis
     
    555506            lout << "Positioning done in " << i << (i==1?" step.":" steps.") << endl;
    556507            SetStatus(MCosy::kStopped);
    557 
    558             // ====================================
    559             RequestRePos();
    560             ZdAz after = GetRePos();
    561             // ====================================
    562 
    563             after -= before;
    564 
    565             cout << "Drove: " << after.Zd() << " " << after.Az() << endl;
    566508            return TRUE;
    567509        }
     
    571513        //
    572514        rd *= kGearRatio; // [re]
     515        rd.Zd(f2-f1);
    573516
    574517        //
     
    590533            if (rd.Az()>-15*kGearRatio.Y() && rd.Az()<15*kGearRatio.Y())
    591534            {
     535#ifdef EXPERT
    592536                cout << " -------------- LO ---------------- " << endl;
     537#endif
    593538                fMac1->SetAcceleration(0.05*vr);
    594539                fMac1->SetDeceleration(0.05*vr);
     
    596541            else
    597542            {
     543#ifdef EXPERT
    598544                cout << " -------------- HI ---------------- " << endl;
     545                fMac1->SetAcceleration(0.4*vr);// 0.4
     546                fMac1->SetDeceleration(0.4*vr);// 0.4
     547#else
    599548                fMac1->SetAcceleration(0.2*vr);
    600549                fMac1->SetDeceleration(0.1*vr);
     550#endif
    601551            }
    602552
     553#ifdef EXPERT
     554            fMac2->SetAcceleration(0.4*vr);// 0.4
     555            fMac2->SetDeceleration(0.4*vr);// 0.4
     556            SetPosVelocity(fabs(rd.Ratio()), 0.2); // 0.175
     557#else
    603558            fMac2->SetAcceleration(0.2*vr);
    604559            fMac2->SetDeceleration(0.1*vr);
    605 
    606             // vel(0.6)  acc(0.5)
    607             SetPosVelocity(fabs(rd.Ratio()), 0.175);
    608             //            SetPosVelocity(fabs(rd.Ratio()), 0.1, 0.3);
     560            SetPosVelocity(fabs(rd.Ratio()), 0.1);
     561#endif
    609562        }
    610563
     
    632585    if (i<10)
    633586        StopMovement();
     587    else
     588        SetStatus(MCosy::kStopped);
    634589
    635590    lout << "Warning: Requested position not reached (i=" << i << ")" << endl;
     
    653608
    654609    //
    655     // Wait for the objects to be OKed.
    656     //
    657 
     610    // Wait for the objects to be acknoledged.
     611    //
    658612    fMac2->WaitForSdo(0x3006, 1);
    659613    fMac1->WaitForSdo(0x3006, 1);
    660614
    661     // FIXME, what when waiting times out (Zombie)
    662     // WaitForSdos();
    663 
    664615    //
    665616    // If the waiting for the objects wasn't interrupted return kTRUE
    666617    //
    667     if (!(Break() || HasError()) && !HasZombie())
     618    if (!(Break() || HasError() || HasZombie()))
    668619        return kTRUE;
    669620
     
    694645    // Start revolution mode
    695646    //
    696     fMac2->SetAcceleration(0.2*fMac2->GetVelRes());
    697     fMac2->SetDeceleration(0.2*fMac2->GetVelRes());
     647    fMac2->SetAcceleration(0.1*fMac2->GetVelRes());
     648    fMac2->SetDeceleration(0.1*fMac2->GetVelRes());
    698649    if (fMac2->IsZombieNode())
    699650        return false;
    700651
    701     fMac1->SetAcceleration(0.2*fMac1->GetVelRes());
    702     fMac1->SetDeceleration(0.2*fMac1->GetVelRes());
     652    fMac1->SetAcceleration(0.1*fMac1->GetVelRes());
     653    fMac1->SetDeceleration(0.1*fMac1->GetVelRes());
    703654    if (fMac1->IsZombieNode())
    704655        return false;
     
    732683    // we don't want fast changes!
    733684    //
    734 
    735685    ULong_t vrzd = fMac1->GetVelRes();
    736686    ULong_t vraz = fMac2->GetVelRes();
     
    738688#define sgn(x) (x<0?-1:1)
    739689
    740     const Float_t limit = 0.25;
     690    //
     691    // When speed changes sign, the maximum allowed speed
     692    // is 25% of the |v|
     693    //
     694    const Float_t limit    = 0.25;
     695
     696    //
     697    // The maximum allowed speed while tracking is 10%
     698    //
     699    const Float_t maxtrack = 0.1;
    741700/*
    742701    if (sgn(vt->Az()) != sgn(vcalc.Az()))
     
    766725        && fabs(vt->Az()) < limit*fabs(vcalc.Az())
    767726       )
    768         vt->Az(0);
     727        {
     728            lout << "Warning: Negative Azimuth speed limit (" << limit*100 << "%) exceeded... set to 0." << endl;
     729            vt->Az(0);
     730        }
    769731    else
    770         if (fabs(vt->Az()) > 0.9*vraz)
    771         {
    772             lout << "Warning: Azimuth speed limit exceeded. Limiting speed to 90% max." << endl;
    773             vt->Az(0.9*vraz*sgn(vt->Az()));
     732        if (fabs(vt->Az()) > maxtrack*vraz)
     733        {
     734            lout << "Warning: Azimuth speed limit (" << maxtrack*100 << "%) exceeded... limited." << endl;
     735            vt->Az(maxtrack*vraz*sgn(vcalc.Az()));
    774736        }
    775737
     
    777739        && fabs(vt->Zd()) < limit*fabs(vcalc.Zd())
    778740       )
    779         vt->Zd(0);
     741        {
     742            lout << "Warning: Negative Altitude speed limit (" << limit*100 << "%) exceeded... set to 0." << endl;
     743            vt->Zd(0);
     744        }
    780745    else
    781         if (fabs(vt->Zd()) > 0.9*vrzd)
    782         {
    783             lout << "Warning: Altitude speed limit exceeded. Limiting speed to 90% max." << endl;
    784             vt->Zd(0.9*vrzd*sgn(vt->Zd()));
    785         }
    786 }
    787 
    788 Bool_t MCosy::AlignTrackingPos(ZdAz pointing, ZdAz &za)
     746        if (fabs(vt->Zd()) > maxtrack*vrzd)
     747        {
     748            lout << "Warning: Altitude speed limit (" << maxtrack*100 << "%) exceeded... limited." << endl;
     749            vt->Zd(maxtrack*vrzd*sgn(vcalc.Zd()));
     750        }
     751}
     752
     753Bool_t MCosy::AlignTrackingPos(ZdAz pointing, ZdAz &za) const
    789754{
    790755    // pointing [deg]
    791 
    792756    if (pointing.Zd()<0)
    793757    {
     
    796760    }
    797761
    798     const ZdAz se = GetSePos()*360/16384; // [deg]
    799     const ZdAz unbendedse = fBending.CorrectBack(se); // ist pointing
     762    const ZdAz se = GetSePos()*2*TMath::Pi()/16384;   // [rad]
     763    const ZdAz unbendedse = fBending.CorrectBack(se)*kRad2Deg; // ist pointing
    800764
    801765    do
     
    805769            break;
    806770
    807         pointing.Az(pointing.Az()+TMath::Sign(360., -d));
     771        pointing.Az(pointing.Az()+TMath::Sign(360., d));
    808772    } while (1);
    809   /*
    810     while (pointing.Az()<fMin.Az())
    811         pointing.Az(pointing.Az() + 360);
    812 
    813     while (pointing.Az()>fMax.Az())
    814         pointing.Az(pointing.Az() - 360);
    815         */
     773
    816774    const Bool_t rc = CheckRange(pointing);
    817     za = fBending(pointing/kRad2Deg); // [rad]
     775    za = pointing/kRad2Deg; // [rad]
    818776
    819777    if (!rc)
     
    821779
    822780    return rc;
     781}
     782
     783Double_t MCosy::Starguider(Double_t mjd, ZdAz &dest) const
     784{
     785    ifstream fin("pointingpos.txt");
     786    if (!fin)
     787        return -1;
     788
     789    Double_t mjd0, zd, az;
     790    fin >> mjd0 >> zd >> az;
     791
     792    mjd0 += 52000;
     793
     794    if (mjd0+1./24/60 <mjd)
     795        return -1;
     796
     797    ZdAz point;
     798    if (!AlignTrackingPos(ZdAz(zd, az), point))
     799    {
     800        cout << "Starguider position couldn't be aligned..." << endl;
     801        return -1;
     802    }
     803
     804    const ZdAz diff = (dest-point)*kRad2Deg;
     805
     806    if (diff.Zd()>5 || diff.Az()>5)
     807    {
     808        cout << "Starguider deviation too large... dZd=" << diff.Zd() <<" dAz="<<diff.Az() << endl;
     809        return -1;
     810    }
     811
     812    dest -= point;
     813    dest *= 16384/TMath::Pi()/2; // [se]
     814    dest *= -kGearRatio;         // [re]
     815
     816    cout << "Using Starguider... dZd=" << dest.Zd() << " dAz=" << dest.Az() << endl;
     817
     818    return (mjd-mjd0) * (24*60*60); // [s]
    823819}
    824820
     
    877873    //
    878874    if (!InitTracking())
     875    {
     876        StopMovement();
    879877        return;
     878    }
    880879
    881880    XY xy(Rad2Deg(dst.Ra())*24/360, Rad2Deg(dst.Dec()));
     
    883882    lout << "Start tracking:";
    884883    lout << " Ra: " << xy.X() << "h  " << "Dec: " << xy.Y() << "\xb0" << endl;
    885 
     884#ifdef EXPERT
    886885    ofstream fout("coordinates.txt");
    887886    fout << xy;
    888887    fout.close();
    889 
     888#endif
    890889    //
    891890    // Initialize Tracker (slalib or starguider)
     
    922921            break;
    923922
    924         dest *= 16384/TMath::Pi()/2;  // [se]
    925 
    926         /*
    927         ZdAz dummy1 = sla.CalcZdAz(fRaDec);
    928 
    929         if (dummy1.Az()<-TMath::Pi()/2)
    930             dummy1.Az(dummy1.Az() + TMath::Pi()*2);
    931         if (dummy1.Az()>3*TMath::Pi()/2)
    932             dummy1.Az(dummy1.Az() -TMath::Pi()*2);
    933 
    934         if (!CheckRange(dummy1*kRad2Deg))
    935         {
    936             lout << "Error: Tracking position out of Range." << endl;
    937             break;
    938         }
    939 
    940         ZdAz dummy = fBending(dummy1);
    941         dest = CorrectTarget(GetSePos(), dummy); // [se]
    942         */
    943 
    944 //*LP*      const ZdAz d = dest*360./16384; // [deg]
    945         dest *= kGearRatio;  // [re]
    946 
    947 //*LP*      ZdAz min = fBending(fMin/kRad2Deg)*kRad2Deg;
    948 //*LP*      ZdAz max = fBending(fMax/kRad2Deg)*kRad2Deg;
    949 
    950923        ZdAz vcalc = sla.GetApproxVel(fRaDec) * kGearRatio2*4./60.;  // [re/min]
    951924
    952         //
    953         // Request absolute position of rotary encoder from Macs
    954         //
    955         if (!RequestRePos())
    956             break;
    957 
    958         //
    959         // distance between (To+dt) and To [re]
    960         // position time difference < 5usec
    961         // fOffset does the synchronization between the
    962         // Shaft- and the rotary encoders
    963         //
    964         dest -= GetRePos() + fOffset;
     925        float dtime = -1;
     926        if (kFALSE /*fUseStarguider*/)
     927            dtime = Starguider(mjd, dest);
     928
     929        if (dtime<0)
     930        {
     931            dest = fBending(dest);       // [rad]
     932            dest *= 16384/TMath::Pi()/2; // [se]
     933            dest *= kGearRatio;          // [re]
     934
     935            //
     936            // Request absolute position of rotary encoder from Macs
     937            //
     938            if (!RequestRePos())
     939                break;
     940
     941            //
     942            // distance between (To+dt) and To [re]
     943            // position time difference < 5usec
     944            // fOffset does the synchronization between the
     945            // Shaft- and the rotary encoders
     946            dest -= GetRePos() + fOffset;
     947
     948            dtime = dt;
     949        }
    965950
    966951        //
     
    968953        // correct for the duration of RaDec2AltAz
    969954        //
    970         const ZdAz v = dest*60.0/(dt/*-(fMac2->GetTime()-sla)*/);
     955        const ZdAz v = dest*60.0/(dtime/*-(fMac2->GetTime()-sla)*/);
    971956
    972957        //
     
    10201005        // (This is important on fast machines >500MHz)
    10211006        //
     1007        /*
     1008        MTimeout t(1000);
     1009        while (!t.HasTimedOut())
     1010            usleep(1);
     1011         */
    10221012        usleep(1000000); // 1s
    10231013        //usleep(50000); // 0.05s
     
    10471037    //
    10481038    cout << "Stopping movement (dec=30%)..." << endl;
    1049 
     1039#ifdef EXPERT
     1040    fMac1->SetDeceleration(0.5*fMac1->GetVelRes());
     1041    fMac2->SetDeceleration(0.5*fMac2->GetVelRes());
     1042#else
    10501043    fMac1->SetDeceleration(0.3*fMac1->GetVelRes());
    10511044    fMac2->SetDeceleration(0.3*fMac2->GetVelRes());
     1045#endif
    10521046    fMac1->SetRpmMode(FALSE);
    10531047    fMac2->SetRpmMode(FALSE);
     
    10681062    // Wait for the movement to really be finished.
    10691063    //
     1064#ifdef EXPERT
    10701065    cout << "Waiting for end of movement..." << endl;
     1066#endif
    10711067    WaitForEndMovement();
    10721068
     
    10751071    //
    10761072    CheckForError();
     1073#ifdef EXPERT
    10771074    cout << "Movement stopped." << endl;
     1075#endif
    10781076}
    10791077
     
    12031201        return (void*)0xaffe;
    12041202        */
    1205 
     1203#ifdef EXPERT
    12061204    case WM_TPOINT:
    12071205        {
     
    12291227        }
    12301228        return (void*)0xca1b;
     1229#endif
    12311230
    12321231    case WM_TRACKPOS:
     
    13981397
    13991398    cout << "Reading telescope range..." << flush;
    1400     const Double_t amin = env.GetValue("Az_Min[deg]", -90.0);
    1401     const Double_t zmin = env.GetValue("Zd_Min[deg]", -74.5);
     1399    const Double_t amin = env.GetValue("Az_Min[deg]", -95.0);
     1400    const Double_t zmin = env.GetValue("Zd_Min[deg]", -75.0);
    14021401    fMin.Set(zmin, amin);
    14031402
    14041403    cout << " Min: " << zmin << "deg  " << amin << "deg" << endl;
    14051404
    1406     const Double_t amax = env.GetValue("Az_Max[deg]", 318.0);
    1407     const Double_t zmax = env.GetValue("Zd_Max[deg]", 100.5);
     1405    const Double_t amax = env.GetValue("Az_Max[deg]", 305.0);
     1406    const Double_t zmax = env.GetValue("Zd_Max[deg]", 98.25);
    14081407    fMax.Set(zmax, amax);
    14091408
     
    14501449    cout << " * Setting Gear Ratios:" << endl;
    14511450    cout << "   --------------------" << endl;
    1452     cout << " *  X: " << gzd << "*" << resrezd << "/" << ressezd << "=" << kGearRatio.X() << endl;
    1453     cout << " *  Y: " << gaz << "*" << resreaz << "/" << resseaz << "=" << kGearRatio.Y() << endl;
     1451    cout << " *  X: " << gzd << "*" << resrezd << "/" << ressezd << "=4*" << kGearRatio.X() << endl;
     1452    cout << " *  Y: " << gaz << "*" << resreaz << "/" << resseaz << "=4*" << kGearRatio.Y() << endl;
    14541453}
    14551454
     
    14891488    ZdAz ist = GetSePos();              // [se]
    14901489
    1491 //    ZdAz istre = -fOffset;              // [re]
    14921490    ZdAz time;
    14931491
     
    15831581        ZdAz soll(sollzd.Zd(), sollaz.Az()); // [rad]
    15841582
    1585         AlignTrackingPos(soll*360/16384, fZdAzSoll);
    1586         /*
    1587         fZdAzSoll = fBending.CorrectBack(soll*2*TMath::Pi()/16384);
    1588 
    1589         // FIXME?
    1590         if (fZdAzSoll.Az()<-TMath::Pi()/2)
    1591             fZdAzSoll.Az(fZdAzSoll.Az() + TMath::Pi()*2);
    1592         if (fZdAzSoll.Az()>3*TMath::Pi()/2)
    1593             fZdAzSoll.Az(fZdAzSoll.Az() -TMath::Pi()*2);
    1594 
    1595         // FIXME?
    1596         while (ist.Az()>3*16384/4/2)
    1597             ist.Az(ist.Az() - 16384);
    1598         while (soll.Az()>3*16384/4/2)
    1599             soll.Az(soll.Az() - 16384);
    1600         while (ist.Az()<-16384/4)
    1601             ist.Az(ist.Az() + 16384);
    1602         while (soll.Az()<-16384/4)
    1603             soll.Az(soll.Az() + 16384);
    1604             */
     1583        AlignTrackingPos(soll*kRad2Deg, fZdAzSoll);
     1584
    16051585        ist *= TMath::Pi()*2/16384;
    1606         fTrackingError.Set(ist.Zd()-fZdAzSoll.Zd(), ist.Az()-fZdAzSoll.Az());
     1586        soll = fBending(fZdAzSoll);
     1587        fTrackingError.Set(ist.Zd()-soll.Zd(), ist.Az()-soll.Az());
    16071588
    16081589        //---            fout << setprecision(15) << setw(17) << time.Zd()*60.*60.*24. << " ";
     
    17241705            re0.Zd(re.Zd());
    17251706
     1707            se -= dse/2;
     1708
    17261709            ZdAz bend = fBending.CorrectBack(se*2*TMath::Pi()/16384)*kRad2Deg;
    17271710            ((TH3*)fHist)->Fill(bend.Zd(), bend.Az(), dre.Zd()/dse.Zd());
     
    17321715            se0.Az(se.Az());
    17331716            re0.Az(re.Az());
     1717
     1718            se -= dse/2;
    17341719
    17351720            ZdAz bend = fBending.CorrectBack(se*2*TMath::Pi()/16384)*kRad2Deg;
     
    21242109    fZd2->SetDisplay(fWin->GetLabel3());
    21252110    fAz->SetDisplay(fWin->GetLabel1());
    2126 
     2111#ifdef EXPERT
    21272112    int i=0;
    21282113    char name[100];
     
    21452130    *tpout << time.Year() << " " << time.Month() << " " << time.Day() << " ";
    21462131    *tpout << /*"20 1013.25 300 0.5 0.55 0.0065" <<*/ endl;
     2132#endif
    21472133    // temp(°C) pressure(mB) height(m) humidity(1) wavelength(microm) troplapserate(K/m)
    21482134}
     
    21702156MCosy::~MCosy()
    21712157{
     2158#ifdef EXPERT
    21722159    *tpout << "END" << endl;
    21732160    delete tpout;
     2161#endif
    21742162
    21752163    cout << "Deleting GUI timer." << endl;
  • trunk/MagicSoft/Cosy/main/MCosy.h

    r1953 r2019  
    118118    ofstream *tpout;
    119119
    120     Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za);
     120    Bool_t AlignTrackingPos(ZdAz pointing, ZdAz &za) const;
    121121    Bool_t CheckRange(const ZdAz &d) const;
     122    Double_t Starguider(Double_t mjd, ZdAz &dest) const;
    122123
    123124    double Rad2SE(double rad) const;
     
    132133    ZdAz GetRePos();
    133134    ZdAz GetRePosPdo();
    134     ZdAz GetSePos();    // [se]
     135    ZdAz GetSePos() const; // [se]
    135136
    136137    Bool_t RequestRePos();
  • trunk/MagicSoft/Cosy/videodev/Filter.cc

    r1959 r2019  
    205205void Filter::Stretch(byte *img)
    206206{
    207     const int offset = 10;
     207    const int offset = 25;
    208208
    209209    int max;
     
    212212    /*const float mean =*/Mean(img, offset, &min, &max);
    213213
     214    const byte diff = max-min;
     215
    214216    for (int x=0; x<768; x++)
    215217        for (int y=0; y<576; y++)
    216218        {
    217             img[y*768+x] -= min;
    218             img[y*768+x] *= 255/(max-min);
    219         }
    220 }
     219            byte &b = img[y*768+x];
     220
     221            if (b<min)
     222            {
     223                b=0;
     224                continue;
     225            }
     226            if (b>max)
     227            {
     228                b=max;
     229                continue;
     230            }
     231            b -= min;
     232            b *= 255/diff;
     233        }
     234}
Note: See TracChangeset for help on using the changeset viewer.