Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00024
00025 #ifndef ICL_HARDWARE_CAN_SINK_HARDWARE_CAN_SINK_CANFILE_H_INCLUDED
00026 #define ICL_HARDWARE_CAN_SINK_HARDWARE_CAN_SINK_CANFILE_H_INCLUDED
00027
00028 #include <icl_sourcesink/DataSinkRegistration.h>
00029
00030 #include <icl_hardware_can/sink/ImportExport.h>
00031 #include <icl_hardware_can/sink/HardwareCanSink.h>
00032
00033 #include <vector>
00034 #include <fstream>
00035 #include <boost/filesystem.hpp>
00036
00037 namespace icl_hardware {
00038 namespace can {
00039
00050 class ICL_HARDWARE_CAN_SINK_IMPORT_EXPORT HardwareCanSinkCanfile : public HardwareCanSink
00051 {
00052 public:
00054 typedef boost::shared_ptr<HardwareCanSinkCanfile> Ptr;
00056 typedef boost::shared_ptr<const HardwareCanSinkCanfile> ConstPtr;
00057
00058 static icl_sourcesink::URISchemeMap supportedURISchemes()
00059 {
00060 using namespace icl_sourcesink;
00061 URISchemeMap schemes;
00062 schemes.insert(
00063 std::make_pair(
00064 "can+file",
00065 URISchemeInfo(
00066 "Writes CAN message data to a file, using the FZI CAN file format.",
00067 "can+file:<path>[?container_size=<container_size>]",
00068 "<path> Path to the CAN file. A .can suffix is added if not yet\n"
00069 " present.\n"
00070 "<container_size> Number of messages to buffer before writing out to disk\n"
00071 " (default: 500).\n"
00072 )));
00073 return schemes;
00074 }
00075
00077 HardwareCanSinkCanfile(const std::string& uri = "HardwareCanSinkCanfile",
00078 const std::string& name = "UnnamedHardwareCanSinkCanfile");
00079
00081 virtual ~HardwareCanSinkCanfile();
00082
00084 virtual void set(const CanMessageStamped::Ptr& msg);
00085
00086 protected:
00088 bool prepareFile();
00089
00090 private:
00092 std::ofstream m_data_file;
00093
00097 std::vector<CanMessageStamped::ConstPtr> m_msg_container;
00101 std::size_t m_msg_container_size;
00105 boost::posix_time::time_duration m_commit_timediff;
00106
00108 boost::posix_time::ptime m_last_msg_time;
00110 boost::posix_time::ptime m_last_commit_time;
00111
00113 static const short cMAJOR_FILEVERSION = 1;
00115 static const short cMINOR_FILEVERSION = 2;
00116 };
00117
00118 SOURCESINK_DECLARE_GENERIC_SINK_FACTORY(HardwareCanSinkCanfile)
00119
00120 }
00121 }
00122
00123 #endif