PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
IOSignal.h
Go to the documentation of this file.
1
13
14#pragma once
15
16#include <cstddef>
17#include <cstdint>
18#include <string>
19#include <string_view>
20#include <vector>
21
22#include "profinet/gsdml.h"
23
24namespace profinet::io
25{
26
30{
32 Sensor,
35};
36
52
60{
62 std::size_t bitOffset = 0;
63
65 std::string textId;
66};
67
83{
86
88 std::string name;
89
91 std::string textId;
92
94 bool bitSignal = false;
95
101 std::size_t bitOffset = 0;
102
110
117
119 std::string gsdmlDataType;
120
123
126 bool doubleCompatible = false;
127
129 std::string moduleId;
130
132 std::string moduleName;
133
135 std::string submoduleId;
136
138 std::string submoduleName;
139
141 std::uint32_t moduleIdentNumber = 0;
142
144 std::uint32_t submoduleIdentNumber = 0;
145
147 std::size_t byteOffset = 0;
148
150 std::size_t byteLength = 0;
151
155 std::vector<int> possibleSlots;
156
160 std::vector<int> possibleSubslots;
161
163 [[nodiscard]] bool IsBitSignal() const noexcept;
164
166 [[nodiscard]] bool IsSensor() const noexcept;
167
169 [[nodiscard]] bool IsActuator() const noexcept;
170
172 [[nodiscard]] bool IsDoubleCompatible() const noexcept;
173
175 bool operator==(const IoSignal&) const = default;
176};
177
186{
187 public:
194 [[nodiscard]] static IoSignalCatalog FromGsdml(const gsdml::GSDMLDevice& device);
195
197 [[nodiscard]] const std::vector<IoSignal>& Sensors() const noexcept;
198
200 [[nodiscard]] const std::vector<IoSignal>& Actuators() const noexcept;
201
203 [[nodiscard]] std::size_t Size() const noexcept;
204
205 private:
206 std::vector<IoSignal> sensors;
207 std::vector<IoSignal> actuators;
208};
209
213[[nodiscard]] IoSignalValueType ClassifyDataType(std::string_view dataType) noexcept;
214
226[[nodiscard]] bool IsReservedSignal(std::string_view textId, std::string_view name) noexcept;
227
239[[nodiscard]] bool IsReservedSignal(std::string_view textId, std::string_view bitId, std::string_view name) noexcept;
240
241} // namespace profinet::io
Builds and owns the logical sensor and actuator signals described by a GSDML device.
Definition IOSignal.h:186
std::vector< IoSignal > actuators
Definition IOSignal.h:207
std::vector< IoSignal > sensors
Definition IOSignal.h:206
Declares the GSDML parser and PROFINET device-description data model.
bool IsReservedSignal(std::string_view textId, std::string_view name) noexcept
Determine whether a DataItem should be hidden from the normal signal catalogue.
Definition IOSignal.cpp:465
IoSignalValueType ClassifyDataType(std::string_view dataType) noexcept
Classify a GSDML DataType into a logical connector value category.
Definition IOSignal.cpp:433
IoSignalValueType
Logical value category used when exposing a signal to higher layers.
Definition IOSignal.h:40
@ FloatingPoint
IEEE floating-point value.
@ Boolean
Boolean value, represented by the connector as 0.0 or 1.0.
@ SignedInteger
Signed integer value.
@ UnsignedInteger
Unsigned integer value.
@ Unsupported
Data for which this catalogue does not define a numeric double representation.
IoSignalDirection
Logical direction of a process-data signal from the controller's perspective.
Definition IOSignal.h:30
@ Sensor
Data received from the PROFINET device and therefore exposed as a sensor.
@ Actuator
Data sent to the PROFINET device and therefore exposed as an actuator.
Complete parsed GSDML device profile.
Definition gsdml.h:166
One bit-defined logical signal within a GSDML DataItem.
Definition IOSignal.h:60
std::string textId
GSDML TextId identifying this logical bit signal.
Definition IOSignal.h:65
std::size_t bitOffset
Bit offset within the containing DataItem.
Definition IOSignal.h:62
Describes one logical process-data signal available from a GSDML device.
Definition IOSignal.h:83
bool IsSensor() const noexcept
Returns whether this signal is an input/sensor.
Definition IOSignal.cpp:418
bool IsDoubleCompatible() const noexcept
Returns whether this signal can be represented by the IO connector's double field.
Definition IOSignal.cpp:428
bool IsActuator() const noexcept
Returns whether this signal is an output/actuator.
Definition IOSignal.cpp:423
std::uint32_t moduleIdentNumber
Module ident number of the containing module.
Definition IOSignal.h:141
std::size_t byteLength
Size of the GSDML DataItem in bytes.
Definition IOSignal.h:150
std::string submoduleName
Human-readable submodule name, when supplied by the GSDML.
Definition IOSignal.h:138
bool IsBitSignal() const noexcept
Returns whether this signal represents one BitDataItem.
Definition IOSignal.cpp:413
std::string gsdmlDataType
GSDML DataType string.
Definition IOSignal.h:119
std::size_t bitOffset
Bit offset within the containing DataItem.
Definition IOSignal.h:101
std::size_t parentDataItemByteOffset
Byte offset of the parent DataItem.
Definition IOSignal.h:109
bool doubleCompatible
Whether the connector can represent this logical value using its double field.
Definition IOSignal.h:126
std::string textId
Original GSDML TextId.
Definition IOSignal.h:91
std::string submoduleId
GSDML submodule identifier containing the signal.
Definition IOSignal.h:135
std::string moduleName
Human-readable module name, when supplied by the GSDML.
Definition IOSignal.h:132
std::vector< int > possibleSubslots
Subslots in which the containing submodule may occur, when known.
Definition IOSignal.h:160
bool bitSignal
Whether this logical signal originated from a BitDataItem.
Definition IOSignal.h:94
std::string parentDataItemTextId
TextId of the parent DataItem.
Definition IOSignal.h:116
IoSignalDirection direction
Sensor or actuator direction.
Definition IOSignal.h:85
std::uint32_t submoduleIdentNumber
Submodule ident number of the containing submodule.
Definition IOSignal.h:144
std::size_t byteOffset
Byte offset within the submodule's input or output process-data area.
Definition IOSignal.h:147
IoSignalValueType valueType
Logical value category inferred from gsdmlDataType.
Definition IOSignal.h:122
std::string name
Current display name of the signal.
Definition IOSignal.h:88
std::vector< int > possibleSlots
Slots in which the containing module may occur, when known.
Definition IOSignal.h:155
std::string moduleId
GSDML module identifier containing the signal.
Definition IOSignal.h:129