HardwareCanSinkCanfile.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
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


fzi_icl_can
Author(s):
autogenerated on Tue Aug 8 2017 03:07:51