PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::sim::VirtualProfinetRpcDevice Class Reference

Stateful UDP PROFINET IO-Device protocol simulator. More...

#include <virtual_profinet_rpc_device.h>

+ Collaboration diagram for profinet::sim::VirtualProfinetRpcDevice:

Public Member Functions

 VirtualProfinetRpcDevice (VirtualProfinetDeviceConfiguration config={})
 Construct a stopped simulator.
 
 ~VirtualProfinetRpcDevice ()
 Stop the simulator.
 
 VirtualProfinetRpcDevice (const VirtualProfinetRpcDevice &)=delete
 
VirtualProfinetRpcDevice & operator= (const VirtualProfinetRpcDevice &)=delete
 
void Start ()
 Start listening for controller RPC packets.
 
void Stop () noexcept
 Stop listening and join the worker thread.
 
VirtualProfinetDeviceState State () const noexcept
 Return the current protocol state.
 
std::size_t ConnectCount () const noexcept
 Return the number of CONNECT requests accepted.
 
std::size_t PrmBeginCount () const noexcept
 Return the number of PrmBegin requests accepted.
 
std::size_t PrmEndCount () const noexcept
 Return the number of PrmEnd requests accepted.
 
std::size_t ApplicationReadyRequestCount () const noexcept
 Return the number of ApplicationReady requests sent.
 
std::size_t ApplicationReadyResponseCount () const noexcept
 Return the number of ApplicationReady responses accepted.
 
std::size_t ReleaseCount () const noexcept
 Return the number of Release requests observed.
 
bool SawInputIocr () const noexcept
 Return whether the controller supplied an Input IOCR.
 
bool SawOutputIocr () const noexcept
 Return whether the controller supplied an Output IOCR.
 
bool SawExpectedSubmodules () const noexcept
 Return whether the controller supplied ExpectedSubmodule blocks.
 
bool SawAlarmCr () const noexcept
 Return whether the controller supplied an AlarmCR.
 
std::string LastError () const
 Return the last diagnostic/rejection text.
 
bool WaitForState (VirtualProfinetDeviceState expected, std::chrono::milliseconds timeout) const
 Wait until the simulator reaches a state.
 
std::uint16_t RpcPort () const noexcept
 Return the configured device RPC port.
 

Private Member Functions

void Run ()
 Worker loop receiving controller datagrams.
 
void HandlePacket (const PNRPCHeader &request, const asio::ip::udp::endpoint &sender)
 Dispatch one complete RPC packet.
 
void HandleConnect (const PNRPCHeader &request, const asio::ip::udp::endpoint &sender)
 Handle a CONNECT request.
 
void HandleControl (const PNRPCHeader &request, const asio::ip::udp::endpoint &sender)
 Handle a CONTROL request such as PrmBegin or PrmEnd.
 
void HandleApplicationReadyResponse (const PNRPCHeader &response)
 Handle the response to the device-originated ApplicationReady.
 
bool ValidateConnect (const Bytes &nrdPayload)
 Validate and extract the CONNECT blocks.
 
void SendResponse (const PNRPCHeader &request, const Bytes &nrdPayload, const asio::ip::udp::endpoint &sender)
 Send a successful RPC response.
 
void SendApplicationReady ()
 Send a device-originated ApplicationReady request.
 
void WakeWorker () noexcept
 Wake the synchronous receive so the worker can observe shutdown.
 
void ScheduleApplicationReady ()
 Start a cancellable ApplicationReady delay.
 

Static Private Member Functions

static Bytes MakeNrd (const Bytes &payload)
 Build an NRD wrapper with successful status.
 
static PNRPCHeader MakeResponse (const PNRPCHeader &request, const Bytes &nrdPayload)
 Build an RPC response preserving correlation fields.
 
static Bytes MakeIocrResponse (const PNIOCRBlockReqHeader &request, std::uint16_t frameId)
 Build one IOCRBlockRes from a controller IOCR request.
 
static Bytes MakeAlarmCrResponse (std::uint16_t deviceAlarmReference)
 Build a minimal successful AlarmCRBlockRes.
 
static bool ContainsBlock (const Bytes &data, BlockType blockType)
 Find a block type in a serialized CONNECT payload.
 
