17 #ifndef SCIP2_RESPONSE_STREAM_H
18 #define SCIP2_RESPONSE_STREAM_H
20 #include <boost/asio.hpp>
44 using Callback = boost::function<void(
45 const boost::posix_time::ptime&,
56 const boost::posix_time::ptime&,
62 const boost::posix_time::ptime& time_read,
63 const std::string& echo_back,
64 const std::string& status,
73 if (!std::getline(stream, stamp))
78 const uint8_t
checksum = stamp.back();
87 auto it = dec.begin();
89 if ((dec.getChecksum() & 0x3F) + 0x30 !=
checksum)
107 return std::string(
"MD");
110 const boost::posix_time::ptime& time_read,
111 const std::string& echo_back,
112 const std::string& status,
113 std::istream& stream)
override
116 if (!
readTimestamp(time_read, echo_back, status, stream, scan))
120 cb_(time_read, echo_back, status, scan);
129 while (std::getline(stream, line))
131 if (line.size() == 0)
134 const uint8_t
checksum = line.back();
142 auto it = dec.begin();
143 for (; it != dec.end(); ++it)
147 remain = it.getRemain();
148 if ((dec.getChecksum() & 0x3F) + 0x30 !=
checksum)
150 logger::error() <<
"Checksum mismatch; scan dropped" << std::endl
151 << line << std::endl;
157 cb_(time_read, echo_back, status, scan);
167 return std::string(
"ME");
170 const boost::posix_time::ptime& time_read,
171 const std::string& echo_back,
172 const std::string& status,
173 std::istream& stream)
override
176 if (!
readTimestamp(time_read, echo_back, status, stream, scan))
179 cb_(time_read, echo_back, status, scan);
187 while (std::getline(stream, line))
189 if (line.size() == 0)
192 const uint8_t
checksum = line.back();
200 auto it = dec.begin();
201 for (; it != dec.end(); ++it)
203 scan.
ranges_.push_back((*it) >> 18);
206 remain = it.getRemain();
207 if ((dec.getChecksum() & 0x3F) + 0x30 !=
checksum)
209 logger::error() <<
"Checksum mismatch; scan dropped" << std::endl
210 << line << std::endl;
216 cb_(time_read, echo_back, status, scan);
223 #endif // SCIP2_RESPONSE_STREAM_H