00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "C_LogValue.hpp"
00021 #include "Utils.hpp"
00022 #include "string_t.hpp"
00023
00024 C_LogValue::C_LogValue(char *P_string) {
00025 m_type = E_TYPE_STRING ;
00026 ALLOC_TABLE (m_string,
00027 char*,
00028 sizeof(char),
00029 100);
00030 strncpy(m_string, P_string, 100);
00031 }
00032 C_LogValue::C_LogValue(double P_time, double P_data) {
00033 m_type = E_TYPE_DATA ;
00034 ALLOC_TABLE (m_string,
00035 char*,
00036 sizeof(char),
00037 100);
00038 m_data.m_x = P_time ;
00039 m_data.m_y = P_data ;
00040 }
00041 C_LogValue::~C_LogValue() {
00042 FREE_TABLE (m_string)
00043 }
00044 void C_LogValue::set_string (char *P_string) {
00045 m_type = E_TYPE_STRING ;
00046 strncpy(m_string, P_string, 100);
00047 }
00048 void C_LogValue::set_data (double P_time, double P_data) {
00049 m_type = E_TYPE_DATA ;
00050 m_data.m_x = P_time ;
00051 m_data.m_y = P_data ;
00052 }
00053 void C_LogValue::get_value (char *P_buf) {
00054 switch (m_type) {
00055 case E_TYPE_STRING:
00056 strncpy(P_buf, m_string, 100);
00057 break ;
00058 case E_TYPE_DATA:
00059 snprintf(P_buf, 100, (char*)"%f;%f;", m_data.m_x,
00060 m_data.m_y);
00061 break ;
00062 }
00063 }