Changeset 6923 for trunk/MagicSoft/Cosy


Ignore:
Timestamp:
04/11/05 10:58:30 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r6867 r6923  
    11                                                                  -*-*- END -*-*-
     2
     3 2005/04/11 - Thomas Bretz
     4
     5   * main/MTracking.cc:
     6     - allow to send velocity and request position twice
     7     - enhanced some debugging output
     8
     9   * candrv/network.[h,cc]:
     10     - implemented PrintError
     11
     12   * candrv/nodedrv.[h,cc]:
     13     - implemented new argument (zombie) to WaitForSdo which allows
     14       to mark a missing CANbus message as non-critical
     15
     16
    217
    318 2005/03/21 - Thomas Bretz
  • trunk/MagicSoft/Cosy/candrv/network.cc

    r2518 r6923  
    278278// --------------------------------------------------------------------------
    279279//
     280// Print all errors which are currently set
     281//
     282void Network::PrintError() const
     283{
     284    for (int i=0; i<32; i++)
     285    {
     286        if (!fNodes[i])
     287            continue;
     288
     289        if (!fNodes[i]->HasError())
     290            continue;
     291
     292        lout << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName() << "' ";
     293
     294        if (fNodes[i]->GetError() <= 0)
     295            lout << "Error occured." << endl;
     296        else
     297            lout << "has error #" << fNodes[i]->GetError() << endl;
     298    }
     299}
     300
     301// --------------------------------------------------------------------------
     302//
    280303// returns true if one of the nodes has the error-flag set (HasError).
    281304//
     
    354377            fNodes[i]->CheckConnection();
    355378}
    356 
  • trunk/MagicSoft/Cosy/candrv/network.h

    r4105 r6923  
    3737    virtual void Stop();
    3838
     39    void PrintError() const;
     40
    3941    bool HasError() const;
    4042    bool HasZombie() const;
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r4105 r6923  
    416416// queue and no waiting is done, false is returned..
    417417//
    418 bool NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORDS_t timeout)
     418bool NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORDS_t timeout, bool zombie)
    419419{
    420420    bool rc = fNetwork->WaitForSdo(fId, idx, subidx, fIsZombie?-1:timeout);
    421 
    422     if (!rc)
    423     {
    424         lout << "NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " " << GetNodeName() << " --> ZOMBIE!" << endl;
     421    if (rc)
     422        return true;
     423
     424    lout << " + " << GetNodeName() << ": NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " --> ZOMBIE! " << MTime() << endl;
     425    if (zombie)
    425426        SetZombie();
    426     }
    427 /*
    428     if (HasError())
    429     {
    430         lout << "NodeDrv::WaitForSdo: HasError 0x" << hex << idx << "/" << dec << (int)subidx << " " << GetNodeName() << " --> ZOMBIE!" << endl;
    431         fIsZombie = kTRUE;
    432     }
    433 */
    434     return fIsZombie ? false : rc;
     427    return false;
    435428}
    436429
  • trunk/MagicSoft/Cosy/candrv/nodedrv.h

    r4105 r6923  
    106106
    107107    // void WaitForSdos();
    108     bool WaitForSdo(WORD_t idx, BYTE_t subidx=0, WORDS_t timeout=500);
     108    bool WaitForSdo(WORD_t idx, BYTE_t subidx=0, WORDS_t timeout=500, bool zombie=true);
    109109
    110110    void EnableCanMsg(BYTE_t fcode);
  • trunk/MagicSoft/Cosy/main/MTracking.cc

    r6823 r6923  
    2222bool MTracking::RequestRePos()
    2323{
    24     //
    25     // Send request
    26     //
    27     fCosy->fMac2->RequestSDO(0x6004);
    28     fCosy->fMac1->RequestSDO(0x6004);
    29 
    30     //
    31     // Wait until the objects are received.
    32     //
    33     fCosy->fMac2->WaitForSdo(0x6004);
    34     fCosy->fMac1->WaitForSdo(0x6004);
    35 
    36     //
    37     // If waiting was not interrupted everything is ok. return.
    38     //
    39     if (!Break())
    40         return true;
     24    for (int i=0; i<2; i++)
     25    {
     26        //
     27        // Send request
     28        //
     29        fCosy->fMac2->RequestSDO(0x6004);
     30        fCosy->fMac1->RequestSDO(0x6004);
     31
     32        //
     33        // Wait until the objects are received.
     34        //
     35        fCosy->fMac2->WaitForSdo(0x6004, 0, 500, i>0);
     36        fCosy->fMac1->WaitForSdo(0x6004, 0, 500, i>0);
     37
     38        //
     39        // If waiting was not interrupted everything is ok. return.
     40        //
     41        if (!Break())
     42            return true;
     43
     44        fCosy->PrintError();
     45    }
    4146
    4247    //
     
    4853
    4954    return false;
     55}
     56
     57// --------------------------------------------------------------------------
     58//
     59// Sets the tracking velocity
     60//
     61// The velocities are given in a ZdAz object in re/min. Return kTRUE
     62// in case of success, kFALSE in case of failure.
     63//
     64Bool_t MTracking::SetVelocity(const ZdAz &v)
     65{
     66    for (int i=0; i<2; i++)
     67    {
     68        //
     69        // Send the new velocities for both axes.
     70        //
     71        fCosy->fMac2->SendSDO(0x3006, 1, (LWORD_t)v.Zd());  // SetRpmVelocity [re/min]
     72        fCosy->fMac1->SendSDO(0x3006, 1, (LWORD_t)v.Az());  // SetRpmVelocity [re/min]
     73
     74        //
     75        // Wait for the objects to be acknoledged.
     76        //
     77        fCosy->fMac2->WaitForSdo(0x3006, 1, 500, i>0);
     78        fCosy->fMac1->WaitForSdo(0x3006, 1, 500, i>0);
     79
     80        //
     81        // If the waiting for the objects wasn't interrupted return kTRUE
     82        //
     83        if (!Break())
     84            return kTRUE;
     85
     86        fCosy->PrintError();
     87    }
     88
     89    //
     90    // print a message if the interruption was due to a Can-node Error
     91    //
     92    if (fCosy->HasError())
     93        lout << "Error while setting tracking velocity (SDO #3006)" << endl;
     94
     95    return kFALSE;
    5096}
    5197
     
    189235}
    190236
    191 // --------------------------------------------------------------------------
    192 //
    193 // Sets the tracking velocity
    194 //
    195 // The velocities are given in a ZdAz object in re/min. Return kTRUE
    196 // in case of success, kFALSE in case of failure.
    197 //
    198 Bool_t MTracking::SetVelocity(const ZdAz &v)
    199 {
    200     //
    201     // Send the new velocities for both axes.
    202     //
    203     fCosy->fMac2->SendSDO(0x3006, 1, (LWORD_t)v.Zd());  // SetRpmVelocity [re/min]
    204     fCosy->fMac1->SendSDO(0x3006, 1, (LWORD_t)v.Az());  // SetRpmVelocity [re/min]
    205 
    206     //
    207     // Wait for the objects to be acknoledged.
    208     //
    209     fCosy->fMac2->WaitForSdo(0x3006, 1);
    210     fCosy->fMac1->WaitForSdo(0x3006, 1);
    211 
    212     //
    213     // If the waiting for the objects wasn't interrupted return kTRUE
    214     //
    215     if (!Break())
    216         return kTRUE;
    217 
    218     //
    219     // print a message if the interruption was due to a Can-node Error
    220     //
    221     if (fCosy->HasError())
    222         lout << "Error while setting tracking velocity (SDO #3006)" << endl;
    223 
    224     return kFALSE;
    225 }
    226 
    227237// --------------------------------------------------------------------
    228238//
     
    237247    const XY re = fCosy->kGearTot/fCosy->kResSE; //[re/se]
    238248
     249    Int_t pzd1 = fCosy->fZd1->GetPos();
     250    Int_t pzd2 = fCosy->fZd2->GetPos();
     251    Int_t paz  = fCosy->fAz->GetPos();
     252
     253    if (fCosy->fZd1->DirHasChanged() != fCosy->fZd2->DirHasChanged())
     254    {
     255        pzd1 -= fCosy->fZd1->GetDirection();
     256        pzd2 -= fCosy->fZd2->GetDirection();
     257    }
     258    else
     259    {
     260        fCosy->fZd1->ResetDirHasChanged();
     261        fCosy->fZd2->ResetDirHasChanged();
     262    }
     263
    239264    // Get current shaftencoder position of the telescope
    240     Double_t seposzd1 = ((fCosy->fZd1->GetPos()+8192)%16384)*re.X();
    241     Double_t seposzd2 = ((fCosy->fZd2->GetPos()+8192)%16384)*re.X();
    242     Double_t seposaz  =   fCosy->fAz->GetPos() *re.Y();
     265    Double_t seposzd1 = ((pzd1+8192)%16384)*re.X();
     266    Double_t seposzd2 = ((pzd2+8192)%16384)*re.X();
     267    Double_t seposaz  =   paz              *re.Y();
    243268
    244269    // distance between (To+dt) and To [re]
     
    503528        return (void*)3;
    504529
    505     lout << "- Tracking Thread started..." << endl;
     530    lout << "- Tracking Thread started (" << MTime() << ")" << endl;
    506531
    507532    //const XY re2se = fCosy->kGearTot/fCosy->kResSE; //[re/se]
     
    590615    }
    591616
    592     lout << "- Tracking Thread done." << endl;
    593 
     617    lout << "- Tracking Thread done. (" << MTIme() << ")" << endl;
    594618    return 0;
    595619}
Note: See TracChangeset for help on using the changeset viewer.