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:
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
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
psen_scan_v2_standalone::configuration::ScannerId
ScannerId
Definition: scanner_ids.h:27
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MessageStamped::msg_
Message msg_
Definition: monitoring_frame_msg.h:111
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasIOPinField
bool hasIOPinField() const
Definition: monitoring_frame_msg.cpp:128
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::scannerId
configuration::ScannerId scannerId() const
Definition: monitoring_frame_msg.cpp:31
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasActiveZonesetField
bool hasActiveZonesetField() const
Definition: monitoring_frame_msg.cpp:123
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::scanner_id_
configuration::ScannerId scanner_id_
Definition: monitoring_frame_msg.h:90
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::AdditionalFieldMissing
Exception thrown if an additional field was missing during deserialization of a Message.
Definition: monitoring_frame_msg.h:49
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::fromTheta
util::TenthOfDegree fromTheta() const
Definition: monitoring_frame_msg.cpp:36
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::diagnostic_messages_
boost::optional< std::vector< diagnostic::Message > > diagnostic_messages_
Definition: monitoring_frame_msg.h:99
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::io::PinData
Represents the IO PIN field of a monitoring frame.
Definition: io_pin_data.h:72
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::intensities_
boost::optional< std::vector< double > > intensities_
Definition: monitoring_frame_msg.h:98
psen_scan_v2_standalone::configuration::VALID_SCANNER_IDS
static constexpr std::array< ScannerId, 4 > VALID_SCANNER_IDS
Definition: scanner_ids.h:35
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MessageStamped::MessageStamped
MessageStamped(const Message &message, const int64_t timestamp)
Definition: monitoring_frame_msg.h:111
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MessageBuilder
Definition: monitoring_frame_msg_builder.h:33
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::scan_counter_
boost::optional< uint32_t > scan_counter_
Definition: monitoring_frame_msg.h:94
tenth_of_degree.h
message
def message(msg, *args, **kwargs)
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasScanCounterField
bool hasScanCounterField() const
Definition: monitoring_frame_msg.cpp:118
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasDiagnosticMessagesField
bool hasDiagnosticMessagesField() const
Definition: monitoring_frame_msg.cpp:143
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasMeasurementsField
bool hasMeasurementsField() const
Definition: monitoring_frame_msg.cpp:133
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::iOPinData
const io::PinData & iOPinData() const
Definition: monitoring_frame_msg.cpp:70
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::scanCounter
uint32_t scanCounter() const
Definition: monitoring_frame_msg.cpp:46
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MessageStamped
Wrapping class for a Message and its corresponding timestamp.
Definition: monitoring_frame_msg.h:109
diagnostics.h
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::diagnosticMessages
std::vector< diagnostic::Message > diagnosticMessages() const
Definition: monitoring_frame_msg.cpp:106
psen_scan_v2_standalone::configuration::ScannerId::master
@ master
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::AdditionalFieldMissing::AdditionalFieldMissing
AdditionalFieldMissing(const std::string &field_name)
Definition: monitoring_frame_msg.h:116
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::active_zoneset_
boost::optional< uint8_t > active_zoneset_
Definition: monitoring_frame_msg.h:95
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MAX_SCANNER_ID
static constexpr uint8_t MAX_SCANNER_ID
Definition: monitoring_frame_msg.h:44
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::measurements_
boost::optional< std::vector< double > > measurements_
Definition: monitoring_frame_msg.h:97
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::intensities
const std::vector< double > & intensities() const
Definition: monitoring_frame_msg.cpp:94
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::from_theta_
util::TenthOfDegree from_theta_
Definition: monitoring_frame_msg.h:91
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::measurements
const std::vector< double > & measurements() const
Definition: monitoring_frame_msg.cpp:82
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MessageStamped::stamp_
int64_t stamp_
Definition: monitoring_frame_msg.h:113
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::activeZoneset
uint8_t activeZoneset() const
Definition: monitoring_frame_msg.cpp:58
scanner_ids.h
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::io_pin_data_
boost::optional< io::PinData > io_pin_data_
Definition: monitoring_frame_msg.h:96
std
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::monitoring_frame::Message
Higher level data type representing a single monitoring frame.
Definition: monitoring_frame_msg.h:62
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::resolution
util::TenthOfDegree resolution() const
Definition: monitoring_frame_msg.cpp:41
psen_scan_v2_standalone::util::TenthOfDegree
Helper class representing angles in tenth of degree.
Definition: tenth_of_degree.h:34
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::resolution_
util::TenthOfDegree resolution_
Definition: monitoring_frame_msg.h:92
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasIntensitiesField
bool hasIntensitiesField() const
Definition: monitoring_frame_msg.cpp:138
io_pin_data.h


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