Namespaces | Macros | Functions
Message_data.cpp File Reference
#include "roch_base/core/Message_data.h"
#include "roch_base/core/Number.h"
#include "roch_base/core/Transport.h"
#include <iostream>
#include <string>
#include <string.h>
#include <sstream>
Include dependency graph for Message_data.cpp:

Go to the source code of this file.

Namespaces

 sawyer
 

Macros

#define MESSAGE_CONSTRUCTORS(MessageClass, ExpectedLength)
 
#define MESSAGE_CONVENIENCE_FNS(MessageClass, DataMsgID)
 

Functions

 sawyer::MESSAGE_CONSTRUCTORS (DataDifferentialSpeed, PAYLOAD_LEN)
 
 sawyer::MESSAGE_CONSTRUCTORS (DataWheelInfo, PAYLOAD_LEN)
 
 sawyer::MESSAGE_CONSTRUCTORS (DataEncodersRaw,(1+getCount()*4)) uint8_t DataEncodersRaw
 
 sawyer::MESSAGE_CONSTRUCTORS (DataPlatformInfo,(int) strlenModel()+6) uint8_t DataPlatformInfo
 
 sawyer::MESSAGE_CONSTRUCTORS (DataPlatformName,(int)(*getPayloadPointer())+1) string DataPlatformName
 
 sawyer::MESSAGE_CONSTRUCTORS (DataProcessorStatus,(1+getProcessCount()*2)) uint8_t DataProcessorStatus
 
 sawyer::MESSAGE_CONSTRUCTORS (DataRangefinders,(1+getRangefinderCount()*2)) uint8_t DataRangefinders
 
 sawyer::MESSAGE_CONSTRUCTORS (DataRangefinderTimings,(1+getRangefinderCount()*6)) uint8_t DataRangefinderTimings
 
 sawyer::MESSAGE_CONSTRUCTORS (DataRawCurrent,(1+getCurrentCount()*2)) uint8_t DataRawCurrent
 
 sawyer::MESSAGE_CONSTRUCTORS (DataRawTemperature,(1+2 *getTemperatureCount())) uint8_t DataRawTemperature
 
 sawyer::MESSAGE_CONSTRUCTORS (DataRawVoltage,(1+2 *getVoltageCount())) uint8_t DataRawVoltage
 
 sawyer::MESSAGE_CONVENIENCE_FNS (DataDifferentialSpeed, DATA_DIFF_WHEEL_SPEEDS)
 
 sawyer::MESSAGE_CONVENIENCE_FNS (DataWheelInfo, DATA_WHEEL_INFO)
 
 sawyer::MESSAGE_CONVENIENCE_FNS (DataEncoders, DATA_ENCODER)
 

Macro Definition Documentation

#define MESSAGE_CONSTRUCTORS (   MessageClass,
  ExpectedLength 
)
Value:
MessageClass::MessageClass(void* input, size_t msg_len) : Message(input, msg_len) \
{ \
if( ((ExpectedLength) >= 0) && ((ssize_t)getPayloadLength() != (ExpectedLength)) ) { \
stringstream ss; \
ss << "Bad payload length: actual="<<getPayloadLength(); \
ss <<" vs. expected="<<(ExpectedLength); \
throw new MessageException(ss.str().c_str(), MessageException::INVALID_LENGTH); \
} \
} \
MessageClass::MessageClass(const MessageClass& other) : Message(other) {}

Macro which generates definitions of the Message constructors ExpectedLength is an expression valid within the constructor which gives the expected payload length of the message. If the length reported in the message header does not match, and exception will be thrown. If ExpectedLength is -1, the length check will be skipped. NB: Some Messages need to do some extra work in the constructor and don't use this macro!

Definition at line 24 of file Message_data.cpp.

#define MESSAGE_CONVENIENCE_FNS (   MessageClass,
  DataMsgID 
)
Value:
MessageClass* MessageClass::popNext() { \
return dynamic_cast<MessageClass*>( Transport::instance().popNext(DataMsgID)); \
} \
\
MessageClass* MessageClass::waitNext(double timeout) { \
return dynamic_cast<MessageClass*>(Transport::instance().waitNext(DataMsgID, timeout)); \
} \
\
MessageClass* MessageClass::getUpdate(double timeout) { \
subscribe(0); \
return dynamic_cast<MessageClass*>( \
Transport::instance().waitNext(DataMsgID, timeout) ); \
}\
\
void MessageClass::subscribe(uint16_t freq) { \
Request(DataMsgID-0x4000, freq).sendRequest(); \
} \
\
enum MessageTypes MessageClass::getTypeID() { \
return DataMsgID; \
}
MessageTypes
Definition: Message.h:207

Macro which generates definitios of the Message convenience functions All message classes should use this macro to define these functions.

Definition at line 41 of file Message_data.cpp.



roch_base
Author(s): Mike Purvis , Paul Bovbel , Chen
autogenerated on Mon Jun 10 2019 14:41:14