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

Owns one shared Ethernet bus plus any number of virtual PLCs and AUMA valves. More...

#include <virtual_pn_lab.h>

+ Collaboration diagram for profinet::sim::VirtualProfinetLab:

Classes

struct  AumaEntry
 
struct  PlcEntry
 

Public Member Functions

 VirtualProfinetLab ()=default
 Create an empty virtual network.
 
 ~VirtualProfinetLab ()
 
 VirtualProfinetLab (const VirtualProfinetLab &)=delete
 
VirtualProfinetLab & operator= (const VirtualProfinetLab &)=delete
 
VirtualAumaValve & AddAumaValve (std::string name, const gsdml::GSDMLDevice &gsdml, MacAddress deviceMac, rt::IOCRConfig inputIocr, rt::IOCRConfig outputIocr, VirtualAumaValveConfiguration config={})
 Add one AUMA valve instance.
 
VirtualPhoenixPlc & AddPhoenixPlc (std::string name, const gsdml::GSDMLDevice &gsdml, MacAddress controllerMac)
 Add one Phoenix AXC F 1252 controller instance.
 
void Connect (asio::io_context &ioContext, const std::string &plcName, const std::string &valveName, rt::IOCRConfig inputIocr, rt::IOCRConfig outputIocr, int maxConsecutiveTimeouts=cyclic::DEFAULT_MAX_CONSECUTIVE_TIMEOUTS)
 Connect a PLC to an AUMA valve.
 
void SetAumaScenario (const std::string &valveName, VirtualAumaScenario scenario)
 Set one valve scenario.
 
InMemoryEthernetBus & Bus () noexcept
 Return the shared virtual bus.
 
VirtualAumaValve & Valve (const std::string &name)
 Find a valve by name.
 
const VirtualAumaValve & Valve (const std::string &name) const
 Find a valve by name from a const lab.
 
VirtualPhoenixPlc & Plc (const std::string &name)
 Find a PLC by name.
 
const VirtualPhoenixPlc & Plc (const std::string &name) const
 Find a PLC by name from a const lab.
 
std::vector< std::string > ValveNames () const
 Return all valve names.
 
std::vector< std::string > PlcNames () const
 Return all PLC names.
 
std::string StatusReport () const
 Render a compact multi-device status dashboard.
 
void Stop ()
 Stop all devices and controllers.
 

Private Member Functions

bool IsMacInUse (const MacAddress &mac) const noexcept
 Determine whether a node MAC is already used by this lab.
 

Private Attributes

InMemoryEthernetBus bus
 
std::vector< AumaEntry > valves
 
std::vector< PlcEntry > plcs
 

Detailed Description

Owns one shared Ethernet bus plus any number of virtual PLCs and AUMA valves.

Definition at line 21 of file virtual_pn_lab.h.

Constructor & Destructor Documentation

◆ VirtualProfinetLab() [1/2]

profinet::sim::VirtualProfinetLab::VirtualProfinetLab ( )
default

Create an empty virtual network.

◆ ~VirtualProfinetLab()

profinet::sim::VirtualProfinetLab::~VirtualProfinetLab ( )

Definition at line 13 of file virtual_pn_lab.cpp.

References Stop().

+ Here is the call graph for this function:

◆ VirtualProfinetLab() [2/2]

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

Member Function Documentation

◆ AddAumaValve()

VirtualAumaValve & profinet::sim::VirtualProfinetLab::AddAumaValve ( std::string  name,
const gsdml::GSDMLDevice &  gsdml,
MacAddress  deviceMac,
rt::IOCRConfig  inputIocr,
rt::IOCRConfig  outputIocr,
VirtualAumaValveConfiguration  config = {} 
)

Add one AUMA valve instance.

Parameters
nameStable logical instance name.
gsdmlParsed AUMA GSDML.
deviceMacUnique device MAC.
inputIocrDevice input IOCR.
outputIocrDevice output IOCR.
configValve application configuration.
Returns
Reference to the created valve.

Definition at line 18 of file virtual_pn_lab.cpp.

References bus, IsMacInUse(), profinet::Mac2String(), and valves.

Referenced by profinet::sim::TEST(), profinet::sim::TEST(), and profinet::sim::TEST().

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

◆ AddPhoenixPlc()

VirtualPhoenixPlc & profinet::sim::VirtualProfinetLab::AddPhoenixPlc ( std::string  name,
const gsdml::GSDMLDevice &  gsdml,
MacAddress  controllerMac 
)

Add one Phoenix AXC F 1252 controller instance.

Definition at line 47 of file virtual_pn_lab.cpp.

References IsMacInUse(), profinet::Mac2String(), and plcs.

Referenced by profinet::sim::TEST(), profinet::sim::TEST(), and profinet::sim::TEST().

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

◆ Bus()

