HardwareCanSourceTest.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_SOURCE_HARDWARE_CAN_SOURCE_TEST_H_INCLUDED
26 #define ICL_HARDWARE_CAN_SOURCE_HARDWARE_CAN_SOURCE_TEST_H_INCLUDED
27 
28 #include <string>
29 
30 #include <boost/date_time/posix_time/posix_time.hpp>
31 #include <boost/random.hpp>
32 
36 
37 namespace icl_hardware {
38 namespace can {
39 
45 {
46 public:
48  typedef boost::shared_ptr<HardwareCanSourceTest> Ptr;
50  typedef boost::shared_ptr<const HardwareCanSourceTest> ConstPtr;
51 
53  enum Pattern
54  {
58  P_LINEAR = 1,
64  P_CHANGING_WITH_REPEAT
65  };
66 
68  virtual bool good() const
69  {
70  return true;
71  }
72 
74  static icl_sourcesink::URISchemeMap supportedURISchemes()
75  {
76  using namespace icl_sourcesink;
77  URISchemeMap schemes;
78  schemes.insert(
79  std::make_pair(
80  "can+test",
81  URISchemeInfo(
82  "Test source for CAN message data.",
83  "can+test:[?rate=<rate>][&pattern=<pattern>][&id_value=<id_value>]",
84  "<rate> Data generation rate in Hz.\n"
85  "<pattern> One of 'Linear' (default), 'Fixed', 'ChangingRandom', 'ChangingWithRepeat'.\n"
86  "<id_value> In Fixed mode, the ID to generate (default: 1).\n")));
87  return schemes;
88  }
89 
91  virtual CanMessageStamped::Ptr get() const
92  {
93  return m_buffer;
94  }
95 
97  virtual bool isSeekable() const
98  {
99  return false;
100  }
101 
102 protected:
104  HardwareCanSourceTest(const std::string& uri = "",
105  const std::string& name = "HardwareCanSourceTest");
106 
108  friend class icl_sourcesink::SourceSinkManager;
109 
111  friend class icl_sourcesink::DataSourceFactory<HardwareCanSourceTest>;
112 
114  bool advance();
115 
119  unsigned int createCanMessageId();
120 
121 private:
123  boost::random::mt19937 m_rng;
124 
126  boost::random::uniform_int_distribution<unsigned int> m_can_id_distribution;
127 
129  boost::random::uniform_int_distribution<uint8_t> m_data_distribution;
130 
133 
135  float m_rate;
136 
139 
142 };
143 
144 SOURCESINK_DECLARE_GENERIC_SOURCE_FACTORY(HardwareCanSourceTest)
145 
146 }
147 }
148 
149 #endif
Pattern m_pattern
The message generation pattern.
boost::random::uniform_int_distribution< unsigned int > m_can_id_distribution
Uniform distribution over possible CAN IDs.
icl_sourcesink::DataSource< tCanMessage > HardwareCanSource
Base type for all sources providing tCanMessage data.
virtual bool isSeekable() const
This is a non-seekable source.
#define ICL_HARDWARE_CAN_SOURCE_IMPORT_EXPORT
uint16_t m_next_id
The next CAN message ID to be used.
float m_rate
Data generation rate in Hz.
boost::shared_ptr< Stamped< DataType > > Ptr
Contains CAN driver interface functions.
static icl_sourcesink::URISchemeMap supportedURISchemes()
URI schemes supported by this source.
CanMessageStamped::Ptr m_buffer
Buffers the latest generated message.
boost::random::uniform_int_distribution< uint8_t > m_data_distribution
Uniform distribution over possible payload bytes.
boost::shared_ptr< const HardwareCanSourceTest > ConstPtr
Const shared pointer shorthand.
boost::shared_ptr< HardwareCanSourceTest > Ptr
Shared pointer shorthand.
virtual bool good() const
Always returns true for the test source.
The IDs will be created randomly (seed is fixed).
boost::random::mt19937 m_rng
Random number generator.
unsigned short uint16_t


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