Changeset 10453


Ignore:
Timestamp:
04/22/11 19:35:49 (14 years ago)
Author:
tbretz
Message:
Commented unused functions; fixed a bug in the naming of the services; replaced DimService by DimDescribedService; added dummy descriptions to states and events.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/dataLogger.cc

    r10451 r10453  
    5151#include "MessageImp.h"
    5252#include "LocalControl.h"
     53#include "DimDescriptionService.h"
    5354
    5455#include "Description.h"
     
    138139        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
    139140        ///Inherited from state machine impl
    140         int Execute();
     141        //int Execute();
    141142       
    142143        ///Inherited from state machine impl
    143         int Transition(const Event& evt);
     144        //int Transition(const Event& evt);
    144145       
    145146        ///Inherited from state machine impl
    146         int Configure(const Event& evt);
     147        //int Configure(const Event& evt);
    147148       
    148149        //overloading of DIM's infoHandler function
     
    317318                char* data = new char[dataSize];
    318319                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");
    320322                double deltaT = 1;
    321323                fPreviousSize = 0;
     
    384386                        targetRate = (targetSize - fPreviousSize)/deltaT; 
    385387                        fPreviousSize = targetSize;
    386                         if (targetRate != 0) //if data has been written
     388//                      if (targetRate != 0) //if data has been written
    387389                        {
    388390std::cout << "fBaseSizeDaily: " << fBaseSizeDaily << " fBaseSizeRun: " << fBaseSizeRun << std::endl;
     
    413415#endif
    414416                //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");
    420422
    421423        /*Add the possible transitions for this machine*/
    422424
    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));
    444447
    445448        /*Add the possible configurations for this machine*/
    446449       
    447         //configure the daily file location. cannot be done before the file is actually opened
    448                 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.");
    454457
    455458                //Provide a logging command
    456459                //I get the feeling that I should be going through the EventImp
    457                 //instead of DimCommand directly, mainly because the commandHandler
    458                 //is already done in StateMachineImp.cc
    459                 //Thus I'll simply add a configuration, which I will treat as the logging command
    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));
    462465
    463466                fServiceList.SetHandler(this);
     
    474477                fDimBuffer[sizeof(int)] = '\0';
    475478                //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");
    477481               
    478482               
     
    587591#endif
    588592}
     593/*
    589594// --------------------------------------------------------------------------
    590595//
     
    623628        {
    624629                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
    627632                        switch (GetCurrentState())
    628633                        {
     
    640645               
    641646                case kSM_DailyOpen:
    642                         /*Attempt to open the daily file */
     647                        //Attempt to open the daily file
    643648                        switch (GetCurrentState())
    644649                        {
     
    650655               
    651656                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
    653658                        switch (GetCurrentState())
    654659                        {
     
    662667               
    663668                case kSM_Logging:
    664                         /*Attempt to open run file */
     669                        //Attempt to open run file
    665670                        switch (GetCurrentState())
    666671                        {
     
    706711        return kSM_FatalError;
    707712}
     713*/
    708714// --------------------------------------------------------------------------
    709715//
     
    855861
    856862}
     863
    857864// --------------------------------------------------------------------------
    858865//
Note: See TracChangeset for help on using the changeset viewer.