OpenDaVINCI  4.16.0
ManagedClientModule.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_BASE_MANAGEDCLIENTMODULE_H_
21 #define OPENDAVINCI_BASE_MANAGEDCLIENTMODULE_H_
22 
23 #include <string>
24 
27 #include <memory>
34 #include "opendavinci/generated/odcore/data/dmcp/ModuleExitCodeMessage.h"
35 #include "opendavinci/generated/odcore/data/dmcp/PulseMessage.h"
36 
37 namespace odcontext { namespace base { class ControlledTimeFactory; } }
38 
39 namespace odcore {
40  namespace base {
41  namespace module {
42 
43  using namespace std;
44 
53  private:
55 
64  ManagedClientModule(const int32_t &argc, char **argv, const string &name) throw (odcore::exceptions::InvalidArgumentException);
65 
66  private:
73 
79  ManagedClientModule& operator=(const ManagedClientModule&);
80 
81  public:
82  virtual ~ManagedClientModule();
83 
87  const odcore::data::TimeStamp getStartOfCurrentCycle() const;
88 
92  const odcore::data::TimeStamp getStartOfLastCycle() const;
93 
94  protected:
98  virtual void setUp() = 0;
99 
103  virtual void tearDown() = 0;
104 
105  virtual void nextContainer(odcore::data::Container &c) = 0;
106 
112  virtual odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode body() = 0;
113 
114  virtual odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation();
115 
116  virtual void reached();
117 
118  private:
119  virtual void wait();
120 
121  virtual void DMCPconnectionLost();
122 
123  odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation_ManagedLevel_None();
124  void wait_ManagedLevel_None();
125  void wait_ManagedLevel_None_realtime();
126 
127  odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation_ManagedLevel_Pulse();
128  void wait_ManagedLevel_Pulse();
129  void reached_ManagedLevel_Pulse();
130 
131  odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation_ManagedLevel_Pulse_Shift();
132  void wait_ManagedLevel_Pulse_Shift();
133  void reached_ManagedLevel_Pulse_Shift();
134 
135  odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation_ManagedLevel_Pulse_Time();
136  void wait_ManagedLevel_Pulse_Time();
137  void reached_ManagedLevel_Pulse_Time();
138 
139  odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation_ManagedLevel_Pulse_Time_Ack();
140  void wait_ManagedLevel_Pulse_Time_Ack();
141  void reached_ManagedLevel_Pulse_Time_Ack();
142 
143  odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode runModuleImplementation_ManagedLevel_Pulse_Time_Ack_Containers();
144  void wait_ManagedLevel_Pulse_Time_Ack_Containers();
145  void reached_ManagedLevel_Pulse_Time_Ack_Containers();
146 
154  uint32_t getWaitingTimeAndUpdateRuntimeStatistics();
155 
160  void logProfilingData(const odcore::data::TimeStamp &current,
161  const odcore::data::TimeStamp &lastCycle,
162  const float &freq,
163  const long &lastWaitTime,
164  const long &timeConsumptionCurrent,
165  const long &nominalDuration,
166  const long &waitingTimeCurrent,
167  const int32_t &cycleCounter);
168 
169  protected:
182  void setContainerConference(std::shared_ptr<odcore::io::conference::ContainerConference> c);
183 
191  std::shared_ptr<odcore::io::conference::ContainerConference> getContainerConference();
192 
193  private:
194 #ifndef WIN32
195  struct timespec m_waitForSlice;
196 #endif
197  odcore::data::TimeStamp m_startOfCurrentCycle;
198  odcore::data::TimeStamp m_startOfLastCycle;
199  odcore::data::TimeStamp m_lastCycle;
200  long m_lastWaitTime;
201  int32_t m_cycleCounter;
202  ofstream *m_profilingFile;
203 
204  bool m_firstCallToBreakpoint_ManagedLevel_Pulse;
205 
206  odcontext::base::Clock m_time;
207  odcontext::base::ControlledTimeFactory *m_controlledTimeFactory;
208 
209  odcore::data::dmcp::PulseMessage m_pulseMessage;
210  std::shared_ptr<odcore::io::conference::ContainerConference> m_localContainerConference;
211  bool m_hasExternalContainerConference;
212  std::shared_ptr<odcore::io::conference::ContainerConference> m_containerConference;
213  };
214 
215  }
216  }
217 } // odcore::base::module
218 
219 #endif /*OPENDAVINCI_BASE_MANAGEDCLIENTMODULE_H_*/
Definition: ContainerListener.h:35
Definition: Container.h:40
Definition: AbstractConferenceClientModule.h:50
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: Clock.h:32
Definition: ControlledTimeFactory.h:39
Definition: ClientModule.h:47
Definition: ManagedClientModule.h:52
Definition: TimeStamp.h:38
Definition: Breakpoint.h:33