8 #include "daq/slc/runcontrol/RCCommand.h"
10 #include "daq/slc/runcontrol/RCState.h"
14 const RCCommand RCCommand::CONFIGURE(101,
"RC_CONFIGURE");
15 const RCCommand RCCommand::LOAD(102,
"RC_LOAD");
16 const RCCommand RCCommand::START(103,
"RC_START");
17 const RCCommand RCCommand::STOP(104,
"RC_STOP");
18 const RCCommand RCCommand::RESUME(105,
"RC_RESUME");
19 const RCCommand RCCommand::PAUSE(106,
"RC_PAUSE");
20 const RCCommand RCCommand::RECOVER(107,
"RC_RECOVER");
21 const RCCommand RCCommand::ABORT(108,
"RC_ABORT");
22 const RCCommand RCCommand::BOOT(109,
"RC_BOOT");
23 const RCCommand RCCommand::STATUS(110,
"RC_STATUS");
25 const RCCommand& RCCommand::operator=(
const std::string& label)
27 if (NSMCommand::operator=(label) != Enum::UNKNOWN)
return *
this;
28 else if (label == CONFIGURE.getLabel()) *
this = CONFIGURE;
29 else if (label == LOAD.getLabel()) *
this = LOAD;
30 else if (label == START.getLabel()) *
this = START;
31 else if (label == STOP.getLabel()) *
this = STOP;
32 else if (label == RECOVER.getLabel()) *
this = RECOVER;
33 else if (label == RESUME.getLabel()) *
this = RESUME;
34 else if (label == PAUSE.getLabel()) *
this = PAUSE;
35 else if (label == ABORT.getLabel()) *
this = ABORT;
36 else if (label == BOOT.getLabel()) *
this = BOOT;
37 else if (label == STATUS.getLabel()) *
this = STATUS;
38 else *
this = Enum::UNKNOWN;
42 const RCCommand& RCCommand::operator=(
int id)
44 if (NSMCommand::operator=(
id) != Enum::UNKNOWN)
return *
this;
45 else if (
id == CONFIGURE.getId()) *
this = CONFIGURE;
46 else if (
id == LOAD.getId()) *
this = LOAD;
47 else if (
id == START.getId()) *
this = START;
48 else if (
id == STOP.getId()) *
this = STOP;
49 else if (
id == RECOVER.getId()) *
this = RECOVER;
50 else if (
id == RESUME.getId()) *
this = RESUME;
51 else if (
id == PAUSE.getId()) *
this = PAUSE;
52 else if (
id == ABORT.getId()) *
this = ABORT;
53 else if (
id == BOOT.getId()) *
this = BOOT;
54 else if (
id == STATUS.getId()) *
this = STATUS;
55 else *
this = Enum::UNKNOWN;
59 const RCCommand& RCCommand::operator=(
const char* label)
61 if (label != NULL) *
this = std::string(label);
62 else *
this = Enum::UNKNOWN;
66 int RCCommand::isAvailable(
const RCState& state)
const
69 if ((cmd == LOAD || cmd == CONFIGURE) &&
70 state == RCState::NOTREADY_S) {
76 }
else if (cmd == START && state == RCState::READY_S) {
78 }
else if (cmd == STOP && (state == RCState::RUNNING_S ||
79 state == RCState::PAUSED_S)) {
81 }
else if (cmd == PAUSE && state == RCState::RUNNING_S) {
83 }
else if (cmd == RESUME && state == RCState::PAUSED_S) {
85 }
else if (cmd == ABORT) {
87 }
else if (cmd == RECOVER && state == RCState::ERROR_ES) {
89 }
else if (cmd == BOOT && state == RCState::NOTREADY_S) {
96 RCState RCCommand::nextState()
const
99 if (cmd == LOAD)
return RCState::READY_S;
100 else if (cmd == START)
return RCState::RUNNING_S;
101 else if (cmd == STOP)
return RCState::READY_S;
102 else if (cmd == RESUME)
return RCState::RUNNING_S;
103 else if (cmd == PAUSE)
return RCState::PAUSED_S;
104 else if (cmd == RECOVER)
return RCState::READY_S;
105 else if (cmd == ABORT)
return RCState::NOTREADY_S;
106 else if (cmd == BOOT)
return RCState::NOTREADY_S;
107 else if (cmd == CONFIGURE)
return RCState::NOTREADY_S;
108 else return Enum::UNKNOWN;
111 RCState RCCommand::nextTState()
const
114 if (cmd == CONFIGURE)
return RCState::CONFIGURING_TS;
115 else if (cmd == LOAD)
return RCState::LOADING_TS;
116 else if (cmd == START)
return RCState::STARTING_TS;
117 else if (cmd == STOP)
return RCState::STOPPING_TS;
118 else if (cmd == RESUME)
return RCState::RUNNING_S;
119 else if (cmd == PAUSE)
return RCState::PAUSED_S;
120 else if (cmd == RECOVER)
return RCState::RECOVERING_RS;
121 else if (cmd == ABORT)
return RCState::ABORTING_RS;
122 else if (cmd == BOOT)
return RCState::BOOTING_RS;
123 else return Enum::UNKNOWN;
Abstract base class for different kinds of events.