CARMA C++
Message.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_CANBUS_MESSAGE_H
11 #define CARMA_CANBUS_MESSAGE_H
12 
13 #include "carma/canbus/Types.h"
14 
15 namespace carma {
16 namespace canbus {
17 
21  class Message {
22  public:
23 
28  Message( );
29 
36 
43  const DataVector & data,
44  carma::canbus::busIdType busId );
45 
49  Message( const Message &other );
50 
56 
61 
65  DataVector getData( ) const;
66 
70  double getRxMjd( ) const;
71 
79  bool isSimulated( ) const;
80 
86  void setId( carma::canbus::idType id );
87 
91  void setBusId( carma::canbus::busIdType busId );
92 
98  void setData( const carma::canbus::DataVector & data );
99 
103  void setRxMjd( double mjd );
104 
113  void setSimFlag( bool sim );
114 
118  Message & operator=( const Message & other );
119 
124  bool operator==( const Message & other );
125 
130  bool operator!=( const Message & other );
131 
137  carma::canbus::Message & operator<<( unsigned char rvalue );
138 
144  carma::canbus::Message & operator<<( unsigned short rvalue );
145 
151  carma::canbus::Message & operator<<( short rvalue );
152 
158  carma::canbus::Message & operator<<( unsigned long int rvalue );
159 
165  carma::canbus::Message & operator<<( long int rvalue );
166 
172  carma::canbus::Message & operator<<( float rvalue );
173 
179  carma::canbus::Message & operator<<( double rvalue );
180 
190  ::std::string dump( bool abbreviate, bool ascii ) const;
191 
192  protected:
193 
194  // There are no protected methods or data.
195 
196  private:
197 
199  carma::canbus::busIdType busId_;
200  // Use a hard sized data array as opposed to a vector as these
201  // will be put in shared memory IPQs which can't contain pointers.
202  carma::canbus::byteType data_[8];
203  size_t dlc_;
204  bool simulated_;
205  double rxMjd_;
206 
207  };
208 } // namespace canbus
209 } // namespace carma
210 #endif
void setData(const carma::canbus::DataVector &data)
Set the data.
carma::canbus::busIdType getBusId() const
Get CAN bus Id.
unsigned char byteType
Base raw CAN byte.
Definition: Types.h:61
bool operator!=(const Message &other)
Returns false if the id&#39;s, busId&#39;s or data differs (including length).
Declarations of carma::canbus types.
Class to encapsulate a CAN message.
Definition: Message.h:21
double getRxMjd() const
Return the Rx MJD time.
carma::canbus::Message & operator<<(unsigned char rvalue)
Add an unsigned char to CAN message data.
carma::canbus::idType getId() const
Get CAN message id.
void setRxMjd(double mjd)
Set the rxMjd time.
::std::string dump(bool abbreviate, bool ascii) const
Dump everything we know about this message in CARMAesque.
bool operator==(const Message &other)
Returns true if the id&#39;s, data and busId&#39;s are identical (including data length). ...
DataVector getData() const
Get the data as a vector of up to 8 bytes.
bool isSimulated() const
Return simulated flag.
void setBusId(carma::canbus::busIdType busId)
Set bus Id.
Message()
Default constructor.
::std::vector< ::carma::canbus::byteType > DataVector
Alias for CAN data.
Definition: Types.h:72
unsigned int idType
Type for full 29 bit CAN id.
Definition: Types.h:60
unsigned short busIdType
Carma Bus Id type.
Definition: Types.h:70
void setSimFlag(bool sim)
Set the simulated flag.
Message & operator=(const Message &other)
Assignment operator.
void setId(carma::canbus::idType id)
Set CAN message id.