PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::rpc::IRPCCon Class Referenceabstract

Abstract interface for a PROFINET RPC connection. More...

#include <IRPCCon.h>

+ Inheritance diagram for profinet::rpc::IRPCCon:
+ Collaboration diagram for profinet::rpc::IRPCCon:

Public Member Functions

virtual ~IRPCCon ()=default
 Virtual destructor.
 
virtual std::optional< ConnectResultConnect (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 Disconnect ()=0
 Disconnects the Application Relationship.
 
virtual void Close () noexcept=0
 Disconnects and closes the underlying RPC sockets.
 
virtual bool IsConnected () const =0
 Indicates whether the Application Relationship is established.
 
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 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 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 std::vector< blocks::WriteMultipleResultWriteMultiple (const std::vector< WriteItem > &writes)=0
 Writes multiple PROFINET records in one operation.
 
virtual PNInM0 ReadIm0 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M0 identification data.
 
virtual PNInM1 ReadIm1 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M1 tag function and location data.
 
virtual PNInM2 ReadIm2 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M2 installation date data.
 
virtual PNInM3 ReadIm3 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M3 free-text descriptor data.
 
virtual PNInM4 ReadIm4 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M4 PROFIsafe signature data.
 
virtual PNInM5 ReadIm5 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M5 free-text annotation data.
 
virtual PNInM6 ReadIm6 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M6 data.
 
virtual PNInM7 ReadIm7 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M7 data.
 
virtual PNInM8 ReadIm8 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M8 data.
 
virtual PNInM9 ReadIm9 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M9 data.
 
virtual PNInM10 ReadIm10 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M10 data.
 
virtual PNInM11 ReadIm11 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M11 data.
 
virtual PNInM12 ReadIm12 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M12 data.
 
virtual PNInM13 ReadIm13 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M13 data.
 
virtual PNInM14 ReadIm14 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M14 data.
 
virtual PNInM15 ReadIm15 (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads I&M15 data.
 
virtual AllIM ReadAllIm (std::uint16_t slot=0, std::uint16_t subslot=1)=0
 Reads all supported I&M records.
 
virtual blocks::ModuleDiffBlock ReadModuleDiff ()=0
 Reads the ModuleDiffBlock.
 
virtual diagnosis::DiagnosisData ReadDiagnosis (std::uint16_t slot=0, std::uint16_t subslot=0, std::uint16_t index=0xF000)=0
 Reads diagnosis information.
 
virtual std::map< std::uint16_t, diagnosis::DiagnosisDataReadAllDiagnosis ()=0
 Reads diagnosis information for all standard indices.
 
virtual blocks::PDRealData ReadPdRealData ()=0
 Reads physical-device topology information.
 
virtual blocks::RealIdentificationData ReadRealIdentificationData ()=0
 Reads logical slot and subslot information.
 
virtual std::vector< blocks::SlotInfoDiscoverSlots ()=0
 Discovers the populated device slots.
 
virtual std::pair< blocks::PDRealData, blocks::RealIdentificationDataDiscoverTopology ()=0
 Reads physical and logical topology information.
 
virtual std::map< std::uint16_t, IndexProbeResultEnumerateIndices (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 Bytes PrmBegin ()=0
 Sends the PrmBegin control operation.
 
virtual Bytes PrmEnd ()=0
 Sends the PrmEnd control operation.
 
virtual Bytes ReadyForRtClass3 ()=0
 Sends the ReadyForRTClass3 control operation.
 
virtual Bytes ApplicationReady (double timeoutSec=30.0)=0
 Waits for and confirms the ApplicationReady request.
 
virtual asio::io_context & IoContext ()=0
 Returns the underlying Asio I/O context.
 
virtual const dcp::DCPDeviceDescriptionInfo () const =0
 Returns the device's DCP description.
 
virtual std::uint16_t LocalAlarmRef () const =0
 Returns the controller's local alarm reference.
 
virtual int DeviceAlarmRef () const =0
 Returns the device's alarm reference.
 
virtual bool HasAlarmCr () const =0
 Indicates whether an AlarmCR was established.
 

Detailed Description

Abstract interface for a PROFINET RPC connection.

IRPCCon abstracts the operations exposed by RPCCon that are required by higher-level components such as ProfinetDevice.

The interface separates device-level logic from the concrete RPC transport implementation. This allows unit tests to replace the real RPCCon with a mock implementation and verify delegation, argument mapping, error handling, and connection state without communicating with a physical PROFINET IO-Device.

RPCCon is the production implementation of this interface.

Note
Implementations must preserve the semantics and exception behaviour of RPCCon for the operations defined by this interface.

Definition at line 49 of file IRPCCon.h.

Constructor & Destructor Documentation

◆ ~IRPCCon()

virtual profinet::rpc::IRPCCon::~IRPCCon ( )
virtualdefault

Virtual destructor.

Ensures that derived RPC implementations can be destroyed safely through an IRPCCon pointer.

Member Function Documentation

◆ ApplicationReady()

virtual Bytes profinet::rpc::IRPCCon::ApplicationReady ( double  timeoutSec = 30.0)
pure virtual

Waits for and confirms the ApplicationReady request.

Parameters
timeoutSecMaximum time to wait for ApplicationReady.
Returns
ApplicationReady NRD body.
Exceptions
RPCTimeoutErrorIf ApplicationReady is not received before timeout.

Implemented in profinet::rpc::RPCCon.

◆ Close()

virtual void profinet::rpc::IRPCCon::Close ( )
pure virtualnoexcept

Disconnects and closes the underlying RPC sockets.

Releases all resources associated with the RPC connection. The operation is safe to invoke during object cleanup.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReleaseAr().

+ Here is the caller graph for this function:

◆ Connect()

virtual std::optional< ConnectResult > profinet::rpc::IRPCCon::Connect ( std::optional< MacAddress srcMac = std::nullopt,
bool  withAlarmCr = false,
std::optional< IOCRSetup iocrSetup = std::nullopt 
)
pure virtual

Establishes an Application Relationship with the IO-Device.

Parameters
srcMacSource MAC address of the PROFINET controller.
withAlarmCrWhether an AlarmCR should also be established.
iocrSetupOptional cyclic IO configuration.
Returns
A ConnectResult when cyclic IO configuration was supplied; otherwise std::nullopt.
Exceptions
RPCConnectionErrorIf the Application Relationship cannot be established.

Implemented in profinet::rpc::RPCCon.

◆ DeviceAlarmRef()

virtual int profinet::rpc::IRPCCon::DeviceAlarmRef ( ) const
pure virtual

Returns the device's alarm reference.

Returns
Device alarm reference, or the implementation's sentinel value when no AlarmCR was established.

Implemented in profinet::rpc::RPCCon.

◆ Disconnect()

virtual void profinet::rpc::IRPCCon::Disconnect ( )
pure virtual

Disconnects the Application Relationship.

Sends the PROFINET Release operation when appropriate. The operation is best-effort and does not return a response.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReleaseAr().

+ Here is the caller graph for this function:

◆ DiscoverSlots()

virtual std::vector< blocks::SlotInfo > profinet::rpc::IRPCCon::DiscoverSlots ( )
pure virtual

Discovers the populated device slots.

Returns
Vector containing the discovered slot information.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::DiscoverSlots().

+ Here is the caller graph for this function:

◆ DiscoverTopology()

virtual std::pair< blocks::PDRealData, blocks::RealIdentificationData > profinet::rpc::IRPCCon::DiscoverTopology ( )
pure virtual

Reads physical and logical topology information.

Returns
Pair containing PDRealData and RealIdentificationData.

Implemented in profinet::rpc::RPCCon.

◆ EnumerateIndices()

virtual std::map< std::uint16_t, IndexProbeResult > profinet::rpc::IRPCCon::EnumerateIndices ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1,
std::optional< std::vector< std::uint16_t > >  customIndices = std::nullopt 
)
pure virtual

Enumerates readable PROFINET record indices.

Parameters
slotSlot number to probe.
subslotSubslot number to probe.
customIndicesOptional list of indices to probe.
Returns
Map containing the result for each probed index.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::EnumerateIndices().

+ Here is the caller graph for this function:

◆ HasAlarmCr()

virtual bool profinet::rpc::IRPCCon::HasAlarmCr ( ) const
pure virtual

Indicates whether an AlarmCR was established.

Returns
true if AlarmCR is enabled; otherwise false.

Implemented in profinet::rpc::RPCCon.

◆ Info()

virtual const dcp::DCPDeviceDescription & profinet::rpc::IRPCCon::Info ( ) const
pure virtual

Returns the device's DCP description.

Returns
Constant reference to the target device description.

Implemented in profinet::rpc::RPCCon.

◆ IoContext()

virtual asio::io_context & profinet::rpc::IRPCCon::IoContext ( )
pure virtual

Returns the underlying Asio I/O context.

Returns
Reference to the Asio I/O context used by the RPC connection.

Implemented in profinet::rpc::RPCCon.

◆ IsConnected()

virtual bool profinet::rpc::IRPCCon::IsConnected ( ) const
pure virtual

Indicates whether the Application Relationship is established.

Returns
true when the RPC connection currently has a live AR; otherwise false.

Implemented in profinet::rpc::RPCCon.

◆ LocalAlarmRef()

virtual std::uint16_t profinet::rpc::IRPCCon::LocalAlarmRef ( ) const
pure virtual

Returns the controller's local alarm reference.

Returns
Local alarm reference used by AlarmCR.

Implemented in profinet::rpc::RPCCon.

◆ PrmBegin()

virtual Bytes profinet::rpc::IRPCCon::PrmBegin ( )
pure virtual

Sends the PrmBegin control operation.

Returns
NRD response payload.

Implemented in profinet::rpc::RPCCon.

◆ PrmEnd()

virtual Bytes profinet::rpc::IRPCCon::PrmEnd ( )
pure virtual

Sends the PrmEnd control operation.

Returns
NRD response payload.

Implemented in profinet::rpc::RPCCon.

◆ Read()

virtual PNIODHeader profinet::rpc::IRPCCon::Read ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx 
)
pure virtual

Reads a PROFINET data record through the established AR.

Parameters
apiApplication Process Identifier.
slotSlot number.
subslotSubslot number.
idxRecord data index.
Returns
Parsed IOD response header and payload.
Exceptions
PNIOErrorIf the device reports a PROFINET error.
RPCTimeoutErrorIf no RPC response is received before timeout.

Implemented in profinet::rpc::RPCCon.

◆ ReadAllDiagnosis()

virtual std::map< std::uint16_t, diagnosis::DiagnosisData > profinet::rpc::IRPCCon::ReadAllDiagnosis ( )
pure virtual

Reads diagnosis information for all standard indices.

Returns
Diagnosis data indexed by record index.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadAllDiagnosis().

+ Here is the caller graph for this function:

◆ ReadAllIm()

virtual AllIM profinet::rpc::IRPCCon::ReadAllIm ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads all supported I&M records.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Collection containing all successfully read I&M records.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadAllIm().

+ Here is the caller graph for this function:

◆ ReadDiagnosis()

virtual diagnosis::DiagnosisData profinet::rpc::IRPCCon::ReadDiagnosis ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 0,
std::uint16_t  index = 0xF000 
)
pure virtual

