colaa.hpp
Go to the documentation of this file.
1 //
2 // colaa.hpp
3 //
4 // (c) 2011 SICK AG, Hamburg, Germany
5 //
6 
7 #ifndef COLAA_HPP
8 #define COLAA_HPP
9 
11 // #include <boost/tokenizer.hpp>
12 
17 namespace colaa
18 {
19 
20 // typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
21 // typedef boost::char_separator<char> separator_type;
22 
25 
26 void addFrameToBuffer(UINT8* sendBuffer, UINT8* cmdBuffer, UINT16* len);
27 UINT16 addUINT8ToBuffer(UINT8* buffer, UINT8 value);
28 UINT16 addUINT16ToBuffer(UINT8* buffer, UINT16 value);
29 UINT16 addINT8ToBuffer(UINT8* buffer, INT8 value);
30 UINT16 addINT32ToBuffer(UINT8* buffer, INT32 value);
31 UINT16 addUINT32ToBuffer(UINT8* buffer, UINT32 value);
32 UINT16 addStringToBuffer(UINT8* buffer, const std::string& text);
33 std::string getNextStringToken(std::string* rxData);
34 
35 namespace detail
36 {
37 UINT16 writeToBuffer(BYTE* buffer, double value);
38 inline UINT16 writeToBuffer(BYTE* buffer, UINT8 value) { return addUINT8ToBuffer(buffer, value); }
39 inline UINT16 writeToBuffer(BYTE* buffer, INT8 value) { return addINT8ToBuffer(buffer, value); }
40 inline UINT16 writeToBuffer(BYTE* buffer, UINT16 value) { return addUINT16ToBuffer(buffer, value); }
41 inline UINT16 writeToBuffer(BYTE* buffer, INT16 value) { return addUINT16ToBuffer(buffer, value); }
42 inline UINT16 writeToBuffer(BYTE* buffer, UINT32 value) { return addUINT32ToBuffer(buffer, value); }
43 inline UINT16 writeToBuffer(BYTE* buffer, INT32 value) { return addINT32ToBuffer(buffer, value); }
44 inline UINT16 writeToBuffer(BYTE* buffer, const std::string& value) { return addStringToBuffer(buffer, value); }
45 }
46 
47 double decodeReal(std::string* rxData);
48 INT16 decodeINT16(std::string* rxData);
49 INT32 decodeINT32(std::string* rxData);
50 UINT32 decodeUINT32(std::string* rxData);
51 UINT16 decodeUINT16(std::string* rxData);
52 UINT8 decodeUINT8(std::string* rxData);
53 UINT32 decodeXByte(std::string* rxData, UINT16 len);
54 std::string decodeString(std::string* rxData, UINT16 len = 0);
55 std::string convertRxBufferToString(UINT8* buffer, UINT16 bufferLen);
56 
58 double decodeReal(const std::string& rxData);
59 INT16 decodeINT16(const std::string& rxData);
60 INT32 decodeINT32(const std::string& rxData);
61 UINT8 decodeUINT8(const std::string& rxData);
62 UINT16 decodeUINT16(const std::string& rxData);
63 UINT32 decodeUINT32(const std::string& rxData);
64 
65 //
66 UINT16 decodeUINT16(BYTE* buffer);
67 
68 namespace detail
69 {
71 template<typename T>
72 inline T read (const std::string& str)
73 {
74 // BOOST_STATIC_ASSERT(sizeof(T) == 0); // must not be instantiated
75  return T(); // to avoid additional compiler errors
76 }
77 template<> inline double read<double>(const std::string& rxData) { return decodeReal(rxData); }
78 template<> inline INT16 read<INT16>(const std::string& rxData) { return decodeINT16(rxData); }
79 template<> inline INT32 read<INT32>(const std::string& rxData) { return decodeINT32(rxData); }
80 template<> inline INT8 read<INT8>(const std::string& rxData) { return decodeUINT8(rxData); }
81 template<> inline UINT8 read<UINT8>(const std::string& rxData) { return decodeUINT8(rxData); }
82 template<> inline UINT32 read<UINT32>(const std::string& rxData) { return decodeUINT32(rxData); }
83 template<> inline UINT16 read<UINT16>(const std::string& rxData) { return decodeUINT16(rxData); }
84 template<> inline std::string read<std::string>(const std::string& rxData) { return rxData; }
85 }
86 
87 //
88 // Lese ein XByte-Array bekannter Laenge (1..4 Bytes) und verpacke es als UINT32-Wert.
89 // Das 1. empfangene Byte steht in den unteren 8 Bit des Ergebniswerts, usw.
90 //
91 // HINWEIS: der Iterator wird weitergeschoben len-1 mal. Um das naechste Element zu lesen
92 // muss vorher ++tok aufgerufen werden.
93 //
94 // @param begin = Startpunkt, von wo aus einzelne Stringtokens in Zahlen verwandelt werden
95 // @param end = Ende des containers, ueber den iteriert wird
96 // @param len = Anzahl der Bytes (= Array-Elemente)
97 //
98 //UINT32 decodeXByte(tokenizer::const_iterator& tok, const tokenizer::const_iterator& end, UINT16 len);
99 
100 } // END namespace colaa
101 #endif
UINT16
uint16_t UINT16
Definition: BasicDatatypes.hpp:27
UINT8
uint8_t UINT8
Definition: BasicDatatypes.hpp:29
colaa::decodeUINT8
UINT8 decodeUINT8(std::string *rxData)
Definition: colaa.cpp:649
INT16
int16_t INT16
Definition: BasicDatatypes.hpp:28
BasicDatatypes.hpp
BYTE
unsigned char BYTE
INT8
int8_t INT8
Definition: BasicDatatypes.hpp:30
colaa::getNextStringToken
std::string getNextStringToken(std::string *rxData)
Definition: colaa.cpp:246
colaa::detail::read< UINT8 >
UINT8 read< UINT8 >(const std::string &rxData)
Definition: colaa.hpp:81
colaa::addUINT8ToBuffer
UINT16 addUINT8ToBuffer(UINT8 *buffer, UINT8 value)
Definition: colaa.cpp:111
colaa
Definition: colaa.cpp:21
colaa::detail::read< INT16 >
INT16 read< INT16 >(const std::string &rxData)
Definition: colaa.hpp:78
colaa::convertRxBufferToString
std::string convertRxBufferToString(UINT8 *buffer, UINT16 bufferLen)
Definition: colaa.cpp:793
INT32
int32_t INT32
Definition: BasicDatatypes.hpp:25
colaa::decodeXByte
UINT32 decodeXByte(std::string *rxData, UINT16 len)
Definition: colaa.cpp:735
colaa::addINT8ToBuffer
UINT16 addINT8ToBuffer(UINT8 *buffer, INT8 value)
Definition: colaa.cpp:139
colaa::detail::read< INT32 >
INT32 read< INT32 >(const std::string &rxData)
Definition: colaa.hpp:79
colaa::addUINT16ToBuffer
UINT16 addUINT16ToBuffer(UINT8 *buffer, UINT16 value)
Definition: colaa.cpp:125
colaa::addINT32ToBuffer
UINT16 addINT32ToBuffer(UINT8 *buffer, INT32 value)
Definition: colaa.cpp:185
colaa::decodeReal
double decodeReal(std::string *rxData)
Definition: colaa.cpp:332
colaa::decodeUINT16
UINT16 decodeUINT16(BYTE *buffer)
Definition: colaa.cpp:627
colaa::decodeINT32
INT32 decodeINT32(std::string *rxData)
Definition: colaa.cpp:483
colaa::detail::read< double >
double read< double >(const std::string &rxData)
Definition: colaa.hpp:77
colaa::detail::read< UINT32 >
UINT32 read< UINT32 >(const std::string &rxData)
Definition: colaa.hpp:82
colaa::decodeString
std::string decodeString(std::string *rxData, UINT16 len)
Definition: colaa.cpp:603
colaa::detail::read< UINT16 >
UINT16 read< UINT16 >(const std::string &rxData)
Definition: colaa.hpp:83
colaa::decodeINT16
INT16 decodeINT16(std::string *rxData)
Definition: colaa.cpp:472
colaa::addUINT32ToBuffer
UINT16 addUINT32ToBuffer(UINT8 *buffer, UINT32 value)
Definition: colaa.cpp:200
colaa::detail::read
T read(const std::string &str)
General template which is unimplemented; implemented specializations follow below.
Definition: colaa.hpp:72
colaa::addStringToBuffer
UINT16 addStringToBuffer(UINT8 *buffer, const std::string &text)
Definition: colaa.cpp:224
colaa::decodeUINT32
UINT32 decodeUINT32(std::string *rxData)
Definition: colaa.cpp:434
UINT32
uint32_t UINT32
Definition: BasicDatatypes.hpp:26
colaa::detail::writeToBuffer
UINT16 writeToBuffer(BYTE *buffer, double value)
Definition: colaa.cpp:234
colaa::detail::read< INT8 >
INT8 read< INT8 >(const std::string &rxData)
Definition: colaa.hpp:80
colaa::addFrameToBuffer
void addFrameToBuffer(UINT8 *sendBuffer, UINT8 *cmdBuffer, UINT16 *len)
Definition: colaa.cpp:82
colaa::getValueOfChar
UINT16 getValueOfChar(UINT8 c)
Definition: colaa.cpp:27
colaa::nibbleToAscii
UINT8 nibbleToAscii(UINT8 value)
Definition: colaa.cpp:53


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19