PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
mockRPCCon.h
Go to the documentation of this file.
1
17#pragma once
18
19#include <gmock/gmock.h>
20
21#include "profinet/IRPCCon.h"
22
23namespace profinet::rpc
24{
25
34class MockRPCCon : public IRPCCon
35{
36 public:
38 MockRPCCon() = default;
39
41 ~MockRPCCon() override = default;
42
43 MOCK_METHOD(std::optional<ConnectResult>, Connect, (std::optional<MacAddress> srcMac, bool withAlarmCr, std::optional<IOCRSetup> iocrSetup), (override));
44
45 MOCK_METHOD(void, Disconnect, (), (override));
46
47 MOCK_METHOD(void, Close, (), (noexcept, override));
48
49 MOCK_METHOD(bool, IsConnected, (), (const, override));
50
51 MOCK_METHOD(PNIODHeader, Read, (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx), (override));
52
53 MOCK_METHOD(PNIODHeader, ReadImplicit, (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx), (override));
54
55 MOCK_METHOD(void, Write, (std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx, const Bytes& data), (override));
56
57 MOCK_METHOD(std::vector<blocks::WriteMultipleResult>, WriteMultiple, (const std::vector<WriteItem>& writes), (override));
58
59 MOCK_METHOD(PNInM0, ReadIm0, (std::uint16_t slot, std::uint16_t subslot), (override));
60 MOCK_METHOD(PNInM1, ReadIm1, (std::uint16_t slot, std::uint16_t subslot), (override));
61 MOCK_METHOD(PNInM2, ReadIm2, (std::uint16_t slot, std::uint16_t subslot), (override));
62 MOCK_METHOD(PNInM3, ReadIm3, (std::uint16_t slot, std::uint16_t subslot), (override));
63 MOCK_METHOD(PNInM4, ReadIm4, (std::uint16_t slot, std::uint16_t subslot), (override));
64 MOCK_METHOD(PNInM5, ReadIm5, (std::uint16_t slot, std::uint16_t subslot), (override));
65 MOCK_METHOD(PNInM6, ReadIm6, (std::uint16_t slot, std::uint16_t subslot), (override));
66 MOCK_METHOD(PNInM7, ReadIm7, (std::uint16_t slot, std::uint16_t subslot), (override));
67 MOCK_METHOD(PNInM8, ReadIm8, (std::uint16_t slot, std::uint16_t subslot), (override));
68 MOCK_METHOD(PNInM9, ReadIm9, (std::uint16_t slot, std::uint16_t subslot), (override));
69 MOCK_METHOD(PNInM10, ReadIm10, (std::uint16_t slot, std::uint16_t subslot), (override));
70 MOCK_METHOD(PNInM11, ReadIm11, (std::uint16_t slot, std::uint16_t subslot), (override));
71 MOCK_METHOD(PNInM12, ReadIm12, (std::uint16_t slot, std::uint16_t subslot), (override));
72 MOCK_METHOD(PNInM13, ReadIm13, (std::uint16_t slot, std::uint16_t subslot), (override));
73 MOCK_METHOD(PNInM14, ReadIm14, (std::uint16_t slot, std::uint16_t subslot), (override));
74 MOCK_METHOD(PNInM15, ReadIm15, (std::uint16_t slot, std::uint16_t subslot), (override));
75
76 MOCK_METHOD(AllIM, ReadAllIm, (std::uint16_t slot, std::uint16_t subslot), (override));
77
79
80 MOCK_METHOD(diagnosis::DiagnosisData, ReadDiagnosis, (std::uint16_t slot, std::uint16_t subslot, std::uint16_t index), (override));
81
82 MOCK_METHOD((std::map<std::uint16_t, diagnosis::DiagnosisData>), ReadAllDiagnosis, (), (override));
83
85
87
88 MOCK_METHOD(std::vector<blocks::SlotInfo>, DiscoverSlots, (), (override));
89
90 MOCK_METHOD((std::pair<blocks::PDRealData, blocks::RealIdentificationData>), DiscoverTopology, (), (override));
91
92 MOCK_METHOD((std::map<std::uint16_t, IndexProbeResult>), EnumerateIndices, (std::uint16_t slot, std::uint16_t subslot, std::optional<std::vector<std::uint16_t>> customIndices), (override));
93
94 MOCK_METHOD(Bytes, PrmBegin, (), (override));
95
96 MOCK_METHOD(Bytes, PrmEnd, (), (override));
97
99
100 MOCK_METHOD(Bytes, ApplicationReady, (double timeoutSec), (override));
101
102 MOCK_METHOD(const dcp::DCPDeviceDescription&, Info, (), (const, override));
103
104 MOCK_METHOD(std::uint16_t, LocalAlarmRef, (), (const, override));
105
106 MOCK_METHOD(int, DeviceAlarmRef, (), (const, override));
107
108 MOCK_METHOD(bool, HasAlarmCr, (), (const, override));
109
110 MOCK_METHOD(std::vector<EPMEndpoint>, EpmLookup, (const std::string&, std::uint16_t, double timeoutSec, std::optional<std::string>), (override));
111};
112
113} // namespace profinet::rpc
Interface for PROFINET IO-Device RPC connections.
Parsed PROFINET device information from a DCP response.
Definition dcp.h:268
Abstract interface for a PROFINET RPC connection.
Definition IRPCCon.h:81
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 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 std::vector< EPMEndpoint > EpmLookup(const std::string &ip, std::uint16_t port=RPC_PORT, double timeoutSec=DEFAULT_TIMEOUT, std::optional< std::string > interfaceFilter=std::nullopt)=0
Query a device's Endpoint Mapper for available RPC endpoints.
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.
Google Mock implementation of the IRPCCon RPC connection interface.
Definition mockRPCCon.h:35
MOCK_METHOD(std::optional< ConnectResult >, Connect,(std::optional< MacAddress > srcMac, bool withAlarmCr, std::optional< IOCRSetup > iocrSetup),(override))
MOCK_METHOD(bool, HasAlarmCr,(),(const, override))
MOCK_METHOD(PNInM10, ReadIm10,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM6, ReadIm6,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD((std::pair< blocks::PDRealData, blocks::RealIdentificationData >), DiscoverTopology,(),(override))
MOCK_METHOD(void, Write,(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx, const Bytes &data),(override))
MOCK_METHOD(void, Close,(),(noexcept, override))
MOCK_METHOD(PNInM15, ReadIm15,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(Bytes, ReadyForRtClass3,(),(override))
MOCK_METHOD(const dcp::DCPDeviceDescription &, Info,(),(const, override))
MOCK_METHOD(PNIODHeader, ReadImplicit,(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx),(override))
MOCK_METHOD(PNIODHeader, Read,(std::uint32_t api, std::uint16_t slot, std::uint16_t subslot, std::uint16_t idx),(override))
MOCK_METHOD(PNInM5, ReadIm5,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(std::vector< blocks::SlotInfo >, DiscoverSlots,(),(override))
MOCK_METHOD((std::map< std::uint16_t, IndexProbeResult >), EnumerateIndices,(std::uint16_t slot, std::uint16_t subslot, std::optional< std::vector< std::uint16_t > > customIndices),(override))
MOCK_METHOD(PNInM2, ReadIm2,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(blocks::PDRealData, ReadPdRealData,(),(override))
MOCK_METHOD(std::uint16_t, LocalAlarmRef,(),(const, override))
MOCK_METHOD(std::vector< blocks::WriteMultipleResult >, WriteMultiple,(const std::vector< WriteItem > &writes),(override))
~MockRPCCon() override=default
Destroys the mock RPC connection.
MOCK_METHOD(PNInM7, ReadIm7,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM14, ReadIm14,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(void, Disconnect,(),(override))
MOCK_METHOD(AllIM, ReadAllIm,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(diagnosis::DiagnosisData, ReadDiagnosis,(std::uint16_t slot, std::uint16_t subslot, std::uint16_t index),(override))
MOCK_METHOD(PNInM1, ReadIm1,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(Bytes, ApplicationReady,(double timeoutSec),(override))
MOCK_METHOD((std::map< std::uint16_t, diagnosis::DiagnosisData >), ReadAllDiagnosis,(),(override))
MOCK_METHOD(Bytes, PrmBegin,(),(override))
MOCK_METHOD(blocks::ModuleDiffBlock, ReadModuleDiff,(),(override))
MOCK_METHOD(Bytes, PrmEnd,(),(override))
MOCK_METHOD(bool, IsConnected,(),(const, override))
MOCK_METHOD(PNInM12, ReadIm12,(std::uint16_t slot, std::uint16_t subslot),(override))
MockRPCCon()=default
Constructs a mock RPC connection.
MOCK_METHOD(std::vector< EPMEndpoint >, EpmLookup,(const std::string &, std::uint16_t, double timeoutSec, std::optional< std::string >),(override))
MOCK_METHOD(PNInM11, ReadIm11,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM8, ReadIm8,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM4, ReadIm4,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM0, ReadIm0,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM13, ReadIm13,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(PNInM3, ReadIm3,(std::uint16_t slot, std::uint16_t subslot),(override))
MOCK_METHOD(int, DeviceAlarmRef,(),(const, override))
MOCK_METHOD(blocks::RealIdentificationData, ReadRealIdentificationData,(),(override))
MOCK_METHOD(PNInM9, ReadIm9,(std::uint16_t slot, std::uint16_t subslot),(override))
@ 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:55
IOD read/write request/response header (RPC body for READ/WRITE/IMPLICIT_READ).
Definition protocol.h:1190
I&M0: mandatory identification data (vendor, order ID, serial number, revisions).
Definition protocol.h:1517
I&M1: user-assigned tag function and location strings.
Definition protocol.h:1624
I&M2: installation date.
Definition protocol.h:1668
I&M3: free-text descriptor.
Definition protocol.h:1709
I&M4: PROFIsafe signature (binary, not text).
Definition protocol.h:1749
I&M5: free-text annotation.
Definition protocol.h:1789
I&M6-I&M15: reserved for future use per IEC 61158-6-10.
Definition protocol.h:1833
Parsed ModuleDiffBlock (0x8104).
Definition blocks.h:415
Parsed PDRealData (0xF841) structure.
Definition blocks.h:221
Parsed RealIdentificationData (0xF000/0x0013) structure.
Definition blocks.h:244
Complete diagnosis data for one slot/subslot.
Definition diagnosis.h:275
All I&M records a device supports, read in one call.
Definition rpcTypes.h:451