gusimplewhiteboard
NXT_Lights_Control.hpp
Go to the documentation of this file.
1#ifndef NXT_Lights_Control_DEFINED
2#define NXT_Lights_Control_DEFINED
3
4#include <cstdlib>
5#include <stdlib.h>
6#include <cstring>
7#include <sstream>
8#include <gu_util.h>
9#include "gusimplewhiteboard.h"
10#include "wb_lights.h"
11
12namespace guWhiteboard {
18 public:
21
22#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
24 NXT_Lights_Control(const std::string &name) {
25 from_string(name);
26 }
27
29 std::string description() {
30 std::ostringstream ss;
31 for (int b= 0 ; b <wb_lights_h_NUMBER_OF_LIGHTS; b++)
32 { u_int8_t anIntenisty =lights(b);
33 ss << static_cast<int>(anIntenisty) << ",";
34 }
35 return ss.str();
36 }
37
39 void from_string (std::string str) {
40 std::istringstream iss(str);
41 std::string token;
42 for (int i = 0; i < wb_lights_h_NUMBER_OF_LIGHTS && getline(iss, token, ','); i++)
43 { const u_int8_t v = static_cast <u_int8_t>( ( atoi(token.c_str()) > 100 ) ?
44 100:
45 ( (atoi(token.c_str()) < 0) ? 0
46 : atoi(token.c_str())
47 ) );
48 set_lights(v, i);
49 }
50 }
51#endif
54 bool temp = true;
55 for (int b= 0 ; b <wb_lights_h_NUMBER_OF_LIGHTS; b++)
56 { u_int8_t anIntenisty =lights(b);
57 u_int8_t otherIntenisty =s.lights(b);
58 if (anIntenisty != otherIntenisty )
59 return false;
60 }
61 return temp;
62 }
63
64 };
65}
66#endif //NXT_Lights_Control_DEFINED
Class for controlling differential robots Defines whiteboard message.
bool operator==(const NXT_Lights_Control &s)
override equality operator so we can compare instances
NXT_Lights_Control()
Designated constructor.
std::string description()
get message description
NXT_Lights_Control(const std::string &name)
String constructor.
void from_string(std::string str)
string conversion
#define u_int8_t
/file APM_Interface.h
Lights that can go an on — C struct.
Definition: wb_lights.h:20
#define wb_lights_h_NUMBER_OF_LIGHTS
/file wb_lights.h
Definition: wb_lights.h:14