CARMA C++
JanzMessage.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_CANBUS_JANZMESSAGE_H
11 #define CARMA_CANBUS_JANZMESSAGE_H
12 
13 #include "carma/canbus/Types.h"
14 
15 namespace carma {
16 namespace canbus {
17 
18  class Message;
19 
20  // Typedefs to mimic Janz internal FastMessage structure
21  typedef unsigned char BYTE_t;
22 
23  typedef struct {
24  BYTE_t unused; /* driver internal flags */
25  BYTE_t cmd; /* command specifier */
26  BYTE_t data[14]; /* data array */
27  } FastMessage;
28 
56  class JanzMessage {
57  public:
58 
65  typedef enum {
66  STANDARD = 0,
67  EXTENDED = 1
69 
76 
83 
90  const std::vector<carma::canbus::byteType> &data,
92 
96  JanzMessage(carma::canbus::FastMessage,
98 
102  JanzMessage( const carma::canbus::Message & message );
103 
107  JanzMessage(const JanzMessage &other);
108 
112  JanzMessage &operator=(const JanzMessage &other);
113 
117  bool operator==( const JanzMessage & other ) const;
118 
122  bool operator!=( const JanzMessage & other ) const;
123 
133 
139 
144 
148  std::vector<carma::canbus::byteType> getData() const;
149 
156 
161  carma::canbus::FastMessage getRawMessage() const;
162 
166  double getRxMjd() const;
167 
175  bool isSimulated() const;
176 
177 
183  void setId(carma::canbus::idType id);
184 
189 
195  void setData(const std::vector<carma::canbus::byteType> &data);
196 
202  void setPort(carma::canbus::portType port);
203 
207  void setRxMjd(double mjd);
208 
217  void setSimFlag(bool sim);
218 
241  void disableTxRetry();
242 
250  void enableEcho();
251 
252  protected:
253 
254  // There are no protected methods or data.
255 
256  private:
257 
259  static const idType MAX_STANDARD_ID = 0x7FF;
261  static const idType MAX_EXTENDED_ID = 0x1FFFFFFF;
262 
266  int getDataLength() const;
267 
271  void setMessageType( JanzMessage::messageTypeType messageType);
272 
276  bool validateId(carma::canbus::idType id) const;
277 
278  // Private variables.
279  carma::canbus::busIdType busId_; // Bus id.
280  carma::canbus::FastMessage rawMsg_; // Janz raw message
281  bool simulated_; // Flag to indicate if msg is for sim purposes.
282  double rxMjd_; // Rx time in Mean Julian Day format.
283  };
284 } // namespace canbus
285 } // namespace carma
286 #endif
JanzMessage & operator=(const JanzMessage &other)
Assignment operator.
unsigned short portType
Port id type for multi-port boards.
Definition: Types.h:62
std::vector< carma::canbus::byteType > getData() const
Get the data as a vector of bytes (raw).
carma::canbus::JanzMessage::messageTypeType getMessageType() const
Get message type.
void disableTxRetry()
Set retry mode for message.
Declarations of carma::canbus types.
messageTypeType
Message type definition.
Definition: JanzMessage.h:65
Class to encapsulate a CAN message.
Definition: Message.h:21
void setPort(carma::canbus::portType port)
Set port number.
void setData(const std::vector< carma::canbus::byteType > &data)
Set the data.
bool isSimulated() const
Return simulated flag.
void setId(carma::canbus::idType id)
Set CAN message id.
double getRxMjd() const
Return the Rx MJD time.
bool operator==(const JanzMessage &other) const
Check for equality.
carma::canbus::busIdType getBusId() const
Get CAN bus Id.
void setRxMjd(double mjd)
Set the rxMjd time.
JanzMessage(JanzMessage::messageTypeType msgType=EXTENDED)
Default constructor.
carma::canbus::portType getPort() const
Get port number.
carma::canbus::FastMessage getRawMessage() const
Return the underlying drivers raw message.
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
unsigned short msgType
Carma Message id type.
Definition: Types.h:69
This class encapsulate a Janz CAN message.
Definition: JanzMessage.h:56
void setSimFlag(bool sim)
Set the simulated flag.
bool operator!=(const JanzMessage &other) const
Check for inequality.
carma::canbus::idType getId() const
Get CAN message id.
void setBusId(carma::canbus::busIdType busId)
Set bus Id.
void enableEcho()
Echo this message.