Reads diagnosis information.

Parameters
slotSlot number.
subslotSubslot number.
indexDiagnosis record index.
Returns
Parsed diagnosis information.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadDiagnosis().

+ Here is the caller graph for this function:

◆ ReadIm0()

virtual PNInM0 profinet::rpc::IRPCCon::ReadIm0 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M0 identification data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M0 record.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadIm0().

+ Here is the caller graph for this function:

◆ ReadIm1()

virtual PNInM1 profinet::rpc::IRPCCon::ReadIm1 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M1 tag function and location data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M1 record.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadIm1().

+ Here is the caller graph for this function:

◆ ReadIm10()

virtual PNInM10 profinet::rpc::IRPCCon::ReadIm10 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M10 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M10 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm11()

virtual PNInM11 profinet::rpc::IRPCCon::ReadIm11 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M11 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M11 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm12()

virtual PNInM12 profinet::rpc::IRPCCon::ReadIm12 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M12 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M12 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm13()

virtual PNInM13 profinet::rpc::IRPCCon::ReadIm13 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M13 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M13 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm14()

virtual PNInM14 profinet::rpc::IRPCCon::ReadIm14 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M14 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M14 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm15()

virtual PNInM15 profinet::rpc::IRPCCon::ReadIm15 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M15 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M15 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm2()

