Changeset 14586 for trunk/Cosy


Ignore:
Timestamp:
11/08/12 12:11:29 (12 years ago)
Author:
tbretz
Message:
Moved cout to gLog and added a debug file which can be switched on on purpose
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosy/candrv/sdolist.cc

    r8838 r14586  
    11#include "sdolist.h"
    22
    3 #include <iostream>
     3#include "MLog.h"
     4#include "MLogManip.h"
     5
     6#include "MTime.h"
     7
    48
    59ClassImp(PendingSDO);
     
    812using namespace std;
    913
     14#undef DEBUG
     15
     16#ifdef DEBUG
     17#include <fstream>
     18static ofstream fout;
     19#endif
     20
    1021PendingSDOList::PendingSDOList()
    1122{
     23#ifdef DEBUG
     24    fout.open("sdolist.txt", ios::app);
     25    fout.rdbuf()->pubsetbuf(0,0);
     26    fout << hex;
     27#endif
     28
    1229    fFirst = new PendingSDO;
    1330    fLast  = fFirst;
     
    1835    DelAll();
    1936    delete fFirst;
     37
     38#ifdef DEBUG
     39    fout.close();
     40#endif
    2041}
    2142
     
    2344{
    2445    if (fMux.Lock()==13)
    25         cout << "PendingSDOList::DelAll - mutex is already locked by this thread" << endl;
     46        gLog << err << MTime(-1) << " -  PendingSDOList::DelAll - mutex is already locked by this thread" << endl;
     47
     48#ifdef DEBUG
     49    fout << MTime(-1) << " - DelAll" << endl;
     50#endif
    2651
    2752    PendingSDO *prev = fFirst;
     
    3964
    4065    if (fMux.UnLock()==13)
    41         cout << "PendingSDOList::DelAll - tried to unlock mutex locked by other thread." << endl;
     66        gLog << err << MTime(-1) << " -  PendingSDOList::DelAll - tried to unlock mutex locked by other thread." << endl;
    4267}
    4368
     
    4772
    4873    if (fMux.Lock()==13)
    49         cout << "PendingSDOList::Add - mutex is already locked by this thread" << endl;
     74        gLog << err << MTime(-1) << " -  PendingSDOList::Add - mutex is already locked by this thread" << endl;
     75
     76#ifdef DEBUG
     77    fout << MTime(-1) << " - Add " << idx << "/" << subidx << " @ " << node << endl;
     78#endif
     79
    5080    while ((sdo=sdo->Next))
    5181        if (sdo->Node==node && sdo->Idx==idx && sdo->Subidx==subidx)
    5282        {
    53             cout << "Warning: SDO Node #" << dec << (int)node << ", 0x";
    54             cout << hex << idx << "/" << (int)subidx;
    55             cout << " still pending." << endl;
     83            gLog << warn << MTime(-1) << " - SDO Node #" << dec << (int)node << ", 0x";
     84            gLog << hex << idx << "/" << (int)subidx;
     85            gLog << " still pending." << endl;
    5686            break;
    5787        }
     
    6090    fLast = fLast->Next;
    6191    if (fMux.UnLock()==13)
    62         cout << "PendingSDOList::Add - tried to unlock mutex locked by other thread." << endl;
     92        gLog << err << MTime(-1) << " - PendingSDOList::Add - tried to unlock mutex locked by other thread." << endl;
    6393}
    6494
     
    6999
    70100    if (fMux.Lock()==13)
    71         cout << "PendingSDOList::Del - mutex is already locked by this thread" << endl;
     101        gLog << err << MTime(-1) << " -  PendingSDOList::Del - mutex is already locked by this thread" << endl;
     102
     103#ifdef DEBUG
     104    fout << MTime(-1) << " - Del " << idx << "/" << subidx << " @ " << node << endl;
     105#endif
     106
    72107    while ((sdo=prev->Next))
    73108    {
     
    88123    }
    89124    if (fMux.UnLock()==13)
    90         cout << "PendingSDOList::Del - tried to unlock mutex locked by other thread." << endl;
     125        gLog << err <<  MTime(-1) << " - PendingSDOList::Del - tried to unlock mutex locked by other thread." << endl;
    91126}
    92127
     
    102137
    103138    if (fMux.Lock()==13)
    104         cout << "PendingSDOList::IsPending(byte) - mutex is already locked by this thread" << endl;
     139        gLog << err << MTime(-1) << " - PendingSDOList::IsPending(byte) - mutex is already locked by this thread" << endl;
    105140    while ((sdo=sdo->Next))
    106141        if (sdo->Node==node)
     
    110145        }
    111146    if (fMux.UnLock()==13)
    112         cout << "PendingSDOList::IsPending(byte) - tried to unlock mutex locked by other thread." << endl;
     147        gLog << err << MTime(-1) << " - PendingSDOList::IsPending(byte) - tried to unlock mutex locked by other thread." << endl;
    113148
    114149    return rc;
     
    121156
    122157    if (fMux.Lock()==13)
    123         cout << "PendingSDOList::IsPending - mutex is already locked by this thread" << endl;
     158        gLog << err <<  MTime(-1) << " - PendingSDOList::IsPending - mutex is already locked by this thread" << endl;
    124159    while ((sdo=sdo->Next))
    125160        if (sdo->Node==node && sdo->Idx==idx && sdo->Subidx==subidx)
     
    129164        }
    130165    if (fMux.UnLock()==13)
    131         cout << "PendingSDOList::IsPending - tried to unlock mutex locked by other thread." << endl;
     166        gLog << err <<  MTime(-1) << " - PendingSDOList::IsPending - tried to unlock mutex locked by other thread." << endl;
    132167
    133168    return rc;
Note: See TracChangeset for help on using the changeset viewer.