monitoring_frame_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_MONITORING_FRAME_MSG_H
17 #define PSEN_SCAN_V2_STANDALONE_MONITORING_FRAME_MSG_H
18 
19 #include <cstdint>
20 #include <stdexcept>
21 #include <string>
22 #include <vector>
23 
24 #include <boost/optional.hpp>
25 
30 
32 {
33 namespace data_conversion_layer
34 {
42 namespace monitoring_frame
43 {
44 static constexpr uint8_t MAX_SCANNER_ID{ configuration::VALID_SCANNER_IDS.size() - 1 };
45 
49 class AdditionalFieldMissing : public std::runtime_error
50 {
51 public:
52  AdditionalFieldMissing(const std::string& field_name);
53 };
54 
62 class Message
63 {
64 public:
65  configuration::ScannerId scannerId() const;
66  util::TenthOfDegree fromTheta() const;
67  util::TenthOfDegree resolution() const;
69  uint32_t scanCounter() const;
71  uint8_t activeZoneset() const;
73  const io::PinData& iOPinData() const;
75  const std::vector<double>& measurements() const;
77  const std::vector<double>& intensities() const;
79  std::vector<diagnostic::Message> diagnosticMessages() const;
80 
81  bool hasScanCounterField() const;
82  bool hasActiveZonesetField() const;
83  bool hasIOPinField() const;
84  bool hasMeasurementsField() const;
85  bool hasIntensitiesField() const;
86  bool hasDiagnosticMessagesField() const;
87 
88 private:
89  // fixed fields
91  util::TenthOfDegree from_theta_{ 0 };
92  util::TenthOfDegree resolution_{ 1 };
93  // additional fields
94  boost::optional<uint32_t> scan_counter_;
95  boost::optional<uint8_t> active_zoneset_;
96  boost::optional<io::PinData> io_pin_data_;
97  boost::optional<std::vector<double>> measurements_;
98  boost::optional<std::vector<double>> intensities_;
99  boost::optional<std::vector<diagnostic::Message>> diagnostic_messages_;
100 
101 public:
102  friend class MessageBuilder;
103 };
104 
110 {
111  MessageStamped(const Message& message, const int64_t timestamp) : msg_(message), stamp_(timestamp){};
112  Message msg_;
113  int64_t stamp_;
114 };
115 
116 inline AdditionalFieldMissing::AdditionalFieldMissing(const std::string& field_name)
117  : std::runtime_error(field_name + " not set! (Contact PILZ support if the error persists.)")
118 {
119 }
120 } // namespace monitoring_frame
121 } // namespace data_conversion_layer
122 } // namespace psen_scan_v2_standalone
123 
124 #endif // PSEN_SCAN_V2_STANDALONE_MONITORING_FRAME_MSG_H
Higher level data type representing a single monitoring frame.
Exception thrown if an additional field was missing during deserialization of a Message.
static constexpr std::array< ScannerId, 4 > VALID_SCANNER_IDS
Definition: scanner_ids.h:35
Represents the IO PIN field of a monitoring frame.
Definition: io_pin_data.h:72
Wrapping class for a Message and its corresponding timestamp.
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
boost::optional< std::vector< diagnostic::Message > > diagnostic_messages_
Helper class representing angles in tenth of degree.


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