Changeset 912


Ignore:
Timestamp:
08/17/01 15:12:57 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft
Files:
6 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r911 r912  
    11                                                                  -*-*- END -*-*-
     2
     3 2001/08/17 - Thomas Bretz:
     4
     5    * Added:
     6      - catalog/SlaStars.cc
     7      - catalog/SlaStars.h
     8      - catalog/SlaPlanets.cc
     9      - catalog/SlaPlanets.h
     10      - gui/MGAccuracy.cc
     11      - gui/MGAccuracy.h
     12
     13    * MCosy.[h,cc]:
     14      - removed dependance from MGSkyPosition
     15      - changed Timer function names
     16      - moved timer calls into Slalib calls
     17      - changed Slalib to SlaStars
     18      - added fAccuracy
     19      - added accuracy display to MTGui
     20   
     21    * Makefile: 
     22      - changed order of libraries
     23   
     24    * Starguider.cc:
     25      - changed Timer function names
     26   
     27    * base/timer.[h,cc]
     28      - changed GetTime -> Now
     29      - changed GetMjd  -> CalcMjd
     30   
     31    * catalog/Makefile:
     32      - added new file SlaStars.cc
     33      - added new file SlaPlanets.cc
     34   
     35    * catalog/Slalib.[h,cc]:
     36      - moved star dependent functions to derived class SlaStars
     37      - changed name of Set to SetMjd
     38      - made SetMjd virtual
     39      - derives from Timer now
     40      - added conversion function for XYZ->ZdAz
     41   
     42    * catalog/StarCatalog.cc:
     43      - moved timer calls into Slalib calls
     44      - changed Slalib to SlaStars
     45
     46    * devdrv/macs.cc:
     47      - changed names of timer function calls
     48
     49    * devdrv/shaftencoder.cc:
     50      - changed names of timer function calls
     51      - changed some cout's to lout's
     52   
     53    * gui/MGCosy.[h,cc]:
     54      - added fAccuracy
     55      - moved timer calls into Slalib calls
     56      - changed Slalib to SlaStars
     57   
     58    * gui/MGSkyPosition.[h,cc]:
     59      - added display of planet positions
     60
     61    * slalib/Makefile:
     62    - added missing files
     63   
     64
     65
     66
    267 2001/08/15 - Thomas Bretz:
    368
    4    * Added:
    5      - Makefile.conf.general
    6      - gui/Makefile
    7      - base/Makefile
    8      - candrv/Makefile
    9      - catalog/Makefile
    10      - slalib/Makefile
    11      - videodev/Makefile
    12      - devdrv/Makefile
    13      - base/MThread.[h,cc]
    14      - base/MTimeout.[h, cc]
    15      - mgui/MGSkyPosition.[h, cc]
    16      - catalog/Slalib.[h,cc]
     69    * Added:
     70      - Makefile.conf.general
     71      - gui/Makefile
     72      - base/Makefile
     73      - candrv/Makefile
     74      - catalog/Makefile
     75      - slalib/Makefile
     76      - videodev/Makefile
     77      - devdrv/Makefile
     78      - base/MThread.[h,cc]
     79      - base/MTimeout.[h, cc]
     80      - mgui/MGSkyPosition.[h, cc]
     81      - catalog/Slalib.[h,cc]
    1782     
    18    * .cosyrc:
    19      - changed names
    20      - added HomeTime
    21    
    22    * MCosy.[h,cc]:
    23      - added home time
    24      - added MTGui, MTTalk
    25      - added reading environment
    26    
    27    * Makefile, Makefile.conf.linux-gnu, Makefile.rules
    28      - changed to Mars style
    29    
    30    * Starguider.cc:
    31      - changed include timer.g to base/timer.h
    32    
    33    * Starguider.[h,cc]:
    34      - renamed Execute to ProcessFrame
     83    * .cosyrc:
     84      - changed names
     85      - added HomeTime
     86   
     87    * MCosy.[h,cc]:
     88      - added home time
     89      - added MTGui, MTTalk
     90      - added reading environment
     91   
     92    * Makefile, Makefile.conf.linux-gnu, Makefile.rules
     93      - changed to Mars style
     94   
     95    * Starguider.cc:
     96      - changed include timer.g to base/timer.h
     97   
     98    * Starguider.[h,cc]:
     99      - renamed Execute to ProcessFrame
    35100 
    36    * cosy.cc:
    37      - removed unnecessary includes
    38    
    39    * base/MGList.h:
    40      - added debug output
    41    
    42    * base/msgqueue.cc:
    43      - added comments
    44    
    45    * base/msgqueue.h:
    46      - made Break const
    47    
    48    * candrv/canopen.[h,cc]:
    49      - made CobId const
    50    
    51    * candrv/network.[h,cc]:
    52      - fixed typo
    53      - StopReceiver -> VmodIcan::Stop
    54      - made HasError const
    55    
    56    * candrv/nodedrv.[h,cc]:
    57      - added timeout to WaitForSdo
    58    
    59    * candrv/sdolist.[h,cc]:
    60      - made IsPending const
     101    * cosy.cc:
     102      - removed unnecessary includes
     103   
     104    * base/MGList.h:
     105      - added debug output
     106   
     107    * base/msgqueue.cc:
     108      - added comments
     109   
     110    * base/msgqueue.h:
     111      - made Break const
     112   
     113    * candrv/canopen.[h,cc]:
     114      - made CobId const
     115   
     116    * candrv/network.[h,cc]:
     117      - fixed typo
     118      - StopReceiver -> VmodIcan::Stop
     119      - made HasError const
     120   
     121    * candrv/nodedrv.[h,cc]:
     122      - added timeout to WaitForSdo
     123   
     124    * candrv/sdolist.[h,cc]:
     125      - made IsPending const
    61126     
    62    * candrv/vmodican.[h,cc]:
    63      - changed ReceiveThread to new stylish MThread
    64    
    65    * devdrv/macs.[h,cc]:
    66      - changed SetHome to use a maximum positioning time
    67      - added comments
    68      - replaces SetSyncMode by StartPosSync and StartVelSync
    69 
    70    * devdrv/shaftencoder.[h,cc]:
    71      - removed gui thread (the update is done by MTGui now)
    72    
    73    * gui/MGCosy.[h,cc]:
    74      - some small changed
    75      - removed fList->Delete()
    76      - added MSkyPosition-Object
    77      - gSystem->ExitLoop() replaced by gSystem->Terminate(0)
    78    
    79    * videodev/Camera.[h,cc]:
    80      - renamed Execute to ProcessFrame
     127    * candrv/vmodican.[h,cc]:
     128      - changed ReceiveThread to new stylish MThread
     129   
     130    * devdrv/macs.[h,cc]:
     131      - changed SetHome to use a maximum positioning time
     132      - added comments
     133      - replaces SetSyncMode by StartPosSync and StartVelSync
     134
     135    * devdrv/shaftencoder.[h,cc]:
     136      - removed gui thread (the update is done by MTGui now)
     137   
     138    * gui/MGCosy.[h,cc]:
     139      - some small changed
     140      - removed fList->Delete()
     141      - added MSkyPosition-Object
     142      - gSystem->ExitLoop() replaced by gSystem->Terminate(0)
     143   
     144    * videodev/Camera.[h,cc]:
     145      - renamed Execute to ProcessFrame
    81146
    82147
  • trunk/MagicSoft/Cosy/MCosy.cc

    r909 r912  
    1111
    1212#include "MGCosy.h"
    13 #include "Slalib.h"
     13#include "SlaStars.h"
    1414
    1515#include "macs.h"
    1616#include "base/timer.h"
    1717#include "shaftencoder.h"
    18 
    19 #include "MGSkyPosition.h" // FIXME!!!!!!!!!!!!!!!!!
    2018
    2119//#include <sys/resource.h>  // PRIO_PROCESS
     
    265263void MCosy::TrackPosition(const RaDec &dst) // ra, dec [rad]
    266264{
    267     Slalib sla;
     265    SlaStars sla;
    268266
    269267    //
    270268    // Position to actual position
    271269    //
    272     Timer t;
    273     t.GetTime();
    274 
    275     sla.Set(t.GetMjd());
     270    sla.SetMjd2Now();
    276271    ZdAz dest = sla.CalcZdAz(dst);
    277272
     
    311306    fMac1->SetRpmMode(TRUE);
    312307
    313     /*-*/ int s = t.GetSecs();
     308    /*-*/ int s = sla.GetSecs();
    314309    cout << "Start tracking: Ra: " << Rad2Deg(dst.Ra()) << kDEG << "  Dec: ";
    315310    cout << Rad2Deg(dst.Dec()) << kDEG << endl;
     
    333328        // Request Real Position from Drive
    334329        //
    335         Timer t;
    336         t.GetTime();
     330        sla.Now();
    337331
    338332        //
    339333        // Request theoretical Position for a time in the future (To+dt) from CPU
    340334        //
    341         sla.Set(t.GetMjd()+dt/(60*60*24));
     335        sla.SetMjd(sla.CalcMjd()+dt/(60*60*24));
    342336        dest = CorrectTarget(GetSePos(), sla.CalcZdAz(dst));
    343337
     
    367361        // correct for the duration of RaDec2AltAz
    368362        //
    369         const ZdAz v = dest*60.0/(dt-(fMac2->GetTime()-t));
     363        const ZdAz v = dest*60.0/(dt-(fMac2->GetTime()-sla));
    370364
    371365        //
     
    404398        {
    405399            const double mjd = fMac2->GetMjd();
    406             sla.Set(mjd);
     400            sla.SetMjd(mjd);
    407401            ZdAz dest0=CorrectTarget(GetSePos(), sla.CalcZdAz(dst));
    408402            dest0 *= kGearRatio;
    409403            dest0 -= GetRePos()+offset;
    410404            dest0.Round();
     405
     406            fAccuracy = dest0/kGearRatio2; // [deg]
     407
    411408            //cout << "Control deviation: ";
    412409            fout << setprecision(15) << setw(15) << mjd*60.*60.*24. << " ";
    413410            fout << setw(4) << (int)fOffset.Zd() << " ";
    414411            fout << setw(4) << (int)fOffset.Az() << " ";
    415 
    416412            fout << setw(4) << dest0.Zd() << " ";
    417413            fout << setw(4) << dest0.Az() << " ";
     
    478474        {
    479475            cout << "WM_POLARIS: START" << endl;
    480             Slalib sla;
    481 
    482             Timer t;
    483             t.GetTime();
    484 
    485             sla.Set(t.GetMjd());
     476            SlaStars sla;
     477            sla.SetMjd2Now();
    486478
    487479            RaDec rd(37.94, 89.2644);
     
    608600    // SetPosition(dest);
    609601
    610     Slalib sla;
     602    SlaStars sla;
    611603    while (1)
    612604    {
     
    665657                // calculate were we should be
    666658                //
    667                 sla.Set(t);
     659                sla.SetMjd(t);
    668660                sollalt = CorrectTarget(ist, sla.CalcZdAz(fRaDec));
    669661
     
    684676                // calculate were we should be
    685677                //
    686                 sla.Set(t);
     678                sla.SetMjd(t);
    687679                sollaz = CorrectTarget(ist, sla.CalcZdAz(fRaDec));
    688680
     
    695687void MCosy::GuiThread(MTGui *t)
    696688{
    697     MGSkyPosition *disp = fWin->GetSkyDisplay();
    698689    while (!t->HasStopFlag())
    699690    {
     
    707698
    708699        ZdAz ist = GetSePos()*(360.0/16384.0); // [se]
    709         disp->DrawPosition(ist);
     700        fWin->Update(ist, fAccuracy);
     701
    710702    }
    711703    cout << "Not running anymore." << endl;
     
    714706int MCosy::StopWaitingForSDO() const
    715707{
    716     return Break() || HasError(); //fMac1->HasError() || fMac2->HasError();
     708    return Break() || HasError();
    717709}
    718710
     
    773765{
    774766    cout << "MCosy::TerminateApp()" << endl;
     767/*
     768    Int_t rc;
     769    TGMessageBox msg(this, gClient->GetRoot(),
     770                     "Information",
     771                     "Cosy is shutting down the system - this may take wa while!",
     772                     kMBIconExclamation,
     773                     kMBOK, //kMBClose
     774                     &rc, 0);
     775*/
     776
    775777    gApplication->Terminate(0);
    776778}
  • trunk/MagicSoft/Cosy/MCosy.h

    r909 r912  
    7474    RaDec fRaDec;     // Position to track
    7575    int   fTracking;  // Flag for present tracking action
     76    ZdAz  fAccuracy;  // Actual accuracy of Tracking
    7677
    7778    ZdAz GetRePos();
  • trunk/MagicSoft/Cosy/Makefile

    r911 r912  
    3838#
    3939SUBDIRS = \
     40        gui         \
    4041        candrv      \
     42        devdrv      \
    4143        catalog     \
    42         devdrv      \
    43         gui         \
    4444        videodev    \
    4545        base        \
  • trunk/MagicSoft/Cosy/Starguider.cc

    r909 r912  
    336336
    337337            Timer time(tm);
    338             fSao.GetImg(img, cimg, time.GetMjd(), fRaDec);
     338            fSao.GetImg(img, cimg, time.CalcMjd(), fRaDec);
    339339            fImage->DrawColImg(img, cimg);
    340340
  • trunk/MagicSoft/Cosy/base/timer.cc

    r738 r912  
    4545}
    4646
    47 void Timer::SetTimer(struct timeval *tv)
     47void Timer::SetTimer(const struct timeval *tv)
    4848{
    4949    SetTimer(tv->tv_sec, (double)tv->tv_usec/1000000.0);
     
    7575}
    7676
    77 double Timer::GetTime()
     77double Timer::Now()
    7878{
    7979    struct timeval tv;
    8080    gettimeofday(&tv, NULL);
    8181
    82     SetTimer(tv.tv_sec, (double)tv.tv_usec/1000000.0);
     82    SetTimer(&tv);
    8383
    8484    return fMs+fSecs;
    8585}
    8686
    87 double Timer::GetMjd()
     87double Timer::CalcMjd()
    8888{
    8989    int status;
  • trunk/MagicSoft/Cosy/base/timer.h

    r808 r912  
    2727
    2828    void SetTimer(int tv_sec, double tv_usec);
    29     void SetTimer(struct timeval *tv);
     29    void SetTimer(const struct timeval *tv);
    3030
    3131
    3232    int GetSecs() { return fSecs; }
    33     double GetTime();
    34     double GetMjd();
     33    double Now();
     34    double CalcMjd();
    3535
    3636    int H() const { return fHor; }
  • trunk/MagicSoft/Cosy/catalog/Makefile

    r911 r912  
    3333SRCFILES = SaoFile.cc \
    3434           Slalib.cc \
     35           SlaStars.cc \
     36           SlaPlanets.cc \
    3537           StarCatalog.cc
    3638
  • trunk/MagicSoft/Cosy/catalog/Slalib.cc

    r911 r912  
    66#include "slalib.h"
    77
    8 Slalib::Slalib()
     8Slalib::Slalib() : Timer()
    99{
    1010    // p = pointer to MainFrame (not owner)
     
    2525}
    2626
    27 void Slalib::Set(const AltAz &altaz)
    28 {
    29     fAltAz = altaz * D2PI/360.0;
    30     fRaDec = CalcRaDec(fAltAz);
    31 }
    32 
    33 void Slalib::Set(const ZdAz &zdaz)
    34 {
    35     fAltAz = AltAz(DPI/2-zdaz.Zd(), zdaz.Az()) * D2PI/360.0;
    36     fRaDec = CalcRaDec(fAltAz);
    37 }
    38 
    39 void Slalib::Set(const RaDec &radec)
    40 {
    41     fRaDec = radec * D2PI/360.0;
    42     fAltAz = CalcAltAz(fRaDec);
    43 }
    44 
    45 void Slalib::Set(const double mjd)
     27void Slalib::SetMjd(const double mjd)
    4628{
    4729    fMjd   = mjd;
    4830    fAlpha = slaGmst(fMjd) + fElong;
     31}
     32
     33void Slalib::SetMjd2Now()
     34{
     35    Now();
     36    SetMjd(CalcMjd());
     37//    cout << "GetMjd: "<< (*this)() << " " << GetMjd() << endl;
     38}
     39
     40void Slalib::SetMjd(const struct timeval *tm)
     41{
     42    SetTimer(tm);
     43    SetMjd(CalcMjd());
     44}
     45
     46
     47ZdAz Slalib::XYZ2ZdAz(double coord[3]) const
     48{
     49    //
     50    // -- xyz to spherical coordinates --
     51    //
     52    double ra, dec;
     53    slaDcc2s(coord, &ra, &dec);
    4954
    5055    //
    51     // ----- calculate star independent parameters ----------
     56    // radec[rad] -> hadec[rad]
    5257    //
    53     slaMappa(2000.0, fMjd, fAmprms);
    54     slaAoppa(fMjd, 0,                // mjd, UT1-UTC
    55              fElong, fPhi, 148,      // g”ttingen long, lat, height
    56              0, 0,                   // polar motion x, y-coordinate (radians)
    57              273.155, 1013.25, 0.5,  // temp, pressure, humidity
    58              0.2, 0.0065,            // wavelength, tropo lapse rate
    59              fAoprms);
    60 }
    61 
    62 RaDec Slalib::CalcRaDec(const AltAz &altaz) const
    63 {
    64     return CalcRaDec(ZdAz(DPI/2-altaz.Alt(), altaz.Az()));
    65 }
    66 
    67 RaDec Slalib::CalcRaDec(const ZdAz &zdaz) const
    68 {
    69     //
    70     // -- observed to apparent --
    71     //  Workaraound for slalib: discard const
    72     //
    73     double r=0, d=0;
    74     slaOapqk ("A", zdaz.Az(), zdaz.Zd(), (double*)fAoprms, &r, &d);
     58    const double ha = fAlpha-ra;
    7559
    7660    //
    77     // -- apparent to mean --
    78     //  Workaraound for slalib: discard const
     61    // hadec[rad] -> altaz[rad]
    7962    //
    80     double ra, dec;
    81     slaAmpqk(r, d, (double*)fAmprms, &ra, &dec);
     63    double alt, az;
     64    slaDe2h(ha, dec, fPhi, &az, &alt);
    8265
    83     return RaDec(ra, dec);
     66    return ZdAz(DPI/2-alt, az);
    8467}
    85 
    86 ZdAz Slalib::CalcZdAz(const RaDec &radec) const
    87 {
    88     //
    89     // ---- Mean to apparent ----
    90     //
    91 
    92     double r=0, d=0;
    93     slaMapqkz(radec.Ra(), radec.Dec(), (double*)fAmprms, &r, &d);
    94     //
    95     // Doesn't work - don't know why
    96     //
    97     //    slaMapqk (radec.Ra(), radec.Dec(), rdpm.Ra(), rdpm.Dec(),
    98     //              0, 0, (double*)fAmprms, &r, &d);
    99     //
    100 
    101     //
    102     // -- apparent to observed --
    103     //
    104     double r1=0;  // ra
    105     double d1=0;  // dec
    106     double h0=0;  // ha
    107 
    108     double zd;
    109     double az;
    110     slaAopqk (r, d, (double*)fAoprms,
    111               &az,    // observed azimuth (radians: N=0,E=90)
    112               &zd,    // observed zenith distance (radians) [-pi/2, pi/2]
    113               &h0,    // observed hour angle (radians)
    114               &d1,    // observed declination (radians)
    115               &r1);   // observed right ascension (radians)
    116 
    117     return ZdAz(zd, az);
    118 }
    119 AltAz Slalib::CalcAltAz(const RaDec &radec) const
    120 {
    121     ZdAz zdaz = CalcZdAz(radec);
    122     return AltAz(DPI/2-zdaz.Zd(), zdaz.Az());
    123 }
    124 
  • trunk/MagicSoft/Cosy/catalog/Slalib.h

    r911 r912  
    33
    44#include "coord.h"
     5#include "base/timer.h"
    56
    6 class Slalib
     7class Slalib : public Timer
    78{
    89private:
    9     double   fPhi;      // location of observatory
    10     double   fElong;
    11 
    12     AltAz    fAltAz;    // [rad]
    13     RaDec    fRaDec;    // [rad]
    14 
    1510    double   fAlpha;
    1611    double   fMjd;
    1712
    18     double   fAmprms[21];
    19     double   fAoprms[14];
     13    double   fPhi;      // location of observatory
     14    double   fElong;
    2015
    2116public:
     
    2722    //    const RaDec GetRaDec() const { return fRaDec*360/D2PI; }
    2823
    29     void   Set(const double mjd);
     24    void SetMjd2Now();
     25    void SetMjd(const struct timeval *tm);
    3026
    31     void   Set(const AltAz &altaz);
    32     void   Set(const ZdAz  &zdaz);
    33     void   Set(const RaDec &radec);
     27    virtual void SetMjd(const double mjd);
    3428
    3529    double GetAlpha() const { return fAlpha; }
     30    double GetMjd() const   { return fMjd; }
    3631
    3732    double GetPhi() const   { return fPhi; }
    3833    double GetElong() const { return fElong; }
    3934
    40     RaDec  CalcRaDec(const AltAz &altaz) const;
    41     RaDec  CalcRaDec(const ZdAz  &altaz) const;
    42 
    43     AltAz  CalcAltAz(const RaDec &radec) const;
    44     ZdAz   CalcZdAz (const RaDec &radec) const;
    45 
     35    ZdAz   XYZ2ZdAz(double coord[3]) const;
    4636};
    4737
  • trunk/MagicSoft/Cosy/catalog/StarCatalog.cc

    r808 r912  
    99#include "slamac.h"
    1010#include "File.h"
    11 #include "timer.h"
    12 
    13 StarCatalog::StarCatalog() : fEntries(0)
     11
     12StarCatalog::StarCatalog() : SlaStars(), fEntries(0)
    1413{
    1514    // p = pointer to MainFrame (not owner)
     
    6867    cout << "  Az: " << fAltAz.Az() << endl;
    6968
    70     fRaDec = sla.CalcRaDec(fAltAz);
     69    fRaDec = CalcRaDec(fAltAz);
    7170
    7271    cout << "Ra: " << 360.0/D2PI*fRaDec.Ra();
     
    8281    fRaDec *= D2PI/360.0;
    8382
    84     fAltAz = sla.CalcAltAz(fRaDec);
     83    fAltAz = CalcAltAz(fRaDec);
    8584
    8685    cout << "Alt: " << 360.0/D2PI*fAltAz.Alt() << "  ";
     
    215214    double de0, de1;
    216215
    217     const double phi   = sla.GetPhi();
    218     const double alpha = sla.GetAlpha();
     216    const double phi   = GetPhi();
     217    const double alpha = GetAlpha();
    219218    //
    220219    // scan horizontal border
     
    401400    memset(cimg, 0, 768*576);
    402401
    403     sla.Set(utc);
     402    SetMjd(utc);
    404403    //fAlpha = sla.GetAlpha();
    405404    SetRaDec(radec);
     
    419418    memset(cimg, 0, 768*576);
    420419
    421     sla.Set(utc);
     420    SetMjd(utc);
    422421    //fAlpha = sla.GetAlpha();
    423422    SetAltAz(altaz);
     
    496495    // ---- mean to observed ---
    497496    //
    498     AltAz altaz=sla.CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
     497    AltAz altaz=CalcAltAz(sao->GetRaDec()) * 360.0/D2PI;
    499498
    500499    if (sao->MagV() > fLimitMag)
     
    520519    // radec[rad] -> hadec[rad]
    521520    //
    522     const double ha = sla.GetAlpha()-ra;
     521    const double ha = GetAlpha()-ra;
    523522
    524523    //
     
    526525    //
    527526    double alt, az;
    528     slaDe2h(ha, dec, sla.GetPhi(), &az, &alt);
     527    slaDe2h(ha, dec, GetPhi(), &az, &alt);
    529528
    530529    //
  • trunk/MagicSoft/Cosy/catalog/StarCatalog.h

    r808 r912  
    88#include "SaoFile.h"
    99#endif
    10 #ifndef SLALIB_H
    11 #include "Slalib.h"
     10#ifndef SLASTARS_H
     11#include "SlaStars.h"
    1212#endif
    1313
     
    1616typedef unsigned char byte;
    1717
    18 class StarCatalog
     18class StarCatalog : public SlaStars
    1919{
    2020private:
     
    2222    sort_t  *fSrt;
    2323    int      fEntries;
    24 
    25     Slalib   sla;
    26 
    27 //    double   fPhi;      // location of observatory
    28 //    double   fElong;
    2924
    3025    double   fPixSize;  // [rad/pix] size of one pixel
     
    4641    int      fDecMax;
    4742
    48 //    double   fAlpha;
    49 //    double   fMjd;
    50 //    double   fAmprms[21];
    51 //    double   fAoprms[14];
    52 
    5343    void DrawCross(byte *img, const int x, const int y);
    5444    void DrawCircle(int color, byte *img, int xx, int yy, int size);
     
    6555    void   SetRaDec(const RaDec &radec);
    6656    void   SetAltAz(const AltAz &altaz);
    67 //    void   SetMjd(const double mjd);
    6857    void   DrawSCAltAz(byte *img, const int color);
    6958    void   DrawSCRaDec(byte *img, const int color);
  • trunk/MagicSoft/Cosy/cosy.cc

    r909 r912  
    1111int main(int argc, char **argv)
    1212{
     13    cout << endl;
     14    cout << "Starting..." << endl;
     15    cout << endl;
     16
    1317    //
    1418    // this must move to MGCosy !!!! (or MApplication)
  • trunk/MagicSoft/Cosy/devdrv/macs.cc

    r910 r912  
    419419double Macs::GetTime()
    420420{
    421     return fPosTime.GetTime();
     421    return fPosTime.Now();
    422422}
    423423
    424424double Macs::GetMjd()
    425425{
    426     return fPosTime.GetMjd();
     426    return fPosTime.CalcMjd();
    427427}
    428428
    429429double Macs::GetPdoTime()
    430430{
    431     return fPdoTime.GetTime();
     431    return fPdoTime.Now();
    432432}
    433433
    434434double Macs::GetPdoMjd()
    435435{
    436     return fPdoTime.GetMjd();
     436    return fPdoTime.CalcMjd();
    437437}
    438438
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc

    r910 r912  
    3232    {
    3333    case 0x1000:
    34         cout << "Model: ";
     34        lout << "- Model: ";
    3535        switch (val&0xffff)
    3636        {
    3737        case 0x0196:
    38             cout << "Shaft Encoder  Type: ";
     38            lout << "Shaft Encoder  Type: ";
    3939            switch ((val>>16)&0xff)
    4040            {
    4141            case 0x01:
    42                 cout << "Singleturn" << endl;
     42                lout << "Singleturn" << endl;
    4343                return;
    4444            case 0x02:
    45                 cout << "Multiturn" << endl;
     45                lout << "Multiturn" << endl;
    4646                return;
    4747            default:
    48                 cout << "?" << endl;
     48                lout << "?" << endl;
    4949                return;
    5050            }
    5151        default:
    52             cout << "???" << endl;
     52            lout << "???" << endl;
    5353            return;
    5454        }
    5555    case 0x100b:
    56         cout << "Node ID: " << dec << val << endl;
     56        lout << "Node ID: " << dec << val << endl;
    5757        return;
    5858
    5959    case 0x6000:
    6060    case 0x6500:
    61         cout << "Counting: " << (val&1   ?"anti-clockwise":"clockwise") << "  ";
    62         cout << "HwTest: " <<   (val&2   ?"on":"off") << "  ";
    63         cout << "Scaling: " <<  (val&4   ?"on":"off") << "  ";
    64         cout << "Modulo: " <<   (val&4096?"on":"off") << endl;
     61        lout << "- Counting: " << (val&1   ?"anti-clockwise":"clockwise") << "  ";
     62        lout << "HwTest: " <<   (val&2   ?"on":"off") << "  ";
     63        lout << "Scaling: " <<  (val&4   ?"on":"off") << "  ";
     64        lout << "Modulo: " <<   (val&4096?"on":"off") << endl;
    6565
    6666    case 0x6001:
    67         cout << "Logical Ticks/Turn: " << dec << val << endl;
     67        lout << "- Logical Ticks/Revolution: " << dec << val << endl;
    6868        return;
    6969
    7070    case 0x6004:
    71         cout << "Position: " << dec << val << endl;
     71        lout << "- Position: " << dec << val << endl;
    7272        fPos  = val;
    7373        fTurn = 0;
     
    7676
    7777    case 0x6501:
    78         cout << "Phys. Ticks/Turn: " << dec << val << endl;
     78        lout << "- Phys. Ticks/Revolution: " << dec << val << endl;
    7979        fTicks = val;
    8080        return;
    8181
    8282    case 0x6502:
    83         cout << "Possible Turns: " << dec << val << endl;
     83        lout << "- Possible Turns: " << dec << val << endl;
    8484        fTurns = val ? val : 1; // Single Turn = Multiturn with one turn
    8585        return;
     
    209209double ShaftEncoder::GetTime()
    210210{
    211     return fTime.GetTime();
     211    return fTime.Now();
    212212}
    213213
    214214double ShaftEncoder::GetMjd()
    215215{
    216     return fTime.GetMjd();
     216    return fTime.CalcMjd();
    217217}
    218218
     
    228228    // Requesting and checking (FIXME) type of encoder
    229229    //
    230     lout << "- Requesting SDO 0x1000 of " << (int)GetId() << endl;
     230    lout << "- Requesting Hardware Type (SDO 0x1000) of " << (int)GetId() << endl;
    231231    RequestSDO(0x1000);
    232232    WaitForSdo(0x1000);
    233233
    234234    //
    235     // Read physical ticks per turn
    236     //
    237     lout << "- Requesting SDO 0x6501 of " << (int)GetId() << endl;
     235    // Read physical ticks per revolution
     236    //
     237    lout << "- Requesting physical ticks/revolution (SDO 0x6501) of " << (int)GetId() << endl;
    238238    RequestSDO(0x6501);
    239239    WaitForSdo(0x6501);
    240240
    241241    //
    242     // Read number of possible ticks per turn
    243     //
    244     lout << "- Requesting SDO 0x6502 of " << (int)GetId() << endl;
     242    // Read number of possible ticks per revolution
     243    //
     244    lout << "- Requesting possible ticks/revolution (SDO 0x6502) of " << (int)GetId() << endl;
    245245    RequestSDO(0x6502);
    246246    WaitForSdo(0x6502);
    247247
    248248    //
    249     // Set logic ticks per turn = physical ticks per turn => scale factor = 1
     249    // Set logic ticks/revolution = physical ticks/revolution => scale factor = 1
    250250    //
    251251    lout << "- Configuring SDO 0x6001 of " << (int)GetId() << endl;
  • trunk/MagicSoft/Cosy/gui/MGCosy.cc

    r910 r912  
    1212#include <TApplication.h>  // gApplication
    1313
    14 #include "timer.h"         // Timer
     14//#include "timer.h"         // Timer
    1515
    1616#include "MCosy.h"
    1717#include "MGList.h"
     18#include "MGAccuracy.h"
    1819#include "MGCoordinates.h"
    1920#include "MGSkyPosition.h"
    2021
    21 #include "Slalib.h"
     22#include "SlaStars.h"
    2223
    2324#define IDM_EXIT 1
     
    155156    fList->Add(fCoord);
    156157
    157     fSkyPosition = new MGSkyPosition(this);
     158    fAccuracy = new MGAccuracy(this, 200, 200);
     159    fAccuracy->Move(320, 260);
     160    fList->Add(fAccuracy);
     161
     162    fSkyPosition = new MGSkyPosition(this, 200, 200);
    158163    fSkyPosition->Move(320, 40);
    159     fSkyPosition->Resize(200, 200);
    160164    fList->Add(fSkyPosition);
    161165
     
    163167    //   Map the window, set up the layout, etc.
    164168    //
    165     SetWMSizeHints(550, 250, 550, 250, 10, 10);  // set the smallest and biggest size of the Main frame
     169    SetWMSizeHints(550, 500, 550, 500, 10, 10);  // set the smallest and biggest size of the Main frame
    166170
    167171    MapSubwindows();
     
    190194
    191195    cout << "MGCosy deleted." << endl;
     196}
     197// ======================================================================
     198void MGCosy::Update(ZdAz pos, ZdAz acc)
     199{
     200    fSkyPosition->Update(pos);
     201    fAccuracy->Update(acc);
    192202}
    193203// ======================================================================
     
    253263            case kPB_CALCALTAZ:
    254264                {
    255                     Timer t;
    256                     t.GetTime();
    257 
    258                     Slalib sla;
    259                     sla.Set(t.GetMjd());
     265                    SlaStars sla;
     266                    sla.SetMjd2Now();
    260267
    261268                    XY xy = fCoord->GetCoordinates();
  • trunk/MagicSoft/Cosy/gui/MGCosy.h

    r910 r912  
    1616#include <iostream.h>
    1717
     18#include "coord.h"
     19
    1820class TGLabel;
    1921class TGPopupMenu;
     
    2729class MGCoordinates;
    2830class MGSkyPosition;
     31class MGAccuracy;
    2932
    3033class MGCosy : public TGMainFrame
     
    4649    MGCoordinates *fCoord;
    4750    MGSkyPosition *fSkyPosition;
     51    MGAccuracy    *fAccuracy;
    4852
    4953    MsgQueue      *fQueue;
     
    6367    TGLabel **GetLabel3() { return fLabel3; }
    6468
    65     MGSkyPosition *GetSkyDisplay() { return fSkyPosition; }
     69    void Update(ZdAz pos, ZdAz acc);
    6670
    6771    Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
  • trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc

    r911 r912  
    88
    99#include <iostream.h>  // cout
    10 #include <TRootEmbeddedCanvas.h>
    11 #include <TGWindow.h>
     10
    1211#include <TArc.h>
     12#include <TLine.h>
     13#include <TList.h>
    1314#include <TCanvas.h>
    14 #include <TH1.h>
    15 #include <TLine.h>
    1615
    1716#include "coord.h"
    18 
    19 MGSkyPosition::MGSkyPosition(const TGWindow* p)
    20 : TRootEmbeddedCanvas("SkyPosition", p, 50, 50, kSunkenFrame)//, 0) //234, 76, kFixedSize)
     17#include "SlaPlanets.h"
     18
     19void MGSkyPosition::InitPlanets()
     20{
     21    //
     22    // Magnitudes:
     23    // -----------
     24    //   Moon     -12.8
     25    //   Jupiter   -4.6
     26    //   Venus     -4.0
     27    //   Mars      -2.0
     28    //   Merkur     0.0
     29    //   Saturn     0.7
     30    //   Uranus     5.5
     31    //   Neptun     7.8
     32    //
     33    fSlalib = new SlaPlanets;
     34
     35    //
     36    // Colors: black .. white:
     37    //
     38    //   1, 12, 13, 14, 15, 16, 17, 18, 19, 10
     39    //
     40    fMars = new TArc(0, 0, 1);
     41    fMars->SetFillStyle(1001);     // solid      (s. TAttFill)
     42    fMars->SetFillColor(13);       // light grey (s. TAttFill)
     43    fMars->SetLineColor(12);
     44    fMars->Draw();
     45
     46    fVenus = new TArc(0, 0, 2);
     47    fVenus->SetFillStyle(1001);    // solid      (s. TAttFill)
     48    fVenus->SetFillColor(15);      // light grey (s. TAttFill)
     49    fVenus->SetLineColor(14);
     50    fVenus->Draw();
     51
     52    fJupiter = new TArc(0, 0, 2);
     53    fJupiter->SetFillStyle(1001);  // solid      (s. TAttFill)
     54    fJupiter->SetFillColor(17);    // light grey (s. TAttFill)
     55    fJupiter->SetLineColor(16);
     56    fJupiter->Draw();
     57
     58    fMoon = new TArc(0, 0, 3, 290, 70);
     59    fMoon->SetFillStyle(1001);     // solid      (s. TAttFill)
     60    fMoon->SetFillColor(19);       // light grey (s. TAttFill)
     61    fMoon->SetLineColor(15);
     62    fMoon->Draw();
     63
     64    for (int i=0; i<4; i++)
     65    {
     66        fSunL[i] = new TLine(0,0,0,0);
     67        fSunL[i]->SetLineColor(10);    // white gray
     68        fSunL[i]->SetLineStyle(1);     // solid  (s. TAttLine)
     69        fSunL[i]->Draw();
     70
     71        fList->Add(fSunL[i]);
     72    }
     73
     74    fSun = new TArc(0, 0, 2);
     75    fSun->SetFillStyle(1001);     // solid      (s. TAttFill)
     76    fSun->SetFillColor(10);       // white      (s. TAttFill)
     77    fSun->SetLineColor(19);
     78    fSun->Draw();
     79
     80    fList->Add(fMars);
     81    fList->Add(fVenus);
     82    fList->Add(fJupiter);
     83    fList->Add(fMoon);
     84    fList->Add(fSun);
     85
     86    //
     87    // Reset 'static' positions of planets
     88    //
     89    for (int i=0; i<9; i++)
     90    {
     91        fX[i] = ~0;
     92        fY[i] = ~0;
     93    }
     94}
     95
     96void MGSkyPosition::DrawCoordinateSystem()
     97{
     98    TArc arc;
     99    arc.SetFillStyle(4000);  // transparent
     100    arc.SetLineColor(13);    // dark gray
     101    arc.SetLineStyle(1);     // solid  (s. TAttLine)
     102    arc.DrawArc(0, 0, 90);
     103    arc.DrawArc(0, 0, 67.5);
     104    arc.DrawArc(0, 0, 45);
     105    arc.DrawArc(0, 0, 22.5);
     106
     107    TLine line;
     108    line.SetLineColor(1);  // black
     109    line.SetLineStyle(1);  // solid  (s. TAttLine)
     110    line.DrawLine(-95,   0, 95,  0);
     111    line.DrawLine(  0, -95,  0, 95);
     112}
     113
     114void MGSkyPosition::InitPosition()
     115{
     116    fLin1a = new TLine(0, 0, 0, 0);
     117    fLin1b = new TLine(0, 0, 0, 0);
     118    fLin2  = new TLine(0, 0, 0, 0);
     119
     120    fLin1a->SetLineColor(5);  // yellow (s. TAttFill)
     121    fLin1b->SetLineColor(5);  // yellow
     122    fLin2 ->SetLineColor(10); // white
     123    fLin1a->SetLineStyle(1);  // solid  (s. TAttLine)
     124    fLin1b->SetLineStyle(2);  // dashed
     125
     126    fLin1a->Draw();
     127    fLin1b->Draw();
     128    fLin2->Draw();
     129
     130    fList->Add(fLin1a);
     131    fList->Add(fLin1b);
     132    fList->Add(fLin2);
     133}
     134
     135MGSkyPosition::MGSkyPosition(const TGWindow* p, const Int_t w, const Int_t h)
     136    : TRootEmbeddedCanvas("SkyPosition", p, w-1, h-1, kRaisedFrame),//, 0) //234, 76, kFixedSize)
     137    fModified(kFALSE)
    21138{
    22139    fCanvas = GetCanvas();
    23140
     141    fCanvas->SetFillColor(39); // s. TAttFill
    24142    fCanvas->Range(-100, -100, 100, 100);
    25143
    26     fArc = new TArc;
    27     fArc->SetLineColor(15);
    28     fArc->DrawArc(0, 0, 90);
    29     fArc->DrawArc(0, 0, 67.5);
    30     fArc->DrawArc(0, 0, 45);
    31     fArc->DrawArc(0, 0, 22.5);
    32 
    33     fLin1 = new TLine;
    34     fLin1->DrawLine(-95,   0, 95,  0);
    35     fLin1->DrawLine(  0, -95,  0, 95);
    36     fLin2 = new TLine;
    37 
    38     //    fCanvas->Modified();
    39     //    fCanvas->Update();
    40 
     144    fList = new TList;
     145    fList->SetOwner();
     146
     147    DrawCoordinateSystem();
     148    InitPosition();
     149    InitPlanets();
     150
     151    Resize(w, h); //GetDefaultSize()); // ???
    41152    MapSubwindows();
    42     //    MapWindow();
    43 
    44     //    DrawPosition(66, 25);
    45     //    DrawPosition(22, 278);
    46153}
    47154
    48155MGSkyPosition::~MGSkyPosition()
    49156{
    50     delete fLin1;
    51     delete fLin2;
    52     delete fArc;
     157    delete fList;
     158    delete fSlalib;
    53159
    54160    cout << "MGSkyPosition destroyed." << endl;
     161}
     162
     163void MGSkyPosition::SetLin1(int x, int y)
     164{
     165    fLin1a->SetX2(x);
     166    fLin1a->SetY2(y);
     167    fLin1b->SetX2(-x);
     168    fLin1b->SetY2(-y);
     169}
     170
     171void MGSkyPosition::SetLin2(int x1, int y1, int x2, int y2)
     172{
     173    fLin2->SetX1(x1);
     174    fLin2->SetX2(x2);
     175    fLin2->SetY1(y1);
     176    fLin2->SetY2(y2);
    55177}
    56178
     
    71193        return;
    72194
    73     const int dx = (int)(s*6);
    74     const int dy = (int)(c*6);
    75 
    76     delete fArc;
    77     fArc = new TArc(x, y, 2);
    78     fArc->SetFillStyle(1001);
    79     fArc->SetFillColor(43);
    80     fArc->Draw();
    81 
    82     delete fLin1;
    83     delete fLin2;
    84     //fLin1 = new TLine(x-dx, y-dy, x+dx, y+dy);
    85     fLin1 = new TLine(0, 0, s*95, c*95);
    86     fLin2 = new TLine(x+dy, y-dx, x-dy, y+dx);
    87     fLin1->Draw();
    88     fLin2->Draw();
    89 
     195    X = x;
     196    Y = y;
     197
     198    const int dx = (int)(s*4);
     199    const int dy = (int)(c*4);
     200
     201    SetLin1(s*95, c*95);
     202    SetLin2(x+dy, y-dx, x-dy, y+dx);
     203
     204    fModified = kTRUE;
     205}
     206
     207void MGSkyPosition::Update(ZdAz &pos)
     208{
     209    //
     210    // calculate actual time for planet positions
     211    //
     212    fSlalib->SetMjd2Now();
     213
     214    DrawPlanet(kESun,     fSun);
     215    DrawPlanet(kEMoon,    fMoon);
     216    DrawPlanet(kEJupiter, fJupiter);
     217    DrawPlanet(kEVenus,   fVenus);
     218    DrawPlanet(kEMars,    fMars);
     219
     220    DrawPosition(pos.Zd(), pos.Az());
     221
     222    if (!fModified)
     223        return;
     224
     225    // FIXME: Sometimes (if the canvas couldn't be created correctly:
     226    // X11 Pixmap error) Update hangs the Gui system.
     227
     228    fCanvas->Modified();
    90229    fCanvas->Update();
    91 }
    92 
    93 void MGSkyPosition::DrawPosition(ZdAz &pos)
    94 {
    95     DrawPosition(pos.Zd(), pos.Az());
    96 }
     230
     231    fModified = kFALSE;
     232}
     233
     234void MGSkyPosition::DrawPlanet(Int_t planet, TArc *arc)
     235{
     236    //
     237    // calculate actual position of planet
     238    //
     239    fSlalib->UpdatePlanetPos((ePlanets_t)planet);
     240
     241    ZdAz zdaz = fSlalib->GetPlanetPos((ePlanets_t)planet);
     242
     243    //
     244    // check whether we have to change the position where it is drawn
     245    //
     246    const float s = sin(zdaz.Az());
     247    const float c = cos(zdaz.Az());
     248
     249    const float deg = 360.0/D2PI*zdaz.Zd();
     250
     251    const int x = (int)(s*deg);
     252    const int y = (int)(c*deg);
     253
     254    if (fX[planet]==x && fY[planet]==y)
     255        return;
     256
     257    fX[planet] = x;
     258    fY[planet] = y;
     259
     260    //
     261    // Set new position
     262    //
     263    arc->SetX1(x);
     264    arc->SetY1(y);
     265
     266    fModified = kTRUE;
     267
     268    if (planet!=kESun)
     269        return;
     270
     271    cout << "Sun: x=" << x << " y=" << y;
     272    cout << "   Zd=" << deg << " Az=" << 360./D2PI*zdaz.Az() << endl;
     273
     274    fSunL[0]->SetX1(x-4); fSunL[0]->SetX2(x+4);
     275    fSunL[1]->SetX1(x-3); fSunL[1]->SetX2(x+3);
     276    fSunL[2]->SetX1(x-3); fSunL[2]->SetX2(x+3);
     277    fSunL[3]->SetX1(x  ); fSunL[3]->SetX2(x  );
     278
     279    fSunL[0]->SetY1(y  ); fSunL[0]->SetY2(y  );
     280    fSunL[1]->SetY1(y-3); fSunL[1]->SetY2(y+3);
     281    fSunL[2]->SetY1(y+3); fSunL[2]->SetY2(y-3);
     282    fSunL[3]->SetY1(y-4); fSunL[3]->SetY2(y+4);
     283}
  • trunk/MagicSoft/Cosy/gui/MGSkyPosition.h

    r911 r912  
    1313#endif
    1414
     15class TArc;
     16class TList;
     17class TLine;
    1518class TCanvas;
    16 class TArc;
    17 class TLine;
     19
    1820class ZdAz;
     21class SlaPlanets;
    1922
    2023class MGSkyPosition : public TRootEmbeddedCanvas
    2124{
    22     TCanvas *fCanvas;
     25    TCanvas    *fCanvas;
    2326
    24     TArc    *fArc;
    25     TLine   *fLin1;
    26     TLine   *fLin2;
     27    TArc       *fMoon;
     28    TArc       *fJupiter;
     29    TArc       *fVenus;
     30    TArc       *fMars;
     31    TArc       *fSun;
     32
     33    TLine      *fLin1a;
     34    TLine      *fLin1b;
     35    TLine      *fLin2;
     36
     37    TLine      *fSunL[4];
     38
     39    SlaPlanets *fSlalib;
     40
     41    TList      *fList;
     42
     43    Int_t fX[9];
     44    Int_t fY[9];
     45
     46    Bool_t fModified;
     47
     48    void InitPlanets();
     49    void InitPosition();
     50
     51    void SetLin1(int x, int y);
     52    void SetLin2(int x1, int y1, int x2, int y2);
     53
     54    void DrawPlanet(Int_t planet, TArc *arc);
     55    void DrawPosition(Float_t zd, Float_t az);
     56    void DrawCoordinateSystem();
     57
     58    Bool_t CheckRange(Int_t x, Int_t y) const
     59    {
     60        return x>-95 && x<95 && y>-95 && y<95;
     61    }
    2762
    2863public:
    29     MGSkyPosition(const TGWindow* p);
     64    MGSkyPosition(const TGWindow* p, const Int_t w, const Int_t h);
    3065    ~MGSkyPosition();
    3166
    32     void DrawPosition(Float_t zd, Float_t az);
    33     void DrawPosition(ZdAz &pos);
     67    void Update(ZdAz &pos);
    3468};
    3569
  • trunk/MagicSoft/Cosy/gui/Makefile

    r910 r912  
    3535           MGCosy.cc \
    3636           MGImage.cc \
     37           MGAccuracy.cc \
    3738           MGSkyPosition.cc
    3839
  • trunk/MagicSoft/slalib/Makefile

    r911 r912  
    3232
    3333SRCFILES = \
    34         daf2r.c  gmst.c   mappa.c aoppa.c  oapqk.c ampqk.c mapqkz.c \
    35         dr2af.c  dcs2c.c  dimxv.c dvdv.c   dvn.c   dcc2s.c dranrm.c \
    36         geoc.c   refco.c  eqeqx.c aoppat.c dd2tf.c epj.c   prenut.c \
    37         nutc.c   dmxv.c   refro.c prec.c   nut.c   dmxm.c  evp.c \
    38         drange.c deuler.c cldj.c  aopqk.c  refz.c  dh2e.c  de2h.c
     34        daf2r.c  gmst.c   mappa.c  aoppa.c  oapqk.c ampqk.c mapqkz.c \
     35        dr2af.c  dcs2c.c  dimxv.c  dvdv.c   dvn.c   dcc2s.c dranrm.c \
     36        geoc.c   refco.c  eqeqx.c  aoppat.c dd2tf.c epj.c   prenut.c \
     37        nutc.c   dmxv.c   refro.c  prec.c   nut.c   dmxm.c  evp.c    \
     38        drange.c deuler.c cldj.c   aopqk.c  refz.c  dh2e.c  de2h.c   \
     39        dt.c     dmoon.c  planet.c planel.c el2ue.c ue2pv.c pv2ue.c
    3940#       addet.c
    4041#        afin.c airmas.c altaz.c amp.c \
Note: See TracChangeset for help on using the changeset viewer.