Ignore:
Timestamp:
04/12/02 16:59:23 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/devdrv/macs.cc

    r1140 r1275  
    99
    1010ClassImp(Macs);
     11
     12/*
     13 ---------------------------
     14 For test purposes
     15 ---------------------------
     16
     17class MyTimer : public TTimer
     18{
     19public:
     20    MyTimer(TObject *obj, Long_t ms, Bool_t mode) : TTimer(obj, ms, mode) {}
     21    Bool_t Notify()
     22    {
     23        cout << "Notify" << endl;
     24        TTimer::Notify();
     25        return kTRUE;
     26    }
     27};
     28*/
    1129
    1230Macs::Macs(const BYTE_t nodeid, const char *name, MLog &out)
     
    1533    fPosActive(0), fRpmActive(0)
    1634{
    17     fTimeout = new TTimer(this, 100, kFALSE); // 100ms
     35    fTimeout = new TTimer(this, 100, kFALSE); // 100ms, asynchronous
    1836}
    1937
     
    102120void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx)
    103121{
    104     if (idx==0x4000 && subidx==0 && fTimerOn)
    105     {
    106         ResetTimeout();
    107         return;
     122    switch (idx)
     123    {
     124    case 0x2002:
     125        switch (subidx)
     126        {
     127        case 0:
     128            lout << ddev(MLog::eGui);
     129            lout << "- Velocity set (" << GetNodeName() << ")" << endl;
     130            lout << edev(MLog::eGui);
     131            return;
     132        }
     133        break;
     134    case 0x2003:
     135        switch (subidx)
     136        {
     137        case 0:
     138            lout << ddev(MLog::eGui);
     139            lout << "- Acceleration set (" << GetNodeName() << ")" << endl;
     140            lout << edev(MLog::eGui);
     141            return;
     142        case 1:
     143            lout << ddev(MLog::eGui);
     144            lout << "- Deceleration set (" << GetNodeName() << ")" << endl;
     145            lout << edev(MLog::eGui);
     146            return;
     147        }
     148        break;
     149    case 0x3006:
     150        switch (subidx)
     151        {
     152        case 0:
     153            lout << ddev(MLog::eGui);
     154            lout << "- RPM mode switched (" << GetNodeName() << ")" << endl;
     155            lout << edev(MLog::eGui);
     156            return;
     157
     158        case 1:
     159            /*
     160             lout << ddev(MLog::eGui);
     161             lout << "- Velocity set (" << GetNodeName() << ")" << endl;
     162             lout << edev(MLog::eGui);
     163             */
     164            return;
     165        }
     166        break;
     167    case 0x4000:
     168        if (subidx==0 && fTimerOn)
     169        {
     170            ResetTimeout();
     171            return;
     172        }
     173        break;
     174    case 0x6004:
     175        switch (subidx)
     176        {
     177        case 0:
     178            lout << ddev(MLog::eGui);
     179            lout << "- Relative positioning started (" << GetNodeName() << ")" << endl;
     180            lout << edev(MLog::eGui);
     181            return;
     182
     183        case 1:
     184            lout << ddev(MLog::eGui);
     185            lout << "- Absolute positioning started (" << GetNodeName() << ")" << endl;
     186            lout << edev(MLog::eGui);
     187            return;
     188        }
     189        break;
     190
     191
    108192    }
    109193    NodeDrv::HandleSDOOK(idx, subidx);
     
    348432    if (!errnum)
    349433    {
    350         cout << "Mac " << GetNodeName() << " reports Error occursion." << endl;
     434        lout << "Mac " << GetNodeName() << " reports Error occursion." << endl;
    351435        SetError(-1);
    352436        return;
     
    358442    //
    359443    if (GetError()>0)
    360         cout << "Mac " << GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
     444        lout << GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
    361445
    362446    SetError(errnum);
    363447
    364     cout << "Mac " << GetNodeName() << " reports: ";
     448    lout << GetNodeName() << " reports: ";
    365449    switch (errnum)
    366450    {
    367451    case 6:
    368         cout << "Home position not the first positioning command." << endl;
     452        lout << "Home position not the first positioning command." << endl;
    369453        return;
    370454
    371455    case 8:
    372         cout << "Control deviation overflow." << endl;
     456        lout << "Control deviation overflow." << endl;
    373457        return;
    374458
    375459    case 9:
    376         cout << "Zero index not found." << endl;
     460        lout << "Zero index not found." << endl;
    377461        return;
    378462
     
    382466        {
    383467        case -1:
    384             cout << "Negative";
     468            lout << "Negative";
    385469            break;
    386470        case 1:
    387             cout << "Positive";
     471            lout << "Positive";
    388472            break;
    389473        default:
    390             cout << "-unknown-";
     474            lout << "-unknown-";
    391475        }
    392476        switch (errnum)
    393477        {
    394478        case 11:
    395             cout << " software endswitch activated." << endl;
     479            lout << " software endswitch activated." << endl;
    396480            break;
    397481        case 25:
    398             cout << " hardware endswitch activated." << endl;
     482            lout << " hardware endswitch activated." << endl;
    399483            break;
    400484        }
     
    402486
    403487    case 84:
    404         cout << "Too many (>12) ON TIME calls." << endl;
     488        lout << "Too many (>12) ON TIME calls." << endl;
    405489        return;
    406490
    407491    case 100:
    408         cout << "Connection timed out." << endl;
     492        lout << "Connection timed out." << endl;
    409493        return;
    410494
    411495    default:
    412         cout << "Error Nr. " << errnum << ", " << errinf << endl;
     496        lout << "Error Nr. " << errnum << ", " << errinf << endl;
    413497    }
    414498}
     
    436520    // we can go on working 'as usual' Eg. Initialize a Display Update
    437521    //
    438     cout << "Mac " << GetNodeName() << " Handling Error #" << GetError() << endl;
     522    cout << GetNodeName() << " Handling Error #" << GetError() << endl;
    439523    switch (GetError())
    440524    {
     
    525609
    526610        fTimerOn = kTRUE;
    527         fTimeout->Start(fGuardTime, kFALSE); //kTRUE);
    528 
    529         SendSDO(0x4000, 1, string('o', 'n'));
    530         WaitForSdo(0x4000, 1);
     611        fTimeout->Start(fGuardTime/*/3*2*/, kTRUE); //kFALSE); //TRUE);
     612        //
     613        // Start with kFALSE would be a continous timer, but this
     614        // timer seems to stop it's activity at some stage without
     615        // any reason
     616        //
     617
     618//        SendSDO(0x4000, 1, string('o', 'n'));
     619//        WaitForSdo(0x4000, 1);
    531620    }
    532621    lout << "- Timeout timer of " << GetNodeName() << " turned "
     
    565654    //  FIXME! Use NMT!
    566655    //
     656    // --- lout << ddev(MLog::eGui);
     657    // --- lout << "Send 0x4000: " << GetNodeName() << endl;
     658
    567659    SendSDO(0x4000, 0, (LWORD_t)0, false);
    568660
     661    // --- lout << "Done 0x4000: " << GetNodeName() << endl;
     662
    569663    Timer time;
    570     if (time.Now() > fTimeoutTime)
     664
     665    // --- lout << "dT " << GetNodeName() << ": " <<  dec <<(int)((fTimeoutTime-time.Now())*1000) << endl;
     666    // --- lout << edev(MLog::eGui);
     667
     668    if (time.Now() > fTimeoutTime+0.5)
    571669    {
    572670        lout << ddev(MLog::eGui);
     
    576674    }
    577675
    578 
    579676    //WaitForSdo(0x4000, 0, kDontWait);
    580     //    if (fTimerOn)
    581     //        fTimeout->Start(fGuardTime, kTRUE);
     677    //
     678    // Would not be necessary if I would Start the timer with
     679    // kFALSE. This would be a continous timer, but this
     680    // timer seems to stop it's activity at some stage without
     681    // any reason
     682    //
     683    if (fTimerOn)
     684        fTimeout->Start(fGuardTime/*/3*2*/, kTRUE);
    582685
    583686    return kTRUE;
     
    587690{
    588691    Timer time;
    589     fTimeoutTime = time.Now() + 2.*fGuardTime/1000.; //[usec]
     692
     693    // --- lout << ddev(MLog::eGui);
     694    // --- lout << "Reset " << GetNodeName() << ": " << dec << (int)((fTimeoutTime-time.Now())*1000) << endl;
     695    // --- lout << edev(MLog::eGui);
     696
     697    fTimeoutTime = time.Now() + 3.*fGuardTime/1000.;
    590698}
    591699
    592700void Macs::SetTimeoutTime(LWORD_t ms)
    593701{
    594     fGuardTime = ms/2; // FIXME: Is '/2' the best choose?
    595 
    596     SendSDO(0x4000, 2, ms);
     702    // FIXME: Is '/2' the best choose?
     703    fGuardTime = ms/3;      // how often do we send/request the handshake
     704
     705    SendSDO(0x4000, 2, ms); // How often do we check for the handshake
    597706    WaitForSdo(0x4000, 2);
    598707}
Note: See TracChangeset for help on using the changeset viewer.