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
28{
30 std::string dataType;
35 int length = 0;
37 std::string textId;
38};
39
42{
44 std::string submoduleId;
45
47 std::vector<int> allowedSubslots;
48
50 std::vector<int> fixedSubslots;
51
53 std::vector<int> usedSubslots;
54};
55
58{
60 std::string id;
62 std::uint32_t submoduleIdentNumber = 0;
64 std::string name;
66 int inputLength = 0;
68 int outputLength = 0;
70 std::vector<GSDMLDataItem> inputItems;
72 std::vector<GSDMLDataItem> outputItems;
73
75 std::vector<int> allowedSubslots;
77 std::vector<int> fixedSubslots;
79 std::vector<int> usedSubslots;
80};
81
84{
86 std::string id;
88 std::uint32_t moduleIdentNumber = 0;
90 std::string name;
91
96 std::map<std::string, GSDMLSubmodule> submodules;
97
103 std::vector<GSDMLSubmoduleReference> submoduleReferences;
104
106 std::vector<int> physicalSubslots;
107};
108
115{
117 std::uint32_t submoduleIdentNumber = 0;
119 std::uint16_t subslot = 0;
120};
121
124{
126 std::string moduleId;
127
129 std::vector<int> allowedSlots;
130
132 std::vector<int> fixedSlots;
133
135 std::vector<int> usedSlots;
136};
137
140{
142 std::string vendorName;
144 std::string deviceName;
146 std::uint16_t vendorId = 0;
148 std::uint16_t deviceId = 0;
149
151 std::string dapModuleId;
153 std::uint32_t dapSubmoduleIdentNumber = 0;
155 std::uint32_t dapModuleIdentNumber = 0;
157 std::vector<int> dapSlots;
158
160 std::vector<GSDMLSubmodule> dapSubmodules;
161
163 std::vector<GSDMLSystemSubmodule> systemSubmodules;
164
166 std::map<std::string, GSDMLModule> modules;
167
169 std::map<std::string, GSDMLSubmodule> submodules;
170
172 std::vector<GSDMLModuleReference> moduleReferences;
173
174 /*
176 std::map<std::string, std::vector<int>> allowedSlots;
178 std::vector<std::pair<int, std::string>> fixedModules;
179 */
184 [[nodiscard]] const GSDMLModule* FindModule(const std::string& moduleId) const;
185
190 [[nodiscard]] const GSDMLSubmodule* FindSubmodule(const std::string& submoduleId) const;
191
218 [[nodiscard]] std::vector<rpc::IOSlot> BuildIoSlots(const std::vector<std::tuple<int, std::string, int, std::string>>& plugged = {}) const;
219};
220
227GSDMLDevice ParseGsdml(const std::string& path);
228
234GSDMLDevice ParseGsdmlString(const std::string& xml);
235
236} // namespace profinet::gsdml
GSDMLDevice ParseGsdmlString(const std::string &xml)
Parse GSDML content already held in memory.
Definition gsdml.cpp:1012
GSDMLDevice ParseGsdml(const std::string &path)
Parse a GSDML file into a GSDMLDevice.
Definition gsdml.cpp:1244
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:28
int length
Length in bytes of this item.
Definition gsdml.h:35
std::string dataType
GSDML DataType attribute, e.g. "Unsigned8", "Integer16", "OctetString".
Definition gsdml.h:30
std::string textId
Human-readable text ID/name for this item, if the GSDML supplied one.
Definition gsdml.h:37
Complete parsed GSDML device profile.
Definition gsdml.h:140
std::string vendorName
Vendor name from the GSDML's DeviceIdentity.
Definition gsdml.h:142
std::map< std::string, GSDMLModule > modules
Every module declared in the GSDML's ModuleList, keyed by GSDML ID.
Definition gsdml.h:166
std::vector< GSDMLModuleReference > moduleReferences
Modules referenced by the DAP's UseableModules list.
Definition gsdml.h:172
std::vector< GSDMLSubmodule > dapSubmodules
DAP virtual submodules.
Definition gsdml.h:160
std::uint16_t vendorId
PROFINET vendor ID from the GSDML's DeviceIdentity (VendorID attribute).
Definition gsdml.h:146
std::uint32_t dapSubmoduleIdentNumber
The device access point's own (built-in) submodule ident number.
Definition gsdml.h:153
const GSDMLSubmodule * FindSubmodule(const std::string &submoduleId) const
Look up a globally defined submodule.
Definition gsdml.cpp:428
std::vector< GSDMLSystemSubmodule > systemSubmodules
System-defined submodules built into the DAP (e.g. interface, port 1).
Definition gsdml.h:163
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:520
std::uint16_t deviceId
PROFINET device ID from the GSDML's DeviceIdentity (DeviceID attribute).
Definition gsdml.h:148
std::uint32_t dapModuleIdentNumber
The device access point's own module ident number.
Definition gsdml.h:155
std::map< std::string, GSDMLSubmodule > submodules
Every globally defined SubmoduleItem, keyed by GSDML ID.
Definition gsdml.h:169
std::string deviceName
Device name from the GSDML's DeviceIdentity / DeviceFunction.
Definition gsdml.h:144
const GSDMLModule * FindModule(const std::string &moduleId) const
Look up a module by its GSDML ID.
Definition gsdml.cpp:423
std::vector< int > dapSlots
Slot numbers where the DAP may be fixed/plugged (from UseableModules/PlugSlots).
Definition gsdml.h:157
std::string dapModuleId
The device access point's own (built-in) identifier to matchs with the submodule.
Definition gsdml.h:151
Reference describing how a module may be used by the DAP.
Definition gsdml.h:124
std::string moduleId
Referenced ModuleItem ID.
Definition gsdml.h:126
std::vector< int > usedSlots
Slots where the module is currently used/preselected.
Definition gsdml.h:135
std::vector< int > allowedSlots
Slots where the module is allowed.
Definition gsdml.h:129
std::vector< int > fixedSlots
Slots where the module is fixed.
Definition gsdml.h:132
A GSDML module definition (ModuleItem), possibly offering multiple virtual submodules.
Definition gsdml.h:84
std::string id
GSDML ID attribute (used to resolve ModuleItemTarget references).
Definition gsdml.h:86
std::vector< GSDMLSubmoduleReference > submoduleReferences
References to globally defined SubmoduleItem definitions.
Definition gsdml.h:103
std::map< std::string, GSDMLSubmodule > submodules
Virtual submodules this module offers, keyed by their GSDML ID.
Definition gsdml.h:96
std::string name
Human-readable module name (from the GSDML's Name/TextId, resolved via ExternalTextList).
Definition gsdml.h:90
std::vector< int > physicalSubslots
Physical subslots supported by this module.
Definition gsdml.h:106
std::uint32_t moduleIdentNumber
Module ident number (hex value from the GSDML, parsed to an integer).
Definition gsdml.h:88
Reference to a submodule that may be used by a module.
Definition gsdml.h:42
std::vector< int > usedSubslots
Subslots where this submodule is currently used/preselected.
Definition gsdml.h:53
std::vector< int > allowedSubslots
Subslots where this submodule is allowed.
Definition gsdml.h:47
std::vector< int > fixedSubslots
Subslots where this submodule is fixed.
Definition gsdml.h:50
std::string submoduleId
Referenced SubmoduleItem ID.
Definition gsdml.h:44
A GSDML virtual submodule definition (VirtualSubmoduleItem).
Definition gsdml.h:58
std::string name
Human-readable submodule name (from the GSDML's Name/TextId, resolved via ExternalTextList).
Definition gsdml.h:64
std::uint32_t submoduleIdentNumber
Submodule ident number (hex value from the GSDML, parsed to an integer).
Definition gsdml.h:62
std::vector< GSDMLDataItem > inputItems
Individual input data items, in wire order.
Definition gsdml.h:70
std::vector< int > allowedSubslots
Subslots where this inline virtual submodule is allowed.
Definition gsdml.h:75
std::string id
GSDML ID attribute (used to resolve VirtualSubmoduleItemTarget references).
Definition gsdml.h:60
int outputLength
Total output data length in bytes (sum of Output DataItems).
Definition gsdml.h:68
std::vector< GSDMLDataItem > outputItems
Individual output data items, in wire order.
Definition gsdml.h:72
std::vector< int > usedSubslots
Subslots where this inline virtual submodule is selected/used.
Definition gsdml.h:79
int inputLength
Total input data length in bytes (sum of Input DataItems).
Definition gsdml.h:66
std::vector< int > fixedSubslots
Subslots where this inline virtual submodule is fixed.
Definition gsdml.h:77
A GSDML system-defined submodule (e.g. built into the DAP: interface, port).
Definition gsdml.h:115
std::uint16_t subslot
Subslot this submodule occupies.
Definition gsdml.h:119
std::uint32_t submoduleIdentNumber
Submodule ident number.
Definition gsdml.h:117