Aligned Messages
This commit is contained in:
parent
db1265a135
commit
8d778ab41e
@ -1,15 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Messages.h"
|
||||
#include "IMessage.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
/// @brief Message to send thing-specific data
|
||||
/// @brief A message containing binary data for custom communication
|
||||
class BinaryMsg : public IMessage {
|
||||
public:
|
||||
/// @brief The message ID
|
||||
static const unsigned char id = 0xB1;
|
||||
/// @brief The length of the message without the binary data itslef
|
||||
/// @brief The length of the message in bytes, excluding the binary data
|
||||
/// For the total size of the message this.bytes.Length should be added to this value.
|
||||
static const unsigned length = 4;
|
||||
|
||||
/// @brief The network ID of the thing
|
||||
@ -23,7 +25,7 @@ class BinaryMsg : public IMessage {
|
||||
/// @brief The binary data which is communicated
|
||||
char* data = nullptr;
|
||||
|
||||
/// @brief Create a new message for sending
|
||||
/// @brief Create a BinaryMsg
|
||||
/// @param networkId The network ID of the thing
|
||||
/// @param thing The thing for which binary data is sent
|
||||
BinaryMsg(unsigned char networkId, Thing* thing);
|
||||
|
@ -15,10 +15,10 @@ DestroyMsg::DestroyMsg(char* buffer) {
|
||||
DestroyMsg::~DestroyMsg() {}
|
||||
|
||||
unsigned char DestroyMsg::Serialize(char* buffer) {
|
||||
//#if defined(DEBUG)
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send DestroyMsg [" << (int)this->networkId << "/"
|
||||
<< (int)this->thingId << "] " << std::endl;
|
||||
//#endif
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -1,13 +1,15 @@
|
||||
#include "Messages.h"
|
||||
#pragma once
|
||||
|
||||
#include "IMessage.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
/// @brief Message notifiying that a Thing no longer exists
|
||||
/// @brief A Message notifiying that a Thing no longer exists
|
||||
class DestroyMsg : public IMessage {
|
||||
public:
|
||||
/// @brief The message ID
|
||||
static const unsigned char id = 0x20;
|
||||
/// @brief The length of the message
|
||||
/// @brief The length of the message in bytes
|
||||
static const unsigned length = 3;
|
||||
/// @brief The network ID of the thing
|
||||
unsigned char networkId;
|
||||
|
@ -1,7 +1,4 @@
|
||||
#include "Messages.h"
|
||||
|
||||
#include "LowLevelMessages.h"
|
||||
#include "string.h"
|
||||
#include "IMessage.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
16
Messages/IMessage.h
Normal file
16
Messages/IMessage.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
/// @brief Root structure for all communcation messages
|
||||
class IMessage {
|
||||
public:
|
||||
IMessage();
|
||||
/// @brief Serialize the message into a byte array for sending
|
||||
/// @param buffer The buffer to serilize into
|
||||
/// @return The length of the message in the buffer
|
||||
virtual unsigned char Serialize(char* buffer);
|
||||
|
||||
};
|
||||
|
||||
} // namespace RoboidControl
|
@ -7,9 +7,9 @@ InvestigateMsg::InvestigateMsg(char* buffer) {
|
||||
this->networkId = buffer[ix++];
|
||||
this->thingId = buffer[ix++];
|
||||
}
|
||||
InvestigateMsg::InvestigateMsg(unsigned char networkId, unsigned char thingId) {
|
||||
InvestigateMsg::InvestigateMsg(unsigned char networkId, Thing* thing) {
|
||||
this->networkId = networkId;
|
||||
this->thingId = thingId;
|
||||
this->thingId = thing->id;
|
||||
}
|
||||
|
||||
InvestigateMsg::~InvestigateMsg() {}
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "Messages.h"
|
||||
#pragma once
|
||||
|
||||
#include "IMessage.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
@ -14,10 +17,10 @@ class InvestigateMsg : public IMessage {
|
||||
/// @brief the ID of the thing
|
||||
unsigned char thingId;
|
||||
|
||||
/// @brief Create a new message for sending
|
||||
/// @brief Create an investigate message
|
||||
/// @param networkId The network ID for the thing
|
||||
/// @param thingId The ID of the thing
|
||||
InvestigateMsg(unsigned char networkId, unsigned char thingId);
|
||||
/// @param thing The thing for which the details are requested
|
||||
InvestigateMsg(unsigned char networkId, Thing* thing);
|
||||
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||
InvestigateMsg(char* buffer);
|
||||
/// @brief Destructor for the message
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "LinearAlgebra/Spherical.h"
|
||||
#include "LinearAlgebra/SwingTwist.h"
|
||||
|
||||
@ -5,18 +7,18 @@ namespace RoboidControl {
|
||||
|
||||
class LowLevelMessages {
|
||||
public:
|
||||
static void SendAngle8(char* buffer, unsigned char* ix, const float angle);
|
||||
static Angle8 ReceiveAngle8(const char* buffer, unsigned char* startIndex);
|
||||
|
||||
static void SendFloat16(char* buffer, unsigned char* ix, float value);
|
||||
static float ReceiveFloat16(const char* buffer, unsigned char* startIndex);
|
||||
|
||||
static void SendSpherical(char* buffer, unsigned char* ix, Spherical s);
|
||||
static Spherical ReceiveSpherical(const char* buffer,
|
||||
unsigned char* startIndex);
|
||||
|
||||
static void SendQuat32(char* buffer, unsigned char* ix, SwingTwist q);
|
||||
static SwingTwist ReceiveQuat32(const char* buffer, unsigned char* ix);
|
||||
|
||||
static void SendAngle8(char* buffer, unsigned char* ix, const float angle);
|
||||
static Angle8 ReceiveAngle8(const char* buffer, unsigned char* startIndex);
|
||||
|
||||
static void SendFloat16(char* buffer, unsigned char* ix, float value);
|
||||
static float ReceiveFloat16(const char* buffer, unsigned char* startIndex);
|
||||
};
|
||||
|
||||
} // namespace RoboidControl
|
||||
|
@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "LinearAlgebra/Spherical.h"
|
||||
#include "LinearAlgebra/SwingTwist.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
class ParticipantUDP;
|
||||
|
||||
class IMessage {
|
||||
public:
|
||||
IMessage();
|
||||
virtual unsigned char Serialize(char* buffer);
|
||||
|
||||
static unsigned char* ReceiveMsg(unsigned char packetSize);
|
||||
|
||||
// bool Publish(ParticipantUDP *participant);
|
||||
// bool SendTo(ParticipantUDP *participant);
|
||||
};
|
||||
|
||||
} // namespace RoboidControl
|
@ -1,4 +1,7 @@
|
||||
#include "Messages.h"
|
||||
#pragma once
|
||||
|
||||
#include "IMessage.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
@ -26,8 +29,6 @@ class ModelUrlMsg : public IMessage {
|
||||
ModelUrlMsg(unsigned char networkId, Thing* thing);
|
||||
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||
ModelUrlMsg(const char* buffer);
|
||||
// ModelUrlMsg(unsigned char networkId, unsigned char thingId,
|
||||
// unsigned char urlLegth, const char *url, float scale = 1);
|
||||
|
||||
/// @brief Destructor for the message
|
||||
virtual ~ModelUrlMsg();
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "Messages.h"
|
||||
#pragma once
|
||||
|
||||
#include "IMessage.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
@ -22,9 +25,6 @@ class NameMsg : public IMessage {
|
||||
/// @param networkId The network ID of the thing
|
||||
/// @param thing The ID of the thing
|
||||
NameMsg(unsigned char networkId, Thing* thing);
|
||||
// NameMsg(unsigned char networkId, unsigned char thingId, const char *name,
|
||||
// unsigned char nameLength);
|
||||
|
||||
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||
NameMsg(const char* buffer);
|
||||
/// @brief Destructor for the message
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "Messages.h"
|
||||
#pragma once
|
||||
|
||||
#include "IMessage.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Messages.h"
|
||||
#include "IMessage.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "Messages.h"
|
||||
#pragma once
|
||||
#include "IMessage.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
@ -9,7 +11,7 @@ class PoseMsg : public IMessage {
|
||||
public:
|
||||
/// @brief The message ID
|
||||
static const unsigned char id = 0x10;
|
||||
/// @brief The length of the message
|
||||
/// @brief The length of the message in bytes
|
||||
unsigned char length = 4 + 4 + 4;
|
||||
|
||||
/// @brief The network ID of the thing
|
||||
@ -40,7 +42,8 @@ class PoseMsg : public IMessage {
|
||||
|
||||
/// @brief Create a new message for sending
|
||||
/// @param networkId he network ID of the thing
|
||||
/// @param thing The thing for which the pose shouldbe sent
|
||||
/// @param thing The thing for which the pose should be sent
|
||||
/// @param force If true, position and orientation are always included, even when they are not updated
|
||||
PoseMsg(unsigned char networkId, Thing* thing, bool force = false);
|
||||
|
||||
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Messages.h"
|
||||
#include "IMessage.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
@ -9,10 +9,6 @@ class TextMsg : public IMessage {
|
||||
static const unsigned char id = 0xB0;
|
||||
/// @brief The length of the message without the text itself
|
||||
static const unsigned char length = 2;
|
||||
/// @brief The network ID of the thing
|
||||
unsigned char networkId;
|
||||
/// @brief the ID of the thing
|
||||
unsigned char thingId;
|
||||
/// @brief The text without the null terminator
|
||||
const char* text;
|
||||
/// @brief The length of the text
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "Messages.h"
|
||||
#include "IMessage.h"
|
||||
#include "Thing.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
/// @brief Message providing generic information about a Thing
|
||||
/// @brief Message providing generic details about a Thing
|
||||
class ThingMsg : public IMessage {
|
||||
public:
|
||||
/// @brief The message ID
|
||||
@ -13,17 +14,15 @@ class ThingMsg : public IMessage {
|
||||
unsigned char networkId;
|
||||
/// @brief The ID of the thing
|
||||
unsigned char thingId;
|
||||
/// @brief The Thing.Type of the thing
|
||||
/// @brief The type of thing
|
||||
unsigned char thingType;
|
||||
/// @brief The parent of the thing in the hierarachy. This is null for root Things
|
||||
/// @brief The ID of the parent thing in the hierarchy. This is zero for root things
|
||||
unsigned char parentId;
|
||||
|
||||
/// @brief Create a message for sending
|
||||
/// @param networkId The network ID of the thing</param>
|
||||
/// @param thing The thing
|
||||
ThingMsg(unsigned char networkId, Thing* thing);
|
||||
// ThingMsg(unsigned char networkId, unsigned char thingId,
|
||||
// unsigned char thingType, unsigned char parentId);
|
||||
|
||||
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||
ThingMsg(const char* buffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user