Changeset 8814


Ignore:
Timestamp:
01/16/08 14:26:10 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/gui/MGCoordinate.cc

    r8376 r8814  
    3333{
    3434    fList = new MGList;
     35    fList->SetOwner();
    3536
    3637    const Int_t offset = TString(txt).IsNull() ? 23 : 0;
     
    9192    }
    9293
    93     TGLabel *label;
     94    TGLabel *label=0;
    9495
    9596    const char *sdeg = type==kETypeDeg ? "\xb0" : "h";
  • trunk/MagicSoft/Cosy/gui/MGPngReader.cc

    r4076 r8814  
    193193{
    194194    fList = new MGList;
     195    fList->SetOwner();
    195196
    196197    const TGWindow *p=gClient->GetRoot();
  • trunk/MagicSoft/Cosy/main/MPointing.cc

    r8376 r8814  
    1 #include "MPointing.h"
     1#include "MSlewing.h"
    22
    33#include "MCosy.h"
     
    55#include "MDriveCom.h"
    66
    7 ClassImp(MPointing);
     7#include "MPointing.h"
     8
     9ClassImp(MSlewing);
    810
    911using namespace std;
     
    2224//  target position at the same time.
    2325//
    24 void MPointing::SetPosVelocity(const Float_t ratio, Float_t vel)
     26void MSlewing::SetPosVelocity(const Float_t ratio, Float_t vel)
    2527{
    2628    //
     
    5153// if Axis 2==kTRUE. The function waits for the movement to be finished.
    5254//
    53 void MPointing::DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2)
     55void MSlewing::DoRelPos(const ZdAz &rd, const Bool_t axe1, const Bool_t axe2)
    5456{
    5557    if (fCosy->HasZombie())
     
    7274}
    7375
    74 bool MPointing::SetAccDec(Macs *mac, Float_t acc, Float_t dec)
     76bool MSlewing::SetAccDec(Macs *mac, Float_t acc, Float_t dec)
    7577{
    7678    const int vr = mac->GetVelRes();
     
    8082}
    8183
    82 bool MPointing::Break()
     84bool MSlewing::Break()
    8385{
    8486    return fCosy->Break() || fCosy->HasError() || fCosy->HasZombie();
     
    9698// As a reference the shaftencoder values are used.
    9799//
    98 int MPointing::SetPosition(const ZdAz &dst, Bool_t track) // [rad]
     100int MSlewing::SetPosition(const ZdAz &dst, Bool_t track) // [rad]
    99101{
    100102    const ZdAz d = dst*kRad2Deg;
    101103
    102104    MTime t(-1);
    103     lout << t << " - Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl;
     105    gLog << t << " - Target Position: " << d.Zd() << "deg, " << d.Az() << "deg (Zd/Az)" << endl;
    104106
    105107    //
     
    148150    {
    149151
    150         lout << "- Step #" << i << endl;
     152        gLog << "- Step #" << i << endl;
    151153
    152154        // Get Shaft Encoder Positions
     
    171173        {
    172174            t.Now();
    173             lout << t << " - Positioning done in " << i << (i==1?" step.":" steps.") << endl;
     175            gLog << t << " - Positioning done in " << i << (i==1?" step.":" steps.") << endl;
    174176            fCosy->SetStatus(MDriveCom::kStopped);
    175177            fCosy->fCom->SendStatus("Target position reached.");
     
    206208            const Double_t y = 15*fCosy->kGearTot.Y()/fCosy->kResSE.Y();
    207209
    208 //          lout << "MPointing::SetPosition y: " << y << " rd.Az(): " << rd.Az() << endl;
    209 //          lout << "MPointing::SetPosition fCosy->kGearTot.Y(): " << fCosy->kGearTot.Y() << " fCosy->kResSE.Y(): " << fCosy->kResSE.Y() << endl;
     210//          lout << "MSlewing::SetPosition y: " << y << " rd.Az(): " << rd.Az() << endl;
     211//          lout << "MSlewing::SetPosition fCosy->kGearTot.Y(): " << fCosy->kGearTot.Y() << " fCosy->kResSE.Y(): " << fCosy->kResSE.Y() << endl;
    210212
    211213            if (rd.Az()>-y && rd.Az()<y)
     
    217219              {
    218220
    219                 //lout << "MPointing::SetPosition SetAccDec Mac1: " << fAcc << fDec << endl;
     221                //lout << "MSlewing::SetPosition SetAccDec Mac1: " << fAcc << fDec << endl;
    220222               
    221223                SetAccDec(fCosy->fMac1, fAcc, fDec);
     
    243245
    244246        // repositioning (relative)
    245         lout << "- Do Relative Positioning..." << endl;
     247        gLog << "- Do Relative Positioning..." << endl;
    246248        DoRelPos(rd, cdzd, cdaz);
    247         lout << "- Relative Positioning Done" << endl;
     249        gLog << "- Relative Positioning Done" << endl;
    248250    }
    249251    if (i==1 && track && !Break()/*(fCosy->Break() || fCosy->HasError() || fCosy->HasZombie())*/)
    250252    {
    251253        t.Now();
    252         lout << t << " - Positioning done." << endl;
     254        gLog << t << " - Positioning done." << endl;
    253255        fCosy->SetStatus(MDriveCom::kStopped);
    254256        fCosy->fCom->SendStatus("Tracking preposition reached.");
     
    262264
    263265    t.Now();
    264     lout << t << " - Warning: Requested position not reached (i=" << dec << i << ")" << endl;
     266    gLog << t << " - Warning: Requested position not reached (i=" << dec << i << ")" << endl;
    265267
    266268    fCosy->fCom->SendStatus("Target position missed!");
  • trunk/MagicSoft/Cosy/main/MPointing.h

    r3935 r8814  
    1 #ifndef COSY_MPointing
    2 #define COSY_MPointing
     1#ifndef COSY_MSlewing
     2#define COSY_MSlewing
    33
    4 #include "coord.h"
    5 #include "log.h"
    6 
    7 #ifndef ROOT_TObject
    8 #include <TObject.h>
     4#ifndef MARS_MLog
     5#include "MLog.h"
    96#endif
    107
    118class Macs;
    129class MCosy;
     10class ZdAz;
    1311
    14 class MPointing : public Log, public TObject
     12class MSlewing : public MLog
    1513{
    1614protected:
     
    2927
    3028public:
    31     MPointing(MCosy *cosy, const Log &log) : Log(log), fCosy(cosy), fVel(0.1), fAcc(0.2), fDec(0.1) { }
     29    MSlewing(MCosy *cosy) : fCosy(cosy), fVel(0.1), fAcc(0.2), fDec(0.1) { }
    3230
    3331    void SetPointAccDec(Float_t acc, Float_t dec) { fAcc = acc; fDec = dec; }
    3432    void SetPointVelocity(Float_t vel) { fVel = vel; }
    3533    int  SetPosition(const ZdAz &dst, Bool_t track=kFALSE);
    36  
    37     ClassDef(MPointing, 0)
     34
     35    ClassDef(MSlewing, 0)
    3836};
    3937
  • trunk/MagicSoft/Cosy/main/MTracking.cc

    r8377 r8814  
    5252    //
    5353    if (fCosy->HasError())
    54         lout << "Error while requesting re pos from Macs (SDO #6004)" << endl;
     54        gLog << "Error while requesting re pos from Macs (SDO #6004)" << endl;
    5555
    5656    return false;
     
    9393    //
    9494    if (fCosy->HasError())
    95         lout << "Error while setting tracking velocity (SDO #3006)" << endl;
     95        gLog << "Error while setting tracking velocity (SDO #3006)" << endl;
    9696
    9797    return kFALSE;
     
    223223    {
    224224        vt->Az(maxtrack*vraz*4*sgn(vcalc.Az()));
    225         lout << "Warning: Azimuth speed limit (" << maxtrack*100 << "%) exceeded (" << fabs(vt->Az()) << " > " << maxtrack*vraz << ")... limited." << endl;
    226         lout << "Vcalc: " << vcalc.Zd() << " " << vcalc.Az() << "re/min" <<endl;
     225        gLog << "Warning: Azimuth speed limit (" << maxtrack*100 << "%) exceeded (" << fabs(vt->Az()) << " > " << maxtrack*vraz << ")... limited." << endl;
     226        gLog << "Vcalc: " << vcalc.Zd() << " " << vcalc.Az() << "re/min" <<endl;
    227227        rc=kTRUE;
    228228    }
     
    230230    {
    231231        vt->Zd(maxtrack*vrzd*4*sgn(vcalc.Zd()));
    232         lout << "Warning: Altitude speed limit (" << maxtrack*100 << "%) exceeded (" << fabs(vt->Zd()) <<" > " << maxtrack*vrzd << ")... limited." << endl;
    233         lout << "Vcalc: " << vcalc.Zd() << " " << vcalc.Az() << "re/min" <<endl;
     232        gLog << "Warning: Altitude speed limit (" << maxtrack*100 << "%) exceeded (" << fabs(vt->Zd()) <<" > " << maxtrack*vrzd << ")... limited." << endl;
     233        gLog << "Vcalc: " << vcalc.Zd() << " " << vcalc.Az() << "re/min" <<endl;
    234234        rc=kTRUE;
    235235    }
     
    329329    ZdAz dest = sla.CalcZdAz(dst);
    330330
    331     lout << sla.GetTime() << ": Track Position " << dst.Ra()*kRad2Deg/15 << "h, " << dst.Dec()*kRad2Deg <<"deg" << endl;
     331    gLog << sla.GetTime() << ": Track Position " << dst.Ra()*kRad2Deg/15 << "h, " << dst.Dec()*kRad2Deg <<"deg" << endl;
    332332
    333333    // If the star is culminating behind the zenith (South) we want to
     
    338338    {
    339339        // align az from -180/180 to 0/360
    340         lout << "Star culminating behind zenith: Adding 360deg to Azimuth " << dest.Az()*kRad2Deg << endl;
     340        gLog << "Star culminating behind zenith: Adding 360deg to Azimuth " << dest.Az()*kRad2Deg << endl;
    341341        dest.Az(dest.Az() + TMath::TwoPi());
    342342    }
     
    347347    if (!SetPosition(dest, kTRUE))
    348348    {
    349         lout << "Error: Cannot start tracking, positioning failed." << endl;
     349        gLog << "Error: Cannot start tracking, positioning failed." << endl;
    350350        return;
    351351    }
     
    369369    fCosy->fRaDec = dst;
    370370
    371     // StartThread
    372     Start();
     371    RunThread();
    373372
    374373    //
     
    387386    // Some output
    388387    XY xy(Rad2Deg(dst.Ra())*24/360, Rad2Deg(dst.Dec()));
    389     lout << sla.GetTime() << " - Start Tracking: Ra=" << xy.X() << "h Dec=";
    390     lout << xy.Y() << "\xb0 @ Zd=" << pos.Zd()*kRad2Deg <<"deg Az=" << pos.Az()*kRad2Deg <<"deg" << endl;
     388    gLog << sla.GetTime() << " - Start Tracking: Ra=" << xy.X() << "h Dec=";
     389    gLog << xy.Y() << "\xb0 @ Zd=" << pos.Zd()*kRad2Deg <<"deg Az=" << pos.Az()*kRad2Deg <<"deg" << endl;
    391390
    392391    //
     
    470469        if (LimitSpeed(&v, sla))
    471470        {
    472             lout << "vt: " << v.Zd() << " " << v.Az() << "re/min" << endl;
    473             lout << "Dest: " << dest.Zd() << " " << dest.Az() << endl;
    474         }             
     471            gLog << "vt: " << v.Zd() << " " << v.Az() << "re/min" << endl;
     472            gLog << "Dest: " << dest.Zd() << " " << dest.Az() << endl;
     473        }
    475474
    476475        //
     
    488487        if (vt.Zd()>.9*fCosy->fMac1->GetVelRes() || vt.Az()>.9*fCosy->fMac2->GetVelRes())
    489488        {
    490             lout << "Error: Tracking speed faster than 90% of possible maximum velocity." << endl;
     489            gLog << "Error: Tracking speed faster than 90% of possible maximum velocity." << endl;
    491490            break;
    492491        }
     
    524523        //
    525524        usleep(1000000); // 1s
    526 // *****FIXME****        cout << "." << flush;
    527525    }
    528526
    529527    sla.Now();
    530528
    531     // StopThread
    532     Stop();
    533 
     529    CancelThread();
     530
     531    // If CancelPoints are used we have to make this a Cleanup!
    534532    fCosy->StopMovement();
    535533
    536     lout << sla.GetTime() << " - Tracking stopped @ Zd=";
    537     lout << fCosy->fZdAzSoll.Zd()*TMath::RadToDeg() <<"deg Az=";
    538     lout << fCosy->fZdAzSoll.Az()*TMath::RadToDeg() <<"deg" << endl;
    539 }
    540 
    541 void *MTracking::Thread()
     534    gLog << sla.GetTime() << " - Tracking stopped @ Zd=";
     535    gLog << fCosy->fZdAzSoll.Zd()*TMath::RadToDeg() <<"deg Az=";
     536    gLog << fCosy->fZdAzSoll.Az()*TMath::RadToDeg() <<"deg" << endl;
     537}
     538
     539Int_t MTracking::Thread()
    542540{
    543541    if (fCosy->fZd1->IsZombieNode() && fCosy->fZd2->IsZombieNode())
    544         return (void*)1;
     542        return 1;
    545543
    546544    if (fCosy->fAz->IsZombieNode())
    547         return (void*)2;
     545        return 2;
    548546
    549547    if (!fCosy->fMac1 || !fCosy->fMac2)
    550         return (void*)3;
    551 
    552     lout << "- Tracking Thread started (" << MTime(-1) << ")" << endl;
     548        return 3;
     549
     550    gLog << "- Tracking Thread started (" << MTime(-1) << ")" << endl;
    553551
    554552    //const XY re2se = fCosy->kGearTot/fCosy->kResSE; //[re/se]
     
    571569    //ZdAz oldse = fCosy->GetSePos();
    572570
    573     while (!HasStopFlag())
     571    while (1)
    574572    {
    575573        // Make changes (eg wind) smoother - attenuation of control function
     
    589587            phca2 = fCosy->fZd2->PosHasChanged();
    590588            phcaz = fCosy->fAz->PosHasChanged();
     589
    591590            usleep(1);
    592         } while (!phca1 && !phca2 && !phcaz && !HasStopFlag());
     591            TThread::CancelPoint();
     592
     593        } while (!phca1 && !phca2 && !phcaz);
    593594
    594595        // Get time from last shaftencoder position change (position: ist)
     
    619620            fCosy->fZdAzSoll.Zd(dummy.Zd());
    620621            soll.Zd(fCosy->fBending(dummy).Zd()); // [rad]
     622
     623            fCosy->fTrackingError.Zd(soll.Zd()-istse.Zd());
     624
     625            TThread::CancelPoint();
    621626        }
    622627        if (phcaz)
     
    626631            fCosy->fZdAzSoll.Az(dummy.Az());
    627632            soll.Az(fCosy->fBending(dummy).Az()); // [rad]
     633
     634            fCosy->fTrackingError.Az(soll.Az()-istse.Az());
     635
     636            TThread::CancelPoint();
    628637        }
    629638
     639
    630640        //fCosy->fZdAzSoll = soll;
    631 
    632         // Calculate the aligned tracking posotion from 'soll'-position
     641/*
     642        // Calculate the aligned tracking position from 'soll'-position
    633643        if (phca1 || phca2)
    634644            fCosy->fTrackingError.Zd(soll.Zd()-istse.Zd());
    635645        if (phcaz)
    636646            fCosy->fTrackingError.Az(soll.Az()-istse.Az());
    637     }
    638 
    639     lout << "- Tracking Thread done. (" << MTime(-1) << ")" << endl;
     647            */
     648    }
     649
     650    gLog << "- Tracking Thread done. (" << MTime(-1) << ")" << endl;
    640651    return 0;
    641652}
  • trunk/MagicSoft/Cosy/main/MTracking.h

    r4105 r8814  
    44#include "coord.h"
    55
    6 #ifndef COSY_MPointing
    7 #include "MPointing.h"
     6#ifndef COSY_MSlewing
     7#include "MSlewing.h"
    88#endif
    99
    10 #ifndef COSY_MThread
     10#ifndef MARS_MThread
    1111#include "MThread.h"
    1212#endif
     
    1414class SlaStars;
    1515
    16 class MTracking : public MPointing, public MThread
     16class MTracking : public MSlewing, public MyThreadX
    1717{
    1818private:
     
    3939    ZdAz GetPointingPosRE(Bool_t pdo=kFALSE) const;
    4040
    41     void *Thread();
     41    Int_t Thread();
    4242
    4343public:
    44     MTracking(MCosy *cosy, const Log &log) : MPointing(cosy, log), MThread(kFALSE), fTrackAcc(0.1), fTrackDec(0.1), fOut(0) { }
     44    MTracking(MCosy *cosy) : MSlewing(cosy), MyThreadX("MTracking"), fTrackAcc(0.1), fTrackDec(0.1), fOut(0) { }
    4545
    4646    void TrackPosition(const RaDec &dst); // ra, dec [rad]
  • trunk/MagicSoft/Cosy/main/MainLinkDef.h

    r4865 r8814  
    55#pragma link off all functions;
    66
    7 #pragma link C++ class MCosy;
     7#pragma link C++ class MCosy+;
    88#pragma link C++ class MStarguider+;
    99#pragma link C++ class MStargHistograms+;
    1010
    11 #pragma link C++ class MBending;
    12 
    13 #pragma link C++ class MPointing;
    14 #pragma link C++ class MTracking;
     11#pragma link C++ class MSlewing+;
     12#pragma link C++ class MTracking+;
    1513
    1614#endif
Note: See TracChangeset for help on using the changeset viewer.