static void ParseArIdentity (const Bytes &connectPayload, std::array< std::uint8_t, uuidLenght > &arUuid, std::uint16_t &sessionKey)
 Parse the AR UUID and session key from a CONNECT request.
 

Private Attributes

VirtualProfinetDeviceConfiguration config
 
std::mutex mutex
 
std::condition_variable stateCondition
 
std::atomic< bool > running {false}
 
std::thread worker
 
std::thread applicationReadyWorker
 Delayed ApplicationReady worker.
 
std::unique_ptr< asio::io_context > ioContext
 
std::unique_ptr< asio::ip::udp::socket > socket
 
VirtualProfinetDeviceState state = VirtualProfinetDeviceState::Idle
 
std::size_t connectCount = 0
 
std::size_t prmBeginCount = 0
 
std::size_t prmEndCount = 0
 
std::size_t applicationReadyRequestCount = 0
 
std::size_t applicationReadyResponseCount = 0
 
std::size_t releaseCount = 0
 
bool sawInputIocr = false
 
bool sawOutputIocr = false
 
bool sawExpectedSubmodules = false
 
bool sawAlarmCr = false
 
std::string lastError
 
std::array< std::uint8_t, uuidLenght > arUuid {}
 
std::uint16_t sessionKey = 0
 
std::optional< asio::ip::udp::endpoint > controllerEndpoint
 
std::optional< PNRPCHeader > lastApplicationReadyRequest
 

Detailed Description

Stateful UDP PROFINET IO-Device protocol simulator.

Requests are parsed with the production PNRPCHeader, PNNRDData, PNIOCRBlockReqHeader and control block definitions. The simulator keeps a strict state machine and records every accepted/rejected lifecycle step. It therefore fails tests when the controller performs startup in the wrong order rather than silently accepting the traffic.

Definition at line 130 of file virtual_profinet_rpc_device.h.

Constructor & Destructor Documentation

◆ VirtualProfinetRpcDevice() [1/2]

profinet::sim::VirtualProfinetRpcDevice::VirtualProfinetRpcDevice ( VirtualProfinetDeviceConfiguration  config = {})
explicit

Construct a stopped simulator.

Parameters
configDevice protocol configuration.

Definition at line 63 of file virtual_profinet_rpc_device.cpp.

◆ ~VirtualProfinetRpcDevice()

profinet::sim::VirtualProfinetRpcDevice::~VirtualProfinetRpcDevice ( )

Stop the simulator.

Definition at line 69 of file virtual_profinet_rpc_device.cpp.

References Stop().

+ Here is the call graph for this function:

◆ VirtualProfinetRpcDevice() [2/2]

profinet::sim::VirtualProfinetRpcDevice::VirtualProfinetRpcDevice ( const VirtualProfinetRpcDevice &  )
delete

Member Function Documentation

◆ ApplicationReadyRequestCount()

std::size_t profinet::sim::VirtualProfinetRpcDevice::ApplicationReadyRequestCount ( ) const
noexcept

Return the number of ApplicationReady requests sent.

Definition at line 219 of file virtual_profinet_rpc_device.cpp.

References applicationReadyRequestCount, and mutex.

◆ ApplicationReadyResponseCount()

std::size_t profinet::sim::VirtualProfinetRpcDevice::ApplicationReadyResponseCount ( ) const
noexcept

Return the number of ApplicationReady responses accepted.

Definition at line 225 of file virtual_profinet_rpc_device.cpp.

References applicationReadyResponseCount, and mutex.

◆ ConnectCount()

std::size_t profinet::sim::VirtualProfinetRpcDevice::ConnectCount ( ) const
noexcept

Return the number of CONNECT requests accepted.

Definition at line 201 of file virtual_profinet_rpc_device.cpp.

References connectCount, and mutex.

◆ ContainsBlock()

bool profinet::sim::VirtualProfinetRpcDevice::ContainsBlock ( const Bytes &  data,
BlockType  blockType 
)
staticprivate

Find a block type in a serialized CONNECT payload.

Definition at line 807 of file virtual_profinet_rpc_device.cpp.

References profinet::rpc::PeekBlockHeader().

Referenced by ValidateConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleApplicationReadyResponse()

void profinet::sim::VirtualProfinetRpcDevice::HandleApplicationReadyResponse ( const PNRPCHeader &  response)
private

