scanner_reply_msg.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 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 PSEN_SCAN_V2_STANDALONE_SCANNER_REPLY_MSG_H
17 #define PSEN_SCAN_V2_STANDALONE_SCANNER_REPLY_MSG_H
18 
19 #include <cstdint>
20 
22 {
23 namespace data_conversion_layer
24 {
28 namespace scanner_reply
29 {
33 class Message
34 {
35 public:
37  enum class Type : uint32_t
38  {
39  unknown = 0,
40  start = 0x35,
41  stop = 0x36,
42  };
43 
45  enum class OperationResult : uint32_t
46  {
47  accepted = 0x00,
48  refused = 0xEB,
49  unknown = 0xFF
50  };
51 
52  // See protocol description
53  static constexpr std::size_t SIZE{ 16u };
54 
55 public:
56  static constexpr Type convertToReplyType(const uint32_t& value);
57  static constexpr OperationResult convertToOperationResult(const uint32_t& value);
58 
59 public:
60  constexpr Message(const Type& type, const OperationResult& result);
61 
62  constexpr Type type() const;
63  constexpr OperationResult result() const;
64 
65 private:
66  const Type type_;
68 };
69 
70 inline constexpr Message::Type Message::convertToReplyType(const uint32_t& value)
71 {
72  Type retval{ static_cast<Type>(value) };
73  if ((retval != Type::start) && (retval != Type::stop))
74  {
75  retval = Type::unknown;
76  }
77  return retval;
78 }
79 
80 inline constexpr Message::OperationResult Message::convertToOperationResult(const uint32_t& value)
81 {
82  OperationResult retval{ static_cast<OperationResult>(value) };
83  if ((retval != OperationResult::accepted) && (retval != OperationResult::refused))
84  {
85  retval = OperationResult::unknown;
86  }
87  return retval;
88 }
89 
90 inline constexpr Message::Message(const Type& type, const OperationResult& result) : type_(type), result_(result)
91 {
92 }
93 
94 inline constexpr Message::Type Message::type() const
95 {
96  return type_;
97 }
98 
99 inline constexpr Message::OperationResult Message::result() const
100 {
101  return result_;
102 }
103 
104 } // namespace scanner_reply
105 } // namespace data_conversion_layer
106 } // namespace psen_scan_v2_standalone
107 #endif // PSEN_SCAN_V2_STANDALONE_SCANNER_REPLY_MSG_H
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type
Type
Defines the possible types of reply messages which can be received from the scanner.
Definition: scanner_reply_msg.h:37
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::type_
const Type type_
Definition: scanner_reply_msg.h:66
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult
OperationResult
Defines the operation result from the scanner.
Definition: scanner_reply_msg.h:45
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type::start
@ start
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::result
constexpr OperationResult result() const
Definition: scanner_reply_msg.h:99
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::result_
const OperationResult result_
Definition: scanner_reply_msg.h:67
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::type
constexpr Type type() const
Definition: scanner_reply_msg.h:94
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message
Higher level data type representing a reply message from the scanner.
Definition: scanner_reply_msg.h:33
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::convertToReplyType
static constexpr Type convertToReplyType(const uint32_t &value)
Definition: scanner_reply_msg.h:70
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::convertToOperationResult
static constexpr OperationResult convertToOperationResult(const uint32_t &value)
Definition: scanner_reply_msg.h:80
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult::accepted
@ accepted
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type::stop
@ stop
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Message
constexpr Message(const Type &type, const OperationResult &result)
Definition: scanner_reply_msg.h:90
psen_scan_v2_standalone
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult::unknown
@ unknown
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type::unknown
@ unknown
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult::refused
@ refused
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::SIZE
static constexpr std::size_t SIZE
Definition: scanner_reply_msg.h:53


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:12