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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.