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