8#include "daq/slc/runcontrol/RCCommand.h"
10#include "daq/slc/runcontrol/RCState.h"
14const RCCommand RCCommand::CONFIGURE(101,
"RC_CONFIGURE");
15const RCCommand RCCommand::LOAD(102,
"RC_LOAD");
16const RCCommand RCCommand::START(103,
"RC_START");
17const RCCommand RCCommand::STOP(104,
"RC_STOP");
18const RCCommand RCCommand::RESUME(105,
"RC_RESUME");
19const RCCommand RCCommand::PAUSE(106,
"RC_PAUSE");
20const RCCommand RCCommand::RECOVER(107,
"RC_RECOVER");
21const RCCommand RCCommand::ABORT(108,
"RC_ABORT");
22const RCCommand RCCommand::BOOT(109,
"RC_BOOT");
23const RCCommand RCCommand::STATUS(110,
"RC_STATUS");
34 if (NSMCommand::operator=(label) != Enum::UNKNOWN)
return *
this;
35 else if (label == CONFIGURE.getLabel()) *
this = CONFIGURE;
36 else if (label == LOAD.getLabel()) *
this = LOAD;
37 else if (label == START.getLabel()) *
this = START;
38 else if (label == STOP.getLabel()) *
this = STOP;
39 else if (label == RECOVER.getLabel()) *
this = RECOVER;
40 else if (label == RESUME.getLabel()) *
this = RESUME;
41 else if (label == PAUSE.getLabel()) *
this = PAUSE;
42 else if (label == ABORT.getLabel()) *
this = ABORT;
43 else if (label == BOOT.getLabel()) *
this = BOOT;
44 else if (label == STATUS.getLabel()) *
this = STATUS;
45 else *
this = Enum::UNKNOWN;
52 if (NSMCommand::operator=(
id) != Enum::UNKNOWN)
return *
this;
53 else if (
id == CONFIGURE.getId()) *
this = CONFIGURE;
54 else if (
id == LOAD.getId()) *
this = LOAD;
55 else if (
id == START.getId()) *
this = START;
56 else if (
id == STOP.getId()) *
this = STOP;
57 else if (
id == RECOVER.getId()) *
this = RECOVER;
58 else if (
id == RESUME.getId()) *
this = RESUME;
59 else if (
id == PAUSE.getId()) *
this = PAUSE;
60 else if (
id == ABORT.getId()) *
this = ABORT;
61 else if (
id == BOOT.getId()) *
this = BOOT;
62 else if (
id == STATUS.getId()) *
this = STATUS;
63 else *
this = Enum::UNKNOWN;
70 if (label != NULL) *
this = std::string(label);
71 else *
this = Enum::UNKNOWN;
75int RCCommand::isAvailable(
const RCState& state)
const
77 const RCCommand& cmd(*
this);
78 if ((cmd == LOAD || cmd == CONFIGURE) &&
79 state == RCState::NOTREADY_S) {
85 }
else if (cmd == START && state == RCState::READY_S) {
87 }
else if (cmd == STOP && (state == RCState::RUNNING_S ||
88 state == RCState::PAUSED_S)) {
90 }
else if (cmd == PAUSE && state == RCState::RUNNING_S) {
92 }
else if (cmd == RESUME && state == RCState::PAUSED_S) {
94 }
else if (cmd == ABORT) {
96 }
else if (cmd == RECOVER && state == RCState::ERROR_ES) {
98 }
else if (cmd == BOOT && state == RCState::NOTREADY_S) {
105RCState RCCommand::nextState()
const
107 const RCCommand& cmd(*
this);
108 if (cmd == LOAD)
return RCState::READY_S;
109 else if (cmd == START)
return RCState::RUNNING_S;
110 else if (cmd == STOP)
return RCState::READY_S;
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::READY_S;
114 else if (cmd == ABORT)
return RCState::NOTREADY_S;
115 else if (cmd == BOOT)
return RCState::NOTREADY_S;
116 else if (cmd == CONFIGURE)
return RCState::NOTREADY_S;
117 else return Enum::UNKNOWN;
120RCState RCCommand::nextTState()
const
122 const RCCommand& cmd(*
this);
123 if (cmd == CONFIGURE)
return RCState::CONFIGURING_TS;
124 else if (cmd == LOAD)
return RCState::LOADING_TS;
125 else if (cmd == START)
return RCState::STARTING_TS;
126 else if (cmd == STOP)
return RCState::STOPPING_TS;
127 else if (cmd == RESUME)
return RCState::RUNNING_S;
128 else if (cmd == PAUSE)
return RCState::PAUSED_S;
129 else if (cmd == RECOVER)
return RCState::RECOVERING_RS;
130 else if (cmd == ABORT)
return RCState::ABORTING_RS;
131 else if (cmd == BOOT)
return RCState::BOOTING_RS;
132 else return Enum::UNKNOWN;
const NSMCommand & operator=(const NSMCommand &command)
Operator =.
const RCCommand & operator=(const RCCommand &command)
Operator =.
Abstract base class for different kinds of events.