RTC Toolkit  1.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 <Rtctkif.hpp>
16 #include <rad/mal/subscriber.hpp>
17 #include <rad/smAdapter.hpp>
20 
21 namespace rtctk::rtcSupervisor {
22 
23 using stdif::StdCmdsAsync;
24 using stdif::StdCmdsSync;
25 
26 class RtcObject {
27 public:
34  RtcObject(const std::string &name, const std::string &rr_uri, const std::string &ps_uri);
35  virtual ~RtcObject();
36 
41  virtual void BelievedState(const std::string &s);
46  virtual std::string BelievedState();
47  virtual std::string BelievedSubstate();
52  void EvaluatedState(RtcState &state, RtcSubState &sub_state);
53 
57  virtual std::string Name() {
58  return m_name;
59  };
60 
64  virtual void BelievedError(bool i) {
65  m_b_error = i;
66  }
67 
68  virtual bool BelievedError() {
69  return m_b_error;
70  }
71 
75  virtual std::string RunCmd(RtcCommand cmd, bool timed);
79  virtual std::string RunAsync(RtcCommand cmd);
83  virtual std::string WaitAsync();
87  virtual bool GetAsyncCommandOk();
88 
89 private:
91  void BuildObject();
92 
94  std::string m_name;
95  std::string m_stdif_uri;
96  std::string m_rr_uri;
97  std::string m_ps_uri;
98 
100  std::string m_b_state;
101  std::string m_b_substate;
102  bool m_b_error;
104  virtual void EvaluateState(const std::string &s);
105  virtual void
106  EvaluatePrimaryStateAndSubstate(const std::string &state, const std::string &substate);
107  RtcState m_evaluated_state;
108  RtcSubState m_evaluated_substate;
109 
111  std::shared_ptr<StdCmdsAsync> m_cli_async;
112  elt::mal::future<std::string> m_cli_async_future;
113  std::shared_ptr<StdCmdsSync> m_cli_sync;
115  std::shared_ptr<StdCmdsSync> m_cli_timed_sync;
116 
119  bool m_async_command_ok;
120  std::string m_async_command_ok_string;
122  bool m_component_caused_exception;
123 
127  bool m_command_returns_ok;
128 };
129 
130 } // namespace rtctk::rtcSupervisor
131 
132 #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:47
rtctk::rtcSupervisor
Definition: rtcCommandRequest.hpp:18
rtctk::rtcSupervisor::RtcObject::BelievedError
virtual void BelievedError(bool i)
Setter and Getter for BelievedError.
Definition: rtcObject.hpp:64
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:514
rtctk::rtcSupervisor::RtcCommand
RtcCommand
Definition: rtcSupervisorLib.hpp:72
rtctk::rtcSupervisor::RtcObject
Definition: rtcObject.hpp:26
rtctk::rtcSupervisor::RtcObject::RunCmd
virtual std::string RunCmd(RtcCommand cmd, bool timed)
Run command with optional arg.
Definition: rtcObject.cpp:157
rtctk::rtcSupervisor::RtcObject::BelievedSubstate
virtual std::string BelievedSubstate()
Definition: rtcObject.cpp:518
rtctk::rtcSupervisor::RtcObject::EvaluatedState
void EvaluatedState(RtcState &state, RtcSubState &sub_state)
Return the state evaluated as enumeration.
Definition: rtcObject.cpp:395
rtctk::rtcSupervisor::RtcObject::WaitAsync
virtual std::string WaitAsync()
Wait for previously async run command.
Definition: rtcObject.cpp:293
rtctk::rtcSupervisor::RtcObject::~RtcObject
virtual ~RtcObject()
Definition: rtcObject.cpp:69
rtctk::rtcSupervisor::RtcObject::Name
virtual std::string Name()
Definition: rtcObject.hpp:57
rtctk::rtcSupervisor::RtcObject::RunAsync
virtual std::string RunAsync(RtcCommand cmd)
Run command async.
Definition: rtcObject.cpp:328
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:153
rtctk::rtcSupervisor::RtcState
RtcState
Definition: rtcSupervisorLib.hpp:26
rtctk::rtcSupervisor::RtcObject::BelievedError
virtual bool BelievedError()
Definition: rtcObject.hpp:68
rtcSupervisorLib.hpp
Standard enums for rtcSupervisor.