InMemoryEthernetBus & profinet::sim::VirtualProfinetLab::Bus ( )
noexcept

Return the shared virtual bus.

Definition at line 87 of file virtual_pn_lab.cpp.

References bus.

Referenced by profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ Connect()

void profinet::sim::VirtualProfinetLab::Connect ( asio::io_context &  ioContext,
const std::string &  plcName,
const std::string &  valveName,
rt::IOCRConfig  inputIocr,
rt::IOCRConfig  outputIocr,
int  maxConsecutiveTimeouts = cyclic::DEFAULT_MAX_CONSECUTIVE_TIMEOUTS 
)

Connect a PLC to an AUMA valve.

Definition at line 66 of file virtual_pn_lab.cpp.

References bus, profinet::sim::VirtualPhoenixPlc::Connect(), ioContext, Plc(), and Valve().

Referenced by profinet::sim::TEST().

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

◆ IsMacInUse()

bool profinet::sim::VirtualProfinetLab::IsMacInUse ( const MacAddress &  mac) const
privatenoexcept

Determine whether a node MAC is already used by this lab.

Definition at line 185 of file virtual_pn_lab.cpp.

Referenced by AddAumaValve(), and AddPhoenixPlc().

+ Here is the caller graph for this function:

◆ operator=()

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

◆ Plc() [1/2]

VirtualPhoenixPlc & profinet::sim::VirtualProfinetLab::Plc ( const std::string &  name)

Find a PLC by name.

Definition at line 103 of file virtual_pn_lab.cpp.

References plcs.

Referenced by Connect(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ Plc() [2/2]

const VirtualPhoenixPlc & profinet::sim::VirtualProfinetLab::Plc ( const std::string &  name) const

Find a PLC by name from a const lab.

Definition at line 125 of file virtual_pn_lab.cpp.

References plcs.

◆ PlcNames()

std::vector< std::string > profinet::sim::VirtualProfinetLab::PlcNames ( ) const

Return all PLC names.

Definition at line 147 of file virtual_pn_lab.cpp.

References plcs.

Referenced by profinet::sim::TEST(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ SetAumaScenario()

void profinet::sim::VirtualProfinetLab::SetAumaScenario ( const std::string &  valveName,
VirtualAumaScenario  scenario 
)

Set one valve scenario.

Definition at line 81 of file virtual_pn_lab.cpp.

References profinet::sim::VirtualAumaValve::SetScenario(), and Valve().

Referenced by profinet::sim::TEST().

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

◆ StatusReport()

std::string profinet::sim::VirtualProfinetLab::StatusReport ( ) const

Render a compact multi-device status dashboard.

Definition at line 158 of file virtual_pn_lab.cpp.

References bus, profinet::sim::InMemoryEthernetBus::EndpointCount(), profinet::Mac2String(), plcs, profinet::sim::ToString(), and valves.

Referenced by profinet::sim::TEST().

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

◆ Stop()

void profinet::sim::VirtualProfinetLab::Stop ( )

Stop all devices and controllers.

Definition at line 204 of file virtual_pn_lab.cpp.

References plcs, and valves.

Referenced by ~VirtualProfinetLab(), profinet::sim::TEST(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ Valve() [1/2]

VirtualAumaValve & profinet::sim::VirtualProfinetLab::Valve ( const std::string &  name)

Find a valve by name.

Definition at line 92 of file virtual_pn_lab.cpp.

References valves.

Referenced by Connect(), SetAumaScenario(), profinet::sim::TEST(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ Valve() [2/2]

const VirtualAumaValve & profinet::sim::VirtualProfinetLab::Valve ( const std::string &  name) const

Find a valve by name from a const lab.

Definition at line 114 of file virtual_pn_lab.cpp.

References valves.

◆ ValveNames()

std::vector< std::string > profinet::sim::VirtualProfinetLab::ValveNames ( ) const

Return all valve names.

Definition at line 136 of file virtual_pn_lab.cpp.

References valves.

Referenced by profinet::sim::TEST(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

Member Data Documentation

◆ bus

InMemoryEthernetBus profinet::sim::VirtualProfinetLab::bus
private

Definition at line 90 of file virtual_pn_lab.h.

Referenced by AddAumaValve(), Bus(), Connect(), and StatusReport().

◆ plcs

std::vector<PlcEntry> profinet::sim::VirtualProfinetLab::plcs
private

Definition at line 102 of file virtual_pn_lab.h.

Referenced by AddPhoenixPlc(), Plc(), Plc(), PlcNames(), StatusReport(), and Stop().

◆ valves

std::vector<AumaEntry> profinet::sim::VirtualProfinetLab::valves
private

Definition at line 101 of file virtual_pn_lab.h.

Referenced by AddAumaValve(), StatusReport(), Stop(), Valve(), Valve(), and ValveNames().


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