Changeset 8835


Ignore:
Timestamp:
01/24/08 16:38:40 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r8834 r8835  
    8080     - changed to new threading classes
    8181     - thread doesn't run detached anymore
     82
     83   * candrv/nodedrv.[h,cc], devdrv/macs.[h,cc], devdrv/shaftencoder.[h,cc]:
     84     - changed from lout to gLog
     85     - added maipulators
     86     - removed MLog from the constructor
    8287
    8388
  • trunk/MagicSoft/Cosy/candrv/network.cc

    r8813 r8835  
    3232#include "network.h"
    3333
    34 #include <iostream> // cout
    35 #include <iomanip>  // setw, setfill
     34#include "MLog.h"
     35#include "MLogManip.h"
    3636
    3737ClassImp(Network);
     
    4646void Network::Start()
    4747{
    48     gLog << "- Starting network." << endl;
     48    gLog << inf << "- Starting network." << endl;
    4949
    5050    CanOpen::Start();
    5151    InitNodes();
    5252
    53     gLog << "- Network started." << endl;
     53    gLog << inf << "- Network started." << endl;
    5454}
    5555
     
    6060void Network::Stop()
    6161{
    62     gLog << "- Stopping network." << endl;
     62    gLog << inf << "- Stopping network." << endl;
    6363
    6464    StopNodes();
    6565    CanOpen::Stop();
    6666
    67     gLog << "- Network stopped." << endl;
     67    gLog << inf << "- Network stopped." << endl;
    6868}
    6969
     
    7777    memset(fNodeInitialized, 0, 32*sizeof(*fNodeInitialized));
    7878
    79     gLog << "- Network initialized." << endl;
     79    gLog << inf << "- Network initialized." << endl;
    8080}
    8181
     
    115115        }
    116116
    117     cout << dec << setfill('0');
    118     cout << "Network::HandleSDO: Node=" << (int)node  << " Cmd=0x" << hex << (int)cmd << ": ";
    119     cout << "Sdo=" << idx  << "/" << (int)subidx << ": 0x" << setw(8) << data;
    120     cout << endl;
     117    gLog << warn << dec << setfill('0');
     118    gLog << "Network::HandleSDO: Node=" << (int)node  << " Cmd=0x" << hex << (int)cmd << ": ";
     119    gLog << "Sdo=" << idx  << "/" << (int)subidx << ": 0x" << setw(8) << data;
     120    gLog << endl;
    121121}
    122122
     
    129129    if (!fNodes[node])
    130130    {
    131         cout << "Network::HandlePDO1: Node #" << dec << (int)node << " not found - PDO1: " << hex;
     131        gLog << err << "ERROR - Network::HandlePDO1: Node #" << dec << (int)node << " not found - PDO1: " << hex;
    132132        for (int i=0; i<8; i++)
    133             cout << " 0x" << (int)data[i];
    134         cout << endl;
     133            gLog << " 0x" << (int)data[i];
     134        gLog << endl;
    135135        return;
    136136    }
     
    147147    if (!fNodes[node])
    148148    {
    149         cout << "Network::HandlePDO2: Node #" << dec << (int)node << " not found - PDO2: " << hex;
     149        gLog << err << "ERROR - Network::HandlePDO2: Node #" << dec << (int)node << " not found - PDO2: " << hex;
    150150        for (int i=0; i<8; i++)
    151             cout << " 0x" << (int)data[i];
    152         cout << endl;
     151            gLog << " 0x" << (int)data[i];
     152        gLog << endl;
    153153        return;
    154154    }
     
    165165    if (!fNodes[node])
    166166    {
    167         cout << "Network::HandlePDO3: Node #" << dec << (int)node << " not found - PDO3: " << hex;
     167        gLog << err << "ERROR - Network::HandlePDO3: Node #" << dec << (int)node << " not found - PDO3: " << hex;
    168168        for (int i=0; i<8; i++)
    169             cout << " 0x" << (int)data[i];
    170         cout << endl;
     169            gLog << " 0x" << (int)data[i];
     170        gLog << endl;
    171171        return;
    172172    }
     
    183183    if (!fNodes[node])
    184184    {
    185         cout << "Network::HandlePDO4: Node #" << dec << (int)node << " not found - PDO4: " << hex;
     185        gLog << err << "ERROR - Network::HandlePDO4: Node #" << dec << (int)node << " not found - PDO4: " << hex;
    186186        for (int i=0; i<8; i++)
    187             cout << " 0x" << (int)data[i];
    188         cout << endl;
     187            gLog << " 0x" << (int)data[i];
     188        gLog << endl;
    189189        return;
    190190    }
     
    202202    if (!fNodes[node])
    203203    {
    204         cout << "Network::HandleNodeguard: Node #" << dec << (int)node << " not found: Nodeguard." << endl;
     204        gLog << err << "ERROR - Network::HandleNodeguard: Node #" << dec << (int)node << " not found: Nodeguard." << endl;
    205205        return;
    206206    }
     
    218218    if (!fNodes[node])
    219219    {
    220         cout << "Network::HandleEmergency: Node #" << dec << (int)node << " not found: Emergency." << endl;
     220        gLog << err << "ERROR - Network::HandleEmergency: Node #" << dec << (int)node << " not found: Emergency." << endl;
    221221        return;
    222222    }
     
    236236    if (nodeid>31)
    237237    {
    238         cout << "SetNode - Error: Only node Numbers < 32 are allowed"<< endl;
     238        gLog << err << "ERROR - Network::SetNode: Only node Numbers < 32 are allowed"<< endl;
    239239        return;
    240240    }
     
    252252        if (fNodes[i])
    253253        {
    254             gLog << "- Setting up Node #" << dec << i << " (";
     254            gLog << inf2 << "- Setting up Node #" << dec << i << " (";
    255255            gLog << fNodes[i]->GetNodeName() << ")" << endl;
    256256            if (fNodes[i]->InitDevice(this))
    257257                fNodeInitialized[i] = TRUE;
    258258            else
    259                 gLog << "- " << fNodes[i]->GetNodeName() << ": InitDevice failed." << endl;
     259                gLog << err << "- " << fNodes[i]->GetNodeName() << ": InitDevice failed." << endl;
    260260        }
    261     gLog << "- All Nodes setup." << endl;
     261    gLog << inf << "- All Nodes setup." << endl;
    262262}
    263263
     
    271271        if (fNodes[i] && fNodeInitialized[i])
    272272        {
    273             gLog << "- Stopping Node #" << dec << i;
     273            gLog << inf2 << "- Stopping Node #" << dec << i;
    274274            gLog << " (" << fNodes[i]->GetNodeName() << ")" << endl;
    275275            fNodes[i]->StopDevice();
    276276        }
    277     gLog << "- All Nodes stopped." << endl;
     277    gLog << inf << "- All Nodes stopped." << endl;
    278278}
    279279
     
    292292            continue;
    293293
    294         gLog << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName() << "' ";
     294        gLog << err << "- Node #" << dec << i << " '" << fNodes[i]->GetNodeName() << "' ";
    295295
    296296        if (fNodes[i]->GetError() <= 0)
     
    362362                }
    363363
    364     if (rc)
    365         gLog << "- All Zombies rebooted." << endl;
     364//    if (rc)
     365//        gLog << inf << "- All Zombies rebooted." << endl;
    366366
    367367    return rc;
  • trunk/MagicSoft/Cosy/candrv/network.h

    r8813 r8835  
    4242    bool HasZombie() const;
    4343
    44     bool RebootZombies();
     44    bool RebootZombies(Int_t max=33);
    4545    void CheckConnections();
    4646
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r8823 r8835  
    5252#include "MTime.h"
    5353#include "network.h"
     54
    5455#include "MLogManip.h"
    5556
     
    6566// and the node name. The name is a name for debug output.
    6667//
    67 NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE), fGuard(NULL)
     68NodeDrv::NodeDrv(BYTE_t nodeid, const char *name) : fNetwork(NULL), fId(32), fError(0), fIsZombie(kTRUE), fGuard(NULL)
    6869{
    6970    if (nodeid>0x1f)
    7071    {
    71         cout << "SetNode - Error: Only node Numbers < 32 are allowed"<< endl;
     72        gLog << err << "ERROR - NodeDrv::NodeDrv: Only node Numbers < 32 are allowed"<< endl;
    7273        return;
    7374    }
     
    8384    }
    8485
    85     lout << "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl;
     86    gLog << inf2 << "- Node #" << (int)nodeid << " (" << name << ") initialized." << endl;
    8687
    8788}
     
    149150void NodeDrv::HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, const timeval_t &tv)
    150151{
    151     const Bool_t gui = lout.IsOutputDeviceEnabled(MLog::eGui);
     152    const Bool_t gui = gLog.IsOutputDeviceEnabled(MLog::eGui);
    152153
    153154    if (gui)
    154         lout << ddev(MLog::eGui);
    155 
    156     lout << hex << setfill('0');
    157     lout << "Node #" << dec << (int)fId << ": Sdo=" << hex << idx  << "/" << (int)subidx << " set.";
    158     lout << endl;
     155        gLog << ddev(MLog::eGui);
     156
     157    gLog << warn << setfill('0') << "WARNING - Nodedrv::HandleSDOOK: ";
     158    gLog << "Node #" << dec << (int)fId << ": Sdo=" << hex << idx  << "/" << (int)subidx << " set.";
     159    gLog << endl;
    159160
    160161    if (gui)
    161         lout << edev(MLog::eGui);
     162        gLog << edev(MLog::eGui);
    162163}
    163164
     
    168169void NodeDrv::HandleSDOError(LWORD_t data)
    169170{
    170     lout << "Nodedrv: SDO Error: Entry not found in dictionary (data=0x";
    171     lout << hex << setfill('0') << setw(4) << data << ")";
    172     lout << endl;
     171    gLog << warn << "WARNING - Nodedrv::HandleSDOError: Entry not found in dictionary (data=0x";
     172    gLog << hex << setfill('0') << setw(4) << data << ")";
     173    gLog << endl;
    173174}
    174175
     
    179180void NodeDrv::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, const timeval_t &tv)
    180181{
    181     cout << "SdoRx: Idx=0x"<< hex << idx << "/" << (int)subidx;
    182     cout << ", val=0x" << val << endl;
     182    gLog << warn << "WARNING - Nodedrv::HandleSDO: Idx=0x"<< hex << idx << "/" << (int)subidx;
     183    gLog << ", val=0x" << val << endl;
    183184}
    184185
     
    426427        return true;
    427428
    428     lout << " + " << GetNodeName() << ": NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " --> ZOMBIE! " << MTime(-1) << endl;
     429    gLog << inf2 << " + " << GetNodeName() << ": NodeDrv::WaitForSdo: 0x" << hex << idx << "/" << dec << (int)subidx << " --> ZOMBIE! " << MTime(-1) << endl;
    429430    if (zombie)
    430431        SetZombie();
     
    555556    fGuard->RunThread();
    556557
    557     lout << "- " << GetNodeName() << ": Guarding (" << dec;
    558     lout << fLifeTimeFactor << "*" << fGuardTime << "ms) started." << endl;
     558    gLog << inf << "- " << GetNodeName() << ": Guarding (" << dec;
     559    gLog << fLifeTimeFactor << "*" << fGuardTime << "ms) started." << endl;
    559560}
    560561
     
    563564    if (fGuard)
    564565    {
    565         lout << "- " << GetNodeName() << ": ERROR - Guarding already started." << endl;
     566        gLog << err << "- " << GetNodeName() << ": ERROR - Guarding already started." << endl;
    566567        return;
    567568    }
     
    581582    fGuard=NULL;
    582583
    583     lout << "- " << GetNodeName() << ": Guarding stopped." << endl;
     584    gLog << inf << "- " << GetNodeName() << ": Guarding stopped." << endl;
    584585}
    585586
     
    601602        StopGuarding();
    602603    else
    603         lout << " - " << GetNodeName() << ": Zombie set due to timeout." << endl;
    604 }
     604        gLog << warn << " - " << GetNodeName() << ": Zombie set due to timeout." << endl;
     605}
  • trunk/MagicSoft/Cosy/candrv/nodedrv.h

    r8813 r8835  
    44#ifndef ROOT_TString
    55#include <TString.h>
    6 #endif
    7 
    8 #ifndef COSY_Log
    9 #include "log.h"
    106#endif
    117
     
    2521class NodeGuard;
    2622
    27 class NodeDrv : public Log
     23class NodeDrv
    2824{
    2925private:
     
    5046
    5147public:
    52     NodeDrv(BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
     48    NodeDrv(BYTE_t nodeid, const char *name=NULL);
    5349    virtual ~NodeDrv();
    5450
  • trunk/MagicSoft/Cosy/devdrv/macs.cc

    r8811 r8835  
    11#include "macs.h"
    22
    3 #include <iostream>
    43#include <sys/time.h>   // timeval->tv_sec
    54
     
    2928*/
    3029
    31 Macs::Macs(const BYTE_t nodeid, const char *name, MLog &out)
    32     : NodeDrv(nodeid, name, out), fMacId(2*nodeid+1),
     30Macs::Macs(const BYTE_t nodeid, const char *name)
     31    : NodeDrv(nodeid, name), fMacId(2*nodeid+1),
    3332    fPos(0), fPdoPos(0), fPosActive(0), fRpmActive(0),
    3433    fStatusPdo3(0xff)
     
    5352        if (subidx!=2)
    5453            return;
    55         lout << "- " << GetNodeName() << ": Error[0]=" << dec << val << endl;
     54        gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << dec << val << endl;
    5655        SetError(val);
    5756        return;
    5857
    5958    case 0x100a:
    60         lout << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
     59        gLog << inf2 << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
    6160        fSoftVersion = val;
    6261        return;
     
    6867
    6968    case 0x100c:
    70         lout << "- " << GetNodeName() << ": Guard time:" << dec << val << endl;
     69        gLog << inf2 << "- " << GetNodeName() << ": Guard time:" << dec << val << endl;
    7170        return;
    7271
    7372    case 0x100d:
    74         lout << "- " << GetNodeName() << ": Life time factor:" << dec << val << endl;
     73        gLog << inf2 << "- " << GetNodeName() << ": Life time factor:" << dec << val << endl;
    7574        return;
    7675
    7776    case 0x2002:
    78         cout << GetNodeName() << ": Current velocity: " << dec << val << endl;
     77        gLog << inf2 << GetNodeName() << ": Current velocity: " << dec << val << endl;
    7978        fVel = val;
    8079        return;
     
    123122
    124123    case 0x6002:
    125         lout << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " ticks/min" << endl;
     124        gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " ticks/min" << endl;
    126125        fVelRes = val;
    127126        return;
    128127
    129128    case 0x6501:
    130         lout << "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks/min" << endl;
     129        gLog << inf2 << "- " << GetNodeName() << ": Encoder resolution = " << dec << val << " ticks/min" << endl;
    131130        fRes = val;
    132131        return;
    133132    }
    134     cout << "Macs: SDO, idx=0x"<< hex << idx << "/" << (int)subidx;
    135     cout << ", val=0x"<<val<<endl;
     133
     134    NodeDrv::HandleSDO(idx, subidx, val, tv);
     135
     136//    cout << "Macs: SDO, idx=0x"<< hex << idx << "/" << (int)subidx;
     137//    cout << ", val=0x"<<val<<endl;
    136138}
    137139
     
    154156        case 1:
    155157            //lout << ddev(MLog::eGui);
    156             lout << "- " << GetNodeName() << ": State of node set." << endl;
     158            gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl;
    157159            //lout << edev(MLog::eGui);
    158160            return;
     
    165167        case 0:
    166168            //lout << ddev(MLog::eGui);
    167             lout << "- " << GetNodeName() << ": Guard time set." << endl;
     169            gLog << inf2 << "- " << GetNodeName() << ": Guard time set." << endl;
    168170            //lout << edev(MLog::eGui);
    169171            return;
     
    176178        case 0:
    177179            //lout << ddev(MLog::eGui);
    178             lout << "- " << GetNodeName() << ": Life time factor set." << endl;
     180            gLog << inf2 << "- " << GetNodeName() << ": Life time factor set." << endl;
    179181            //lout << edev(MLog::eGui);
    180182            return;
     
    187189        case 1:
    188190            //lout << ddev(MLog::eGui);
    189             lout << "- " << GetNodeName() << ": Status of PDO1 set." << endl;
     191            gLog << inf2 << "- " << GetNodeName() << ": Status of PDO1 set." << endl;
    190192            //lout << edev(MLog::eGui);
    191193            return;
     
    198200        case 0:
    199201            //lout << ddev(MLog::eGui);
    200             lout << "- " << GetNodeName() << ": Velocity set." << endl;
     202            gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl;
    201203            //lout << edev(MLog::eGui);
    202204            return;
     
    209211        case 0:
    210212            //lout << ddev(MLog::eGui);
    211             lout << "- " << GetNodeName() << ": Acceleration set." << endl;
     213            gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl;
    212214            //lout << edev(MLog::eGui);
    213215            return;
    214216        case 1:
    215217            //lout << ddev(MLog::eGui);
    216             lout << "- " << GetNodeName() << ": Deceleration set." << endl;
     218            gLog << inf2 << "- " << GetNodeName() << ": Deceleration set." << endl;
    217219            //lout << edev(MLog::eGui);
    218220            return;
     
    225227        case 0:
    226228            //lout << ddev(MLog::eGui);
    227             lout << "- " << GetNodeName() << ": RPM mode switched." << endl;
     229            gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl;
    228230            //lout << edev(MLog::eGui);
    229231            return;
     
    245247    case 0x6000:
    246248        //lout << ddev(MLog::eGui);
    247         lout << "- " << GetNodeName() << ": Rotation direction set." << endl;
     249        gLog << inf2 << "- " << GetNodeName() << ": Rotation direction set." << endl;
    248250        //lout << edev(MLog::eGui);
    249251        return;
     
    251253    case 0x6002:
    252254        //lout << ddev(MLog::eGui);
    253         lout << "- " << GetNodeName() << ": Velocitz resolution set." << endl;
     255        gLog << inf2 << "- " << GetNodeName() << ": Velocitz resolution set." << endl;
    254256        //lout << edev(MLog::eGui);
    255257        return;
     
    260262        case 0:
    261263            //lout << ddev(MLog::eGui);
    262             lout << "- " << GetNodeName() << ": Absolute positioning started." << endl;
     264            gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;
    263265            //lout << edev(MLog::eGui);
    264266            return;
     
    266268        case 1:
    267269            //lout << ddev(MLog::eGui);
    268             lout << "- " << GetNodeName() << ": Relative positioning started." << endl;
     270            gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;
    269271            //lout << edev(MLog::eGui);
    270272            return;
     
    277279        case 0:
    278280            //lout << ddev(MLog::eGui);
    279             lout << "- " << GetNodeName() << ": Absolute positioning started." << endl;
     281            gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;
    280282            //lout << edev(MLog::eGui);
    281283            return;
     
    283285        case 1:
    284286            //lout << ddev(MLog::eGui);
    285             lout << "- " << GetNodeName() << ": Relative positioning started." << endl;
     287            gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;
    286288            //lout << edev(MLog::eGui);
    287289            return;
     
    296298void Macs::ReqVelRes()
    297299{
    298     lout << "- " << GetNodeName() << ": Requesting velocity resolution (velres, 0x6002)." << endl;
     300    gLog << inf2 << "- " << GetNodeName() << ": Requesting velocity resolution (velres, 0x6002)." << endl;
    299301    RequestSDO(0x6002);
    300302    WaitForSdo(0x6002);
     
    303305void Macs::ReqRes()
    304306{
    305     lout << "- " << GetNodeName() << ": Requesting encoder resolution (res, 0x6501)." << endl;
     307    gLog << inf2 << "- " << GetNodeName() << ": Requesting encoder resolution (res, 0x6501)." << endl;
    306308    RequestSDO(0x6501);
    307309    WaitForSdo(0x6501);
     
    310312void Macs::SetPDO1On(BYTE_t flag)
    311313{
    312     lout << "- " << GetNodeName() << ": " << (flag?"Enable":"Disable") << " PDO1." << endl;
     314    gLog << inf2 << "- " << GetNodeName() << ": " << (flag?"Enable":"Disable") << " PDO1." << endl;
    313315    SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31);
    314316    WaitForSdo(0x1800, 1);           
     
    322324    // After this the MACS will react on real movement commands.
    323325    //
    324     lout << "- " << GetNodeName() << ": Starting Node." << endl;
     326    gLog << inf2 << "- " << GetNodeName() << ": Starting Node." << endl;
    325327    SendSDO(0x1000, 1, (LWORD_t)1);
    326328    WaitForSdo(0x1000, 1);
     
    339341    // error list)
    340342    //
    341     lout << "- " << GetNodeName() << ": Requesting Error[0]." << endl;
     343    gLog << inf2 << "- " << GetNodeName() << ": Requesting Error[0]." << endl;
    342344    RequestSDO(0x1003, 2);
    343345    WaitForSdo(0x1003, 2);
    344346    if (HasError())
    345347    {
    346         lout << "Macs::Init: " << GetNodeName() << " has error --> ZOMBIE!" << endl;
     348        gLog << err << "Macs::Init: " << GetNodeName() << " has error --> ZOMBIE!" << endl;
    347349        SetZombie();
    348350    }
     
    353355    StopGuarding();
    354356
    355     lout << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl;
     357    gLog << inf2 << "- " << GetNodeName() << ": Requesting Mac Software Version." << endl;
    356358    RequestSDO(0x100a);
    357359    WaitForSdo(0x100a);
     
    360362    if (fSoftVersion<0x00000045) // 00.69
    361363    {
    362         lout << GetNodeName() << " - Software Version too old!" << endl;
     364        gLog << err << GetNodeName() << " - Software Version too old!" << endl;
    363365        SetZombie();
    364366        return;
     
    431433void Macs::ReqPos()
    432434{
    433     lout << "- " << GetNodeName() << ": Requesting Position." << endl;
     435    gLog << inf2 << "- " << GetNodeName() << ": Requesting Position." << endl;
    434436    RequestSDO(0x6004);
    435437    WaitForSdo(0x6004);
     
    438440void Macs::ReqVel()
    439441{
    440     lout << "- " << GetNodeName() << ": Requesting Velocity." << endl;
     442    gLog << inf2 << "- " << GetNodeName() << ": Requesting Velocity." << endl;
    441443    RequestSDO(0x2002);
    442444    WaitForSdo(0x2002);
     
    523525    // or by a positioning command (POSA, ...)
    524526    //
    525     lout << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;
     527    gLog << inf2 << "- " << GetNodeName() << ": Starting RPM Sync Mode." << endl;
    526528    SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));
    527529    WaitForSdo(0x3007, 0);
     
    534536    // or by a positioning command (POSA, ...)
    535537    //
    536     lout << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl;
     538    gLog << inf2 << "- " << GetNodeName() << ": Starting Position Sync Mode." << endl;
    537539    SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));
    538540    WaitForSdo(0x3007, 1);
     
    591593    if (!errnum)
    592594    {
    593         lout << "- " << GetNodeName() << ": reports Error occursion." << endl;
    594         lout << "Macs::HandlePDO2: " << GetNodeName() << " --> ZOMBIE!" << endl;
     595        gLog << err << "- " << GetNodeName() << ": reports Error occursion." << endl;
     596        gLog << "Macs::HandlePDO2: " << GetNodeName() << " --> ZOMBIE!" << endl;
    595597        SetZombie();
    596598        SetError(-1);
     
    604606    if (GetError()>0)
    605607    {
    606         lout << GetNodeName() << ": WARNING! Error #" << GetError() << " unhandled (not cleared) by software." << endl;
     608        gLog << warn << GetNodeName() << ": WARNING! Error #" << GetError() << " unhandled (not cleared) by software." << endl;
    607609
    608610        //
     
    615617    SetError(errnum);
    616618
    617     lout << GetNodeName() << " reports: ";
     619    gLog << err << GetNodeName() << " reports: ";
    618620    switch (errnum)
    619621    {
    620622    case 3:
    621         lout << "Axis does not existing." << endl;
     623        gLog << "Axis does not existing." << endl;
    622624        return;
    623625    case 5:
    624         lout << "Error not cleared (while trying to move axis)" << endl;
     626        gLog << "Error not cleared (while trying to move axis)" << endl;
    625627        return;
    626628    case 6:
     
    630632        // from reporting this error a thousands of times.
    631633        //
    632         lout << "Home position not the first positioning command." << endl;
     634        gLog << "Home position not the first positioning command." << endl;
    633635        SetError(0);
    634636        return;
    635637    case 8:
    636         lout << "Control deviation overflow." << endl;
     638        gLog << "Control deviation overflow." << endl;
    637639        return;
    638640    case 9:
    639         lout << "Zero index not found." << endl;
     641        gLog << "Zero index not found." << endl;
    640642        return;
    641643    case 10:
    642         lout << "Unknown command, syntax error." << endl;
    643         lout << "Please recompile and reload program." << endl;
     644        gLog << "Unknown command, syntax error." << endl;
     645        gLog << "Please recompile and reload program." << endl;
    644646        return;
    645647    case 11:
     
    648650        {
    649651        case -1:
    650             lout << "Negative";
     652            gLog << "Negative";
    651653            break;
    652654        case 1:
    653             lout << "Positive";
     655            gLog << "Positive";
    654656            break;
    655657        default:
    656             lout << "-unknown-";
     658            gLog << "-unknown-";
    657659        }
    658660        switch (errnum)
    659661        {
    660662        case 11:
    661             lout << " software";
     663            gLog << " software";
    662664            break;
    663665        case 25:
    664             lout << " hardware";
     666            gLog << " hardware";
    665667            break;
    666668        }
    667         lout << " endswitch activated." << endl;
     669        gLog << " endswitch activated." << endl;
    668670        return;
    669671    case 12:
    670         lout << "Wrong parameter number used in SET command." << endl;
     672        gLog << "Wrong parameter number used in SET command." << endl;
    671673        return;
    672674    case 14:
    673         lout << " Too many LOOP calls." << endl;
     675        gLog << " Too many LOOP calls." << endl;
    674676        return;
    675677    case 16:
    676         lout << "Parameter in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl;
    677         lout << "Please use APOSS to 'Reset' the MACS and reload the parameters." << endl;
     678        gLog << "Parameter in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl;
     679        gLog << "Please use APOSS to 'Reset' the MACS and reload the parameters." << endl;
    678680        return;
    679681    case 17:
    680         lout << "Program in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl;
    681         lout << "Please use APOSS to delete all Programs restore the programs." << endl;
     682        gLog << "Program in EEPROM broken (means: EEPROM broken, or saving not finished)" << endl;
     683        gLog << "Please use APOSS to delete all Programs restore the programs." << endl;
    682684        return;
    683685    case 18:
    684         lout << "Reset by CPU (reset called by Watch-dog cause of CPU halted)" << endl;
    685         lout << "Possible reasons: short under-/overvoltage or shortcut." << endl;
     686        gLog << "Reset by CPU (reset called by Watch-dog cause of CPU halted)" << endl;
     687        gLog << "Possible reasons: short under-/overvoltage or shortcut." << endl;
    686688        return;
    687689    case 19:
    688         lout << "User break (autostart program stopped by user)" << endl;
     690        gLog << "User break (autostart program stopped by user)" << endl;
    689691        return;
    690692    case 51:
    691         lout << "Too many (>=10) GOSUB calls." << endl;
     693        gLog << "Too many (>=10) GOSUB calls." << endl;
    692694        return;
    693695    case 52:
    694         lout << "Too many RETURN calls." << endl;
     696        gLog << "Too many RETURN calls." << endl;
    695697        return;
    696698    case 62:
    697         lout << "Error veryfiing EEPROM after access (Try again savaing parameters or program)" << endl;
     699        gLog << "Error veryfiing EEPROM after access (Try again savaing parameters or program)" << endl;
    698700        return;
    699701    case 70:
    700         lout << "Error in DIM call (call to DIM doesn't fit existing DIM call)" << endl;
     702        gLog << "Error in DIM call (call to DIM doesn't fit existing DIM call)" << endl;
    701703        return;
    702704    case 71:
    703         lout << "Array out of bound." << endl;
     705        gLog << "Array out of bound." << endl;
    704706        return;
    705707    case 79:
    706         lout << "Timeout waiting for index (WAITNDX)." << endl;
     708        gLog << "Timeout waiting for index (WAITNDX)." << endl;
    707709        return;
    708710    case 84:
    709         lout << "Too many (>12) ON TIME calls." << endl;
     711        gLog << "Too many (>12) ON TIME calls." << endl;
    710712        return;
    711713    case 87:
    712         lout << "Out of memory for variables - Check APOSS predifined number of" << endl;
    713         lout << "variables and try deleting the array by doing a 'Reset' from APOSS." << endl;
     714        gLog << "Out of memory for variables - Check APOSS predifined number of" << endl;
     715        gLog << "variables and try deleting the array by doing a 'Reset' from APOSS." << endl;
    714716        return;
    715717    case 89:
    716         lout << "CAN I/O error (REOPEN=" << dec << errinf << " " << (errinf==0?"OK":"ERR") << ")" << endl;
     718        gLog << "CAN I/O error (REOPEN=" << dec << errinf << " " << (errinf==0?"OK":"ERR") << ")" << endl;
    717719        return;
    718720
     
    723725
    724726    default:
    725         lout << "Error Nr. " << errnum << ", " << errinf << endl;
     727        gLog << "Error Nr. " << errnum << ", " << errinf << endl;
    726728    }
    727729}
     
    737739    time.Now();
    738740
    739     lout << time << ": " << GetNodeName() << " - PDO3 = ";
     741    gLog << inf << time << ": " << GetNodeName() << " - PDO3 = ";
    740742    const Bool_t ready = data[3]&0x01;
    741743    const Bool_t fuse  = data[3]&0x02;
     
    745747    const Bool_t rf    = data[3]&0x20;
    746748    const Bool_t brake = data[3]&0x40;
    747     if (ready) lout << "DKC-Ready ";
    748     if (fuse)  lout << "FuseOk ";
    749     if (emcy)  lout << "EmcyOk ";
    750     if (vltg)  lout << "OvervoltOk ";
    751     if (mode)  lout << "SwitchToManualMode ";
    752     if (rf)    lout << "RF ";
    753     if (brake) lout << "BrakeOpen ";
    754     lout << endl;
     749    if (ready) gLog << "DKC-Ready ";
     750    if (fuse)  gLog << "FuseOk ";
     751    if (emcy)  gLog << "EmcyOk ";
     752    if (vltg)  gLog << "OvervoltOk ";
     753    if (mode)  gLog << "SwitchToManualMode ";
     754    if (rf)    gLog << "RF ";
     755    if (brake) gLog << "BrakeOpen ";
     756    gLog << endl;
    755757
    756758    fStatusPdo3 = data[3];
     
    780782    // we can go on working 'as usual' Eg. Initialize a Display Update
    781783    //
    782     cout << GetNodeName() << " Handling Error #" << dec << GetError() << endl;
     784    gLog << inf << GetNodeName() << " Handling Error #" << dec << GetError() << endl;
    783785    switch (GetError())
    784786    {
     
    787789    case   9: // zero idx
    788790    case  84: // ON TIME
    789         lout << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;
     791        gLog << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;
    790792        return;
    791793
    792794    case 11:  // software endswitch
    793795    case 25:  // hardware endswitch
    794         lout << "- " << GetNodeName() << ": Cannot handle error 'Endswitch!'" << endl;
     796        gLog << "- " << GetNodeName() << ": Cannot handle error 'Endswitch!'" << endl;
    795797        return;
    796798
     
    805807        */
    806808    default:
    807         lout << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;
     809        gLog << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;
    808810 
    809811    }
     
    850852    WaitForSdo(0x100d);
    851853
    852     lout << "- " << GetNodeName() << ": Hostguarding started (" << dec;
    853     lout << GetLifeTimeFactor() << "*" << GetGuardTime() << "ms)" << endl;
     854    gLog << inf2 << "- " << GetNodeName() << ": Hostguarding started (" << dec;
     855    gLog << GetLifeTimeFactor() << "*" << GetGuardTime() << "ms)" << endl;
    854856}
    855857
     
    866868    WaitForSdo(0x100d);
    867869
    868     lout << "- " << GetNodeName() << ": Hostguarding stopped." << endl;
    869 }
    870 
     870    gLog << inf2 << "- " << GetNodeName() << ": Hostguarding stopped." << endl;
     871}
     872
  • trunk/MagicSoft/Cosy/devdrv/macs.h

    r8811 r8835  
    6868    };
    6969
    70     Macs(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
     70    Macs(const BYTE_t nodeid, const char *name=NULL);
    7171    virtual ~Macs();
    7272
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc

    r8820 r8835  
    11#include "shaftencoder.h"
    22
     3#include <TGLabel.h>       // TGLabel->SetText
     4
     5#include "MLog.h"
     6#include "MLogManip.h"
     7
     8#include "macs.h"
    39#include "network.h"
    410
    5 #include <iostream>        // cout
    6 #include <iomanip>         // setw, setfill
    7 
    8 #include <TGLabel.h>       // TGLabel->SetText
    9 
    10 #include "macs.h"
    11 
    1211ClassImp(ShaftEncoder);
    1312
    1413using namespace std;
    1514
    16 ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out)
    17     : NodeDrv(nodeid, name, out),
     15ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name)
     16    : NodeDrv(nodeid, name),
    1817    fPos(0), fVel(0), fAcc(0), fTurn(0), fTicks(0),
    1918    fDirection(kUndefined), fHysteresisPos(0), fHysteresisNeg(0),
     
    4039    {
    4140    case 0x1000:
    42         lout << "- Model: ";
     41        gLog << inf2 << "- Model: ";
    4342        switch (val&0xffff)
    4443        {
    4544        case 0x0196:
    46             lout << "Shaft Encoder  Type: ";
     45            gLog << inf2 << "Shaft Encoder  Type: ";
    4746            switch ((val>>16)&0xff)
    4847            {
    4948            case 0x01:
    50                 lout << "Singleturn" << endl;
     49                gLog << "Singleturn" << endl;
    5150                return;
    5251            case 0x02:
    53                 lout << "Multiturn" << endl;
     52                gLog << "Multiturn" << endl;
    5453                return;
    5554            default:
    56                 lout << "?" << endl;
     55                gLog << err << "?" << endl;
    5756                SetZombie();
    5857                return;
    5958            }
    6059        default:
    61             lout << "???" << endl;
     60            gLog << err << "???" << endl;
    6261            SetZombie();
    6362            return;
     
    6968
    7069    case 0x100c:
    71         lout << "- Guardtime: " << dec << val << "ms" << endl;
     70        gLog << inf2 << "- Guardtime: " << dec << val << "ms" << endl;
    7271        return;
    7372
    7473    case 0x100d:
    75         lout << "- Lifetimefactor: " << dec << val << endl;
     74        gLog << inf2 << "- Lifetimefactor: " << dec << val << endl;
    7675        return;
    7776
    7877    case 0x100e:
    79         lout << "- CobId for guarding: 0x" << hex << val << endl;
     78        gLog << inf2 << "- CobId for guarding: 0x" << hex << val << endl;
    8079        return;
    8180
    8281    case 0x6000:
    8382    case 0x6500:
    84         lout << "- Counting: " << (val&1 ?"anti-clockwise":"clockwise") << "  ";
    85         lout << "HwTest: " <<   (val&2   ?"on":"off") << "  ";
    86         lout << "Scaling: " <<  (val&4   ?"on":"off") << "  ";
    87         lout << "Modulo: " <<   (val&4096?"on":"off") << endl;
     83        gLog << inf2 << "- Counting: " << (val&1 ?"anti-clockwise":"clockwise") << "  ";
     84        gLog << "HwTest: " <<   (val&2   ?"on":"off") << "  ";
     85        gLog << "Scaling: " <<  (val&4   ?"on":"off") << "  ";
     86        gLog << "Modulo: " <<   (val&4096?"on":"off") << endl;
    8887        return;
    8988
    9089    case 0x6001:
    91         lout << "- Logical Ticks/Revolution: " << dec << val << endl;
     90        gLog << inf2 << "- Logical Ticks/Revolution: " << dec << val << endl;
    9291        return;
    9392
    9493    case 0x6004:
    95         lout << "- Position: " << dec << val << endl;
     94        gLog << inf2 << "- Position: " << dec << val << endl;
    9695        fPos  = val;
    9796        fTurn = 0;
     
    107106
    108107    case 0x6501:
    109         lout << "- Phys. Ticks/Revolution: " << dec << val << endl;
     108        gLog << inf2 << "- Phys. Ticks/Revolution: " << dec << val << endl;
    110109        fTicks = val;
    111110        return;
     
    114113        //if (val==0)
    115114        //    val = 1;  // Single Turn = Multiturn with one turn
    116         lout << "- Number of Revolutions: " << dec << val << endl;
     115        gLog << inf2 << "- Number of Revolutions: " << dec << val << endl;
    117116        fTurns = val;
    118117        return;
     
    120119
    121120    }
    122     cout << hex << setfill('0');
    123     cout << "Sdo=" << idx  << "/" << (int)subidx << ": 0x" << setw(8) << val;
    124     cout << endl;
     121
     122    NodeDrv::HandleSDO(idx, subidx, val, tv);
     123
     124//    gLog << err << hex << setfill('0');
     125//    gLog << "Sdo=" << idx  << "/" << (int)subidx << ": 0x" << setw(8) << val;
     126//    gLog << endl;
    125127}
    126128
     
    134136        case 1:
    135137            //lout << ddev(MLog::eGui);
    136             lout << "- " << GetNodeName() << ": PDOs configured." << endl;
     138            gLog << inf2 << "- " << GetNodeName() << ": PDOs configured." << endl;
    137139            //lout << edev(MLog::eGui);
    138140            return;
     
    145147        case 0:
    146148            //lout << ddev(MLog::eGui);
    147             lout << "- " << GetNodeName() << ": Log.ticks/revolution set." << endl;
     149            gLog << inf2 << "- " << GetNodeName() << ": Log.ticks/revolution set." << endl;
    148150            //lout << edev(MLog::eGui);
    149151            return;
     
    156158        case 0:
    157159            //lout << ddev(MLog::eGui);
    158             lout << "- " << GetNodeName() << ": Max number of ticks set." << endl;
     160            gLog << inf2 << "- " << GetNodeName() << ": Max number of ticks set." << endl;
    159161            //lout << edev(MLog::eGui);
    160162            return;
     
    167169        case 0:
    168170            //lout << ddev(MLog::eGui);
    169             lout << "- " << GetNodeName() << ": Preset value set." << endl;
     171            gLog << inf2 << "- " << GetNodeName() << ": Preset value set." << endl;
    170172            //lout << edev(MLog::eGui);
    171173            return;
     
    356358    // Requesting and checking (FIXME) type of encoder
    357359    //
    358     lout << "- " << GetNodeName() << ": Requesting Hardware Type (0x1000)." << endl;
     360    gLog << inf2 << "- " << GetNodeName() << ": Requesting Hardware Type (0x1000)." << endl;
    359361    RequestSDO(0x1000);
    360362    WaitForSdo(0x1000);
     
    365367    // Read physical ticks per revolution
    366368    //
    367     lout << "- " << GetNodeName() << ": Requesting physical ticks/revolution (SDO 0x6501)." << endl;
     369    gLog << inf2 << "- " << GetNodeName() << ": Requesting physical ticks/revolution (SDO 0x6501)." << endl;
    368370    RequestSDO(0x6501);
    369371    WaitForSdo(0x6501);
     
    372374    // Read number of possible ticks per revolution
    373375    //
    374     lout << "- " << GetNodeName() << ": Requesting possible ticks/revolution (SDO 0x6502)." << endl;
     376    gLog << inf2 << "- " << GetNodeName() << ": Requesting possible ticks/revolution (SDO 0x6502)." << endl;
    375377    RequestSDO(0x6502);
    376378    WaitForSdo(0x6502);
     
    389391    // Set logic ticks/revolution = physical ticks/revolution => scale factor = 1
    390392    //
    391     lout << "- " << GetNodeName() << ": Configuring log. tick/rev (0x6001)." << endl;
     393    gLog << inf2 << "- " << GetNodeName() << ": Configuring log. tick/rev (0x6001)." << endl;
    392394    SendSDO(0x6001, fTicks);
    393395    WaitForSdo(0x6001);
     
    396398    // Set maximum number of ticks (ticks * turns)
    397399    //
    398     lout << "- " << GetNodeName() << ": Configuring max number of ticks (0x6002)." << endl;
     400    gLog << inf2 << "- " << GetNodeName() << ": Configuring max number of ticks (0x6002)." << endl;
    399401    SendSDO(0x6002, (LWORD_t)(fTicks*fTurns));
    400402    WaitForSdo(0x6002);
     
    403405    // Delete preset Value
    404406    //
    405     lout << "- " << GetNodeName() << ": Delete preset value (0x6003)." << endl;
     407    gLog << inf2 << "- " << GetNodeName() << ": Delete preset value (0x6003)." << endl;
    406408    SendSDO(0x6003, (LWORD_t)0xffffffff);
    407409    WaitForSdo(0x6003);
     
    410412    // Configure PDOs
    411413    //
    412     lout << "- " << GetNodeName() << ": Configuring PDOs (0x1802)." << endl;
     414    gLog << inf2 << "- " << GetNodeName() << ": Configuring PDOs (0x1802)." << endl;
    413415    SendSDO(0x1802, 1, (LWORD_t)0x281);
    414416    WaitForSdo(0x1802, 1);
     
    417419    // Request Parameter
    418420    //
    419     lout << "- " << GetNodeName() << ": Requesting SDO 0x6000." << endl;
     421    gLog << inf2 << "- " << GetNodeName() << ": Requesting SDO 0x6000." << endl;
    420422    RequestSDO(0x6000);
    421423    WaitForSdo(0x6000);
     
    423425    ReqPos();
    424426
    425     lout << "- " << GetNodeName() << ": Start Node (NMT)." << endl;
     427    gLog << inf2 << "- " << GetNodeName() << ": Start Node (NMT)." << endl;
    426428    SendNMT(kNMT_START);
    427429
     
    450452    // Request Position
    451453    //
    452     lout << "- " << GetNodeName() << ": Requesting Position." << endl;
     454    gLog << inf2 << "- " << GetNodeName() << ": Requesting Position." << endl;
    453455    RequestSDO(0x6004);
    454456    WaitForSdo(0x6004);
     
    457459void ShaftEncoder::SetPreset(LWORD_t pre)
    458460{
    459     lout << "- " << GetNodeName() << ": Setting Preset." << endl;
     461    gLog << inf2 << "- " << GetNodeName() << ": Setting Preset." << endl;
    460462
    461463    SendSDO(0x6003, (LWORD_t)pre);
     
    476478void ShaftEncoder::StopDevice()
    477479{
    478     lout << "- " << GetNodeName() << ": Stop Node (NMT)." << endl;
     480    gLog << inf2 << "- " << GetNodeName() << ": Stop Node (NMT)." << endl;
    479481    SendNMT(kNMT_STOP);
    480482}
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.h

    r8811 r8835  
    5656
    5757public:
    58     ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
     58    ShaftEncoder(const BYTE_t nodeid, const char *name=NULL);
    5959
    6060    void StopDevice();
Note: See TracChangeset for help on using the changeset viewer.