virtual PNInM2 profinet::rpc::IRPCCon::ReadIm2 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M2 installation date data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M2 record.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadIm2().

+ Here is the caller graph for this function:

◆ ReadIm3()

virtual PNInM3 profinet::rpc::IRPCCon::ReadIm3 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M3 free-text descriptor data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M3 record.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadIm3().

+ Here is the caller graph for this function:

◆ ReadIm4()

virtual PNInM4 profinet::rpc::IRPCCon::ReadIm4 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M4 PROFIsafe signature data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M4 record.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadIm4().

+ Here is the caller graph for this function:

◆ ReadIm5()

virtual PNInM5 profinet::rpc::IRPCCon::ReadIm5 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M5 free-text annotation data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M5 record.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadIm5().

+ Here is the caller graph for this function:

◆ ReadIm6()

virtual PNInM6 profinet::rpc::IRPCCon::ReadIm6 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M6 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M6 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm7()

virtual PNInM7 profinet::rpc::IRPCCon::ReadIm7 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M7 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M7 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm8()

virtual PNInM8 profinet::rpc::IRPCCon::ReadIm8 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M8 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M8 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadIm9()

virtual PNInM9 profinet::rpc::IRPCCon::ReadIm9 ( std::uint16_t  slot = 0,
std::uint16_t  subslot = 1 
)
pure virtual

