io_constants.h
Go to the documentation of this file.
1 // Copyright (c) 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_IO_CONSTANTS_H
17 #define PSEN_SCAN_V2_STANDALONE_IO_CONSTANTS_H
18 
19 #include <array>
20 #include <map>
21 #include <string>
22 
24 {
25 namespace data_conversion_layer
26 {
27 namespace monitoring_frame
28 {
29 namespace io
30 {
34 static constexpr uint32_t RAW_CHUNK_LENGTH_RESERVED_IN_BYTES{ 4 };
35 static constexpr uint32_t RAW_CHUNK_PHYSICAL_INPUT_SIGNALS_IN_BYTES{ 10 };
36 static constexpr uint32_t RAW_CHUNK_LOGICAL_INPUT_SIGNALS_IN_BYTES{ 8 };
37 static constexpr uint32_t RAW_CHUNK_OUTPUT_SIGNALS_IN_BYTES{ 4 };
38 static constexpr uint32_t RAW_CHUNK_LENGTH_IN_BYTES{
42 };
43 
44 using RawChunk = std::array<uint8_t, io::RAW_CHUNK_LENGTH_IN_BYTES>;
45 
46 #define REV(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1
47 
48 enum class LogicalInputType
49 {
50  zone_sw_2,
51  zone_sw_1,
52  overr_2_a,
53  overr_1_a,
54  muting_2_a,
55  muting_1_a,
56 
57  reset_a,
58  zone_sw_8,
59  zone_sw_7,
60  zone_sw_6,
61  zone_sw_5,
62  zone_sw_4,
63  zone_sw_3,
64 
66  mut_en_2_a,
70  mut_en_1_a,
72 
74  unused
75 };
76 
78 using IoName = std::string;
79 // clang-format off
80 static const std::map<Lit, IoName> LOGICAL_INPUT_BIT_TO_NAME{
81 
82  { Lit::zone_sw_2, "Zone Set Switching Input 2" },
83  { Lit::zone_sw_1, "Zone Set Switching Input 1" },
84  { Lit::overr_2_a, "Override 2 Activated" },
85  { Lit::overr_1_a, "Override 1 Activated" },
86  { Lit::muting_2_a, "Muting 2 Activated" },
87  { Lit::muting_1_a, "Muting 1 Activated" },
88 
89  { Lit::reset_a, "Reset Activated" },
90  { Lit::zone_sw_8, "Zone Set Switching Input 8" },
91  { Lit::zone_sw_7, "Zone Set Switching Input 7" },
92  { Lit::zone_sw_6, "Zone Set Switching Input 6" },
93  { Lit::zone_sw_5, "Zone Set Switching Input 5" },
94  { Lit::zone_sw_4, "Zone Set Switching Input 4" },
95  { Lit::zone_sw_3, "Zone Set Switching Input 3" },
96 
97  { Lit::cor_seq_mut_2, "Correct activation sequence of Muting 2 Pins" },
98  { Lit::mut_en_2_a, "Muting Enable 2 Activated" },
99  { Lit::restart_2_a, "Restart 2 Activated" },
100  { Lit::cor_seq_or_1, "Correct activation sequence of Override 1 Pins" },
101  { Lit::cor_seq_mut_1, "Correct activation sequence of Muting 1 Pins" },
102  { Lit::mut_en_1_a, "Muting Enable 1 Activated" },
103  { Lit::restart_1_a, "Restart 1 Activated" },
104 
105  { Lit::cor_seq_or_2, "Correct activation sequence of Override 2 Pins" },
106  { Lit::unused, "unused" },
107 };
108 
109 static constexpr std::array<std::array<Lit, 8>, RAW_CHUNK_LOGICAL_INPUT_SIGNALS_IN_BYTES> LOGICAL_INPUT_BITS{{
110  // Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
118  { REV(Lit::unused, Lit::unused, Lit::unused, Lit::unused, Lit::unused, Lit::unused, Lit::unused, Lit::cor_seq_or_2) },
119 }};
120 // clang-format on
121 
122 enum class OutputType
123 {
124  unused,
125  ossd1_refpts,
126 
127  warn_2_int,
128  warn_1_int,
129  ossd3_lock,
130  safe_3_int,
131  int_lock_2,
132  safe_2_int,
133  int_lock_1,
134  safe_1_int
135 };
136 
137 using Ot = OutputType;
138 
139 // clang-format off
140 static const std::map<Ot, IoName> OUTPUT_BIT_TO_NAME
141 {
142  { Ot::unused, "unused" },
143  { Ot::ossd1_refpts, "REFERENCE POINTS VIOLATION" },
144 
145  { Ot::warn_2_int, "Warning 2 intrusion" },
146  { Ot::warn_1_int, "Warning 1 intrusion" },
147  { Ot::safe_3_int, "Safety 3 intrusion" },
148  { Ot::int_lock_2, "INTERLOCK 2" },
149  { Ot::safe_2_int, "Safety 2 intrusion" },
150  { Ot::int_lock_1, "INTERLOCK 1" },
151  { Ot::safe_1_int, "Safety 1 intrusion" }
152 };
153 
154 static constexpr std::array<std::array<Ot, 8>, RAW_CHUNK_OUTPUT_SIGNALS_IN_BYTES> OUTPUT_BITS{{
155  // Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
160 }};
161 // clang-format on
162 
163 } // namespace io
164 } // namespace monitoring_frame
165 } // namespace data_conversion_layer
166 } // namespace psen_scan_v2_standalone
167 
168 #endif // PSEN_SCAN_V2_STANDALONE_IO_CONSTANTS_H
static constexpr std::array< std::array< Lit, 8 >, RAW_CHUNK_LOGICAL_INPUT_SIGNALS_IN_BYTES > LOGICAL_INPUT_BITS
Definition: io_constants.h:109
#define REV(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
Definition: io_constants.h:46
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 constexpr uint32_t RAW_CHUNK_LENGTH_RESERVED_IN_BYTES
Contains constants and types needed to define PinData and for the (de)serialization.
Definition: io_constants.h:34
std::array< uint8_t, io::RAW_CHUNK_LENGTH_IN_BYTES > RawChunk
Definition: io_constants.h:44


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