50 if (bytes_received==0 || err)
52 if (err==ba::error::eof)
53 Warn(
"Connection closed by remote host.");
57 if (err && err!=ba::error::eof &&
58 err!=ba::error::basic_errors::not_connected &&
59 err!=ba::error::basic_errors::operation_aborted)
62 str <<
"Reading from " << URL() <<
": " << err.message() <<
" (" << err <<
")";
65 PostClose(err!=ba::error::basic_errors::operation_aborted);
71 const string str(
fArray.data(), bytes_received);
81 int hh=0, mm=0, ss=0, y=0, m=0, d=0;
83 bool keepalive =
false;
88 while (getline(is, line))
90 if (line.size()==1 && line[0]==13)
98 const size_t p = line.find_first_of(
": ");
102 std::transform(line.begin(), line.end(), line.begin(), (int(&)(int))std::tolower);
104 const string key = line.substr(0, p);
105 const string val = line.substr(p+2);
107 if (key==
"connection" && val==
"keep-alive")
114 if (line.substr(0, 2)==
"ZD")
115 data.
fZd = stoi(line.substr(2));
116 if (line.substr(0, 2)==
"AZ")
117 data.
fAz = stof(line.substr(2));
126 if (line.substr(0, 2)==
"T3")
127 data.
fT3 = stof(line.substr(2));
128 if (line.substr(0, 2)==
"T6")
129 data.
fT6 = stof(line.substr(2));
130 if (line.substr(0, 2)==
"T9")
131 data.
fT9 = stof(line.substr(2));
132 if (line.substr(0, 3)==
"T12")
133 data.
fT12 = stof(line.substr(3));
135 if (line.substr(0, 3)==
"CLB")
138 if (line.substr(0, 4)==
"HOUR")
139 hh = stoi(line.substr(4));
140 if (line.substr(0, 6)==
"MINUTS")
141 mm = stoi(line.substr(6));
142 if (line.substr(0, 7)==
"SECONDS")
143 ss = stoi(line.substr(7));
145 if (line.substr(0, 4)==
"YEAR")
146 y = stoi(line.substr(4));
147 if (line.substr(0, 5)==
"MONTH")
148 m = stoi(line.substr(5));
149 if (line.substr(0, 3)==
"DAY")
150 d = stoi(line.substr(3));
152 catch (
const exception &e)
154 Warn(
"Conversion of received data failed");
169 const Time tm =
Time(y>999 ? y : 2000+y, m, d, hh, mm, ss);
175 if (data.
fT3==0 && data.
fT6==0 && data.
fT9==0 && data.
fT12==0)
179 msg << tm.
GetAsStr(
"%H:%M:%S") <<
":" 183 <<
" T3-12=" << data.
fT3 188 <<
" Zd=" << data.
fZd <<
"°" 189 <<
" Az=" << data.
fAz <<
"°";
194 catch (
const exception &e)
196 Warn(
"Corrupted time received.");
virtual void UpdateLidar(const Time &, const DimLidar &)
Adds some functionality to boost::posix_time::ptime for our needs.
boost::array< char, 4096 > fArray
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const