cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsCollectorEvent.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Anton Deguet
7  Created on: 2010-02-12
8 
9  (C) Copyright 2010 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 #ifndef _mtsCollectorEvent_h
23 #define _mtsCollectorEvent_h
24 
29 
30 #include <string>
31 
32 // Always include last
34 
44 {
46 
47  protected:
48 
51  mtsComponent * CheckComponent(const std::string & componentName) const;
52  mtsInterfaceProvided * CheckInterface(const mtsComponent * componentPointer,
53  const std::string & interfaceName) const;
55 
65 
69  mtsInterfaceRequired * GetInterfaceRequiredFor(const mtsComponent * componentPointer,
70  const mtsInterfaceProvided * interfacePointer);
71 
75  public:
76  std::string ComponentName;
77  std::string InterfaceName;
78  std::string EventName;
79  size_t EventId;
81  CollectorEventVoid(const std::string & componentName, const std::string & interfaceName, const std::string & eventName,
82  size_t eventId, mtsCollectorEvent * collector);
83  void EventHandler(void);
84  void PrintHeader(std::ostream & outputStream, const CollectorFileFormat fileFormat);
85  };
86 
88  void SaveEventVoid(const CollectorEventVoid * event);
89 
93  public:
94  std::string ComponentName;
95  std::string InterfaceName;
96  std::string EventName;
99  size_t EventId;
101  CollectorEventWrite(const std::string & componentName, const std::string & interfaceName, const std::string & eventName,
102  size_t eventId, mtsCollectorEvent * collector);
103  void EventHandler(const mtsGenericObject & payload);
104  void PrintHeader(std::ostream & outputStream, const CollectorFileFormat fileFormat);
105  };
106 
108  void SaveEventWrite(const CollectorEventWrite * event, const mtsGenericObject & payload);
109 
111  size_t EventCounter;
112 
115  std::vector<CollectorEventVoid *> EventsVoid;
116  std::vector<CollectorEventWrite *> EventsWrite;
118 
121 
125 
129 
132  bool CheckCollectingStatus(void);
133 
136 
137  public:
139  void Run(void);
140 
141  void Startup(void);
142 
144  void Initialize(void);
145 
146  // documented in base class
147  virtual std::string GetDefaultOutputName(void);
148 
150  mtsCollectorEvent(const std::string & collectorName,
151  const CollectorFileFormat fileFormat);
152 
153  ~mtsCollectorEvent(void);
154 
157  bool AddObservedComponent(const std::string & componentName);
158 
162  bool AddObservedComponent(const mtsComponent * componentPointer);
163 
166  bool AddObservedInterface(const std::string & componentName,
167  const std::string & interfaceName);
168 
169  protected:
173  bool AddObservedInterface(const mtsComponent * componentPointer,
174  const mtsInterfaceProvided * interfacePointer);
175 
176  public:
180  bool AddObservedEventVoid(const std::string & componentName,
181  const std::string & interfaceName,
182  const std::string & eventName);
183  bool AddObservedEventWrite(const std::string & componentName,
184  const std::string & interfaceName,
185  const std::string & eventName);
187 
188  protected:
192  bool AddObservedEventVoid(const mtsComponent * componentPointer,
193  const mtsInterfaceProvided * interfacePointer,
194  const std::string & eventName);
195  bool AddObservedEventWrite(const mtsComponent * componentPointer,
196  const mtsInterfaceProvided * interfacePointer,
197  const std::string & eventName);
199 
201  void PrintHeader(const CollectorFileFormat & fileFormat);
202 
203  public:
205  bool Connect(void);
206 
211  void StartCollection(const mtsDouble & delayInSeconds);
212  void StopCollection(const mtsDouble & delayInSeconds);
214 
215  protected:
216  void SetCollecting(bool collecting, double currentTime);
217 };
218 
220 
221 #endif // _mtsCollectorEvent_h
mtsCollectorEvent * Collector
Definition: mtsCollectorEvent.h:80
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Defines the state data table.
std::string InterfaceName
Definition: mtsCollectorEvent.h:95
size_t EventId
Definition: mtsCollectorEvent.h:99
size_t EventCounter
Definition: mtsCollectorEvent.h:111
size_t EventId
Definition: mtsCollectorEvent.h:79
const mtsGenericObject * ArgumentPrototype
Definition: mtsCollectorEvent.h:98
std::string InterfaceName
Definition: mtsCollectorEvent.h:77
Definition: mtsInterfaceRequired.h:85
ComponentsMap ObservedComponents
Definition: mtsCollectorEvent.h:63
A data collection tool.
double ScheduledStartTime
Definition: mtsCollectorEvent.h:124
std::string EventName
Definition: mtsCollectorEvent.h:96
cmnNamedMap< mtsInterfaceRequired > InterfacesRequiredMap
Definition: mtsCollectorEvent.h:61
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
void Initialize(void)
std::vector< CollectorEventWrite * > EventsWrite
Definition: mtsCollectorEvent.h:116
mtsInterfaceRequired * InterfaceRequired
Definition: mtsCollectorEvent.h:97
virtual void StopCollection(const mtsDouble &delayInSeconds)=0
bool Collecting
Definition: mtsCollectorEvent.h:120
std::string ComponentName
Definition: mtsCollectorEvent.h:94
std::vector< CollectorEventVoid * > EventsVoid
Definition: mtsCollectorEvent.h:115
CollectorFileFormat
Definition: mtsCollectorBase.h:54
std::string ComponentName
Definition: mtsCollectorEvent.h:76
Definition: mtsComponent.h:150
std::string EventName
Definition: mtsCollectorEvent.h:78
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Defines a periodic task.
Definition: mtsInterfaceProvided.h:96
virtual void Startup(void)=0
Definition: mtsCollectorEvent.h:43
Class for relative time.
Definition: osaTimeServer.h:73
Definition: mtsCollectorEvent.h:74
Defines a command with no argument.
virtual void Run(void)=0
virtual std::string GetDefaultOutputName(void)=0
mtsCollectorEvent * Collector
Definition: mtsCollectorEvent.h:100
Rules of exporting.
virtual void StartCollection(const mtsDouble &delayInSeconds)=0
const osaTimeServer * TimeServer
Definition: mtsCollectorEvent.h:135
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
Definition: mtsCollectorEvent.h:92
double ScheduledStopTime
Definition: mtsCollectorEvent.h:128
cmnNamedMap< InterfacesRequiredMap > ComponentsMap
Definition: mtsCollectorEvent.h:62
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
Definition: mtsCollectorBase.h:48