RTC Toolkit  2.0.0
rtcObject.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_RTCSUPERVISOR_RTCOBJECT_HPP
13 #define RTCTK_RTCSUPERVISOR_RTCOBJECT_HPP
14 
15 #include <Stdif.hpp>
16 #include <Rtctkif.hpp>
17 #include <rad/mal/subscriber.hpp>
18 #include <rad/smAdapter.hpp>
21 
22 namespace rtctk::rtcSupervisor {
23 
24 using stdif::StdCmdsAsync;
25 using stdif::StdCmdsSync;
26 
27 class RtcObject {
28 public:
35  RtcObject(const std::string &name, const std::string &rr_uri, const std::string &ps_uri);
36  virtual ~RtcObject();
37 
42  virtual void BelievedState(const std::string &s);
47  virtual std::string BelievedState();
48  virtual std::string BelievedSubstate();
53  void EvaluatedState(RtcState &state, RtcSubState &sub_state);
54 
58  virtual std::string Name() {
59  return m_name;
60  };
61 
65  virtual void BelievedError(bool i) {
66  m_b_error = i;
67  }
68 
69  virtual bool BelievedError() {
70  return m_b_error;
71  }
72 
76  virtual std::string RunCmd(RtcCommand cmd, bool timed);
80  virtual std::string RunAsync(RtcCommand cmd);
84  virtual std::string WaitAsync();
88  virtual bool GetAsyncCommandOk();
89 
90 private:
92  void BuildObject();
93 
95  std::string m_name;
96  std::string m_stdif_uri;
97  std::string m_rr_uri;
98  std::string m_ps_uri;
99 
101  std::string m_b_state;
102  std::string m_b_substate;
103  bool m_b_error;
105  virtual void EvaluateState(const std::string &s);
106  virtual void
107  EvaluatePrimaryStateAndSubstate(const std::string &state, const std::string &substate);
108  RtcState m_evaluated_state;
109  RtcSubState m_evaluated_substate;
110 
112  std::shared_ptr<StdCmdsAsync> m_cli_async;
113  elt::mal::future<std::string> m_cli_async_future;
114  std::shared_ptr<StdCmdsSync> m_cli_sync;
116  std::shared_ptr<StdCmdsSync> m_cli_timed_sync;
117 
120  bool m_async_command_ok;
121  std::string m_async_command_ok_string;
123  bool m_component_caused_exception;
124 
128  bool m_command_returns_ok;
129 };
130 
131 } // namespace rtctk::rtcSupervisor
132 
133 #endif // RTCTK_RTCSUPERVISOR_RTCOBJECT_HPP
rtctk::rtcSupervisor::RtcObject::RtcObject
RtcObject(const std::string &name, const std::string &rr_uri, const std::string &ps_uri)
Definition: rtcObject.cpp:48
rtctk::rtcSupervisor
Definition: rtcCommandRequest.hpp:19
rtctk::rtcSupervisor::RtcObject::BelievedError
virtual void BelievedError(bool i)
Setter and Getter for BelievedError.
Definition: rtcObject.hpp:65
wscript.name
name
Definition: wscript:15
rtctk::rtcSupervisor::RtcObject::BelievedState
virtual std::string BelievedState()
Set the believed state as a string and evaluate as enumeration.
Definition: rtcObject.cpp:515
rtctk::rtcSupervisor::RtcCommand
RtcCommand
Definition: rtcSupervisorLib.hpp:72
rtctk::rtcSupervisor::RtcObject
Definition: rtcObject.hpp:27
rtctk::rtcSupervisor::RtcObject::RunCmd
virtual std::string RunCmd(RtcCommand cmd, bool timed)
Run command with optional arg.
Definition: rtcObject.cpp:158
rtctk::rtcSupervisor::RtcObject::BelievedSubstate
virtual std::string BelievedSubstate()
Definition: rtcObject.cpp:519
rtctk::rtcSupervisor::RtcObject::EvaluatedState
void EvaluatedState(RtcState &state, RtcSubState &sub_state)
Return the state evaluated as enumeration.
Definition: rtcObject.cpp:396
rtctk::rtcSupervisor::RtcObject::WaitAsync
virtual std::string WaitAsync()
Wait for previously async run command.
Definition: rtcObject.cpp:294
rtctk_ctrl_mon_tool.state
def state(ctx, str component)
Definition: rtctk_ctrl_mon_tool.py:158
rtctk::rtcSupervisor::RtcObject::~RtcObject
virtual ~RtcObject()
Definition: rtcObject.cpp:70
rtctk::rtcSupervisor::RtcObject::Name
virtual std::string Name()
Definition: rtcObject.hpp:58
rtctk::rtcSupervisor::RtcObject::RunAsync
virtual std::string RunAsync(RtcCommand cmd)
Run command async.
Definition: rtcObject.cpp:329
stateSubscriber.hpp
Subscribes to stdif state topic via MAL.
rtctk::rtcSupervisor::RtcSubState
RtcSubState
Definition: rtcSupervisorLib.hpp:40
rtctk::rtcSupervisor::RtcObject::GetAsyncCommandOk
virtual bool GetAsyncCommandOk()
Get indication that async command was OK, no exception or funny return values.
Definition: rtcObject.cpp:154
rtctk::rtcSupervisor::RtcState
RtcState
Definition: rtcSupervisorLib.hpp:26
rtctk::rtcSupervisor::RtcObject::BelievedError
virtual bool BelievedError()
Definition: rtcObject.hpp:69
rtcSupervisorLib.hpp
Standard enums for rtcSupervisor.