Changeset 10784 for trunk/FACT++


Ignore:
Timestamp:
05/23/11 15:09:50 (13 years ago)
Author:
tbretz
Message:
Added some code to redirect error output to fadctrl (still commented); replaces stringstream by ostringstream where needed.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilder.h

    r10773 r10784  
    3535extern uint gp_EvtTot   ;
    3636
     37//#define error Error
     38//extern void Error(int severity, int errnum, const char *fmt, ...);
     39
    3740#ifdef __cplusplus
    3841}
  • trunk/FACT++/src/fadctrl.cc

    r10777 r10784  
    103103                err!=ba::error::basic_errors::operation_aborted)  // Connection closed by us
    104104            {
    105                 stringstream str;
     105                ostringstream str;
    106106                str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
    107107                Error(str);
     
    117117            if (fEventHeader.fStartDelimiter!=FAD::kDelimiterStart)
    118118            {
    119                 stringstream str;
     119                ostringstream str;
    120120                str << "Invalid header received: start delimiter wrong, received ";
    121121                str << hex << fEventHeader.fStartDelimiter << ", expected " << FAD::kDelimiterStart << ".";
     
    140140        if (ntohs(fBuffer.back())!=FAD::kDelimiterEnd)
    141141        {
    142             stringstream str;
     142            ostringstream str;
    143143            str << "Invalid data received: end delimiter wrong, received ";
    144144            str << hex << ntohs(fBuffer.back()) << ", expected " << FAD::kDelimiterEnd << ".";
     
    231231        if (error && error!=ba::error::basic_errors::operation_aborted)
    232232        {
    233             stringstream str;
     233            ostringstream str;
    234234            str << "Read timeout of " << URL() << ": " << error.message() << " (" << error << ")";// << endl;
    235235            Error(str);
     
    261261    void PostCmd(std::vector<uint16_t> cmd)
    262262    {
    263         stringstream msg;
     263        ostringstream msg;
    264264        msg << "Sending command:" << hex;
    265265        msg << " 0x" << setw(4) << setfill('0') << cmd[0];
     
    273273    void PostCmd(uint16_t cmd)
    274274    {
    275         stringstream msg;
     275        ostringstream msg;
    276276        msg << "Sending command:" << hex;
    277277        msg << " 0x" << setw(4) << setfill('0') << cmd;
     
    284284    void PostCmd(uint16_t cmd, uint16_t data)
    285285    {
    286         stringstream msg;
     286        ostringstream msg;
    287287        msg << "Sending command:" << hex;
    288288        msg << " 0x" << setw(4) << setfill('0') << cmd;
     
    589589class EventBuilderWrapper
    590590{
     591public:
     592    // FIXME
     593    static EventBuilderWrapper *This;
     594
     595private:
    591596    boost::thread fThread;
    592597
     
    609614    EventBuilderWrapper(MessageImp &msg) : fMsg(msg)
    610615    {
     616        if (This)
     617            throw runtime_error("EventBuilderWrapper cannot be instantiated twice.");
     618
     619        This = this;
    611620        Start();
     621    }
     622
     623    void Update(ostringstream &out, int severity)
     624    {
     625        fMsg.Update(out, severity);
    612626    }
    613627
     
    672686        Abort();
    673687    }
    674 
    675688};
     689/*
     690extern "C" {
     691
     692void Error(int severity, int errnum, const char *fmt, ...)
     693{
     694    va_list ap;
     695    va_start(ap, fmt);
     696
     697    int n=256;
     698
     699    char *ret=0;
     700    while (1)
     701    {
     702        ret = new char[n+1];
     703
     704        const int sz = vsnprintf(ret, n, fmt, ap);
     705        if (sz<=n)
     706            break;
     707
     708        n *= 2;
     709        delete [] ret;
     710    };
     711
     712    va_end(ap);
     713
     714    ostringstream str;
     715    str << ret << " (" << errnum << ":" << strerror(errnum) << ")";
     716
     717    delete [] ret;
     718
     719    EventBuilderWrapper::This->Update(str, severity);
     720}
     721
     722}
     723*/
     724
     725EventBuilderWrapper *EventBuilderWrapper::This = 0;
    676726
    677727// ------------------------------------------------------------------------
     
    696746            return true;
    697747
    698         stringstream msg;
     748        ostringstream msg;
    699749        msg << name << " - Received event has " << has << " bytes, but expected " << size << ".";
    700750        T::Fatal(msg);
     
    725775        if (dat[0]>FAD::kMaxRegAddr)
    726776        {
    727             stringstream msg;
     777            ostringstream msg;
    728778            msg << hex << "Address " << dat[0] << " out of range, max=" << maxaddr << ".";
    729779            T::Error(msg);
     
    733783        if (dat[1]>FAD::kMaxRegValue)
    734784        {
    735             stringstream msg;
     785            ostringstream msg;
    736786            msg << hex << "Value " << dat[1] << " out of range, max=" << maxval << ".";
    737787            T::Error(msg);
     
    840890        if (evt.GetUShort()>0xff)
    841891        {
    842             stringstream msg;
     892            ostringstream msg;
    843893            msg << hex << "Value " << evt.GetUShort() << " out of range, max=" << 0xff << "(?)";
    844894            T::Error(msg);
Note: See TracChangeset for help on using the changeset viewer.