Changeset 10784
- Timestamp:
- 05/23/11 15:09:50 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilder.h
r10773 r10784 35 35 extern uint gp_EvtTot ; 36 36 37 //#define error Error 38 //extern void Error(int severity, int errnum, const char *fmt, ...); 39 37 40 #ifdef __cplusplus 38 41 } -
trunk/FACT++/src/fadctrl.cc
r10777 r10784 103 103 err!=ba::error::basic_errors::operation_aborted) // Connection closed by us 104 104 { 105 stringstream str;105 ostringstream str; 106 106 str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl; 107 107 Error(str); … … 117 117 if (fEventHeader.fStartDelimiter!=FAD::kDelimiterStart) 118 118 { 119 stringstream str;119 ostringstream str; 120 120 str << "Invalid header received: start delimiter wrong, received "; 121 121 str << hex << fEventHeader.fStartDelimiter << ", expected " << FAD::kDelimiterStart << "."; … … 140 140 if (ntohs(fBuffer.back())!=FAD::kDelimiterEnd) 141 141 { 142 stringstream str;142 ostringstream str; 143 143 str << "Invalid data received: end delimiter wrong, received "; 144 144 str << hex << ntohs(fBuffer.back()) << ", expected " << FAD::kDelimiterEnd << "."; … … 231 231 if (error && error!=ba::error::basic_errors::operation_aborted) 232 232 { 233 stringstream str;233 ostringstream str; 234 234 str << "Read timeout of " << URL() << ": " << error.message() << " (" << error << ")";// << endl; 235 235 Error(str); … … 261 261 void PostCmd(std::vector<uint16_t> cmd) 262 262 { 263 stringstream msg;263 ostringstream msg; 264 264 msg << "Sending command:" << hex; 265 265 msg << " 0x" << setw(4) << setfill('0') << cmd[0]; … … 273 273 void PostCmd(uint16_t cmd) 274 274 { 275 stringstream msg;275 ostringstream msg; 276 276 msg << "Sending command:" << hex; 277 277 msg << " 0x" << setw(4) << setfill('0') << cmd; … … 284 284 void PostCmd(uint16_t cmd, uint16_t data) 285 285 { 286 stringstream msg;286 ostringstream msg; 287 287 msg << "Sending command:" << hex; 288 288 msg << " 0x" << setw(4) << setfill('0') << cmd; … … 589 589 class EventBuilderWrapper 590 590 { 591 public: 592 // FIXME 593 static EventBuilderWrapper *This; 594 595 private: 591 596 boost::thread fThread; 592 597 … … 609 614 EventBuilderWrapper(MessageImp &msg) : fMsg(msg) 610 615 { 616 if (This) 617 throw runtime_error("EventBuilderWrapper cannot be instantiated twice."); 618 619 This = this; 611 620 Start(); 621 } 622 623 void Update(ostringstream &out, int severity) 624 { 625 fMsg.Update(out, severity); 612 626 } 613 627 … … 672 686 Abort(); 673 687 } 674 675 688 }; 689 /* 690 extern "C" { 691 692 void 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 725 EventBuilderWrapper *EventBuilderWrapper::This = 0; 676 726 677 727 // ------------------------------------------------------------------------ … … 696 746 return true; 697 747 698 stringstream msg;748 ostringstream msg; 699 749 msg << name << " - Received event has " << has << " bytes, but expected " << size << "."; 700 750 T::Fatal(msg); … … 725 775 if (dat[0]>FAD::kMaxRegAddr) 726 776 { 727 stringstream msg;777 ostringstream msg; 728 778 msg << hex << "Address " << dat[0] << " out of range, max=" << maxaddr << "."; 729 779 T::Error(msg); … … 733 783 if (dat[1]>FAD::kMaxRegValue) 734 784 { 735 stringstream msg;785 ostringstream msg; 736 786 msg << hex << "Value " << dat[1] << " out of range, max=" << maxval << "."; 737 787 T::Error(msg); … … 840 890 if (evt.GetUShort()>0xff) 841 891 { 842 stringstream msg;892 ostringstream msg; 843 893 msg << hex << "Value " << evt.GetUShort() << " out of range, max=" << 0xff << "(?)"; 844 894 T::Error(msg);
Note:
See TracChangeset
for help on using the changeset viewer.