Belle II Software  release-06-02-00
RCState.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include "daq/slc/runcontrol/RCState.h"
9 
10 using namespace Belle2;
11 
12 const RCState RCState::OFF_S(1, "OFF");
13 const RCState RCState::NOTREADY_S(2, "NOTREADY");
14 const RCState RCState::READY_S(3, "READY");
15 const RCState RCState::RUNNING_S(4, "RUNNING");
16 const RCState RCState::PAUSED_S(5, "PAUSED");
17 const RCState RCState::LOADING_TS(6, "LOADING");
18 const RCState RCState::STARTING_TS(7, "STARTING");
19 const RCState RCState::STOPPING_TS(8, "STOPPING");
20 const RCState RCState::CONFIGURING_TS(9, "CONFIGURING");
21 const RCState RCState::ERROR_ES(10, "ERROR");
22 const RCState RCState::FATAL_ES(11, "FATAL");
23 const RCState RCState::BOOTING_RS(12, "BOOTING");
24 const RCState RCState::RECOVERING_RS(13, "RECOVERING");
25 const RCState RCState::ABORTING_RS(14, "ABORTING");
26 
27 const RCState& RCState::operator=(const std::string& label)
28 {
29  if (label == NOTREADY_S.getLabel()) *this = NOTREADY_S;
30  else if (label == READY_S.getLabel()) *this = READY_S;
31  else if (label == RUNNING_S.getLabel()) *this = RUNNING_S;
32  else if (label == PAUSED_S.getLabel()) *this = PAUSED_S;
33  else if (label == LOADING_TS.getLabel()) *this = LOADING_TS;
34  else if (label == STARTING_TS.getLabel()) *this = STARTING_TS;
35  else if (label == STOPPING_TS.getLabel()) *this = STOPPING_TS;
36  else if (label == CONFIGURING_TS.getLabel()) *this = CONFIGURING_TS;
37  else if (label == ERROR_ES.getLabel()) *this = ERROR_ES;
38  else if (label == FATAL_ES.getLabel()) *this = FATAL_ES;
39  else if (label == RECOVERING_RS.getLabel()) *this = RECOVERING_RS;
40  else if (label == ABORTING_RS.getLabel()) *this = ABORTING_RS;
41  else if (label == BOOTING_RS.getLabel()) *this = BOOTING_RS;
42  else *this = Enum::UNKNOWN;
43  return *this;
44 }
45 
46 const RCState& RCState::operator=(const char* label)
47 {
48  if (label != NULL) *this = std::string(label);
49  else *this = Enum::UNKNOWN;
50  return *this;
51 }
52 
53 const RCState& RCState::operator=(int id)
54 {
55  if (id == NOTREADY_S.getId()) *this = NOTREADY_S;
56  else if (id == READY_S.getId()) *this = READY_S;
57  else if (id == RUNNING_S.getId()) *this = RUNNING_S;
58  else if (id == PAUSED_S.getId()) *this = PAUSED_S;
59  else if (id == LOADING_TS.getId()) *this = LOADING_TS;
60  else if (id == STARTING_TS.getId()) *this = STARTING_TS;
61  else if (id == STOPPING_TS.getId()) *this = STOPPING_TS;
62  else if (id == CONFIGURING_TS.getId()) *this = CONFIGURING_TS;
63  else if (id == ERROR_ES.getId()) *this = ERROR_ES;
64  else if (id == FATAL_ES.getId()) *this = FATAL_ES;
65  else if (id == RECOVERING_RS.getId()) *this = RECOVERING_RS;
66  else if (id == ABORTING_RS.getId()) *this = ABORTING_RS;
67  else if (id == BOOTING_RS.getId()) *this = BOOTING_RS;
68  else *this = Enum::UNKNOWN;
69  return *this;
70 }
71 
72 RCState RCState::next() const
73 {
74  if (*this == LOADING_TS) return READY_S;
75  else if (*this == STARTING_TS) return RUNNING_S;
76  else if (*this == STOPPING_TS) return READY_S;
77  else if (*this == RECOVERING_RS) return READY_S;
78  else if (*this == ABORTING_RS) return NOTREADY_S;
79  else if (*this == BOOTING_RS) return NOTREADY_S;
80  else if (*this == CONFIGURING_TS) return NOTREADY_S;
81  else return Enum::UNKNOWN;
82 }
Abstract base class for different kinds of events.