scanner_communication_interface.h
Go to the documentation of this file.
1 // Copyright (c) 2020 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #ifndef SCANNER_COMMUNICATION_INTERFACE_H
17 #define SCANNER_COMMUNICATION_INTERFACE_H
18 
19 #include <stdexcept>
20 #include <chrono>
21 
22 #include <boost/asio.hpp>
23 
24 namespace psen_scan
25 {
26 class ScannerOpenFailed : public std::runtime_error
27 {
28 public:
29  ScannerOpenFailed(const std::string error_desc) : std::runtime_error(error_desc)
30  {
31  }
32 };
33 
34 class ScannerWriteFailed : public std::runtime_error
35 {
36 public:
37  ScannerWriteFailed(const std::string error_desc) : std::runtime_error(error_desc)
38  {
39  }
40 };
41 
42 class ScannerReadTimeout : public std::runtime_error
43 {
44 public:
45  ScannerReadTimeout(const std::string error_desc) : std::runtime_error(error_desc)
46  {
47  }
48 };
49 
50 class ScannerReadFailed : public std::runtime_error
51 {
52 public:
53  ScannerReadFailed(const std::string error_desc) : std::runtime_error(error_desc)
54  {
55  }
56 };
57 
58 class ScannerCloseFailed : public std::runtime_error
59 {
60 public:
61  ScannerCloseFailed(const std::string error_desc) : std::runtime_error(error_desc)
62  {
63  }
64 };
65 
66 // LCOV_EXCL_START
71 {
72 public:
73  virtual ~ScannerCommunicationInterface() = default;
74 
75 public:
77  virtual void open() = 0;
79  virtual void close() = 0;
80 
83  virtual void write(const boost::asio::mutable_buffers_1& buffer) = 0;
84 
90  virtual std::size_t read(boost::asio::mutable_buffers_1& buffer,
91  const std::chrono::steady_clock::duration timeout) = 0;
92 };
93 // LCOV_EXCL_STOP
94 
95 } // namespace psen_scan
96 
97 #endif // SCANNER_COMMUNICATION_INTERFACE_H
ScannerReadFailed(const std::string error_desc)
Abstract base class for the communication interface with the PSENscan scanner.
ScannerOpenFailed(const std::string error_desc)
ScannerWriteFailed(const std::string error_desc)
ScannerCloseFailed(const std::string error_desc)
ScannerReadTimeout(const std::string error_desc)


psen_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:16:20