HardwareCanSinkCanfile.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
24 //----------------------------------------------------------------------
25 #ifndef ICL_HARDWARE_CAN_SINK_HARDWARE_CAN_SINK_CANFILE_H_INCLUDED
26 #define ICL_HARDWARE_CAN_SINK_HARDWARE_CAN_SINK_CANFILE_H_INCLUDED
27 
28 #include <icl_sourcesink/DataSinkRegistration.h>
29 
32 
33 #include <vector>
34 #include <fstream>
35 #include <boost/filesystem.hpp>
36 
37 namespace icl_hardware {
38 namespace can {
39 
51 {
52 public:
54  typedef boost::shared_ptr<HardwareCanSinkCanfile> Ptr;
56  typedef boost::shared_ptr<const HardwareCanSinkCanfile> ConstPtr;
57 
58  static icl_sourcesink::URISchemeMap supportedURISchemes()
59  {
60  using namespace icl_sourcesink;
61  URISchemeMap schemes;
62  schemes.insert(
63  std::make_pair(
64  "can+file",
65  URISchemeInfo(
66  "Writes CAN message data to a file, using the FZI CAN file format.",
67  "can+file:<path>[?container_size=<container_size>]",
68  "<path> Path to the CAN file. A .can suffix is added if not yet\n"
69  " present.\n"
70  "<container_size> Number of messages to buffer before writing out to disk\n"
71  " (default: 500).\n"
72  )));
73  return schemes;
74  }
75 
77  HardwareCanSinkCanfile(const std::string& uri = "HardwareCanSinkCanfile",
78  const std::string& name = "UnnamedHardwareCanSinkCanfile");
79 
81  virtual ~HardwareCanSinkCanfile();
82 
84  virtual void set(const CanMessageStamped::Ptr& msg);
85 
86 protected:
88  bool prepareFile();
89 
90 private:
92  std::ofstream m_data_file;
93 
97  std::vector<CanMessageStamped::ConstPtr> m_msg_container;
101  std::size_t m_msg_container_size;
105  boost::posix_time::time_duration m_commit_timediff;
106 
108  boost::posix_time::ptime m_last_msg_time;
110  boost::posix_time::ptime m_last_commit_time;
111 
113  static const short cMAJOR_FILEVERSION = 1;
115  static const short cMINOR_FILEVERSION = 2;
116 };
117 
118 SOURCESINK_DECLARE_GENERIC_SINK_FACTORY(HardwareCanSinkCanfile)
119 
120 }
121 }
122 
123 #endif
icl_sourcesink::DataSink< tCanMessage > HardwareCanSink
Base type for all sinks providing tCanMessage data.
std::vector< CanMessageStamped::ConstPtr > m_msg_container
boost::posix_time::ptime m_last_msg_time
Timestamp of the last processed message.
std::ofstream m_data_file
CAN data file stream.
boost::shared_ptr< Stamped< DataType > > Ptr
#define ICL_HARDWARE_CAN_SINK_IMPORT_EXPORT
boost::posix_time::time_duration m_commit_timediff
boost::posix_time::ptime m_last_commit_time
Time at which the last message was committed to disk.
boost::shared_ptr< HardwareCanSinkCanfile > Ptr
Shared pointer shorthand.
static icl_sourcesink::URISchemeMap supportedURISchemes()
boost::shared_ptr< const HardwareCanSinkCanfile > ConstPtr
Const shared pointer shorthand.


fzi_icl_can
Author(s):
autogenerated on Mon Jun 10 2019 13:17:02