Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef COLAA_HPP
00008 #define COLAA_HPP
00009
00010 #include "sick_scan/tcp/BasicDatatypes.hpp"
00011
00012
00017 namespace colaa
00018 {
00019
00020
00021
00022
00023 UINT16 getValueOfChar(UINT8 c);
00024 UINT8 nibbleToAscii(UINT8 value);
00025
00026 void addFrameToBuffer(UINT8* sendBuffer, UINT8* cmdBuffer, UINT16* len);
00027 UINT16 addUINT8ToBuffer(UINT8* buffer, UINT8 value);
00028 UINT16 addUINT16ToBuffer(UINT8* buffer, UINT16 value);
00029 UINT16 addINT8ToBuffer(UINT8* buffer, INT8 value);
00030 UINT16 addINT32ToBuffer(UINT8* buffer, INT32 value);
00031 UINT16 addUINT32ToBuffer(UINT8* buffer, UINT32 value);
00032 UINT16 addStringToBuffer(UINT8* buffer, const std::string& text);
00033 std::string getNextStringToken(std::string* rxData);
00034
00035 namespace detail
00036 {
00037 UINT16 writeToBuffer(BYTE* buffer, double value);
00038 inline UINT16 writeToBuffer(BYTE* buffer, UINT8 value) { return addUINT8ToBuffer(buffer, value); }
00039 inline UINT16 writeToBuffer(BYTE* buffer, INT8 value) { return addINT8ToBuffer(buffer, value); }
00040 inline UINT16 writeToBuffer(BYTE* buffer, UINT16 value) { return addUINT16ToBuffer(buffer, value); }
00041 inline UINT16 writeToBuffer(BYTE* buffer, INT16 value) { return addUINT16ToBuffer(buffer, value); }
00042 inline UINT16 writeToBuffer(BYTE* buffer, UINT32 value) { return addUINT32ToBuffer(buffer, value); }
00043 inline UINT16 writeToBuffer(BYTE* buffer, INT32 value) { return addINT32ToBuffer(buffer, value); }
00044 inline UINT16 writeToBuffer(BYTE* buffer, const std::string& value) { return addStringToBuffer(buffer, value); }
00045 }
00046
00047 double decodeReal(std::string* rxData);
00048 INT16 decodeINT16(std::string* rxData);
00049 INT32 decodeINT32(std::string* rxData);
00050 UINT32 decodeUINT32(std::string* rxData);
00051 UINT16 decodeUINT16(std::string* rxData);
00052 UINT8 decodeUINT8(std::string* rxData);
00053 UINT32 decodeXByte(std::string* rxData, UINT16 len);
00054 std::string decodeString(std::string* rxData, UINT16 len = 0);
00055 std::string convertRxBufferToString(UINT8* buffer, UINT16 bufferLen);
00056
00058 double decodeReal(const std::string& rxData);
00059 INT16 decodeINT16(const std::string& rxData);
00060 INT32 decodeINT32(const std::string& rxData);
00061 UINT8 decodeUINT8(const std::string& rxData);
00062 UINT16 decodeUINT16(const std::string& rxData);
00063 UINT32 decodeUINT32(const std::string& rxData);
00064
00065
00066 UINT16 decodeUINT16(BYTE* buffer);
00067
00068 namespace detail
00069 {
00071 template<typename T>
00072 inline T read (const std::string& str)
00073 {
00074
00075 return T();
00076 }
00077 template<> inline double read<double>(const std::string& rxData) { return decodeReal(rxData); }
00078 template<> inline INT16 read<INT16>(const std::string& rxData) { return decodeINT16(rxData); }
00079 template<> inline INT32 read<INT32>(const std::string& rxData) { return decodeINT32(rxData); }
00080 template<> inline INT8 read<INT8>(const std::string& rxData) { return decodeUINT8(rxData); }
00081 template<> inline UINT8 read<UINT8>(const std::string& rxData) { return decodeUINT8(rxData); }
00082 template<> inline UINT32 read<UINT32>(const std::string& rxData) { return decodeUINT32(rxData); }
00083 template<> inline UINT16 read<UINT16>(const std::string& rxData) { return decodeUINT16(rxData); }
00084 template<> inline std::string read<std::string>(const std::string& rxData) { return rxData; }
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 }
00101 #endif