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
static constexpr OperationResult convertToOperationResult(const uint32_t &value)
static constexpr Type convertToReplyType(const uint32_t &value)
constexpr Message(const Type &type, const OperationResult &result)
OperationResult
Defines the operation result from the scanner.
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
Type
Defines the possible types of reply messages which can be received from the scanner.
Higher level data type representing a reply message from the scanner.


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Nov 5 2022 02:13:36