1 #include "daq/slc/runcontrol/RCCommand.h"
3 #include "daq/slc/runcontrol/RCState.h"
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");
18 const RCCommand& RCCommand::operator=(
const std::string& label)
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;
35 const RCCommand& RCCommand::operator=(
int id)
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;
52 const RCCommand& RCCommand::operator=(
const char* label)
54 if (label != NULL) *
this = std::string(label);
55 else *
this = Enum::UNKNOWN;
59 int RCCommand::isAvailable(
const RCState& state)
const
62 if ((cmd == LOAD || cmd == CONFIGURE) &&
63 state == RCState::NOTREADY_S) {
69 }
else if (cmd == START && state == RCState::READY_S) {
71 }
else if (cmd == STOP && (state == RCState::RUNNING_S ||
72 state == RCState::PAUSED_S)) {
74 }
else if (cmd == PAUSE && state == RCState::RUNNING_S) {
76 }
else if (cmd == RESUME && state == RCState::PAUSED_S) {
78 }
else if (cmd == ABORT) {
80 }
else if (cmd == RECOVER && state == RCState::ERROR_ES) {
82 }
else if (cmd == BOOT && state == RCState::NOTREADY_S) {
89 RCState RCCommand::nextState()
const
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;
104 RCState RCCommand::nextTState()
const
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;