OrocosComponentLibrary  2.9.0
ReportingComponent.hpp
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:26 CET 2004 ReportingComponent.hpp
3 
4  ReportingComponent.hpp - description
5  -------------------
6  begin : Mon January 19 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, *
24  * Suite 330, Boston, MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 #ifndef ORO_REPORTING_COMPONENT_HPP
29 #define ORO_REPORTING_COMPONENT_HPP
30 
31 
32 #include <boost/tuple/tuple.hpp>
33 
34 #include <rtt/Property.hpp>
35 #include <rtt/PropertyBag.hpp>
36 #include <rtt/marsh/MarshallInterface.hpp>
37 #include <rtt/os/TimeService.hpp>
38 #include <rtt/TaskContext.hpp>
39 
40 #include <rtt/RTT.hpp>
41 
42 #include <ocl/OCL.hpp>
43 
44 namespace OCL
45 {
82  : public RTT::TaskContext
83  {
84  protected:
88  bool screenImpl( const std::string& comp, std::ostream& output);
89  public:
90 
91  typedef RTT::DataFlowInterface::Ports Ports;
92 
96  ReportingComponent( std::string name = "Reporting" );
97 
98  virtual ~ReportingComponent();
99 
112  bool addMarshaller( RTT::marsh::MarshallInterface* headerM, RTT::marsh::MarshallInterface* bodyM);
113 
117  bool removeMarshallers();
118 
128  virtual bool configureHook();
129 
134  virtual void cleanupHook();
135 
140  virtual bool screenComponent( const std::string& comp );
141 
145  bool reportComponent( const std::string& component );
146 
150  bool unreportComponent( const std::string& component );
151 
155  bool reportPort(const std::string& component, const std::string& port );
156 
160  bool unreportPort(const std::string& component, const std::string& port );
161 
165  bool reportData(const std::string& component,const std::string& dataname);
166 
170  bool unreportData(const std::string& component,const std::string& datasource);
171 
177  bool copydata();
178 
182  void snapshot();
183 
184  void cleanReport();
185 
188  protected:
202  typedef boost::tuple<std::string,
203  RTT::base::DataSourceBase::shared_ptr,
204  std::string,RTT::base::PropertyBase*,RTT::base::InputPortInterface*,bool,bool> DTupple;
205 
207  typedef enum { T_QualName = 0, T_PortDS, T_DataType, T_Property, T_Port, T_NewData, T_Tracked } T_Types;
211  typedef std::vector<DTupple> Reports;
212  Reports root;
213 
214  bool reportDataSource(std::string tag, std::string type, RTT::base::DataSourceBase::shared_ptr origm, RTT::base::InputPortInterface* ipi, bool);
215 
216  bool unreportDataSource(std::string tag);
217 
218  virtual bool startHook();
219 
220  void makeReport2();
221 
225  virtual void updateHook();
226 
227  virtual void stopHook();
228 
229  typedef std::vector< std::pair<boost::shared_ptr<RTT::marsh::MarshallInterface>, boost::shared_ptr<RTT::marsh::MarshallInterface> > > Marshallers;
230  Marshallers marshallers;
231  RTT::PropertyBag report;
232 
238  RTT::Property<std::string> config;
239  RTT::Property<bool> writeHeader;
240  RTT::Property<bool> decompose;
241  RTT::Property<bool> insnapshot;
242  RTT::Property<bool> synchronize_with_logging;
243  RTT::Property<PropertyBag> report_data;
244  RTT::ConnPolicy report_policy;
245  bool onlyNewData;
246 
247  RTT::os::TimeService::ticks starttime;
248  RTT::Property<RTT::os::TimeService::Seconds> timestamp;
250  RTT::internal::DataSource<bool>::shared_ptr mchecker;
251 
252  };
253 
254 }
255 
256 #endif
bool snapshotted
Used to communicate between snapshot() and updateHook() if updateHook needs to make a copy...
virtual bool configureHook()
Implementation of base::TaskCore::configureHook().
void cleanReport()
Implementation of base::TaskCore::configureHook().
bool addMarshaller(RTT::marsh::MarshallInterface *headerM, RTT::marsh::MarshallInterface *bodyM)
Adds a Plugin to receive incomming data.
bool unreportPort(const std::string &component, const std::string &port)
Unreport a specific data port of a component.
virtual void updateHook()
This not real-time function processes the copied data.
RTT::internal::DataSource< bool >::shared_ptr mchecker
If false, a sequence size has changed.
void snapshot()
Copy the reported data and trigger the generation of a sampling line.
bool removeMarshallers()
Remove and delete all added Marshallers.
The Orocos Component Library.
Definition: Component.hpp:43
virtual bool screenComponent(const std::string &comp)
Write state information of a component.
T_Types
Use these to index DTupple objects.
bool reportPort(const std::string &component, const std::string &port)
Report a specific data port of a component.
bool unreportData(const std::string &component, const std::string &datasource)
Unreport a specific data source of a component.
bool reportComponent(const std::string &component)
Report all the data ports of a component.
std::vector< DTupple > Reports
Stores the &#39;datasource&#39; of all reported items as properties.
A Component for periodically reporting Component Port contents to a human readable text format...
bool screenImpl(const std::string &comp, std::ostream &output)
This method writes out the status of a component&#39;s interface.
bool unreportComponent(const std::string &component)
Unreport the data ports of a component.
boost::tuple< std::string, RTT::base::DataSourceBase::shared_ptr, std::string, RTT::base::PropertyBase *, RTT::base::InputPortInterface *, bool, bool > DTupple
tuple that describes each sample.
bool copydata()
This real-time function makes copies of the data to be reported.
ReportingComponent(std::string name="Reporting")
Set up a component for reporting.
bool reportData(const std::string &component, const std::string &dataname)
Report a specific data source of a component.
virtual void cleanupHook()
Implementation of base::TaskCore::cleanupHook().