Reads I&M9 data.

Parameters
slotSlot number.
subslotSubslot number.
Returns
Parsed I&M9 record.

Implemented in profinet::rpc::RPCCon.

◆ ReadImplicit()

virtual PNIODHeader profinet::rpc::IRPCCon::ReadImplicit ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx 
)
pure virtual

Reads a PROFINET data record without an established AR.

Parameters
apiApplication Process Identifier.
slotSlot number.
subslotSubslot number.
idxRecord data index.
Returns
Parsed IOD response header and payload.
Exceptions
PNIOErrorIf the device reports a PROFINET error.
RPCTimeoutErrorIf no RPC response is received before timeout.

Implemented in profinet::rpc::RPCCon.

◆ ReadModuleDiff()

virtual blocks::ModuleDiffBlock profinet::rpc::IRPCCon::ReadModuleDiff ( )
pure virtual

Reads the ModuleDiffBlock.

Returns
Parsed module and submodule configuration differences.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadModuleDiff().

+ Here is the caller graph for this function:

◆ ReadPdRealData()

virtual blocks::PDRealData profinet::rpc::IRPCCon::ReadPdRealData ( )
pure virtual

Reads physical-device topology information.

Returns
Parsed PDRealData.

Implemented in profinet::rpc::RPCCon.

Referenced by profinet::device::ProfinetDevice::ReadTopology().

+ Here is the caller graph for this function:

◆ ReadRealIdentificationData()

virtual blocks::RealIdentificationData profinet::rpc::IRPCCon::ReadRealIdentificationData ( )
pure virtual

Reads logical slot and subslot information.

Returns
Parsed RealIdentificationData.

Implemented in profinet::rpc::RPCCon.

◆ ReadyForRtClass3()

virtual Bytes profinet::rpc::IRPCCon::ReadyForRtClass3 ( )
pure virtual

Sends the ReadyForRTClass3 control operation.

Returns
NRD response payload.

Implemented in profinet::rpc::RPCCon.

◆ Write()

virtual void profinet::rpc::IRPCCon::Write ( std::uint32_t  api,
std::uint16_t  slot,
std::uint16_t  subslot,
std::uint16_t  idx,
const Bytes data 
)
pure virtual

Writes a PROFINET data record through the established AR.

Parameters
apiApplication Process Identifier.
slotSlot number.
subslotSubslot number.
idxRecord data index.
dataRecord data to write.
Exceptions
PNIOErrorIf the device reports a PROFINET error.
RPCTimeoutErrorIf no RPC response is received before timeout.

Implemented in profinet::rpc::RPCCon.

◆ WriteMultiple()

virtual std::vector< blocks::WriteMultipleResult > profinet::rpc::IRPCCon::WriteMultiple ( const std::vector< WriteItem > &  writes)
pure virtual

Writes multiple PROFINET records in one operation.

Parameters
writesRecords to write.
Returns
Per-write results returned by the device.
Exceptions
PNIOErrorIf the overall request fails.
RPCErrorIf the RPC operation fails.

Implemented in profinet::rpc::RPCCon.


The documentation for this class was generated from the following file: