Belle II Software  release-05-01-25
RCCommand.cc
1 #include "daq/slc/runcontrol/RCCommand.h"
2 
3 #include "daq/slc/runcontrol/RCState.h"
4 
5 using namespace Belle2;
6 
7 const RCCommand RCCommand::CONFIGURE(101, "RC_CONFIGURE");
8 const RCCommand RCCommand::LOAD(102, "RC_LOAD");
9 const RCCommand RCCommand::START(103, "RC_START");
10 const RCCommand RCCommand::STOP(104, "RC_STOP");
11 const RCCommand RCCommand::RESUME(105, "RC_RESUME");
12 const RCCommand RCCommand::PAUSE(106, "RC_PAUSE");
13 const RCCommand RCCommand::RECOVER(107, "RC_RECOVER");
14 const RCCommand RCCommand::ABORT(108, "RC_ABORT");
15 const RCCommand RCCommand::BOOT(109, "RC_BOOT");
16 const RCCommand RCCommand::STATUS(110, "RC_STATUS");
17 
18 const RCCommand& RCCommand::operator=(const std::string& label)
19 {
20  if (NSMCommand::operator=(label) != Enum::UNKNOWN) return *this;
21  else if (label == CONFIGURE.getLabel()) *this = CONFIGURE;
22  else if (label == LOAD.getLabel()) *this = LOAD;
23  else if (label == START.getLabel()) *this = START;
24  else if (label == STOP.getLabel()) *this = STOP;
25  else if (label == RECOVER.getLabel()) *this = RECOVER;
26  else if (label == RESUME.getLabel()) *this = RESUME;
27  else if (label == PAUSE.getLabel()) *this = PAUSE;
28  else if (label == ABORT.getLabel()) *this = ABORT;
29  else if (label == BOOT.getLabel()) *this = BOOT;
30  else if (label == STATUS.getLabel()) *this = STATUS;
31  else *this = Enum::UNKNOWN;
32  return *this;
33 }
34 
35 const RCCommand& RCCommand::operator=(int id)
36 {
37  if (NSMCommand::operator=(id) != Enum::UNKNOWN) return *this;
38  else if (id == CONFIGURE.getId()) *this = CONFIGURE;
39  else if (id == LOAD.getId()) *this = LOAD;
40  else if (id == START.getId()) *this = START;
41  else if (id == STOP.getId()) *this = STOP;
42  else if (id == RECOVER.getId()) *this = RECOVER;
43  else if (id == RESUME.getId()) *this = RESUME;
44  else if (id == PAUSE.getId()) *this = PAUSE;
45  else if (id == ABORT.getId()) *this = ABORT;
46  else if (id == BOOT.getId()) *this = BOOT;
47  else if (id == STATUS.getId()) *this = STATUS;
48  else *this = Enum::UNKNOWN;
49  return *this;
50 }
51 
52 const RCCommand& RCCommand::operator=(const char* label)
53 {
54  if (label != NULL) *this = std::string(label);
55  else *this = Enum::UNKNOWN;
56  return *this;
57 }
58 
59 int RCCommand::isAvailable(const RCState& state) const
60 {
61  const RCCommand& cmd(*this);
62  if ((cmd == LOAD || cmd == CONFIGURE) &&
63  state == RCState::NOTREADY_S) {
64  return SUGGESTED;
65  /* } else if ((cmd == LOAD || cmd == CONFIGURE) &&
66  state == RCState::READY_S) {
67  return ENABLED;
68  */
69  } else if (cmd == START && state == RCState::READY_S) {
70  return SUGGESTED;
71  } else if (cmd == STOP && (state == RCState::RUNNING_S ||
72  state == RCState::PAUSED_S)) {
73  return SUGGESTED;
74  } else if (cmd == PAUSE && state == RCState::RUNNING_S) {
75  return ENABLED;
76  } else if (cmd == RESUME && state == RCState::PAUSED_S) {
77  return ENABLED;
78  } else if (cmd == ABORT) {
79  return ENABLED;
80  } else if (cmd == RECOVER && state == RCState::ERROR_ES) {
81  return ENABLED;
82  } else if (cmd == BOOT && state == RCState::NOTREADY_S) {
83  return ENABLED;
84  } else {
85  return DISABLED;
86  }
87 }
88 
89 RCState RCCommand::nextState() const
90 {
91  const RCCommand& cmd(*this);
92  if (cmd == LOAD) return RCState::READY_S;
93  else if (cmd == START) return RCState::RUNNING_S;
94  else if (cmd == STOP) return RCState::READY_S;
95  else if (cmd == RESUME) return RCState::RUNNING_S;
96  else if (cmd == PAUSE) return RCState::PAUSED_S;
97  else if (cmd == RECOVER) return RCState::READY_S;
98  else if (cmd == ABORT) return RCState::NOTREADY_S;
99  else if (cmd == BOOT) return RCState::NOTREADY_S;
100  else if (cmd == CONFIGURE) return RCState::NOTREADY_S;
101  else return Enum::UNKNOWN;
102 }
103 
104 RCState RCCommand::nextTState() const
105 {
106  const RCCommand& cmd(*this);
107  if (cmd == CONFIGURE) return RCState::CONFIGURING_TS;
108  else if (cmd == LOAD) return RCState::LOADING_TS;
109  else if (cmd == START) return RCState::STARTING_TS;
110  else if (cmd == STOP) return RCState::STOPPING_TS;
111  else if (cmd == RESUME) return RCState::RUNNING_S;
112  else if (cmd == PAUSE) return RCState::PAUSED_S;
113  else if (cmd == RECOVER) return RCState::RECOVERING_RS;
114  else if (cmd == ABORT) return RCState::ABORTING_RS;
115  else if (cmd == BOOT) return RCState::BOOTING_RS;
116  else return Enum::UNKNOWN;
117 }
Belle2::RCCommand
Definition: RCCommand.h:14
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RCState
Definition: RCState.h:12