Handle the response to the device-originated ApplicationReady.

Definition at line 532 of file virtual_profinet_rpc_device.cpp.

References profinet::PNRPCHeader::activityUuid, profinet::sim::ApplicationReady, applicationReadyResponseCount, profinet::sim::Fault, profinet::PNRPCHeader::interfaceUuid, lastApplicationReadyRequest, lastError, mutex, profinet::PNRPCHeader::objectUuid, profinet::sim::Parameterized, profinet::PNRPCHeader::sequenceNumber, state, and stateCondition.

Referenced by HandlePacket().

+ Here is the caller graph for this function:

◆ HandleConnect()

void profinet::sim::VirtualProfinetRpcDevice::HandleConnect ( const PNRPCHeader &  request,
const asio::ip::udp::endpoint &  sender 
)
private

◆ HandleControl()

void profinet::sim::VirtualProfinetRpcDevice::HandleControl ( const PNRPCHeader &  request,
const asio::ip::udp::endpoint &  sender 
)
private

Handle a CONTROL request such as PrmBegin or PrmEnd.

Definition at line 459 of file virtual_profinet_rpc_device.cpp.

References profinet::sim::VirtualProfinetDeviceConfiguration::automaticApplicationReady, config, profinet::sim::Connected, profinet::rpc::CONTROL_CMD_PRM_BEGIN, profinet::rpc::CONTROL_CMD_PRM_END, profinet::sim::Fault, profinet::PNIODHeader::kContolCommandOffset, lastError, MakeNrd(), mutex, profinet::sim::Parameterized, profinet::sim::Parameterizing, profinet::PNNRDData::Parse(), profinet::PNRPCHeader::payload, profinet::PNNRDData::payload, prmBeginCount, prmEndCount, releaseCount, profinet::sim::Released, ScheduleApplicationReady(), SendResponse(), profinet::wire::Reader::SkipTo(), state, stateCondition, and profinet::wire::Reader::U16().

Referenced by HandlePacket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandlePacket()

void profinet::sim::VirtualProfinetRpcDevice::HandlePacket ( const PNRPCHeader &  request,
const asio::ip::udp::endpoint &  sender 
)
private

Dispatch one complete RPC packet.

Parameters
requestParsed request.
senderController UDP endpoint.

Definition at line 326 of file virtual_profinet_rpc_device.cpp.

References profinet::PNRPCHeader::CONNECT, profinet::PNRPCHeader::CONTROL, HandleApplicationReadyResponse(), HandleConnect(), HandleControl(), profinet::PNRPCHeader::operationNumber, profinet::PNRPCHeader::packetType, profinet::PNRPCHeader::RELEASE, profinet::PNRPCHeader::REQUEST, and profinet::PNRPCHeader::RESPONSE.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LastError()

std::string profinet::sim::VirtualProfinetRpcDevice::LastError ( ) const

Return the last diagnostic/rejection text.

Definition at line 261 of file virtual_profinet_rpc_device.cpp.

References lastError, and mutex.

◆ MakeAlarmCrResponse()

Bytes profinet::sim::VirtualProfinetRpcDevice::MakeAlarmCrResponse ( std::uint16_t  deviceAlarmReference)
staticprivate

Build a minimal successful AlarmCRBlockRes.

Definition at line 790 of file virtual_profinet_rpc_device.cpp.

References profinet::AlarmCrResponse, profinet::PNAlarmCRBlockRes::blockHeader, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, profinet::PNAlarmCRBlockRes::kSize, profinet::PNAlarmCRBlockRes::localAlarmReference, profinet::PNBlockHeader::ToBytes(), profinet::PNAlarmCRBlockRes::ToBytes(), profinet::rpc::VERSION_HIGH, and profinet::rpc::VERSION_LOW.

Referenced by HandleConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeIocrResponse()

Bytes profinet::sim::VirtualProfinetRpcDevice::MakeIocrResponse ( const PNIOCRBlockReqHeader &  request,
std::uint16_t  frameId 
)
staticprivate

Build one IOCRBlockRes from a controller IOCR request.

Definition at line 775 of file virtual_profinet_rpc_device.cpp.

