Changeset 10453
- Timestamp:
- 04/22/11 19:35:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dataLogger.cc
r10451 r10453 51 51 #include "MessageImp.h" 52 52 #include "LocalControl.h" 53 #include "DimDescriptionService.h" 53 54 54 55 #include "Description.h" … … 138 139 static const char* fRunNumberInfo; ///< This is the name of the dimInfo received to specify the run number. It must be updated once the final name will be defined 139 140 ///Inherited from state machine impl 140 int Execute();141 //int Execute(); 141 142 142 143 ///Inherited from state machine impl 143 int Transition(const Event& evt);144 //int Transition(const Event& evt); 144 145 145 146 ///Inherited from state machine impl 146 int Configure(const Event& evt);147 //int Configure(const Event& evt); 147 148 148 149 //overloading of DIM's infoHandler function … … 317 318 char* data = new char[dataSize]; 318 319 memset(data, 0, dataSize); 319 DimService srvc((GetName()+"/STATS").c_str(), "x:2;l:1", static_cast<void*>(data), dataSize); 320 DimDescribedService srvc((GetName()+"/STATS").c_str(), "x:2;l:1", static_cast<void*>(data), dataSize, 321 "Add description here"); 320 322 double deltaT = 1; 321 323 fPreviousSize = 0; … … 384 386 targetRate = (targetSize - fPreviousSize)/deltaT; 385 387 fPreviousSize = targetSize; 386 if (targetRate != 0) //if data has been written388 // if (targetRate != 0) //if data has been written 387 389 { 388 390 std::cout << "fBaseSizeDaily: " << fBaseSizeDaily << " fBaseSizeRun: " << fBaseSizeRun << std::endl; … … 413 415 #endif 414 416 //Give a name to this machine's specific states 415 AddStateName(kSM_DailyOpen, "DailyFileOpen" );416 AddStateName(kSM_WaitingRun, "WaitForRun" );417 AddStateName(kSM_Logging, "Logging" );418 AddStateName(kSM_BadDailyConfig, "ErrDailyFolder" );419 AddStateName(kSM_BadRunConfig, "ErrRunFolder" );417 AddStateName(kSM_DailyOpen, "DailyFileOpen", "Add description here"); 418 AddStateName(kSM_WaitingRun, "WaitForRun", "Add description here"); 419 AddStateName(kSM_Logging, "Logging", "Add description here"); 420 AddStateName(kSM_BadDailyConfig, "ErrDailyFolder", "Add description here"); 421 AddStateName(kSM_BadRunConfig, "ErrRunFolder", "Add description here"); 420 422 421 423 /*Add the possible transitions for this machine*/ 422 424 423 //start the daily logging. daily file location must be specified already 424 AddTransition(kSM_DailyOpen, fTransStart, kSM_Ready, kSM_BadDailyConfig). 425 AssignFunction(boost::bind(&DataLogger::StartPlease, this)); 426 427 //stop the data logging 428 AddTransition(kSM_Ready, fTransStop, kSM_DailyOpen, kSM_WaitingRun, kSM_Logging). 429 AssignFunction(boost::bind(&DataLogger::GoToReadyPlease, this)); 430 431 //start the run logging. run file location must be specified already. 432 AddTransition(kSM_Logging, fTransStartRun, kSM_WaitingRun, kSM_BadRunConfig). 433 AssignFunction(boost::bind(&DataLogger::StartRunPlease, this)); 434 435 AddTransition(kSM_WaitingRun, fTransStopRun, kSM_Logging). 436 AssignFunction(boost::bind(&DataLogger::StopRunPlease, this)); 437 438 //transition to exit error states. dunno if required or not, would close the daily file if already openned. 439 AddTransition(kSM_Ready, fTransReset, kSM_Error, kSM_BadDailyConfig, kSM_BadRunConfig, kSM_Error). 440 AssignFunction(boost::bind(&DataLogger::GoToReadyPlease, this)); 441 442 AddTransition(kSM_WaitingRun, fTransWait, kSM_DailyOpen). 443 AssignFunction(boost::bind(&DataLogger::DailyToWaitRunPlease, this)); 425 AddTransition(kSM_DailyOpen, fTransStart, kSM_Ready, kSM_BadDailyConfig) 426 (boost::bind(&DataLogger::StartPlease, this)) 427 ("start the daily logging. daily file location must be specified already"); 428 429 AddTransition(kSM_Ready, fTransStop, kSM_DailyOpen, kSM_WaitingRun, kSM_Logging) 430 (boost::bind(&DataLogger::GoToReadyPlease, this)) 431 ("stop the data logging"); 432 433 AddTransition(kSM_Logging, fTransStartRun, kSM_WaitingRun, kSM_BadRunConfig) 434 (boost::bind(&DataLogger::StartRunPlease, this)) 435 ("start the run logging. run file location must be specified already."); 436 437 AddTransition(kSM_WaitingRun, fTransStopRun, kSM_Logging) 438 (boost::bind(&DataLogger::StopRunPlease, this)) 439 (""); 440 441 AddTransition(kSM_Ready, fTransReset, kSM_Error, kSM_BadDailyConfig, kSM_BadRunConfig, kSM_Error) 442 (boost::bind(&DataLogger::GoToReadyPlease, this)) 443 ("transition to exit error states. dunno if required or not, would close the daily file if already openned."); 444 445 AddTransition(kSM_WaitingRun, fTransWait, kSM_DailyOpen) 446 (boost::bind(&DataLogger::DailyToWaitRunPlease, this)); 444 447 445 448 /*Add the possible configurations for this machine*/ 446 449 447 //configure the daily file location. cannot be done before the file is actually opened448 AddConfiguration(fConfigDay, "C", kSM_Ready, kSM_BadDailyConfig). 449 AssignFunction(boost::bind(&DataLogger::ConfigureDailyFileName, this, _1));450 451 //configure the run file location. cannot be done before the file is actually opened, and not in a dailly related error.452 AddConfiguration(fConfigRun, "C", kSM_Ready, kSM_BadDailyConfig, kSM_DailyOpen, kSM_WaitingRun, kSM_BadRunConfig). 453 AssignFunction(boost::bind(&DataLogger::ConfigureRunFileName, this, _1));450 AddConfiguration(fConfigDay, "C", kSM_Ready, kSM_BadDailyConfig) 451 (boost::bind(&DataLogger::ConfigureDailyFileName, this, _1)) 452 ("configure the daily file location. cannot be done before the file is actually opened"); 453 454 AddConfiguration(fConfigRun, "C", kSM_Ready, kSM_BadDailyConfig, kSM_DailyOpen, kSM_WaitingRun, kSM_BadRunConfig) 455 (boost::bind(&DataLogger::ConfigureRunFileName, this, _1)) 456 ("configure the run file location. cannot be done before the file is actually opened, and not in a dailly related error."); 454 457 455 458 //Provide a logging command 456 459 //I get the feeling that I should be going through the EventImp 457 //instead of DimCommand directly, mainly because the commandHandler 458 459 460 AddConfiguration(fConfigLog, "C", kSM_DailyOpen, kSM_Logging, kSM_WaitingRun, kSM_BadRunConfig). 461 AssignFunction(boost::bind(&DataLogger::LogMessagePlease, this, _1));460 //instead of DimCommand directly, mainly because the commandHandler 461 //is already done in StateMachineImp.cc 462 //Thus I'll simply add a configuration, which I will treat as the logging command 463 AddConfiguration(fConfigLog, "C", kSM_DailyOpen, kSM_Logging, kSM_WaitingRun, kSM_BadRunConfig) 464 (boost::bind(&DataLogger::LogMessagePlease, this, _1)); 462 465 463 466 fServiceList.SetHandler(this); … … 474 477 fDimBuffer[sizeof(int)] = '\0'; 475 478 //gives the entire buffer size. Otherwise, dim overwrites memory at bizarre locations if smaller size is given at creation time. 476 fOpenedFiles = new DimService((GetName()+"/FILENAME").c_str(), "i:1;C", static_cast<void*>(fDimBuffer), 256); 479 fOpenedFiles = new DimDescribedService((GetName()+"/FILENAME").c_str(), "i:1;C", static_cast<void*>(fDimBuffer), 256, 480 "Add description here"); 477 481 478 482 … … 587 591 #endif 588 592 } 593 /* 589 594 // -------------------------------------------------------------------------- 590 595 // … … 623 628 { 624 629 case kSM_Ready: 625 / *here we must figure out whether the STOP or RESET command was sent*/626 / *close opened files and go back to ready state*/630 //here we must figure out whether the STOP or RESET command was sent 631 //close opened files and go back to ready state 627 632 switch (GetCurrentState()) 628 633 { … … 640 645 641 646 case kSM_DailyOpen: 642 / *Attempt to open the daily file */647 //Attempt to open the daily file 643 648 switch (GetCurrentState()) 644 649 { … … 650 655 651 656 case kSM_WaitingRun: 652 / *either close the run file, or just go to the waitingrun state (if coming from daily open*/657 //either close the run file, or just go to the waitingrun state (if coming from daily open 653 658 switch (GetCurrentState()) 654 659 { … … 662 667 663 668 case kSM_Logging: 664 / *Attempt to open run file */669 //Attempt to open run file 665 670 switch (GetCurrentState()) 666 671 { … … 706 711 return kSM_FatalError; 707 712 } 713 */ 708 714 // -------------------------------------------------------------------------- 709 715 // … … 855 861 856 862 } 863 857 864 // -------------------------------------------------------------------------- 858 865 //
Note:
See TracChangeset
for help on using the changeset viewer.