|
TOBI Interface A
0.1
|
00001 /* 00002 This file is part of the TOBI Interface A (TiA) library. 00003 00004 Commercial Usage 00005 Licensees holding valid Graz University of Technology Commercial 00006 licenses may use this file in accordance with the Graz University 00007 of Technology Commercial License Agreement provided with the 00008 Software or, alternatively, in accordance with the terms contained in 00009 a written agreement between you and Graz University of Technology. 00010 00011 -------------------------------------------------- 00012 00013 GNU Lesser General Public License Usage 00014 Alternatively, this file may be used under the terms of the GNU Lesser 00015 General Public License version 3.0 as published by the Free Software 00016 Foundation and appearing in the file lgpl.txt included in the 00017 packaging of this file. Please review the following information to 00018 ensure the GNU General Public License version 3.0 requirements will be 00019 met: http://www.gnu.org/copyleft/lgpl.html. 00020 00021 In case of GNU Lesser General Public License Usage ,the TiA library 00022 is distributed in the hope that it will be useful, 00023 but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 GNU General Public License for more details. 00026 00027 You should have received a copy of the GNU Lesser General Public License 00028 along with the TiA library. If not, see <http://www.gnu.org/licenses/>. 00029 00030 Copyright 2010 Graz University of Technology 00031 Contact: TiA@tobi-project.org 00032 */ 00033 00041 #ifndef TIA_CLIENT_IMPL_H 00042 #define TIA_CLIENT_IMPL_H 00043 00044 // Boost 00045 #include <boost/asio.hpp> 00046 #include <boost/cstdint.hpp> 00047 00048 // local 00049 #include "tia-private/client/tia_client_impl_base.h" 00050 #include "tia/ssconfig.h" 00051 #include "tia/defines.h" 00052 00053 namespace tia 00054 { 00055 // forward declaration 00056 class ControlMsgEncoder; 00057 class ControlMsgDecoder; 00058 class DataPacket; 00059 class SSConfig; 00060 00061 //----------------------------------------------------------------------------- 00068 class TiAClientImpl : public TiAClientImplBase 00069 { 00070 public: 00074 TiAClientImpl(); 00078 virtual ~TiAClientImpl(); 00087 virtual void connect(const std::string& address, short unsigned port); 00094 virtual bool connected() const; 00100 virtual void disconnect(); 00107 virtual void requestConfig(); 00112 virtual SSConfig config() const; 00120 virtual void startReceiving(bool use_udp_bc); 00126 virtual bool receiving() const; 00132 virtual void stopReceiving(); 00142 virtual void getDataPacket(DataPacket& packet); 00143 00147 virtual DataPacket* getEmptyDataPacket(); 00148 00153 virtual void setBufferSize(size_t size); 00154 00155 protected: 00156 enum ControlConnState 00157 { 00158 ControlConnState_NotConnected = 0, 00159 ControlConnState_Connected = 1 00160 }; 00161 00162 enum DataInputState 00163 { 00164 DataInputState_NotConnected = 0, 00165 DataInputState_Connected, 00166 DataInputState_Receiving 00167 }; 00168 00169 protected: 00175 void establishDataConnection(bool use_udp_bc); 00180 void closeDataConnection(); 00181 00182 protected: 00183 boost::asio::io_service io_service_; 00184 boost::asio::ip::tcp::iostream ctl_conn_stream_; 00185 00186 boost::asio::ip::tcp::socket data_socket_tcp_; 00187 boost::asio::ip::udp::socket data_socket_udp_; 00188 00189 ControlMsgEncoder* msg_encoder_; 00190 ControlMsgDecoder* msg_decoder_; 00191 00192 int ctl_conn_state_; 00193 int data_input_state_; 00194 00195 SSConfig config_; 00196 bool use_udp_bc_; 00197 00198 boost::uint64_t last_packet_nr_; 00199 boost::uint32_t packet_offset_; 00200 boost::uint32_t buffer_offset_; 00201 size_t buffered_data_; 00202 00203 size_t buffer_size_; 00204 00205 std::vector<char> recv_buf_; 00206 std::vector<char> data_buf_; 00207 boost::asio::ip::tcp::endpoint tcp_target_; 00208 00209 boost::shared_ptr<DataPacket> packet_; 00210 00211 #ifdef TIMING_TEST 00212 private: 00213 bool lpt_flag_; 00214 #endif 00215 }; 00216 00217 } // Namespace tobiss 00218 //----------------------------------------------------------------------------- 00219 00220 #endif // TIA_CLIENT_IMPL_H