References profinet::PNIOCRBlockRes::BLOCK_TYPE, frameId, profinet::PNIOCRBlockReqHeader::iocrReference, profinet::PNIOCRBlockReqHeader::iocrType, profinet::PNIOCRBlockRes::kSize, profinet::wire::PutU16(), profinet::wire::PutU8(), profinet::rpc::VERSION_HIGH, and profinet::rpc::VERSION_LOW.

Referenced by HandleConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeNrd()

Bytes profinet::sim::VirtualProfinetRpcDevice::MakeNrd ( const Bytes &  payload)
staticprivate

Build an NRD wrapper with successful status.

Definition at line 748 of file virtual_profinet_rpc_device.cpp.

References profinet::PNNRDData::actualCount, profinet::PNNRDData::argsLength, profinet::PNNRDData::argsMaximumStatus, profinet::PNNRDData::maximumCount, profinet::PNNRDData::offset, profinet::PNNRDData::payload, payload, and profinet::PNNRDData::ToBytes().

Referenced by HandleConnect(), HandleControl(), and SendApplicationReady().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MakeResponse()

PNRPCHeader profinet::sim::VirtualProfinetRpcDevice::MakeResponse ( const PNRPCHeader &  request,
const Bytes &  nrdPayload 
)
staticprivate

Build an RPC response preserving correlation fields.

Definition at line 760 of file virtual_profinet_rpc_device.cpp.

References profinet::PNRPCHeader::flags1, profinet::PNRPCHeader::flags2, profinet::rpc::raw::LastFragment, profinet::PNRPCHeader::lengthOfBody, profinet::rpc::raw::NoFack, profinet::PNRPCHeader::packetType, profinet::PNRPCHeader::payload, and profinet::PNRPCHeader::RESPONSE.

Referenced by SendResponse().

+ Here is the caller graph for this function:

◆ operator=()

VirtualProfinetRpcDevice & profinet::sim::VirtualProfinetRpcDevice::operator= ( const VirtualProfinetRpcDevice &  )
delete

◆ ParseArIdentity()

void profinet::sim::VirtualProfinetRpcDevice::ParseArIdentity ( const Bytes &  connectPayload,
std::array< std::uint8_t, uuidLenght > &  arUuid,
std::uint16_t &  sessionKey 
)
staticprivate

Parse the AR UUID and session key from a CONNECT request.

Definition at line 833 of file virtual_profinet_rpc_device.cpp.

References profinet::wire::Reader::Fixed(), profinet::wire::Reader::SkipTo(), profinet::wire::Reader::U16(), and profinet::uuidLenght.

Referenced by HandleConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrmBeginCount()

std::size_t profinet::sim::VirtualProfinetRpcDevice::PrmBeginCount ( ) const
noexcept

Return the number of PrmBegin requests accepted.

Definition at line 207 of file virtual_profinet_rpc_device.cpp.

References mutex, and prmBeginCount.

◆ PrmEndCount()

std::size_t profinet::sim::VirtualProfinetRpcDevice::PrmEndCount ( ) const
noexcept

Return the number of PrmEnd requests accepted.

Definition at line 213 of file virtual_profinet_rpc_device.cpp.

References mutex, and prmEndCount.

◆ ReleaseCount()

std::size_t profinet::sim::VirtualProfinetRpcDevice::ReleaseCount ( ) const
noexcept

Return the number of Release requests observed.

Definition at line 231 of file virtual_profinet_rpc_device.cpp.

References mutex, and releaseCount.

◆ RpcPort()

std::uint16_t profinet::sim::VirtualProfinetRpcDevice::RpcPort ( ) const
noexcept

Return the configured device RPC port.

Definition at line 281 of file virtual_profinet_rpc_device.cpp.

References config, and profinet::sim::VirtualProfinetDeviceConfiguration::rpcPort.

◆ Run()

void profinet::sim::VirtualProfinetRpcDevice::Run ( )
private

Worker loop receiving controller datagrams.

Definition at line 286 of file virtual_profinet_rpc_device.cpp.

References buffer, error, profinet::sim::Fault, HandlePacket(), lastError, mutex, profinet::PNRPCHeader::Parse(), running, socket, state, and stateCondition.

Referenced by Start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SawAlarmCr()

bool profinet::sim::VirtualProfinetRpcDevice::SawAlarmCr ( ) const
noexcept

Return whether the controller supplied an AlarmCR.

Definition at line 255 of file virtual_profinet_rpc_device.cpp.

