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

Last change on this file since 10319 was 10183, checked in by tbretz, 14 years ago
New import.
File size: 1.7 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 void exitHandler(int code); /// Overwritten DimCommand::exitHandler.
39 void commandHandler(); /// Overwritten DimCommand::commandHandler
40
41 /// Redirect our own logging to fLog
42 int Write(const Time &time, const char *txt, int qos);
43
44 /// This is an internal function to do some action in case of
45 /// a state change, like updating the corresponding service.
46 std::string SetCurrentState(int state, const char *txt="", const std::string &cmd="");
47
48 EventImp *CreateEvent(int targetstate, const char *name, const char *fmt);
49
50public:
51 StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT");
52};
53
54#endif
Note: See TracBrowser for help on using the repository browser.