ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
Connection.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include <boost/array.hpp>
6#include <boost/asio.hpp>
7#include <boost/asio/buffer.hpp>
8#include <boost/make_shared.hpp>
9#include <boost/shared_ptr.hpp>
10
11#include <chrono>
12#include <memory>
13#include <thread>
14#include <vector>
15
16namespace ChimeraTK::Rebot {
17
19 class Connection {
20 public:
23 Connection(std::string address, std::string port, uint32_t connectionTimeout_sec);
24
26 void open();
27
29 void close();
30
32 std::vector<uint32_t> read(uint32_t numWordsToRead);
33
35 void write(const std::vector<uint32_t>& data);
36
38 bool isOpen();
39
40 private:
41 std::string address_;
42 const std::string port_;
43 boost::asio::io_context ioContext_;
44 boost::asio::ip::tcp::socket s_;
45 boost::asio::deadline_timer disconnectTimer_;
46 boost::asio::deadline_timer::duration_type connectionTimeout_;
47
48 void disconnectionTimerStart();
49 void disconnectionTimerCancel(const boost::system::error_code& ec);
50 };
51} // namespace ChimeraTK::Rebot
Handles the communication over TCP protocol with RebotDevice-based devices.
Definition Connection.h:19
void close()
Closes a connection with the device.
Definition Connection.cc:50
bool isOpen()
Get the connection state.
Definition Connection.cc:58
void open()
Opens a connection to the device.
Definition Connection.cc:17