References mutex, and sawAlarmCr.

◆ SawExpectedSubmodules()

bool profinet::sim::VirtualProfinetRpcDevice::SawExpectedSubmodules ( ) const
noexcept

Return whether the controller supplied ExpectedSubmodule blocks.

Definition at line 249 of file virtual_profinet_rpc_device.cpp.

References mutex, and sawExpectedSubmodules.

◆ SawInputIocr()

bool profinet::sim::VirtualProfinetRpcDevice::SawInputIocr ( ) const
noexcept

Return whether the controller supplied an Input IOCR.

Definition at line 237 of file virtual_profinet_rpc_device.cpp.

References mutex, and sawInputIocr.

◆ SawOutputIocr()

bool profinet::sim::VirtualProfinetRpcDevice::SawOutputIocr ( ) const
noexcept

Return whether the controller supplied an Output IOCR.

Definition at line 243 of file virtual_profinet_rpc_device.cpp.

References mutex, and sawOutputIocr.

◆ ScheduleApplicationReady()

void profinet::sim::VirtualProfinetRpcDevice::ScheduleApplicationReady ( )
private

Start a cancellable ApplicationReady delay.

Definition at line 359 of file virtual_profinet_rpc_device.cpp.

References profinet::sim::VirtualProfinetDeviceConfiguration::applicationReadyDelay, applicationReadyWorker, config, mutex, running, SendApplicationReady(), and stateCondition.

Referenced by HandleControl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendApplicationReady()

void profinet::sim::VirtualProfinetRpcDevice::SendApplicationReady ( )
private

Send a device-originated ApplicationReady request.

Definition at line 671 of file virtual_profinet_rpc_device.cpp.

References profinet::PNRPCHeader::activityHint, profinet::PNRPCHeader::activityUuid, profinet::ApplicationReady, applicationReadyRequestCount, profinet::PNIODReleaseBlock::arUuid, arUuid, profinet::PNRPCHeader::authenticationProtocol, profinet::PNIODReleaseBlock::blockHeader, profinet::PNBlockHeader::blockLength, profinet::PNBlockHeader::blockType, profinet::PNBlockHeader::blockVersionHigh, profinet::PNBlockHeader::blockVersionLow, config, profinet::PNRPCHeader::CONTROL, profinet::ControlApplicationReadyRequest, profinet::PNIODReleaseBlock::controlBlockProperties, profinet::PNIODReleaseBlock::controlCommand, controller, profinet::sim::VirtualProfinetDeviceConfiguration::controllerAddress, profinet::sim::VirtualProfinetDeviceConfiguration::controllerCcontrolPort, controllerEndpoint, profinet::PNRPCHeader::dataRepresentation, profinet::PNRPCHeader::defaultActivityHint, profinet::PNRPCHeader::defaultInterfaceHint, error, profinet::sim::Fault, profinet::PNRPCHeader::flags1, profinet::PNRPCHeader::flags2, profinet::PNRPCHeader::fragmentNumber, profinet::rpc::raw::Idempotent, profinet::PNRPCHeader::IfaceUuidDevice(), profinet::PNRPCHeader::interfaceHint, profinet::PNRPCHeader::interfaceUuid, profinet::PNRPCHeader::interfaceVersion, lastApplicationReadyRequest, lastError, profinet::rpc::raw::LastFragment, profinet::PNRPCHeader::lengthOfBody, MakeNrd(), mutex, profinet::PNRPCHeader::objectUuid, profinet::PNRPCHeader::operationNumber, profinet::PNRPCHeader::packetType, profinet::PNIODReleaseBlock::padding1, profinet::PNIODReleaseBlock::padding2, profinet::sim::Parameterized, profinet::PNRPCHeader::payload, profinet::PNRPCHeader::REQUEST, profinet::PNRPCHeader::sequenceNumber, profinet::PNRPCHeader::serialNrHigh, profinet::PNRPCHeader::serialNrLow, profinet::PNRPCHeader::serverBootTime, profinet::PNIODReleaseBlock::sessionKey, sessionKey, socket, state, stateCondition, profinet::PNRPCHeader::ToBytes(), profinet::PNBlockHeader::ToBytes(), profinet::PNIODReleaseBlock::ToBytes(), and profinet::PNRPCHeader::version.

