io_pin_data.h
Go to the documentation of this file.
1 // Copyright (c) 2021-2022 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_IO_PIN_DATA_H
17 #define PSEN_SCAN_V2_STANDALONE_IO_PIN_DATA_H
18 
19 #include <array>
20 #include <bitset>
21 #include <ostream>
22 #include <string>
23 
24 #include <fmt/format.h>
25 #include <fmt/ostream.h>
26 
29 
31 {
32 namespace data_conversion_layer
33 {
34 namespace monitoring_frame
35 {
40 namespace io
41 {
44 
46 static inline LogicalInputType getInputType(std::size_t byte_location, std::size_t bit_location)
47 {
48  return LOGICAL_INPUT_BITS.at(byte_location).at(bit_location);
49 }
50 
52 static inline std::string getInputName(std::size_t byte_location, std::size_t bit_location)
53 {
54  return LOGICAL_INPUT_BIT_TO_NAME.at(getInputType(byte_location, bit_location));
55 }
56 
58 static inline OutputType getOutputType(std::size_t byte_location, std::size_t bit_location)
59 {
60  return OUTPUT_BITS.at(byte_location).at(bit_location);
61 }
62 
64 static inline std::string getOutputName(std::size_t byte_location, std::size_t bit_location)
65 {
66  return OUTPUT_BIT_TO_NAME.at(getOutputType(byte_location, bit_location));
67 }
68 
72 struct PinData
73 {
74  bool operator==(const PinData& pin_data) const;
75  std::array<std::bitset<8>, NUMBER_OF_INPUT_BYTES> input_state{};
76  std::array<std::bitset<8>, NUMBER_OF_OUTPUT_BYTES> output_state{};
77 };
78 
79 inline bool PinData::operator==(const PinData& pin_data) const
80 {
81  return input_state == pin_data.input_state && output_state == pin_data.output_state;
82 }
83 
84 inline std::ostream& operator<<(std::ostream& os, const PinData& pd)
85 {
86  return os << fmt::format("io::PinData(input = {}, output = {})",
89 }
90 
91 } // namespace io
92 } // namespace monitoring_frame
93 } // namespace data_conversion_layer
94 } // namespace psen_scan_v2_standalone
95 #endif // PSEN_SCAN_V2_STANDALONE_IO_PIN_DATA_H
static constexpr std::array< std::array< Lit, 8 >, RAW_CHUNK_LOGICAL_INPUT_SIGNALS_IN_BYTES > LOGICAL_INPUT_BITS
Definition: io_constants.h:109
static std::string getOutputName(std::size_t byte_location, std::size_t bit_location)
Definition: io_pin_data.h:64
static OutputType getOutputType(std::size_t byte_location, std::size_t bit_location)
Definition: io_pin_data.h:58
static std::string getInputName(std::size_t byte_location, std::size_t bit_location)
Definition: io_pin_data.h:52
Represents the IO PIN field of a monitoring frame.
Definition: io_pin_data.h:72
static constexpr std::array< std::array< Ot, 8 >, RAW_CHUNK_OUTPUT_SIGNALS_IN_BYTES > OUTPUT_BITS
Definition: io_constants.h:154
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
static LogicalInputType getInputType(std::size_t byte_location, std::size_t bit_location)
Definition: io_pin_data.h:46
std::string formatRange(const T &range)
Definition: format_range.h:38
std::ostream & operator<<(std::ostream &os, const PinData &pd)
Definition: io_pin_data.h:84
std::array< std::bitset< 8 >, NUMBER_OF_OUTPUT_BYTES > output_state
Definition: io_pin_data.h:76
std::array< std::bitset< 8 >, NUMBER_OF_INPUT_BYTES > input_state
Definition: io_pin_data.h:75


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