Fawkes API  Fawkes Development Version
sick_tim55x_ethernet_aqt.h
1 
2 /***************************************************************************
3  * sick_tim55x_ethernet_aqt.h - Retrieve data from Sick TiM 55x via Ethernet
4  *
5  * Created: Sun Jun 15 20:44:32 2014
6  * Copyright 2008-2014 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_LASER_SICK_TIM55X_ETHERNET_AQT_H_
24 #define __PLUGINS_LASER_SICK_TIM55X_ETHERNET_AQT_H_
25 
26 #include "sick_tim55x_common_aqt.h"
27 
28 #include <string>
29 #include <boost/asio.hpp>
30 
31 namespace fawkes {
32  class Mutex;
33 }
34 
36 {
37  public:
38  SickTiM55xEthernetAcquisitionThread(std::string &cfg_name, std::string &cfg_prefix);
39 
40  virtual void init();
41  virtual void finalize();
42  virtual void loop();
43 
44  private:
45  void open_device();
46  void close_device();
47  void flush_device();
48  void send_with_reply(const char *request, std::string *reply = NULL);
49 
50  void check_deadline();
51  void check_soft_timeout();
52 
53 #if BOOST_VERSION < 104800
54  void handle_read(boost::system::error_code ec, size_t bytes_read)
55  {
56  ec_ = ec;
57  bytes_read_ = bytes_read;
58  }
59 #endif
60 
61  private:
62  std::string cfg_host_;
63  std::string cfg_port_;
64 
65  fawkes::Mutex *socket_mutex_;
66 
67  boost::asio::io_service io_service_;
68  boost::asio::ip::tcp::socket socket_;
69  boost::asio::deadline_timer deadline_;
70  boost::asio::deadline_timer soft_deadline_;
71  boost::asio::streambuf input_buffer_;
72 
73  boost::system::error_code ec_;
74  size_t bytes_read_;
75 };
76 
77 
78 #endif
Laser acqusition thread for Sick TiM55x laser range finders.
Fawkes library namespace.
Laser acqusition thread for Sick TiM55x laser range finders.
Mutex mutual exclusion lock.
Definition: mutex.h:32