Referenced by ScheduleApplicationReady().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendResponse()

void profinet::sim::VirtualProfinetRpcDevice::SendResponse ( const PNRPCHeader &  request,
const Bytes &  nrdPayload,
const asio::ip::udp::endpoint &  sender 
)
private

Send a successful RPC response.

Definition at line 652 of file virtual_profinet_rpc_device.cpp.

References error, profinet::sim::Fault, lastError, MakeResponse(), mutex, socket, state, stateCondition, and profinet::PNRPCHeader::ToBytes().

Referenced by HandleConnect(), and HandleControl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Start()

void profinet::sim::VirtualProfinetRpcDevice::Start ( )

Start listening for controller RPC packets.

Exceptions
std::system_errorWhen the UDP endpoint cannot be opened.

Definition at line 74 of file virtual_profinet_rpc_device.cpp.

References config, error, ioContext, profinet::sim::VirtualProfinetDeviceConfiguration::rpcPort, Run(), running, socket, and worker.

+ Here is the call graph for this function:

◆ State()

VirtualProfinetDeviceState profinet::sim::VirtualProfinetRpcDevice::State ( ) const
noexcept

Return the current protocol state.

Definition at line 195 of file virtual_profinet_rpc_device.cpp.

References mutex, and state.

◆ Stop()

void profinet::sim::VirtualProfinetRpcDevice::Stop ( )
noexcept

Stop listening and join the worker thread.

Definition at line 113 of file virtual_profinet_rpc_device.cpp.

References applicationReadyWorker, error, ioContext, mutex, running, socket, stateCondition, WakeWorker(), and worker.

Referenced by ~VirtualProfinetRpcDevice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ValidateConnect()

bool profinet::sim::VirtualProfinetRpcDevice::ValidateConnect ( const Bytes &  nrdPayload)
private

Validate and extract the CONNECT blocks.

Parameters
nrdPayloadCONNECT block payload.
Returns
True when the requested configuration is acceptable.

Definition at line 569 of file virtual_profinet_rpc_device.cpp.

References profinet::ApplicationRelationRequest, profinet::PNIOCRBlockReqHeader::BLOCK_TYPE, profinet::PNAlarmCRBlockReq::BLOCK_TYPE, config, ContainsBlock(), profinet::ExpectedSubmoduleRequest, profinet::sim::Fault, profinet::PNIOCRBlockReqHeader::iocrType, lastError, mutex, profinet::PNIOCRBlockReqHeader::Parse(), profinet::rpc::PeekBlockHeader(), profinet::sim::VirtualProfinetDeviceConfiguration::requireAlarmCr, profinet::sim::VirtualProfinetDeviceConfiguration::requireBothIocrs, profinet::sim::VirtualProfinetDeviceConfiguration::requireExpectedSubmodules, sawAlarmCr, sawExpectedSubmodules, sawInputIocr, sawOutputIocr, state, and stateCondition.

Referenced by HandleConnect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WaitForState()

bool profinet::sim::VirtualProfinetRpcDevice::WaitForState ( VirtualProfinetDeviceState  expected,
std::chrono::milliseconds  timeout 
) const

Wait until the simulator reaches a state.

Parameters
expectedState to wait for.
timeoutMaximum wait duration.
Returns
True when the state was reached.

Definition at line 267 of file virtual_profinet_rpc_device.cpp.

References mutex, state, and stateCondition.

◆ WakeWorker()

void profinet::sim::VirtualProfinetRpcDevice::WakeWorker ( )
privatenoexcept

Wake the synchronous receive so the worker can observe shutdown.

Definition at line 156 of file virtual_profinet_rpc_device.cpp.

References config, error, profinet::sim::VirtualProfinetDeviceConfiguration::rpcPort, and socket.

Referenced by Stop().

+ Here is the caller graph for this function:

Member Data Documentation

◆ applicationReadyRequestCount

std::size_t profinet::sim::VirtualProfinetRpcDevice::applicationReadyRequestCount = 0
private

◆ applicationReadyResponseCount

std::size_t profinet::sim::VirtualProfinetRpcDevice::applicationReadyResponseCount = 0
private

◆ applicationReadyWorker

std::thread profinet::sim::VirtualProfinetRpcDevice::applicationReadyWorker
private

