OrocosComponentLibrary  2.8.3
FileReporting.cpp
1 
2 #include "FileReporting.hpp"
3 #include <rtt/RTT.hpp>
4 #include <rtt/Logger.hpp>
5 #include "TableMarshaller.hpp"
6 #include "NiceHeaderMarshaller.hpp"
7 
8 
9 #include "ocl/Component.hpp"
10 ORO_LIST_COMPONENT_TYPE(OCL::FileReporting)
11 
12 namespace OCL
13 {
14  using namespace RTT;
15  using namespace std;
16 
17  FileReporting::FileReporting(const std::string& fr_name)
18  : ReportingComponent( fr_name ),
19  repfile("ReportFile","Location on disc to store the reports.", "reports.dat")
20  {
21  this->properties()->addProperty( repfile );
22  }
23 
24  bool FileReporting::startHook()
25  {
26  mfile.open( repfile.get().c_str() );
27  if (mfile) {
28  if ( this->writeHeader)
29  fheader = new RTT::NiceHeaderMarshaller<std::ostream>( mfile );
30  else
31  fheader = 0;
32  fbody = new RTT::TableMarshaller<std::ostream>( mfile );
33 
34  this->addMarshaller( fheader, fbody );
35  } else {
36  log(Error) << "Could not open file "+repfile.get()+" for reporting."<<endlog();
37  }
38 
39  return ReportingComponent::startHook();
40  }
41 
42  void FileReporting::stopHook()
43  {
44  ReportingComponent::stopHook();
45 
46  this->removeMarshallers();
47  if (mfile)
48  mfile.close();
49  }
50 
51  bool FileReporting::screenComponent( const std::string& comp)
52  {
53  Logger::In in("FileReporting::screenComponent");
54  ofstream file( (comp + ".screen").c_str() );
55  if (!file)
56  return false;
57  return this->screenImpl( comp, file );
58  }
59 
60 }
STL namespace.
bool screenComponent(const std::string &comp)
Writes the interface status of comp to a file &#39;comp.screen&#39;.
A component which writes data reports to a file.
This file contains the macros and definitions to create dynamically loadable components.
The Orocos Component Library.
Definition: Component.hpp:43
A marsh::MarshallInterface for generating headers usable for interpretation by plot programs...
A marsh::MarshallInterface for generating a stream of numbers, ordered in columns.
Definition: Category.hpp:10