PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
gsdml.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <cstdint>
15#include <map>
16#include <optional>
17#include <string>
18#include <tuple>
19#include <vector>
20
21#include "profinet/rpc.h"
22
24{
25
27{
28 std::uint8_t bitOffset = 0;
29 std::string textId;
30 std::string name;
31};
32
35{
37 std::string dataType;
39 std::string textId;
40
42 std::string name;
43
48 int length = 0;
49
50 int byteOffset = 0;
51
52 bool useAsBits = false;
53
59 std::vector<GSDMLBitDataItem> bitDataItems;
60};
61
64{
66 std::string submoduleId;
67
69 std::vector<int> allowedSubslots;
70
72 std::vector<int> fixedSubslots;
73
75 std::vector<int> usedSubslots;
76};
77
80{
82 std::string id;
84 std::uint32_t submoduleIdentNumber = 0;
86 std::string name;
88 int inputLength = 0;
90 int outputLength = 0;
92 std::vector<GSDMLDataItem> inputItems;
94 std::vector<GSDMLDataItem> outputItems;
95
97 std::vector<int> allowedSubslots;
99 std::vector<int> fixedSubslots;
101 std::vector<int> usedSubslots;
102};
103
106{
108 std::string id;
110 std::uint32_t moduleIdentNumber = 0;
112 std::string name;
113
118 std::map<std::string, GSDMLSubmodule> submodules;
119
125 std::vector<GSDMLSubmoduleReference> submoduleReferences;
126
128 std::vector<int> physicalSubslots;
129};
130
137{
139 std::uint32_t submoduleIdentNumber = 0;
140
142 std::uint16_t subslot = 0;
143
145 std::string moduleName;
146};
147
150{
152 std::string moduleId;
153
155 std::vector<int> allowedSlots;
156
158 std::vector<int> fixedSlots;
159
161 std::vector<int> usedSlots;
162};
163
166{
168 std::string vendorName;
170 std::string deviceName;
172 std::uint16_t vendorId = 0;
174 std::uint16_t deviceId = 0;
175
177 std::string dapModuleId;
179 std::string dapModuleName;
181 std::string dapModuleInfo;
183 std::uint32_t dapSubmoduleIdentNumber = 0;
185 std::uint32_t dapModuleIdentNumber = 0;
187 std::vector<int> dapSlots;
188
190 std::vector<GSDMLSubmodule> dapSubmodules;
191
193 std::vector<GSDMLSystemSubmodule> systemSubmodules;
194
196 std::map<std::string, GSDMLModule> modules;
197
199 std::map<std::string, GSDMLSubmodule> submodules;
200
202 std::vector<GSDMLModuleReference> moduleReferences;
203
205
206 /*
208 std::map<std::string, std::vector<int>> allowedSlots;
210 std::vector<std::pair<int, std::string>> fixedModules;
211 */
216 [[nodiscard]] const GSDMLModule* FindModule(const std::string& moduleId) const;
217
222 [[nodiscard]] const GSDMLSubmodule* FindSubmodule(const std::string& submoduleId) const;
223
247 [[nodiscard]] std::vector<rpc::IOSlot> BuildIoSlots(const std::vector<std::tuple<int, std::string, int, std::string>>& plugged = {}) const;
248};
249
256GSDMLDevice ParseGsdml(const std::string& path);
257
263GSDMLDevice ParseGsdmlString(const std::string& xml);
264
265} // namespace profinet::gsdml
GSDMLDevice ParseGsdmlString(const std::string &xml)
Parse GSDML content already held in memory.
Definition gsdml.cpp:1114
GSDMLDevice ParseGsdml(const std::string &path)
Parse a GSDML file into a GSDMLDevice.
Definition gsdml.cpp:1398
PROFINET DCE/RPC protocol structures and IO-Device connection API.
One I/O data item within a submodule's cyclic data (GSDML DataItem element).
Definition gsdml.h:35
int length
Length in bytes of this item.
Definition gsdml.h:48
std::string dataType
GSDML DataType attribute, e.g. "Unsigned8", "Integer16", "OctetString".
Definition gsdml.h:37
std::vector< GSDMLBitDataItem > bitDataItems
Individual BitDataItem definitions belonging to this DataItem.
Definition gsdml.h:59
std::string name
Human-readable name for this item in default language, if the GSDML supplied one.
Definition gsdml.h:42
std::string textId
Human-readable text ID/name for this item, if the GSDML supplied one.
Definition gsdml.h:39
Complete parsed GSDML device profile.
Definition gsdml.h:166
std::string vendorName
Vendor name from the GSDML's DeviceIdentity.
Definition gsdml.h:168
std::string dapModuleInfo
The device access point's own (built-in) module info text.
Definition gsdml.h:181
std::map< std::string, GSDMLModule > modules
Every module declared in the GSDML's ModuleList, keyed by GSDML ID.
Definition gsdml.h:196
std::vector< GSDMLModuleReference > moduleReferences
Modules referenced by the DAP's UseableModules list.
Definition gsdml.h:202
std::vector< GSDMLSubmodule > dapSubmodules
DAP virtual submodules.
Definition gsdml.h:190
std::uint16_t vendorId
PROFINET vendor ID from the GSDML's DeviceIdentity (VendorID attribute).
Definition gsdml.h:172
rpc::ApplicationRelations applicationRelations
Definition gsdml.h:204
std::uint32_t dapSubmoduleIdentNumber
The device access point's own (built-in) submodule ident number.
Definition gsdml.h:183
const GSDMLSubmodule * FindSubmodule(const std::string &submoduleId) const
Look up a globally defined submodule.
Definition gsdml.cpp:636
std::vector< GSDMLSystemSubmodule > systemSubmodules
System-defined submodules built into the DAP (e.g. interface, port 1).
Definition gsdml.h:193
std::vector< rpc::IOSlot > BuildIoSlots(const std::vector< std::tuple< int, std::string, int, std::string > > &plugged={}) const
Build I/O slot descriptions from the parsed GSDML configuration.
Definition gsdml.cpp:728
std::uint16_t deviceId
PROFINET device ID from the GSDML's DeviceIdentity (DeviceID attribute).
Definition gsdml.h:174
std::uint32_t dapModuleIdentNumber
The device access point's own module ident number.
Definition gsdml.h:185
std::map< std::string, GSDMLSubmodule > submodules
Every globally defined SubmoduleItem, keyed by GSDML ID.
Definition gsdml.h:199
std::string dapModuleName
The device access point's own (built-in) module name.
Definition gsdml.h:179
std::string deviceName
Device name from the GSDML's DeviceIdentity / DeviceFunction.
Definition gsdml.h:170
const GSDMLModule * FindModule(const std::string &moduleId) const
Look up a module by its GSDML ID.
Definition gsdml.cpp:631
std::vector< int > dapSlots
Slot numbers where the DAP may be fixed/plugged (from UseableModules/PlugSlots).
Definition gsdml.h:187
std::string dapModuleId
The device access point's own (built-in) identifier to matchs with the submodule.
Definition gsdml.h:177
Reference describing how a module may be used by the DAP.
Definition gsdml.h:150
std::string moduleId
Referenced ModuleItem ID.
Definition gsdml.h:152
std::vector< int > usedSlots
Slots where the module is currently used/preselected.
Definition gsdml.h:161
std::vector< int > allowedSlots
Slots where the module is allowed.
Definition gsdml.h:155
std::vector< int > fixedSlots
Slots where the module is fixed.
Definition gsdml.h:158
A GSDML module definition (ModuleItem), possibly offering multiple virtual submodules.
Definition gsdml.h:106
std::string id
GSDML ID attribute (used to resolve ModuleItemTarget references).
Definition gsdml.h:108
std::vector< GSDMLSubmoduleReference > submoduleReferences
References to globally defined SubmoduleItem definitions.
Definition gsdml.h:125
std::map< std::string, GSDMLSubmodule > submodules
Virtual submodules this module offers, keyed by their GSDML ID.
Definition gsdml.h:118
std::string name
Human-readable module name (from the GSDML's Name/TextId, resolved via ExternalTextList).
Definition gsdml.h:112
std::vector< int > physicalSubslots
Physical subslots supported by this module.
Definition gsdml.h:128
std::uint32_t moduleIdentNumber
Module ident number (hex value from the GSDML, parsed to an integer).
Definition gsdml.h:110
Reference to a submodule that may be used by a module.
Definition gsdml.h:64
std::vector< int > usedSubslots
Subslots where this submodule is currently used/preselected.
Definition gsdml.h:75
std::vector< int > allowedSubslots
Subslots where this submodule is allowed.
Definition gsdml.h:69
std::vector< int > fixedSubslots
Subslots where this submodule is fixed.
Definition gsdml.h:72
std::string submoduleId
Referenced SubmoduleItem ID.
Definition gsdml.h:66
A GSDML virtual submodule definition (VirtualSubmoduleItem).
Definition gsdml.h:80
std::string name
Human-readable submodule name (from the GSDML's Name/TextId, resolved via ExternalTextList).
Definition gsdml.h:86
std::uint32_t submoduleIdentNumber
Submodule ident number (hex value from the GSDML, parsed to an integer).
Definition gsdml.h:84
std::vector< GSDMLDataItem > inputItems
Individual input data items, in wire order.
Definition gsdml.h:92
std::vector< int > allowedSubslots
Subslots where this inline virtual submodule is allowed.
Definition gsdml.h:97
std::string id
GSDML ID attribute (used to resolve VirtualSubmoduleItemTarget references).
Definition gsdml.h:82
int outputLength
Total output data length in bytes (sum of Output DataItems).
Definition gsdml.h:90
std::vector< GSDMLDataItem > outputItems
Individual output data items, in wire order.
Definition gsdml.h:94
std::vector< int > usedSubslots
Subslots where this inline virtual submodule is selected/used.
Definition gsdml.h:101
int inputLength
Total input data length in bytes (sum of Input DataItems).
Definition gsdml.h:88
std::vector< int > fixedSubslots
Subslots where this inline virtual submodule is fixed.
Definition gsdml.h:99
A GSDML system-defined submodule (e.g. built into the DAP: interface, port).
Definition gsdml.h:137
std::string moduleName
Referenced ModuleItem name.
Definition gsdml.h:145
std::uint16_t subslot
Subslot this submodule occupies.
Definition gsdml.h:142
std::uint32_t submoduleIdentNumber
Submodule ident number.
Definition gsdml.h:139