Wyatt
1.0.1
Main Page
Classes
Files
File List
src
messages
MotorMessage.cpp
1
#include "messages/MotorMessage.h"
2
3
4
MotorMessage::MotorMessage
(
Hardware
hardware,
int
data) :
IMessage
(hardware) {
5
6
if
((
int
)(hardware.messageLength) !=
sizeof
(
int
)) {
7
throw
MessageLengthException
(hardware);
8
}
9
10
if
(data > FULL_FORWARD || data < FULL_BACKWARD) {
11
throw
DataSizeException
(data);
12
}
13
14
this->data = data;
15
}
16
17
MotorMessage::~MotorMessage
() {
18
// Nothing.
19
}
20
21
int
MotorMessage::getData
() {
22
return
this->data;
23
}
24
25
std::string
MotorMessage::serialize
() {
26
std::string serial;
27
serial.append(1,
hardware
.address);
28
serial.append((
char
*)(&(this->data)),
sizeof
(
int
));
29
return
serial;
30
}
Hardware
Definition:
Hardware.h:11
MotorMessage::~MotorMessage
~MotorMessage() override
Definition:
MotorMessage.cpp:17
IMessage
Definition:
IMessage.h:10
MotorMessage::getData
int getData()
Definition:
MotorMessage.cpp:21
DataSizeException
Definition:
DataSizeException.h:10
IMessage::hardware
Hardware hardware
Definition:
IMessage.h:45
MotorMessage::MotorMessage
MotorMessage(Hardware hardware, int data)
Definition:
MotorMessage.cpp:4
MotorMessage::serialize
std::string serialize() override
Definition:
MotorMessage.cpp:25
MessageLengthException
Definition:
MessageLengthException.h:13
Generated by
1.8.11