60#ifndef guWhiteboard_DataLogger_h
61#define guWhiteboard_DataLogger_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_DataLogger_DEFINED
73#define guWhiteboard_DataLogger_DEFINED
75#undef DataLogger_DEFINED
76#define DataLogger_DEFINED
90 void init(std::string t_machineName =
"", uint32_t t_currentState = 0, uint32_t t_currentSection = 0, uint8_t t_dataSet = 0,
bool t_loggerRunning =
false,
bool t_shouldExit =
false, std::string t_comment =
"") {
91 gu_strlcpy(
const_cast<char *
>(this->
machineName()), t_machineName.c_str(), 40);
97 gu_strlcpy(
const_cast<char *
>(this->
comment()), t_comment.c_str(), 30);
105 DataLogger(std::string t_machineName =
"", uint32_t t_currentState = 0, uint32_t t_currentSection = 0, uint8_t t_dataSet = 0,
bool t_loggerRunning =
false,
bool t_shouldExit =
false, std::string t_comment =
"") {
106 this->init(t_machineName, t_currentState, t_currentSection, t_dataSet, t_loggerRunning, t_shouldExit, t_comment);
152 return !(*
this == t_other);
162 return !(*
this == t_other);
290#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
300#ifdef USE_WB_DATA_LOGGER_C_CONVERSION
303 std::string descr = buffer;
306 std::ostringstream ss;
308 ss <<
"machineName=" <<
"";
313 ss <<
"currentState=" <<
static_cast<unsigned>(this->
currentState());
315 ss <<
"currentSection=" <<
static_cast<unsigned>(this->
currentSection());
317 ss <<
"dataSet=" <<
static_cast<unsigned>(this->
dataSet());
319 ss <<
"loggerRunning=" << (this->
loggerRunning() ?
"true" :
"false");
321 ss <<
"shouldExit=" << (this->
shouldExit() ?
"true" :
"false");
323 if (0 == strncmp(
"", this->
comment(), 1)) {
324 ss <<
"comment=" <<
"";
326 ss <<
"comment=" << this->
comment();
333#ifdef USE_WB_DATA_LOGGER_C_CONVERSION
336 std::string toString = buffer;
339 std::ostringstream ss;
350 ss << static_cast<unsigned>(this->
dataSet());
354 ss << (this->
shouldExit() ?
"true" :
"false");
356 if (0 == strncmp(
"", this->
comment(), 1)) {
365#ifdef USE_WB_DATA_LOGGER_C_CONVERSION
370 char * str_cstr =
const_cast<char *
>(t_str.c_str());
371 size_t temp_length = strlen(str_cstr);
372 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
377 char* var_str = &var_str_buffer[0];
379 char* key = &key_buffer[0];
386 if (index == 0 && str_cstr[0] ==
'{') {
392 for (
int i = index; i < length; i++) {
394 if (bracecount == 0 && str_cstr[i] ==
'=') {
399 if (bracecount == 0 && isspace(str_cstr[i])) {
406 if (bracecount == 0 && str_cstr[i] ==
',') {
410 if (str_cstr[i] ==
'{') {
414 if (str_cstr[i] ==
'}') {
416 if (bracecount < 0) {
421 if (i == length - 1) {
425 if (endKey >= startKey && endKey - startKey < length) {
426 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
427 key[(endKey - startKey) + 1] = 0;
431 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
432 var_str[(index - startVar) + 1] = 0;
438 if (strlen(key) > 0) {
439 if (0 == strcmp(
"machineName", key)) {
441 }
else if (0 == strcmp(
"currentState", key)) {
443 }
else if (0 == strcmp(
"currentSection", key)) {
445 }
else if (0 == strcmp(
"dataSet", key)) {
447 }
else if (0 == strcmp(
"loggerRunning", key)) {
449 }
else if (0 == strcmp(
"shouldExit", key)) {
451 }
else if (0 == strcmp(
"comment", key)) {
476 this->
set_dataSet(
static_cast<uint8_t
>(atoi(var_str)));
481 this->
set_loggerRunning(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
486 this->
set_shouldExit(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
498 }
while(index < length);
Provides a C++ wrapper around wb_data_logger.
size_t comment_size() const
const uint32_t & currentSection() const
DataLogger & operator=(const DataLogger &t_other)
Copy Assignment Operator.
void set_machineName(const char *t_newValue)
DataLogger(std::string t_machineName="", uint32_t t_currentState=0, uint32_t t_currentSection=0, uint8_t t_dataSet=0, bool t_loggerRunning=false, bool t_shouldExit=false, std::string t_comment="")
Create a new DataLogger.
void set_shouldExit(const bool &t_newValue)
const char & comment(int t_i) const
const bool & loggerRunning() const
DataLogger(const struct wb_data_logger &t_other)
Copy Constructor.
std::string description()
uint32_t & currentState()
void set_currentSection(const uint32_t &t_newValue)
void set_loggerRunning(const bool &t_newValue)
bool operator==(const DataLogger &t_other) const
const bool & shouldExit() const
const char * machineName() const
uint32_t & currentSection()
const uint8_t & dataSet() const
const char & machineName(int t_i) const
bool operator!=(const DataLogger &t_other) const
const uint32_t & currentState() const
DataLogger(const DataLogger &t_other)
Copy Constructor.
const char * comment() const
void set_currentState(const uint32_t &t_newValue)
void set_dataSet(const uint8_t &t_newValue)
char & machineName(int t_i)
void set_comment(const char *t_newValue)
void from_string(const std::string &t_str)
DataLogger(const std::string &t_str)
String Constructor.
size_t machineName_size() const
WHITEBOARD_POSTER_STRING_CONVERSION.
uint8_t dataSet
Enables selection of a data set to be logged (default = 0, joints and sensors) (NYI)
bool shouldExit
Switch to cause DataLogger to exit.
bool loggerRunning
Starts/Stops logging.
char machineName[40]
Name of the machine being monitored, but could be anything.
uint32_t currentSection
Section within the state (e.g.
char comment[30]
Comment to be attached to the logged data (NYI)
uint32_t currentState
The machine's currently executing state (use integer rather than the state's name)
const char * wb_data_logger_description(const struct wb_data_logger *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_data_logger * wb_data_logger_from_string(struct wb_data_logger *self, const char *str)
Convert from a string.
const char * wb_data_logger_to_string(const struct wb_data_logger *self, char *toString, size_t bufferSize)
Convert to a string.
#define DATA_LOGGER_TO_STRING_BUFFER_SIZE
#define DATA_LOGGER_DESC_BUFFER_SIZE