PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
IRPCCon.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#include <asio/io_context.hpp>
16#include <cstdint>
17#include <map>
18#include <optional>
19#include <string>
20#include <vector>
21
22#include "profinet/blocks.h"
23#include "profinet/cyclic.h"
24#include "profinet/dcp.h"
25#include "profinet/diagnosis.h"
26#include "profinet/protocol.h"
27#include "profinet/rpcTypes.h"
28#include "profinet/util.h"
29
31{
32
50{
51 public:
57 virtual ~IRPCCon() = default;
58
70 virtual std::optional<ConnectResult> Connect(std::optional<MacAddress> srcMac = std::nullopt, bool withAlarmCr = false, std::optional<IOCRSetup> iocrSetup = std::nullopt) = 0;
71
77 virtual void Disconnect() = 0;
78
84 virtual void Close() noexcept = 0;
85
90 [[nodiscard]] virtual bool IsConnected() const = 0;
91
103 virtual PNIODHeader Read(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx) = 0;
104
116 virtual PNIODHeader ReadImplicit(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx) = 0;
117
128 virtual void Write(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx, const Bytes& data) = 0;
129
138 virtual std::vector<blocks::WriteMultipleResult> WriteMultiple(const std::vector<WriteItem>& writes) = 0;
139
146 virtual PNInM0 ReadIm0(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
147
154 virtual PNInM1 ReadIm1(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
155
162 virtual PNInM2 ReadIm2(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
163
170 virtual PNInM3 ReadIm3(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
171
178 virtual PNInM4 ReadIm4(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
179
186 virtual PNInM5 ReadIm5(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
187
194 virtual PNInM6 ReadIm6(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
195
202 virtual PNInM7 ReadIm7(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
203
210 virtual PNInM8 ReadIm8(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
211
218 virtual PNInM9 ReadIm9(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
219
226 virtual PNInM10 ReadIm10(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
227
234 virtual PNInM11 ReadIm11(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
235
242 virtual PNInM12 ReadIm12(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
243
250 virtual PNInM13 ReadIm13(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
251
258 virtual PNInM14 ReadIm14(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
259
266 virtual PNInM15 ReadIm15(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
267
274 virtual AllIM ReadAllIm(std::uint16_t slot = 0, std::uint16_t subslot = 1) = 0;
275
279 virtual blocks::ModuleDiffBlock ReadModuleDiff() = 0;
280
288 virtual diagnosis::DiagnosisData ReadDiagnosis(std::uint16_t slot = 0, std::uint16_t subslot = 0, std::uint16_t index = 0xF000) = 0;
289
293 virtual std::map<std::uint16_t, diagnosis::DiagnosisData> ReadAllDiagnosis() = 0;
294
298 virtual blocks::PDRealData ReadPdRealData() = 0;
299
304
308 virtual std::vector<blocks::SlotInfo> DiscoverSlots() = 0;
309
313 virtual std::pair<blocks::PDRealData, blocks::RealIdentificationData> DiscoverTopology() = 0;
314
322 virtual std::map<std::uint16_t, IndexProbeResult> EnumerateIndices(std::uint16_t slot = 0,
323 std::uint16_t subslot = 1,
324 std::optional<std::vector<std::uint16_t>> customIndices = std::nullopt) = 0;
325
329 virtual Bytes PrmBegin() = 0;
330
334 virtual Bytes PrmEnd() = 0;
335
339 virtual Bytes ReadyForRtClass3() = 0;
340
349 virtual Bytes ApplicationReady(double timeoutSec = 30.0) = 0;
350
354 virtual asio::io_context& IoContext() = 0;
355
359 [[nodiscard]] virtual const dcp::DCPDeviceDescription& Info() const = 0;
360
364 [[nodiscard]] virtual std::uint16_t LocalAlarmRef() const = 0;
365
370 [[nodiscard]] virtual int DeviceAlarmRef() const = 0;
371
375 [[nodiscard]] virtual bool HasAlarmCr() const = 0;
376};
377
378} // namespace profinet::rpc
Declares PROFINET IO connection-management block structures and wire serialization.
Abstract interface for a PROFINET RPC connection.
Definition IRPCCon.h:50
virtual const dcp::DCPDeviceDescription & Info() const =0
Returns the device's DCP description.
virtual PNInM5 ReadIm5(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M5 free-text annotation data.
virtual int DeviceAlarmRef() const =0
Returns the device's alarm reference.
virtual PNInM9 ReadIm9(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M9 data.
virtual std::vector< blocks::WriteMultipleResult > WriteMultiple(const std::vector< WriteItem > &writes)=0
Writes multiple PROFINET records in one operation.
virtual diagnosis::DiagnosisData ReadDiagnosis(std::uint16_t slot=0, std::uint16_t subslot=0, std::uint16_t index=0xF000)=0
Reads diagnosis information.
virtual PNInM2 ReadIm2(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M2 installation date data.
virtual bool HasAlarmCr() const =0
Indicates whether an AlarmCR was established.
virtual AllIM ReadAllIm(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads all supported I&M records.
virtual PNInM8 ReadIm8(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M8 data.
virtual Bytes PrmBegin()=0
Sends the PrmBegin control operation.
virtual PNInM13 ReadIm13(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M13 data.
virtual PNIODHeader ReadImplicit(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx)=0
Reads a PROFINET data record without an established AR.
virtual PNInM6 ReadIm6(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M6 data.
virtual PNInM15 ReadIm15(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M15 data.
virtual asio::io_context & IoContext()=0
Returns the underlying Asio I/O context.
virtual ~IRPCCon()=default
Virtual destructor.
virtual PNInM14 ReadIm14(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M14 data.
virtual PNIODHeader Read(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx)=0
Reads a PROFINET data record through the established AR.
virtual std::uint16_t LocalAlarmRef() const =0
Returns the controller's local alarm reference.
virtual PNInM3 ReadIm3(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M3 free-text descriptor data.
virtual Bytes PrmEnd()=0
Sends the PrmEnd control operation.
virtual PNInM12 ReadIm12(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M12 data.
virtual PNInM4 ReadIm4(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M4 PROFIsafe signature data.
virtual PNInM1 ReadIm1(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M1 tag function and location data.
virtual std::pair< blocks::PDRealData, blocks::RealIdentificationData > DiscoverTopology()=0
Reads physical and logical topology information.
virtual void Close() noexcept=0
Disconnects and closes the underlying RPC sockets.
virtual void Disconnect()=0
Disconnects the Application Relationship.
virtual PNInM0 ReadIm0(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M0 identification data.
virtual std::map< std::uint16_t, diagnosis::DiagnosisData > ReadAllDiagnosis()=0
Reads diagnosis information for all standard indices.
virtual blocks::RealIdentificationData ReadRealIdentificationData()=0
Reads logical slot and subslot information.
virtual PNInM10 ReadIm10(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M10 data.
virtual std::optional< ConnectResult > Connect(std::optional< MacAddress > srcMac=std::nullopt, bool withAlarmCr=false, std::optional< IOCRSetup > iocrSetup=std::nullopt)=0
Establishes an Application Relationship with the IO-Device.
virtual void Write(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx, const Bytes &data)=0
Writes a PROFINET data record through the established AR.
virtual PNInM7 ReadIm7(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M7 data.
virtual Bytes ReadyForRtClass3()=0
Sends the ReadyForRTClass3 control operation.
virtual blocks::ModuleDiffBlock ReadModuleDiff()=0
Reads the ModuleDiffBlock.
virtual blocks::PDRealData ReadPdRealData()=0
Reads physical-device topology information.
virtual std::map< std::uint16_t, IndexProbeResult > EnumerateIndices(std::uint16_t slot=0, std::uint16_t subslot=1, std::optional< std::vector< std::uint16_t > > customIndices=std::nullopt)=0
Enumerates readable PROFINET record indices.
virtual PNInM11 ReadIm11(std::uint16_t slot=0, std::uint16_t subslot=1)=0
Reads I&M11 data.
virtual std::vector< blocks::SlotInfo > DiscoverSlots()=0
Discovers the populated device slots.
virtual bool IsConnected() const =0
Indicates whether the Application Relationship is established.
Declares the PROFINET RTC1 cyclic IO controller and process-data exchange API.
PROFINET DCP discovery and device configuration interface.
PROFINET diagnosis data structures, error decoding, and parsers.
@ DiagnosisData
Diagnosis data block.
@ RealIdentificationData
Real identification data block.
@ ApplicationReady
Application Ready command.
std::vector< std::uint8_t > Bytes
Generic byte buffer alias used throughout the library for raw wire data.
Definition protocol.h:52
PROFINET protocol wire-format structures and serialization helpers.
Shared data types used by the PROFINET DCE/RPC layer.
IOD read/write request/response header (RPC body for READ/WRITE/IMPLICIT_READ).
Definition protocol.h:758
I&M0: mandatory identification data (vendor, order ID, serial number, revisions).
Definition protocol.h:1076
I&M1: user-assigned tag function and location strings.
Definition protocol.h:1178
I&M2: installation date.
Definition protocol.h:1222
I&M3: free-text descriptor.
Definition protocol.h:1263
I&M4: PROFIsafe signature (binary, not text).
Definition protocol.h:1303
I&M5: free-text annotation.
Definition protocol.h:1343
I&M6-I&M15: reserved for future use per IEC 61158-6-10.
Definition protocol.h:1387
All I&M records a device supports, read in one call.
Definition rpcTypes.h:227
Result of probing one index in EnumerateIndices().
Definition rpcTypes.h:270
A single write operation for WriteMultiple().
Definition rpcTypes.h:209
Declares Linux Ethernet, addressing, timing, and utility helpers used by the PROFINET stack.