io_state.cpp
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 #include <ostream>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
21 #include <fmt/format.h>
22 #include <fmt/ostream.h>
23 
27 
29 {
30 PinState::PinState(uint32_t pin_id, const std::string& name, bool state) : id_(pin_id), name_(name), state_(state)
31 {
32 }
33 
34 bool PinState::operator==(const PinState& ps) const
35 {
36  return id() == ps.id() && name() == ps.name() && state() == ps.state();
37 }
38 
39 bool PinState::operator!=(const PinState& ps) const
40 {
41  return !operator==(ps);
42 }
43 
44 uint32_t PinState::id() const
45 {
46  return id_;
47 }
48 
49 std::string PinState::name() const
50 {
51  return name_;
52 }
53 
54 bool PinState::state() const
55 {
56  return state_;
57 }
58 
59 std::ostream& operator<<(std::ostream& os, const PinState& pin_state)
60 {
61  os << fmt::format("PinState(id = {}, name = {}, state = {})", pin_state.id(), pin_state.name(), pin_state.state());
62  return os;
63 }
64 
66  : pin_data_(pin_data), timestamp_(timestamp)
67 {
68 }
69 
70 bool IOState::operator==(const IOState& io_state) const
71 {
72  return pin_data_ == io_state.pin_data_;
73 }
74 
75 bool IOState::operator!=(const IOState& io_state) const
76 {
77  return !operator==(io_state);
78 }
79 
80 std::vector<PinState> IOState::input() const
81 {
83 }
84 
85 std::vector<PinState> IOState::output() const
86 {
88 }
89 
90 int64_t IOState::timestamp() const
91 {
92  return timestamp_;
93 }
94 
95 std::vector<PinState> IOState::changedInputStates(const IOState& ref_state) const
96 {
98 }
99 
100 std::vector<PinState> IOState::changedOutputStates(const IOState& ref_state) const
101 {
103 }
104 
105 std::ostream& operator<<(std::ostream& os, const IOState& io_state)
106 {
107  return os << "IOState(timestamp = " << io_state.timestamp_ << " nsec, " << io_state.pin_data_ << ")";
108 }
109 } // namespace psen_scan_v2_standalone
PinState(uint32_t pin_id, const std::string &name, bool state)
Definition: io_state.cpp:30
Represents the set of all I/Os of the scanner and their states.
Definition: io_state.h:76
bool operator==(const PinState &ps) const
Definition: io_state.cpp:34
Represents a single I/O pin.
Definition: io_state.h:29
data_conversion_layer::monitoring_frame::io::PinData pin_data_
Definition: io_state.h:105
std::string name() const
Definition: io_state.cpp:49
static std::vector< PinState > generateChangedOutputStates(const monitoring_frame::io::PinData &new_state, const monitoring_frame::io::PinData &old_state)
static std::vector< PinState > generateChangedInputStates(const monitoring_frame::io::PinData &new_state, const monitoring_frame::io::PinData &old_state)
std::ostream & operator<<(std::ostream &os, const PinState &pin_state)
Definition: io_state.cpp:59
std::vector< PinState > input() const
Definition: io_state.cpp:80
Represents the IO PIN field of a monitoring frame.
Definition: io_pin_data.h:72
static std::vector< PinState > generateOutputPinStates(const monitoring_frame::io::PinData &pin_data)
std::vector< PinState > output() const
Definition: io_state.cpp:85
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
bool operator!=(const PinState &ps) const
Definition: io_state.cpp:39
std::vector< PinState > changedInputStates(const IOState &ref_state) const
Definition: io_state.cpp:95
std::vector< PinState > changedOutputStates(const IOState &ref_state) const
Definition: io_state.cpp:100
bool operator==(const IOState &io_state) const
Definition: io_state.cpp:70
bool operator!=(const IOState &io_state) const
Definition: io_state.cpp:75
friend std::ostream & operator<<(std::ostream &os, const IOState &io_state)
Definition: io_state.cpp:105
static std::vector< PinState > generateInputPinStates(const monitoring_frame::io::PinData &pin_data)


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