Delayed ApplicationReady worker.

Definition at line 268 of file virtual_profinet_rpc_device.h.

Referenced by ScheduleApplicationReady(), and Stop().

◆ arUuid

std::array<std::uint8_t, uuidLenght> profinet::sim::VirtualProfinetRpcDevice::arUuid {}
private

Definition at line 287 of file virtual_profinet_rpc_device.h.

Referenced by HandleConnect(), and SendApplicationReady().

◆ config

◆ connectCount

std::size_t profinet::sim::VirtualProfinetRpcDevice::connectCount = 0
private

Definition at line 274 of file virtual_profinet_rpc_device.h.

Referenced by ConnectCount(), and HandleConnect().

◆ controllerEndpoint

std::optional<asio::ip::udp::endpoint> profinet::sim::VirtualProfinetRpcDevice::controllerEndpoint
private

Definition at line 289 of file virtual_profinet_rpc_device.h.

Referenced by HandleConnect(), and SendApplicationReady().

◆ ioContext

std::unique_ptr<asio::io_context> profinet::sim::VirtualProfinetRpcDevice::ioContext
private

Definition at line 270 of file virtual_profinet_rpc_device.h.

Referenced by Start(), and Stop().

◆ lastApplicationReadyRequest

std::optional<PNRPCHeader> profinet::sim::VirtualProfinetRpcDevice::lastApplicationReadyRequest
private

◆ lastError

std::string profinet::sim::VirtualProfinetRpcDevice::lastError
private

◆ mutex

◆ prmBeginCount

std::size_t profinet::sim::VirtualProfinetRpcDevice::prmBeginCount = 0
private

Definition at line 275 of file virtual_profinet_rpc_device.h.

Referenced by HandleControl(), and PrmBeginCount().

◆ prmEndCount

std::size_t profinet::sim::VirtualProfinetRpcDevice::prmEndCount = 0
private

Definition at line 276 of file virtual_profinet_rpc_device.h.

Referenced by HandleControl(), and PrmEndCount().

◆ releaseCount

std::size_t profinet::sim::VirtualProfinetRpcDevice::releaseCount = 0
private

Definition at line 279 of file virtual_profinet_rpc_device.h.

Referenced by HandleControl(), and ReleaseCount().

◆ running

std::atomic<bool> profinet::sim::VirtualProfinetRpcDevice::running {false}
private

Definition at line 265 of file virtual_profinet_rpc_device.h.

Referenced by Run(), ScheduleApplicationReady(), Start(), and Stop().

◆ sawAlarmCr

bool profinet::sim::VirtualProfinetRpcDevice::sawAlarmCr = false
private

Definition at line 284 of file virtual_profinet_rpc_device.h.

Referenced by HandleConnect(), SawAlarmCr(), and ValidateConnect().

◆ sawExpectedSubmodules

bool profinet::sim::VirtualProfinetRpcDevice::sawExpectedSubmodules = false
private

Definition at line 283 of file virtual_profinet_rpc_device.h.

Referenced by SawExpectedSubmodules(), and ValidateConnect().

◆ sawInputIocr

bool profinet::sim::VirtualProfinetRpcDevice::sawInputIocr = false
private

Definition at line 281 of file virtual_profinet_rpc_device.h.

Referenced by SawInputIocr(), and ValidateConnect().

◆ sawOutputIocr

bool profinet::sim::VirtualProfinetRpcDevice::sawOutputIocr = false
private

Definition at line 282 of file virtual_profinet_rpc_device.h.

Referenced by SawOutputIocr(), and ValidateConnect().

◆ sessionKey

std::uint16_t profinet::sim::VirtualProfinetRpcDevice::sessionKey = 0
private

Definition at line 288 of file virtual_profinet_rpc_device.h.

Referenced by HandleConnect(), and SendApplicationReady().

◆ socket

std::unique_ptr<asio::ip::udp::socket> profinet::sim::VirtualProfinetRpcDevice::socket
private

◆ state

◆ stateCondition

std::condition_variable profinet::sim::VirtualProfinetRpcDevice::stateCondition
mutableprivate

◆ worker

std::thread profinet::sim::VirtualProfinetRpcDevice::worker
private

Definition at line 266 of file virtual_profinet_rpc_device.h.

Referenced by Start(), and Stop().


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