00001 // 00002 // Measurement.cpp 00003 // 00004 // Defines a very basic measurement and its list 00005 // 00006 // Copyright (c) Sick AG 00007 // created: 31.05.2010 00008 // 00009 // HISTORY 00010 // 00011 // 1.0.0 31.05.2010, VWi 00012 // Initial version. 00013 00014 00015 #include <string> // for std::string 00016 #include <vector> // for std::vector 00017 #include "Measurement.hpp" 00018 #include "../tools/toolbox.hpp" 00019 00020 namespace datatypes 00021 { 00022 00023 // 00024 // Returns the type as a readable string. 00025 // 00026 std::string Measurement::getName() const 00027 { 00028 std::string name; 00029 00030 switch (m_measType) 00031 { 00032 case Meastype_Unknown: 00033 name = "Unknown"; 00034 break; 00035 case Meastype_Brightness: 00036 name = "Brightness"; 00037 break; 00038 case Meastype_DeviceName: 00039 name = "DeviceName"; 00040 break; 00041 case Meastype_DeviceVersion: 00042 name = "DeviceVersion"; 00043 break; 00044 case Meastype_ScanFreq: 00045 name = "ScanFreq"; 00046 break; 00047 case Meastype_ScanResolution: 00048 name = "ScanResolution"; 00049 break; 00050 case Meastype_ScanStartAngle: 00051 name = "ScanStartAngle"; 00052 break; 00053 case Meastype_ScanStopAngle: 00054 name = "ScanStopAngle"; 00055 break; 00056 default: 00057 name = "(uninitialized)"; 00058 } 00059 00060 return name; 00061 } 00062 00063 // 00064 // Returns the value as a readable string. 00065 // 00066 std::string Measurement::valueToString() const 00067 { 00068 std::string value; 00069 00070 switch (m_measType) 00071 { 00072 case Meastype_Unknown: 00073 value = "Unknown"; 00074 break; 00075 case Meastype_DeviceName: 00076 case Meastype_DeviceVersion: 00077 value = m_textValue; 00078 break; 00079 case Meastype_ScanFreq: 00080 case Meastype_ScanResolution: 00081 case Meastype_ScanStartAngle: 00082 case Meastype_ScanStopAngle: 00083 value = ::toString(m_doubleValue, 8); 00084 break; 00085 default: 00086 value = "(uninitialized)"; 00087 } 00088 00089 return value; 00090 } 00091 00092 00093 } // namespace datatypes