source: trunk/FACT++/src/StateMachineDim.h@ 10380

Last change on this file since 10380 was 10379, checked in by tbretz, 14 years ago
Added service to provide the STATE_LIST with the available descriptions of the states.
File size: 2.0 KB
Line 
1#ifndef FACT_StateMachineDim
2#define FACT_StateMachineDim
3
4#include "MessageDim.h" // MessageDimTX
5#include "StateMachine.h" // StateMachien
6
7// ***************************************************************************
8/**
9 @class DimStart
10
11 @brief Ensures calling DimServer::start() in its constructor and DimServer::stop() in its destructor
12
13**/
14// ***************************************************************************
15#include "DimErrorRedirecter.h"
16
17class DimStart : public DimErrorRedirecter
18{
19protected:
20 DimStart(const std::string &name, MessageImp &imp) : DimErrorRedirecter(imp)
21 {
22 DimServer::addErrorHandler(this);
23 DimServer::start(name.c_str());
24 }
25 ~DimStart() { DimServer::stop(); }
26};
27
28class StateMachineDim : public DimCommandHandler, public DimExitHandler, public StateMachine, public DimStart
29{
30private:
31 MessageDimTX fLog; /// Logging to the Dim network
32
33 static const int fVersion; /// Version number
34
35 DimService fSrvState; /// DimService offering fCurrentState
36 DimService fSrvVersion; /// DimService offering fVersion
37
38 DimService fDescriptionStates; /// DimService propagating the state descriptions
39
40 void exitHandler(int code); /// Overwritten DimCommand::exitHandler.
41 void commandHandler(); /// Overwritten DimCommand::commandHandler
42
43 /// Redirect our own logging to fLog
44 int Write(const Time &time, const std::string &txt, int qos);
45
46 /// This is an internal function to do some action in case of
47 /// a state change, like updating the corresponding service.
48 std::string SetCurrentState(int state, const char *txt="", const std::string &cmd="");
49
50 EventImp *CreateEvent(int targetstate, const char *name, const char *fmt);
51
52public:
53 StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT");
54
55 void AddStateName(const int state, const std::string &name, const std::string &doc="");
56 void DistStateName(const int state, const std::string &name, const std::string &doc="");
57};
58
59#endif
Note: See TracBrowser for help on using the repository browser.