Changeset 926


Ignore:
Timestamp:
09/10/01 14:32:27 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r925 r926  
    11                                                                  -*-*- END -*-*-
     2
     3 2001/09/10 - Thomas Bretz:
     4 
     5   * base/timer.[h,cc]:
     6     - added dome comments
     7     
     8   * candrv/canopen.[cc,h]:
     9     - added boolean in SendSDO to suppress occurance in SDO list
     10     
     11   * candrv/nodedrv.[h,cc]:
     12     - added Names for Node
     13     - added boolean in SendSDO to suppress occurance in SDO list
     14     
     15   * devdrv/macs.[h,cc]:
     16     - changed GetId() to GetNodeName() in logging output
     17     - made timeout timer periodic again
     18     - added timeout for Mac response (added SDOOK)
     19     - added Name for Node
     20     
     21   * devdrv/shaftencoder.[h,cc]:
     22     - changed GetId() to GetNodeName() in logging output
     23     - added Name for Node
     24     
     25   * main/MCosy.[h,cc]:
     26     - renamed fAlt1 to fZd1
     27     - renamed fAlt2 to fZd2
     28
     29
     30     
    231 2001/09/07 - Thomas Bretz:
    332 
  • trunk/MagicSoft/Cosy/ToDo

    r921 r926  
    2121 
    2222  - Devide MTTalk into NetworkInit and MCalcTrackingError/Offset-Class
     23 
     24  - Add possibility to check for timeout when WaitForSDO returns
     25    (switching on Guarding!)
     26   
     27  - If an Error state is set, the first call to Track/Positioning only
     28    results in Error Handling. The second one gives the requested
     29    action
    2330
  • trunk/MagicSoft/Cosy/base/timer.cc

    r912 r926  
    7575}
    7676
    77 double Timer::Now()
     77double Timer::Now() //[s]
    7878{
    7979    struct timeval tv;
     
    9797}
    9898
    99 Timer::operator double()
     99Timer::operator double() //[s]
    100100{
    101101    return fMs+fSecs;
  • trunk/MagicSoft/Cosy/base/timer.h

    r912 r926  
    3131
    3232    int GetSecs() { return fSecs; }
    33     double Now();
     33    double Now(); //[s]
    3434    double CalcMjd();
    3535
     
    4242    void Print();
    4343
    44     operator double();
     44    operator double(); //[s]
    4545};
    4646
  • trunk/MagicSoft/Cosy/candrv/canopen.cc

    r920 r926  
    184184}
    185185 
    186 void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, BYTE_t val)
    187 {
    188     fSdoList.Add(node, idx, subidx);
     186void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
     187{
     188    if (store)
     189        fSdoList.Add(node, idx, subidx);
    189190
    190191    SendCanFrame(CobId(node, kSDO_TX), kSDO_RX1,
     
    192193}
    193194
    194 void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, WORD_t val)
    195 {
    196     fSdoList.Add(node, idx, subidx);
     195void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
     196{
     197    if (store)
     198        fSdoList.Add(node, idx, subidx);
    197199
    198200    SendCanFrame(CobId(node, kSDO_TX), kSDO_RX2,
     
    201203}
    202204
    203 void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, LWORD_t val)
    204 {
    205     fSdoList.Add(node, idx, subidx);
     205void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
     206{
     207    if (store)
     208        fSdoList.Add(node, idx, subidx);
    206209
    207210    SendCanFrame(CobId(node, kSDO_TX), kSDO_RX4,
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r925 r926  
    77#include "MLogManip.h"
    88
    9 NodeDrv::NodeDrv(BYTE_t nodeid, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
     9NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
    1010{
    1111    if (nodeid>31)
     
    1616
    1717    fId = nodeid;
     18
     19    if (name)
     20    {
     21        fName = new char[strlen(name)+1];
     22        strcpy(fName, name);
     23    }
     24    else
     25    {
     26        fName = new char[9];
     27        sprintf(fName, "Node#%d", nodeid);
     28    }
     29}
     30
     31NodeDrv::~NodeDrv()
     32{
     33    delete fName;
    1834}
    1935
     
    8096}
    8197
    82 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val)
     98void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
    8399{
    84     fNetwork->SendSDO(fId, idx, subidx, val);
     100    fNetwork->SendSDO(fId, idx, subidx, val, store);
    85101}
    86102
    87 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val)
     103void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
    88104{
    89     fNetwork->SendSDO(fId, idx, subidx, val);
     105    fNetwork->SendSDO(fId, idx, subidx, val, store);
    90106}
    91107
    92 void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val)
     108void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
    93109{
    94     fNetwork->SendSDO(fId, idx, subidx, val);
     110    fNetwork->SendSDO(fId, idx, subidx, val, store);
    95111}
    96112
    97113void NodeDrv::SendSDO(WORD_t idx, BYTE_t val)
    98114{
    99     fNetwork->SendSDO(fId, idx, val);
     115    fNetwork->SendSDO(fId, idx, val, true);
    100116}
    101117
    102118void NodeDrv::SendSDO(WORD_t idx, WORD_t val)
    103119{
    104     fNetwork->SendSDO(fId, idx, val);
     120    fNetwork->SendSDO(fId, idx, val, true);
    105121}
    106122
    107123void NodeDrv::SendSDO(WORD_t idx, LWORD_t val)
    108124{
    109     fNetwork->SendSDO(fId, idx, val);
     125    fNetwork->SendSDO(fId, idx, val, true);
    110126}
    111127
    112 void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx=0)
     128void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx)
    113129{
    114130    fNetwork->RequestSDO(fId, idx, subidx);
  • trunk/MagicSoft/Cosy/candrv/nodedrv.h

    r925 r926  
    1313    BYTE_t   fId;
    1414
     15    char *fName;
     16
    1517    int fError;
    1618
     
    2123
    2224public:
    23     NodeDrv(BYTE_t nodeid, MLog &out=gLog);
     25    NodeDrv(BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
     26    virtual ~NodeDrv();
    2427
    25     BYTE_t   GetId()      { return fId; }
    26     Network *GetNetwork() { return fNetwork; }
     28    BYTE_t   GetId() const       { return fId;   }
     29    char    *GetNodeName() const { return fName; }
     30    Network *GetNetwork()        { return fNetwork; }
    2731
    2832    virtual void InitDevice(Network *net);
     
    4751                  BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
    4852
    49     void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val);
    50     void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val);
    51     void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val);
     53    void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store=true);
     54    void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store=true);
     55    void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store=true);
    5256
    5357    void SendSDO(WORD_t idx, BYTE_t val);
  • trunk/MagicSoft/Cosy/devdrv/macs.cc

    r925 r926  
    66#include "timer.h"
    77#include "network.h"
    8 
    9 Macs::Macs(BYTE_t nodeid, MLog &out)
    10     : NodeDrv(nodeid, out), fMacId(2*nodeid+1),
     8#include "MLogManip.h"
     9
     10Macs::Macs(const BYTE_t nodeid, const char *name, MLog &out)
     11    : NodeDrv(nodeid, name, out), fMacId(2*nodeid+1),
    1112    fPos(0), fPosTime(0.0), fPdoPos(0), fPdoTime(0.0),
    1213    fPosActive(0), fRpmActive(0)
     
    2627    {
    2728    case 0x100a:
    28         lout << "- Mac using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
     29        lout << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
    2930        return;
    3031
    3132    case 0x2002:
    32         cout << "Actual velocity: " << dec << val << endl;
     33        cout << GetNodeName() << ": Actual velocity: " << dec << val << endl;
    3334        fVel = val;
    3435        return;
     
    3839        {
    3940        case 1:
    40             cout << "Timeout timer is " << (val?"en":"dis") << "abled." << endl;
     41            cout << GetNodeName() << ": Timeout timer is " << (val?"en":"dis") << "abled." << endl;
    4142            return;
    4243        case 2:
    43             cout << "Actual timeout time: " << dec << val << "ms" << endl;
     44            cout << GetNodeName() << ": Actual timeout time: " << dec << val << "ms" << endl;
    4445            return;
    4546        }
     
    8990
    9091    case 0x6002:
    91         lout << "- Velocity resolution Node#" << (int)GetId() << ": " << dec << val << " ticks/min" << endl;
     92        lout << "- Velocity resolution " << GetNodeName() << ": " << dec << val << " ticks/min" << endl;
    9293        fVelRes = val;
    9394        return;
     
    9798}
    9899
    99 void Macs::SetTimeoutTime(LWORD_t ms)
    100 {
    101     fTimeoutTime = ms/2;
    102 
    103     SendSDO(0x4000, 2, ms);
    104     WaitForSdo(0x4000, 2);
    105 }
    106 
    107 void Macs::ReqTimeoutTime()
    108 {
    109     RequestSDO(0x4000, 2);
    110     WaitForSdo(0x4000, 2);
    111 }
    112 
    113 void Macs::EnableTimeout(bool enable, LWORDS_t ms)
    114 {
    115     if (!enable)
    116     {
    117         SendSDO(0x4000, 1, string('o', 'f', 'f'));
    118         WaitForSdo(0x4000, 1);
    119 
    120         cout << "--> Turn Off. " << endl;
    121         fTimerOn = kFALSE;
    122     }
    123     else
    124     {
    125         if (ms>0)
    126             SetTimeoutTime(ms);
    127 
    128         cout << "--> Turn On." << endl;
    129         fTimerOn = kTRUE;
    130         fTimeout->Start(fTimeoutTime, kTRUE);
    131 
    132         SendSDO(0x4000, 1, string('o', 'n'));
    133         WaitForSdo(0x4000, 1);
    134     }
    135 }
     100void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx)
     101{
     102    if (idx==0x4000 && subidx==0 && fTimerOn)
     103    {
     104        ResetTimeout();
     105        return;
     106    }
     107    NodeDrv::HandleSDOOK(idx, subidx);
     108}
     109
    136110
    137111void Macs::ReqVelRes()
    138112{
    139     lout << "- Requesting velocity resolution (velres, 0x6002) of " << (int)GetId() << endl;
     113    lout << "- Requesting velocity resolution (velres, 0x6002) of " << GetNodeName() << endl;
    140114    RequestSDO(0x6002);
    141115    WaitForSdo(0x6002);
     
    144118void Macs::SetPDO1On(BYTE_t flag)
    145119{
    146     lout << "- " << (flag?"Enable":"Disable") << " PDO1 of #" << (int)GetId() << endl;
     120    lout << "- " << (flag?"Enable":"Disable") << " PDO1 of " << GetNodeName() << endl;
    147121    SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31);
    148122    WaitForSdo(0x1800, 1);           
     
    171145    EnableTimeout(kFALSE);
    172146
    173     lout << "- Requesting Mac Software Version of " << (int)GetId() << endl;
     147    lout << "- Requesting Mac Software Version of " << GetNodeName() << endl;
    174148    RequestSDO(0x100a);
    175149    WaitForSdo(0x100a);
     
    179153    ReqVelRes(); // Init fVelRes
    180154
    181     lout << "- Motor on of " << (int)GetId() << endl;
     155    lout << "- Motor on of " << GetNodeName() << endl;
    182156    SendSDO(0x3000, string('o', 'n'));
    183157    WaitForSdo(0x3000);
     
    219193    SetPDO1On(FALSE);
    220194
    221     lout << "- Motor off of " << (int)GetId() << endl;
     195    lout << "- Motor off of " << GetNodeName() << endl;
    222196    SendSDO(0x3000, string('o', 'f', 'f'));
    223197    WaitForSdo(0x3000);
     
    232206void Macs::ReqPos()
    233207{
    234     lout << "- Requesting Position of #" << (int)GetId() << endl;
     208    lout << "- Requesting Position of " << GetNodeName() << endl;
    235209    RequestSDO(0x6004);
    236210    WaitForSdo(0x6004);
     
    239213void Macs::ReqVel()
    240214{
    241     lout << "- Requesting Velocity of #" << (int)GetId() << endl;
     215    lout << "- Requesting Velocity of " << GetNodeName() << endl;
    242216    RequestSDO(0x2002);
    243217    WaitForSdo(0x2002);
     
    246220void Macs::SetHome(LWORDS_t pos, WORD_t maxtime)
    247221{
    248     lout << "- Driving #" << (int)GetId() << " to home position, Offset=" << dec << pos << endl;
     222    lout << "- Driving " << GetNodeName() << " to home position, Offset=" << dec << pos << endl;
    249223    SendSDO(0x6003, 2, (LWORD_t)pos);       // home
    250224    WaitForSdo(0x6003, 2);
     
    254228    SendSDO(0x3001, string('h','o','m','e'));       // home
    255229    WaitForSdo(0x3001, 0, maxtime*1000);
    256     lout << "- Home position of #" << (int)GetId() << " reached. " << endl;
     230    lout << "- Home position of " << GetNodeName() << " reached. " << endl;
    257231
    258232    SendSDO(0x6003, 0, string('s','e','t'));       // home
     
    305279void Macs::SetNoWait(BYTE_t flag)
    306280{
    307     lout << "- Setting NOWAIT " << (flag?"ON":"OFF") << " #" << (int)GetId() << endl;
     281    lout << "- Setting NOWAIT " << (flag?"ON ":"OFF ") << GetNodeName() << endl;
    308282    SendSDO(0x3008, flag ? string('o', 'n') : string('o', 'f', 'f'));
    309283    WaitForSdo(0x3008);
     
    316290    // or by a positioning command (POSA, ...)
    317291    //
    318     lout << "- Setting Vel Sync Mode #" << (int)GetId() << endl;
     292    lout << "- Setting Vel Sync Mode of " << GetNodeName() << endl;
    319293    SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));
    320294    WaitForSdo(0x3007, 0);
     
    327301    // or by a positioning command (POSA, ...)
    328302    //
    329     lout << "- Setting Pos Sync Mode #" << (int)GetId() << endl;
     303    lout << "- Setting Pos Sync Mode of " << GetNodeName() << endl;
    330304    SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));
    331305    WaitForSdo(0x3007, 1);
     
    372346    if (!errnum)
    373347    {
    374         cout << "Mac #" << (int)GetId() << " reports Error occursion." << endl;
     348        cout << "Mac " << GetNodeName() << " reports Error occursion." << endl;
    375349        SetError(-1);
    376350        return;
     
    382356    //
    383357    if (GetError()>0)
    384         cout << "Mac #" << (int)GetId() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
     358        cout << "Mac " << GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
    385359
    386360    SetError(errnum);
    387361
    388     cout << "Mac #" << (int)GetId() << " reports: ";
     362    cout << "Mac " << GetNodeName() << " reports: ";
    389363    switch (errnum)
    390364    {
     
    429403        return;
    430404
     405    case 100:
     406        cout << "Connection timed out." << endl;
     407        return;
     408
    431409    default:
    432410        cout << "Error Nr. " << errnum << ", " << errinf << endl;
     
    456434    // we can go on working 'as usual' Eg. Initialize a Display Update
    457435    //
    458     cout << "Mac #" << (int)GetId() << " Handling Error #" << GetError() << endl;
     436    cout << "Mac " << GetNodeName() << " Handling Error #" << GetError() << endl;
    459437    switch (GetError())
    460438    {
     
    463441    case   9: // zero idx
    464442    case  84: // ON TIME
    465     case 100: // timeout
    466443        // Stop program?
    467444        return;
    468445
    469     case 11: // software endswitch
    470     case 25: // hardware endswitch
     446    case 11:  // software endswitch
     447    case 25:  // hardware endswitch
     448    case 100: // timeout (movement has been stopped, so we can go on)
     449        DelError();
     450        return;
     451
     452    case 101:
     453        lout << "Warning: " << GetNodeName() << " didn't respond in timeout window - try again." << endl;
    471454        DelError();
    472455        return;
     
    513496    SendSDO(0x2000, 3, (LWORD_t)(neg|(pos<<1)));
    514497    WaitForSdo(0x2000, 3);
     498}
     499
     500void Macs::ReqTimeoutTime()
     501{
     502    RequestSDO(0x4000, 2);
     503    WaitForSdo(0x4000, 2);
     504}
     505
     506void Macs::EnableTimeout(bool enable, LWORDS_t ms)
     507{
     508    if (!enable)
     509    {
     510        SendSDO(0x4000, 1, string('o', 'f', 'f'));
     511        WaitForSdo(0x4000, 1);
     512
     513        fTimeout->Stop(); //kTRUE);
     514
     515        fTimerOn = kFALSE;
     516    }
     517    else
     518    {
     519        if (ms>0)
     520            SetTimeoutTime(ms);
     521
     522        ResetTimeout();
     523
     524        fTimerOn = kTRUE;
     525        fTimeout->Start(fGuardTime, kFALSE); //kTRUE);
     526
     527        SendSDO(0x4000, 1, string('o', 'n'));
     528        WaitForSdo(0x4000, 1);
     529    }
     530    lout << "- Timeout timer of " << GetNodeName() << " turned "
     531        << (enable?"on.":"off.") << endl;
    515532}
    516533
     
    542559       time.
    543560       */
    544     SendSDO(0x4000);
    545     WaitForSdo(0x4000, 0, kDontWait);
    546     if (fTimerOn)
    547         fTimeout->Start(fTimeoutTime, kTRUE);
     561
     562    //
     563    //  FIXME! Use NMT!
     564    //
     565    SendSDO(0x4000, 0, (LWORD_t)0, false);
     566
     567    Timer time;
     568    if (time.Now() > fTimeoutTime)
     569    {
     570        lout << ddev(MLog::eGui);
     571        lout << "Warning: " << GetNodeName() << " didn't respond in timeout window." << endl;
     572        lout << edev(MLog::eGui);
     573        SetError(101);
     574    }
     575
     576
     577    //WaitForSdo(0x4000, 0, kDontWait);
     578    //    if (fTimerOn)
     579    //        fTimeout->Start(fGuardTime, kTRUE);
     580
    548581    return kTRUE;
    549582}
     583
     584void Macs::ResetTimeout()
     585{
     586    Timer time;
     587    fTimeoutTime = time.Now() + 2.*fGuardTime/1000.; //[usec]
     588}
     589
     590void Macs::SetTimeoutTime(LWORD_t ms)
     591{
     592    fGuardTime = ms/2; // FIXME: Is '/2' the best choose?
     593
     594    SendSDO(0x4000, 2, ms);
     595    WaitForSdo(0x4000, 2);
     596}
     597
  • trunk/MagicSoft/Cosy/devdrv/macs.h

    r925 r926  
    2626    TTimer  *fTimeout;
    2727    Bool_t   fTimerOn;
    28     LWORD_t  fTimeoutTime;
     28    LWORD_t  fGuardTime;
     29    double   fTimeoutTime;
    2930
    3031    LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
     
    3334    }
    3435
     36    void ResetTimeout();
    3537    Bool_t HandleTimer(TTimer *t);
    3638
    3739public:
    38     Macs(BYTE_t nodeid, MLog &out=gLog);
     40    Macs(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
    3941    virtual ~Macs();
    4042
     
    4547
    4648    void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
    47     void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
     49    void HandleSDOOK(WORD_t idx, BYTE_t subidx);
    4850    void HandleSDOError(LWORD_t data)           { NodeDrv::HandleSDOError(data); }
    4951
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc

    r921 r926  
    1313#include <sys/resource.h>  // PRIO_PROCESS
    1414
    15 ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL), fPosHasChanged(false)
     15ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out)
     16    : NodeDrv(nodeid, name, out), fLabel(NULL), fPosHasChanged(false)
    1617{
    1718}
     
    195196    // Requesting and checking (FIXME) type of encoder
    196197    //
    197     lout << "- Requesting Hardware Type (SDO 0x1000) of " << (int)GetId() << endl;
     198    lout << "- Requesting Hardware Type (SDO 0x1000) of " << GetNodeName() << endl;
    198199    RequestSDO(0x1000);
    199200    WaitForSdo(0x1000);
     
    202203    // Read physical ticks per revolution
    203204    //
    204     lout << "- Requesting physical ticks/revolution (SDO 0x6501) of " << (int)GetId() << endl;
     205    lout << "- Requesting physical ticks/revolution (SDO 0x6501) of " << GetNodeName() << endl;
    205206    RequestSDO(0x6501);
    206207    WaitForSdo(0x6501);
     
    209210    // Read number of possible ticks per revolution
    210211    //
    211     lout << "- Requesting possible ticks/revolution (SDO 0x6502) of " << (int)GetId() << endl;
     212    lout << "- Requesting possible ticks/revolution (SDO 0x6502) of " << GetNodeName() << endl;
    212213    RequestSDO(0x6502);
    213214    WaitForSdo(0x6502);
     
    216217    // Set logic ticks/revolution = physical ticks/revolution => scale factor = 1
    217218    //
    218     lout << "- Configuring SDO 0x6001 of " << (int)GetId() << endl;
     219    lout << "- Configuring SDO 0x6001 of " << GetNodeName() << endl;
    219220    SendSDO(0x6001, fTicks);
    220221    WaitForSdo(0x6001);
     
    223224    // Set maximum number of ticks (ticks * turns)
    224225    //
    225     lout << "- Configuring SDO 0x6002 of " << (int)GetId() << endl;
     226    lout << "- Configuring SDO 0x6002 of " << GetNodeName() << endl;
    226227    SendSDO(0x6002, (LWORD_t)(fTicks*fTurns));
    227228    WaitForSdo(0x6002);
     
    230231    // Configure PDOs
    231232    //
    232     lout << "- Configuring SDO 0x1802 of " << (int)GetId() << endl;
     233    lout << "- Configuring SDO 0x1802 of " << GetNodeName() << endl;
    233234    SendSDO(0x1802, 1, (LWORD_t)0x281);
    234235    WaitForSdo(0x1802, 1);
     
    237238    // Delete preset Value
    238239    //
    239     lout << "- Configuring SDO 0x6003 of " << (int)GetId() << endl;
     240    lout << "- Configuring SDO 0x6003 of " << GetNodeName() << endl;
    240241    SendSDO(0x6003, (LWORD_t)0xffffffff);
    241242    WaitForSdo(0x6003);
     
    244245    // Request Parameter
    245246    //
    246     lout << "- Requesting SDO 0x6000 of " << (int)GetId() << endl;
     247    lout << "- Requesting SDO 0x6000 of " << GetNodeName() << endl;
    247248    RequestSDO(0x6000);
    248249    WaitForSdo(0x6000);
     
    250251    ReqPos();
    251252
    252     lout << "- Start Node " << (int)GetId() << endl;
     253    lout << "- Start Node " << GetNodeName() << endl;
    253254    SendNMT(kNMT_START);
    254255}
     
    259260    // Request Position
    260261    //
    261     lout << "- Requesting Position of #" << (int)GetId() << endl;
     262    lout << "- Requesting Position of " << GetNodeName() << endl;
    262263    RequestSDO(0x6004);
    263264    WaitForSdo(0x6004);
     
    269270    fTurn = pre/16384;
    270271
    271     lout << " - Setting Preset #" << (int)GetId() << endl;
     272    lout << " - Setting Preset " << GetNodeName() << endl;
    272273    SendSDO(0x6003, (LWORD_t)fPos);
    273274    WaitForSdo(0x6003);
     
    276277void ShaftEncoder::StopDevice()
    277278{
    278     lout << "- Start Node " << (int)GetId() << endl;
     279    lout << "- Start Node " << GetNodeName() << endl;
    279280    SendNMT(kNMT_STOP);
    280281}
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.h

    r924 r926  
    3333
    3434public:
    35     ShaftEncoder(BYTE_t nodeid, MLog &out=gLog);
     35    ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
    3636    virtual ~ShaftEncoder();
    3737
  • trunk/MagicSoft/Cosy/gui/MGCosy.cc

    r921 r926  
    437437
    438438    // TGMainFrame::CloseWindow();
     439    cout << "Closing window - waiting until all nodes are stopped." << endl;
    439440    fQueue->PostMsg(WM_QUIT, 0, 0);
    440441    // gApplication->Terminate(0);
  • trunk/MagicSoft/Cosy/main/MCosy.cc

    r925 r926  
    125125ZdAz MCosy::GetSePos()
    126126{
    127     const int p0 = fAlt1->GetPos();
    128     const int p1 = fAlt2->GetPos();
     127    const int p0 = fZd1->GetPos();
     128    const int p1 = fZd2->GetPos();
    129129    const int p2 = fAz->GetPos();
    130130
     
    362362    else
    363363        if (fabs(vt->Az()) > 0.9*vraz)
     364        {
     365            lout << "Warning: Azimuth speed limit exceeded. Limiting speed to 90% max." << endl;
    364366            vt->Az(0.9*vraz*sgn(vt->Az()));
     367        }
    365368
    366369    if (sgn(vt->Zd()) != sgn(vcalc.Zd()) &&
     
    369372    else
    370373        if (fabs(vt->Zd()) > 0.9*vrzd)
     374        {
     375            lout << "Warning: Altitude speed limit exceeded. Limiting speed to 90% max." << endl;
    371376            vt->Zd(0.9*vrzd*sgn(vt->Zd()));
     377        }
    372378}
    373379
     
    568574    case WM_PRESET:
    569575        cout << "WM_Preset: start." << endl;
    570         fAlt1->SetPreset();
    571         fAlt2->SetPreset();
     576        fZd1->SetPreset();
     577        fZd2->SetPreset();
    572578        fAz->SetPreset();
    573579        cout << "WM_Preset: done. (return 0xaffe)" << endl;
     
    588594            cout << "Got  Zd: " << sepos.Zd() << " Az: " << sepos.Az() << endl;
    589595
    590             fAlt1->SetPreset(za.Zd());
    591             fAlt2->SetPreset(-za.Zd());
     596            fZd1->SetPreset(za.Zd());
     597            fZd2->SetPreset(-za.Zd());
    592598            fAz->SetPreset(za.Az());
    593599
     
    759765            do
    760766            {
    761                 phca1 = fAlt1->PosHasChanged();
    762                 phca2 = fAlt2->PosHasChanged();
     767                phca1 = fZd1->PosHasChanged();
     768                phca2 = fZd2->PosHasChanged();
    763769                phcaz = fAz->PosHasChanged();
    764770                usleep(1);
     
    786792            // FIXME: I cannot take the avarage
    787793            //
    788             time.Zd((fAlt1->GetMjd()+fAlt2->GetMjd())/2.0);
     794            time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0);
    789795            time.Az(fAz->GetMjd());
    790796
     
    823829    // Update Gui, foremer MTGui.
    824830    //
    825     fAlt1->DisplayVal();
    826     fAlt2->DisplayVal();
     831    fZd1->DisplayVal();
     832    fZd2->DisplayVal();
    827833    fAz->DisplayVal();
    828834
     
    874880    // Create Nodes
    875881    //
    876     fMac1=new Macs(1, lout);
    877     fMac2=new Macs(2, lout);
    878     fMac3=new Macs(3, lout);
    879     fAlt1=new ShaftEncoder(4, lout);
    880     fAlt2=new ShaftEncoder(5, lout);
    881     fAz  =new ShaftEncoder(6, lout);
     882    fMac1=new Macs(1, "Mac.1/Az",      lout);
     883    fMac2=new Macs(2, "Mac.2/Zd",      lout);
     884    fMac3=new Macs(3, "Mac.3/Az-Sync", lout);
     885
     886    fZd1=new ShaftEncoder(4, "SE.4/Zd1", lout);
     887    fZd2=new ShaftEncoder(5, "SE.5/Zd2", lout);
     888    fAz =new ShaftEncoder(6, "SE.6/Az",  lout);
    882889
    883890    //
     
    887894    SetNode(fMac2);
    888895    SetNode(fMac3);
    889     SetNode(fAlt1);
    890     SetNode(fAlt2);
     896    SetNode(fZd1);
     897    SetNode(fZd2);
    891898    SetNode(fAz);
    892899
     
    899906
    900907    fAz->SetDisplay(fWin->GetLabel1());
    901     fAlt1->SetDisplay(fWin->GetLabel2());
    902     fAlt2->SetDisplay(fWin->GetLabel3());
     908    fZd1->SetDisplay(fWin->GetLabel2());
     909    fZd2->SetDisplay(fWin->GetLabel3());
    903910
    904911    lout.SetOutputGui(fWin->GetLog(), kTRUE);
     
    930937
    931938    delete fAz;
    932     delete fAlt2;
    933     delete fAlt1;
     939    delete fZd2;
     940    delete fZd1;
    934941    delete fMac1;
    935942    delete fMac2;
  • trunk/MagicSoft/Cosy/main/MCosy.h

    r924 r926  
    5050
    5151private:
    52     ShaftEncoder *fAlt1;
    53     ShaftEncoder *fAlt2;
     52    ShaftEncoder *fZd1;
     53    ShaftEncoder *fZd2;
    5454    ShaftEncoder *fAz;
    5555
Note: See TracChangeset for help on using the changeset viewer.