HardwareCanSourceTest.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_SOURCE_HARDWARE_CAN_SOURCE_TEST_H_INCLUDED
00026 #define ICL_HARDWARE_CAN_SOURCE_HARDWARE_CAN_SOURCE_TEST_H_INCLUDED
00027 
00028 #include <string>
00029 
00030 #include <boost/date_time/posix_time/posix_time.hpp>
00031 #include <boost/random.hpp>
00032 
00033 #include <icl_hardware_can/source/ImportExport.h>
00034 #include <icl_hardware_can/tCanMessage.h>
00035 #include <icl_hardware_can/source/HardwareCanSource.h>
00036 
00037 namespace icl_hardware {
00038 namespace can {
00039 
00044 class ICL_HARDWARE_CAN_SOURCE_IMPORT_EXPORT HardwareCanSourceTest : public HardwareCanSource
00045 {
00046 public:
00048   typedef boost::shared_ptr<HardwareCanSourceTest> Ptr;
00050   typedef boost::shared_ptr<const HardwareCanSourceTest> ConstPtr;
00051 
00053   enum Pattern
00054   {
00058     P_LINEAR = 1,
00060     P_FIXED,
00062     P_CHANGING_RANDOM,
00064     P_CHANGING_WITH_REPEAT
00065   };
00066 
00068   virtual bool good() const
00069   {
00070     return true;
00071   }
00072 
00074   static icl_sourcesink::URISchemeMap supportedURISchemes()
00075   {
00076     using namespace icl_sourcesink;
00077     URISchemeMap schemes;
00078     schemes.insert(
00079       std::make_pair(
00080         "can+test",
00081         URISchemeInfo(
00082           "Test source for CAN message data.",
00083           "can+test:[?rate=<rate>][&pattern=<pattern>][&id_value=<id_value>]",
00084           "<rate>      Data generation rate in Hz.\n"
00085           "<pattern>   One of 'Linear' (default), 'Fixed', 'ChangingRandom', 'ChangingWithRepeat'.\n"
00086           "<id_value>  In Fixed mode, the ID to generate (default: 1).\n")));
00087     return schemes;
00088   }
00089 
00091   virtual CanMessageStamped::Ptr get() const
00092   {
00093     return m_buffer;
00094   }
00095 
00097   virtual bool isSeekable() const
00098   {
00099     return false;
00100   }
00101 
00102 protected:
00104   HardwareCanSourceTest(const std::string& uri = "",
00105                         const std::string& name = "HardwareCanSourceTest");
00106 
00108   friend class icl_sourcesink::SourceSinkManager;
00109 
00111   friend class icl_sourcesink::DataSourceFactory<HardwareCanSourceTest>;
00112 
00114   bool advance();
00115 
00119   unsigned int createCanMessageId();
00120 
00121 private:
00123   boost::random::mt19937 m_rng;
00124 
00126   boost::random::uniform_int_distribution<unsigned int> m_can_id_distribution;
00127 
00129   boost::random::uniform_int_distribution<uint8_t> m_data_distribution;
00130 
00132   CanMessageStamped::Ptr m_buffer;
00133 
00135   float m_rate;
00136 
00138   Pattern m_pattern;
00139 
00141   uint16_t m_next_id;
00142 };
00143 
00144 SOURCESINK_DECLARE_GENERIC_SOURCE_FACTORY(HardwareCanSourceTest)
00145 
00146 }
00147 }
00148 
00149 #endif


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