Changeset 1273


Ignore:
Timestamp:
04/11/02 13:20:10 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/base/MThread.cc

    r910 r1273  
    1010// Starts the derived thread if you don't specify false.
    1111//
    12 MThread::MThread(bool start) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL), fPriority(0)
     12MThread::MThread(bool start, int prio) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL)
    1313{
    1414    if (start)
     15    {
     16        SetPriority(prio);
    1517        Start();
     18    }
    1619}
    1720
  • trunk/MagicSoft/Cosy/base/MThread.h

    r1111 r1273  
    2626
    2727public:
    28     MThread(bool start=true);
     28    MThread(bool start=true, int prio=0);
    2929    virtual ~MThread();
    3030
  • trunk/MagicSoft/Cosy/base/coord.h

    r1109 r1273  
    118118    double Dec() const { return fY; }
    119119
     120    void Ra(double x)  { fX = x; }
     121    void Dec(double y) { fY = y; }
     122
    120123    RaDec operator/(double c) const { return RaDec(fX/c, fY/c); }
    121124    RaDec operator*(double c) const { return RaDec(fX*c, fY*c); }
  • trunk/MagicSoft/Cosy/base/msgqueue.cc

    r1266 r1273  
    5757
    5858        fRc=Proc(fMsg, fMp);
     59
     60        if (fMsg==WM_QUIT)
     61            break;
     62
    5963    }
    6064}
  • trunk/MagicSoft/Cosy/base/msgqueue.h

    r1109 r1273  
    55
    66#define WM_NULL 0x0000
     7#define WM_QUIT 0xffff
    78
    89class MsgQueue
  • trunk/MagicSoft/Cosy/candrv/network.cc

    r1266 r1273  
    263263bool Network::HasError() const
    264264{
    265     for (int i=0; i<32; i++)
    266         if (fNodes[i] && fNodes[i]->HasError())
    267             return true;
    268 
    269     return false;
    270 }
     265    bool rc = false;
     266
     267    for (int i=0; i<32; i++)
     268    {
     269        if (!fNodes[i])
     270            continue;
     271
     272        if (!fNodes[i]->HasError())
     273            continue;
     274
     275        rc = true;
     276
     277        if (fNodes[i]->GetError() <= 0)
     278            continue;
     279
     280        lout << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName();
     281        lout << "' has error #" << fNodes[i]->GetError() << endl;
     282    }
     283
     284    return rc;
     285}
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r1266 r1273  
    7474    }
    7575
    76     lout << "- Node #" << nodeid << " (" << name << ") initialized." << endl;
     76    lout << "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl;
    7777}
    7878
  • trunk/MagicSoft/Cosy/candrv/vmodican.cc

    r1266 r1273  
    915915//  and switch the can bus communication on
    916916//
    917 VmodIcan::VmodIcan(const char *dev, const int baud, MLog &out) : Log(out), MThread(false)//: CanDriver(dev, baud)
     917VmodIcan::VmodIcan(const char *dev, const int baud, MLog &out) : Log(out), MThread(false, -10)//: CanDriver(dev, baud)
    918918{
    919919    //
    920920    // Set priority of receiving thread and detach the receiving thread
    921921    //
    922     SetPriority(-10);
    923922    Detach();
    924923
  • trunk/MagicSoft/Cosy/gui/MGCosy.cc

    r1111 r1273  
    169169    fStopped  = new TGLabel(f, "Stopped");
    170170
    171     fError   ->SetBackgroundColor(224); // red
    172     fMoving  ->SetBackgroundColor(10);  // blue
    173     fTracking->SetBackgroundColor(47);  // blue
    174     fStopping->SetBackgroundColor(164); // orange
    175     fStopped ->SetBackgroundColor(20);  // green
     171
     172    ULong_t color;
     173
     174    gClient->GetColorByName("Red", color);
     175    fError->SetBackgroundColor(color);
     176    gClient->GetColorByName("LightBlue", color);
     177    fMoving->SetBackgroundColor(color);
     178    gClient->GetColorByName("Blue", color);
     179    fTracking->SetBackgroundColor(color);
     180    gClient->GetColorByName("Orange", color);
     181    fStopping->SetBackgroundColor(color);
     182    gClient->GetColorByName("Green", color);
     183    fStopped->SetBackgroundColor(color);
    176184
    177185    fError   ->Move(10, 25);
     
    264272    fList->Add(but);
    265273
     274    ULong_t color;
     275
    266276    but = new TGTextButton(this, "Start", kPB_START);
    267     but->SetBackgroundColor(20);
     277    gClient->GetColorByName("Green", color);
     278    but->SetBackgroundColor(color);
    268279    but->Move(147, 275);
    269280    but->Resize(62, 25);
     
    272283
    273284    but = new TGTextButton(this, "Stop",  kPB_STOP);
    274     but->SetBackgroundColor(224);
     285
     286    gClient->GetColorByName("Red", color);
     287    but->SetBackgroundColor(color);
    275288    but->Move(212, 275);
    276289    but->Resize(62, 25);
     
    285298    fList = new MGList;
    286299
     300    cout << "MGCosy: Creating Menu" << endl;
    287301    CreateMenu();
    288302
     303    cout << "MGCosy: Creating TGCompositeFrame" << endl;
    289304    TGCompositeFrame *f = new TGCompositeFrame(this, 0, 0);
    290305    f->SetLayoutManager(new TGMatrixLayout(f, 3, 2, 10));
    291306    fList->Add(f);
    292307
     308    cout << "MGCosy: Creating TGTab" << endl;
    293309    fTab = new TGTab(f, 300, 300);
    294310    fList->Add(fTab);
    295311
     312    cout << "MGCosy: Creating MGSkyPosition" << endl;
    296313    fSkyPosition = new MGSkyPosition(f, 300);
     314    cout << "MGCosy: Creating MGAccuracy" << endl;
    297315    fAccuracy    = new MGAccuracy   (f, 300);
     316    cout << "MGCosy: Creating MGVelocity" << endl;
    298317    fVelocity    = new MGVelocity   (f, "Velocity [\"/min]", 300);
    299318//    fOffset      = new MGVelocity   (f, "Offset se-re [']", 300);
     
    304323//    fList->Add(fOffset);
    305324
     325    cout << "MGCosy: Creating TGGroupFrame" << endl;
    306326    TGGroupFrame *frame = new TGGroupFrame(f, "Status");
    307327    frame->Resize(300, 300);
    308328    fList->Add(frame);
    309329
     330    cout << "MGCosy: Creating TGListBox" << endl;
    310331    fLog = new TGListBox(f, -1, kSunkenFrame);  //kSunkenFrame|kDoubleBorder,
    311332    fLog->Resize(300, 300);
     
    328349    // FIXME!
    329350    //
     351    cout << "MGCosy: Creating Tabs" << endl;
    330352    CreateTabs(fTab);
     353    cout << "MGCosy: Creating Label" << endl;
    331354    CreateLabel(frame);
    332355
     
    334357    //   Map the window, set up the layout, etc.
    335358    //
     359    cout << "MGCosy: Setting Size" << endl;
    336360    const Int_t w = 940;
    337361    const Int_t h = 660;
     
    341365    SetIconName("Cosy");
    342366
     367    cout << "MGCosy: Map Window" << endl;
    343368    MapSubwindows();
    344369    Resize(GetDefaultSize());
  • trunk/MagicSoft/Cosy/gui/MGSkyPosition.cc

    r1111 r1273  
    1616
    1717#include "coord.h"
     18#include "SlaStars.h"
    1819#include "SlaPlanets.h"
    1920
    2021ClassImp(MGSkyPosition);
     22
     23void MGSkyPosition::InitArc(TArc *arc, Int_t fillstyle, Int_t fillcolor, Int_t linecolor)
     24{
     25    arc->SetFillStyle(fillstyle);      // (s. TAttFill)
     26    arc->SetFillColor(fillcolor);      // (s. TAttFill)
     27    arc->SetLineColor(linecolor);
     28    arc->Draw();
     29}
    2130
    2231void MGSkyPosition::InitPlanets()
     
    3443    //   Neptun     7.8
    3544    //
    36     fSlalib = new SlaPlanets;
     45    fSlaPlanet = new SlaPlanets;
     46    fSlaStar   = new SlaStars;
    3747
    3848    //
     
    4151    //   1, 12, 13, 14, 15, 16, 17, 18, 19, 10
    4252    //
    43     fMars = new TArc(0, 0, 1);
    44     fMars->SetFillStyle(1001);     // solid      (s. TAttFill)
    45     fMars->SetFillColor(13);       // light grey (s. TAttFill)
    46     fMars->SetLineColor(12);
    47     fMars->Draw();
    48 
    49     fVenus = new TArc(0, 0, 2);
    50     fVenus->SetFillStyle(1001);    // solid      (s. TAttFill)
    51     fVenus->SetFillColor(15);      // light grey (s. TAttFill)
    52     fVenus->SetLineColor(14);
    53     fVenus->Draw();
    54 
     53    fMars    = new TArc(0, 0, 1);
     54    fVenus   = new TArc(0, 0, 2);
    5555    fJupiter = new TArc(0, 0, 2);
    56     fJupiter->SetFillStyle(1001);  // solid      (s. TAttFill)
    57     fJupiter->SetFillColor(17);    // light grey (s. TAttFill)
    58     fJupiter->SetLineColor(16);
    59     fJupiter->Draw();
    60 
    61     fMoon = new TArc(0, 0, 3, 290, 70);
    62     fMoon->SetFillStyle(1001);     // solid      (s. TAttFill)
    63     fMoon->SetFillColor(19);       // light grey (s. TAttFill)
    64     fMoon->SetLineColor(15);
    65     fMoon->Draw();
     56    fMoon    = new TArc(0, 0, 3, 290, 70);
     57    fSun     = new TArc(0, 0, 2);
     58
     59    InitArc(fMars,    1001, 13, 12);
     60    InitArc(fVenus,   1001, 15, 14);
     61    InitArc(fJupiter, 1001, 17, 16);
     62    InitArc(fMoon,    1001, 19, 15);
     63    InitArc(fSun,     1001, 10, 19);
    6664
    6765    for (int i=0; i<4; i++)
     
    7472        fList->Add(fSunL[i]);
    7573    }
    76 
    77     fSun = new TArc(0, 0, 2);
    78     fSun->SetFillStyle(1001);     // solid      (s. TAttFill)
    79     fSun->SetFillColor(10);       // white      (s. TAttFill)
    80     fSun->SetLineColor(19);
    81     fSun->Draw();
    8274
    8375    fList->Add(fMars);
     
    168160    fList->Add(fLin1b);
    169161    fList->Add(fLin2);
     162
     163    for (int i=0; i<6; i++)
     164    {
     165        fDot[i] = new TArc(0, 0, 1);
     166        InitArc(fDot[i], 1001, 10, 19);
     167        fList->Add(fDot[i]);
     168    }
    170169}
    171170
     
    173172    : MGEmbeddedCanvas("SkyPosition", p, w, 110)
    174173{
     174    cout << "MGSkyPosition: Initilizing." << endl;
    175175    DrawCoordinateSystem();
    176176    InitPlanets();
     
    178178    InitText();
    179179    InitCanvas();
     180    cout << "MGSkyPosition: Initilizing done." << endl;
    180181}
    181182
    182183MGSkyPosition::~MGSkyPosition()
    183184{
    184     delete fSlalib;
     185    delete fSlaPlanet;
     186    delete fSlaStar;
    185187
    186188    cout << "MGSkyPosition destroyed." << endl;
     
    203205}
    204206
    205 void MGSkyPosition::UpdatePosition(Float_t zd, Float_t az)
    206 {
     207void MGSkyPosition::SetDot(TArc *arc, RaDec &radec, Int_t off)
     208{
     209    RaDec rd(radec.Ra()+off*360/24*kDeg2Rad, radec.Dec());
     210    ZdAz zdaz = fSlaStar->CalcZdAz(rd);
     211
     212    const float s = sin(zdaz.Az());
     213    const float c = cos(zdaz.Az());
     214
     215    const float x = s*zdaz.Zd()*kRad2Deg;             // [deg]
     216    const float y = c*zdaz.Zd()*kRad2Deg;             // [deg]
     217
     218    arc->SetX1(x);
     219    arc->SetY1(y);
     220
     221    SetModified();
     222}
     223
     224void MGSkyPosition::UpdatePosition(RaDec &radec, Float_t zd, Float_t az)
     225{
     226    //
     227    // zd [deg]
     228    // az [deg]
     229    //
    207230    static int X =~0;
    208231    static int Y =~0;
     
    210233    static int Ry=~0;
    211234
    212     const float rad = az*kDeg2Rad;
     235    const float rad = az*kDeg2Rad;    // [rad]
    213236
    214237    const float s = sin(rad);
    215238    const float c = cos(rad);
    216239
    217     const float x = s*zd;
    218     const float y = c*zd;
     240    const float x = s*zd;             // [deg]
     241    const float y = c*zd;             // [deg]
    219242
    220243    const int pixx = (int)(x/fPix);
     
    238261    SetLin1(s*95., c*95.);
    239262    SetLin2(x+dy, y-dx, x-dy, y+dx);
     263
     264    if (zd<80)
     265    {
     266        for(int i=0; i<3; i++)
     267            SetDot(fDot[i], radec, i-3);
     268        for(int i=3; i<6; i++)
     269            SetDot(fDot[i], radec, i-2);
     270    }
    240271
    241272    SetModified();
     
    279310    // calculate actual time for planet positions
    280311    //
    281     fSlalib->SetMjd2Now();
     312    fSlaPlanet->SetMjd2Now();
     313    fSlaStar->SetMjd2Now();
    282314
    283315    UpdatePlanet(kESun,     fSun);
     
    287319    UpdatePlanet(kEMars,    fMars);
    288320
    289     UpdatePosition(pos.Zd(), pos.Az());
     321    RaDec radec = fSlaStar->CalcRaDec(pos*kDeg2Rad);
     322
     323    UpdatePosition(radec, pos.Zd(), pos.Az());
    290324    UpdateText(pos.Zd(), pos.Az());
    291325
     
    298332    // calculate actual position of planet
    299333    //
    300     fSlalib->UpdatePlanetPos((ePlanets_t)planet);
    301 
    302     ZdAz zdaz = fSlalib->GetPlanetPos((ePlanets_t)planet);
     334    fSlaPlanet->UpdatePlanetPos((ePlanets_t)planet);
     335
     336    ZdAz zdaz = fSlaPlanet->GetPlanetPos((ePlanets_t)planet);
    303337
    304338    //
  • trunk/MagicSoft/Cosy/gui/MGSkyPosition.h

    r1111 r1273  
    1717
    1818class ZdAz;
     19class RaDec;
    1920class TText;
     21class SlaStars;
    2022class SlaPlanets;
    2123
     
    2830    TArc       *fSun;
    2931
     32    TArc       *fDot[6];
     33
    3034    TLine      *fLin1a;
    3135    TLine      *fLin1b;
     
    3640    TText      *fText;
    3741
    38     SlaPlanets *fSlalib;
     42    SlaStars   *fSlaStar;
     43    SlaPlanets *fSlaPlanet;
    3944
    4045    Int_t fX[9];
    4146    Int_t fY[9];
     47
     48    void InitArc(TArc *arc, Int_t fillstyle, Int_t fillcolor, Int_t linecolor);
    4249
    4350    void InitText();
     
    4956    void SetLin2(Float_t x1, Float_t y1, Float_t x2, Float_t y2);
    5057
     58    void SetDot(TArc *arc, RaDec &radec, Int_t off);
     59
    5160    void UpdateText(Float_t zd, Float_t az);
    5261    void UpdatePlanet(Int_t planet, TArc *arc);
    53     void UpdatePosition(Float_t zd, Float_t az);
     62    void UpdatePosition(RaDec &radec, Float_t zd, Float_t az);
    5463
    5564public:
Note: See TracChangeset for help on using the changeset viewer.