1 #ifndef _ots_VStateMachine_h_
2 #define _ots_VStateMachine_h_
8 class CoreSupervisorBase;
13 VStateMachine(
const std::string& name) : iterationIndex_(0), subIterationIndex_(0), iterationWorkFlag_(
false), subIterationWorkFlag_(
false), name_(name)
20 virtual void configure(
void) = 0;
21 virtual void halt(
void) = 0;
22 virtual void pause(
void) = 0;
23 virtual void resume(
void) = 0;
24 virtual void start(std::string runNumber) = 0;
25 virtual void stop(
void) = 0;
28 virtual bool running(
void) {
return false; }
29 virtual void paused(
void) { ; }
30 virtual void halted(
void) { ; }
31 virtual void configured(
void) { ; }
32 virtual void initial(
void) { ; }
33 virtual void inError(
void) { ; }
39 virtual std::string getStatusProgressDetail(
void)
41 std::string progress =
"";
43 if(VStateMachine::getSubIterationWork())
46 progress += name_ +
":";
49 if(iterationAliasMap_.find(transitionName_) != iterationAliasMap_.end() &&
50 iterationAliasMap_.at(transitionName_).find(VStateMachine::getIterationIndex()) != iterationAliasMap_.at(transitionName_).end())
51 progress += iterationAliasMap_.at(transitionName_).at(VStateMachine::getIterationIndex());
53 progress += std::to_string(VStateMachine::getIterationIndex());
58 if(subIterationAliasMap_.find(transitionName_) != subIterationAliasMap_.end() &&
59 subIterationAliasMap_.at(transitionName_).find(VStateMachine::getSubIterationIndex()) != subIterationAliasMap_.at(transitionName_).end())
60 progress += subIterationAliasMap_.at(transitionName_).at(VStateMachine::getSubIterationIndex());
62 progress += std::to_string(VStateMachine::getSubIterationIndex());
64 else if(VStateMachine::getIterationWork())
67 progress += name_ +
":";
70 if(iterationAliasMap_.find(transitionName_) != iterationAliasMap_.end() &&
71 iterationAliasMap_.at(transitionName_).find(VStateMachine::getIterationIndex()) != iterationAliasMap_.at(transitionName_).end())
72 progress += iterationAliasMap_.at(transitionName_).at(VStateMachine::getIterationIndex());
74 progress += std::to_string(VStateMachine::getIterationIndex());
76 else if(transitionName_ !=
"")
77 progress += name_ +
":" + transitionName_;
86 void setTransitionName (
const std::string& transitionName) { transitionName_ = transitionName; }
87 const std::string& getTransitionName (
void) {
return transitionName_;}
88 void setIterationIndex (
unsigned int i) { iterationIndex_ = i; }
89 void setSubIterationIndex (
unsigned int i) { subIterationIndex_ = i; }
90 unsigned int getIterationIndex (
void) {
return iterationIndex_; }
91 unsigned int getSubIterationIndex(
void) {
return subIterationIndex_; }
92 void indicateIterationWork(
void) { iterationWorkFlag_ =
true; }
93 void clearIterationWork(
void) { iterationWorkFlag_ =
false; }
94 bool getIterationWork(
void) {
return iterationWorkFlag_; }
95 void indicateSubIterationWork(
void) { subIterationWorkFlag_ =
true; }
96 void clearSubIterationWork(
void) { subIterationWorkFlag_ =
false; }
97 bool getSubIterationWork(
void) {
return subIterationWorkFlag_; }
102 std::map<std::string , std::map<
unsigned int , std::string >> iterationAliasMap_;
103 std::map<std::string , std::map<
unsigned int , std::string >> subIterationAliasMap_;
106 unsigned int iterationIndex_, subIterationIndex_;
107 bool iterationWorkFlag_, subIterationWorkFlag_;
108 const std::string name_;
109 std::string transitionName_;