Changeset 11115
- Timestamp:
- 06/22/11 19:55:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fscctrl.cc
r11076 r11115 37 37 38 38 bool fIsVerbose; 39 bool fDump; 40 41 ofstream fDumpStream; 39 42 40 43 protected: … … 68 71 } 69 72 */ 73 74 void Dump(const string &str) 75 { 76 if (!fDumpStream.is_open()) 77 { 78 fDumpStream.open("socket_dump-fsc.txt", ios::app); 79 if (!fDumpStream) 80 { 81 //ostringstream str; 82 //str << "Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")"; 83 //Error(str); 84 85 return; 86 } 87 } 88 89 fDumpStream << str << endl; 90 } 70 91 71 92 private: … … 93 114 94 115 if (fIsVerbose) 95 Out() << kBold << "Received :" << endl;116 Out() << kBold << "Received (" << bytes_received << " bytes):" << endl; 96 117 97 118 /* … … 124 145 const unsigned int HUMI_OFF = 110; 125 146 const unsigned int TEMP_OFF = 134; 126 */ 147 */ 148 149 if (fDump) 150 { 151 ostringstream msg; 152 msg << "--- " << Time().GetAsStr() << " --- received " << bytes_received << " bytes."; 153 Dump(msg.str()); 154 } 155 156 127 157 istream is(&fBuffer); 128 158 … … 140 170 if (fIsVerbose) 141 171 Out() << buffer << endl; 172 if (fDump) 173 Dump(buffer); 142 174 143 175 buffer = Tools::Trim(buffer); … … 269 301 public: 270 302 ConnectionFSC(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()), 271 fIsVerbose(true) 303 fIsVerbose(true), fDump(false) 272 304 { 273 305 SetLogStream(&imp); … … 277 309 { 278 310 fIsVerbose = b; 311 } 312 313 void SetDumpStream(bool b) 314 { 315 fDump = b; 279 316 } 280 317 }; … … 423 460 } 424 461 462 int SetDumpStream(const EventImp &evt) 463 { 464 if (!CheckEventSize(evt.GetSize(), "SetDumpStream", 1)) 465 return T::kSM_FatalError; 466 467 fFSC.SetDumpStream(evt.GetBool()); 468 469 return T::GetCurrentState(); 470 } 471 425 472 public: 426 473 StateMachineFSC(ostream &out=cout) : … … 443 490 444 491 // Verbosity commands 445 T::AddEvent("SET_VERBOSE", "B ")492 T::AddEvent("SET_VERBOSE", "B:1") 446 493 (boost::bind(&StateMachineFSC::SetVerbosity, this, _1)) 447 494 ("set verbosity state" 448 495 "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data"); 496 497 T::AddEvent("DUMP_STREAM", "B:1") 498 (boost::bind(&StateMachineFSC::SetDumpStream, this, _1)) 499 ("" 500 ""); 449 501 450 502 // Conenction commands
Note:
See TracChangeset
for help on using the changeset viewer.