colaa.hpp
Go to the documentation of this file.
00001 //
00002 // colaa.hpp
00003 //
00004 // (c) 2011 SICK AG, Hamburg, Germany
00005 //
00006 
00007 #ifndef COLAA_HPP
00008 #define COLAA_HPP
00009 
00010 #include "../BasicDatatypes.hpp"
00011 // #include <boost/tokenizer.hpp>
00012 
00017 namespace colaa
00018 {
00019 
00020 // typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
00021 // typedef boost::char_separator<char> separator_type;
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 //      BOOST_STATIC_ASSERT(sizeof(T) == 0); // must not be instantiated
00075         return T(); // to avoid additional compiler errors
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 // Lese ein XByte-Array bekannter Laenge (1..4 Bytes) und verpacke es als UINT32-Wert.
00089 // Das 1. empfangene Byte steht in den unteren 8 Bit des Ergebniswerts, usw.
00090 //
00091 // HINWEIS: der Iterator wird weitergeschoben len-1 mal. Um das naechste Element zu lesen
00092 //          muss vorher ++tok aufgerufen werden.
00093 //
00094 // @param begin = Startpunkt, von wo aus einzelne Stringtokens in Zahlen verwandelt werden
00095 // @param end = Ende des containers, ueber den iteriert wird
00096 // @param len = Anzahl der Bytes (= Array-Elemente)
00097 //
00098 //UINT32 decodeXByte(tokenizer::const_iterator& tok, const tokenizer::const_iterator& end, UINT16 len);
00099 
00100 } // END namespace colaa
00101 #endif


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Wed Jun 14 2017 04:04:50