|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Virtual Phoenix Contact AXC F 1252 controller hosting real CyclicController instances. More...
#include <virtual_phoenix_plc.h>
Collaboration diagram for profinet::sim::VirtualPhoenixPlc:Classes | |
| struct | Connection |
Public Member Functions | |
| VirtualPhoenixPlc (std::string name, const gsdml::GSDMLDevice &gsdml, MacAddress controllerMac) | |
| Construct a virtual Phoenix PLC from its parsed GSDML. | |
| ~VirtualPhoenixPlc () | |
| Stop all device connections. | |
| VirtualPhoenixPlc (const VirtualPhoenixPlc &)=delete | |
| VirtualPhoenixPlc & | operator= (const VirtualPhoenixPlc &)=delete |
| void | Connect (asio::io_context &ioContext, InMemoryEthernetBus &bus, VirtualAumaValve &valve, rt::IOCRConfig inputIocr, rt::IOCRConfig outputIocr, int maxConsecutiveTimeouts=cyclic::DEFAULT_MAX_CONSECUTIVE_TIMEOUTS) |
| Connect the PLC to one virtual AUMA device. | |
| void | Disconnect (const std::string &valveName) |
| Disconnect a named AUMA connection. | |
| void | Stop () |
| Stop all active connections. | |
| void | SetOutput (const std::string &valveName, std::string_view signalTextId, double value) |
| Set a typed AUMA actuator signal. | |
| std::optional< double > | ReadInput (const std::string &valveName, std::string_view signalTextId) const |
| Read a typed AUMA input signal using the production controller API. | |
| void | SetLocalInputBytes (std::string_view signalTextId, const Bytes &data) |
| Set raw bytes in the local Phoenix input process image. | |
| void | SetLocalInputValue (std::string_view signalTextId, double value) |
| Set one typed Phoenix input signal. | |
| std::optional< double > | GetLocalInputValue (std::string_view signalTextId) const |
| Read one typed Phoenix input signal. | |
| void | SetLocalOutputBytes (std::string_view signalTextId, const Bytes &data) |
| Set raw bytes in the local Phoenix output process image. | |
| std::optional< Bytes > | GetLocalOutputBytes (std::string_view signalTextId) const |
| Read raw bytes from the local Phoenix output process image. | |
| void | SetLocalOutputValue (std::string_view signalTextId, double value) |
| Set one typed Phoenix output signal. | |
| std::optional< double > | GetLocalOutputValue (std::string_view signalTextId) const |
| Read one typed Phoenix output signal. | |
| std::optional< Bytes > | GetLocalInputBytes (std::string_view signalTextId) const |
| Read raw bytes from the local Phoenix input process image. | |
| const io::IoSignalCatalog & | SignalCatalog () const noexcept |
| Return the Phoenix PLC's logical signal catalogue. | |
| const MacAddress & | ControllerMac () const noexcept |
| Return the PLC MAC address. | |
| const std::string & | Name () const noexcept |
| Return the simulator instance name. | |
| std::size_t | ConnectionCount () const |
| Return the number of active AUMA connections. | |
| std::optional< cyclic::CyclicState > | ConnectionState (const std::string &valveName) const |
| Return one connection state. | |
| std::optional< cyclic::CyclicStatsSnapshot > | ConnectionStats (const std::string &valveName) const |
| Return one connection statistics snapshot. | |
| std::string | StatusReport () const |
| Return a human-readable PLC and connection dashboard. | |
Private Member Functions | |
| Connection * | FindConnection (const std::string &valveName) |
| Find a mutable connection by valve name. | |
| const Connection * | FindConnection (const std::string &valveName) const |
| Find a const connection by valve name. | |
| double | DecodeSignal (const io::IoSignal &signal, const Bytes &data) const |
| Decode one GSDML signal into the connector's double representation. | |
| Bytes | EncodeSignalValue (const io::IoSignal &signal, const Bytes &data, double value) const |
| Encode one connector double into a device output image. | |
| const io::IoSignal * | FindLocalInputSignal (std::string_view textId) const |
| Return an input signal from the local Phoenix catalogue. | |
| const io::IoSignal * | FindLocalOutputSignal (std::string_view textId) const |
| Return an output signal from the local Phoenix catalogue. | |
Static Private Member Functions | |
| static const io::IoSignal * | FindDeviceSignal (const VirtualAumaValve &valve, std::string_view textId, io::IoSignalDirection direction) |
| Find a unique signal in a connected device catalogue. | |
| static std::size_t | RequiredImageSize (const io::IoSignalCatalog &catalog) |
| Return the image size required by a GSDML catalogue. | |
| static std::pair< std::uint16_t, std::uint16_t > | ResolveDeviceLocation (const io::IoSignal &signal, std::uint16_t defaultSlot, std::uint16_t defaultSubslot) |
| Find a unique configured slot/subslot for an AUMA signal. | |
Private Attributes | |
| std::string | name |
| const gsdml::GSDMLDevice & | gsdml |
| MacAddress | controllerMac {} |
| io::IoSignalCatalog | catalog |
| std::mutex | mutex |
| std::vector< std::unique_ptr< Connection > > | connections |
| VirtualPhoenixIoImage | ioImage |
Virtual Phoenix Contact AXC F 1252 controller hosting real CyclicController instances.
The simulator deliberately does not replace the production cyclic controller. Each connection uses real RTC1 frame generation, source/destination filtering, cycle counters, watchdog handling and IOPS processing. The only substituted layer is the raw Ethernet transport, provided by InMemoryEthernetBus.
Definition at line 50 of file virtual_phoenix_plc.h.
| profinet::sim::VirtualPhoenixPlc::VirtualPhoenixPlc | ( | std::string | name, |
| const gsdml::GSDMLDevice & | gsdml, | ||
| MacAddress | controllerMac | ||
| ) |
Construct a virtual Phoenix PLC from its parsed GSDML.
| name | Stable simulator instance name. |
| gsdml | Parsed AXC F 1252 GSDML document. |
| controllerMac | Ethernet MAC address of the simulated PLC. |
Definition at line 130 of file virtual_phoenix_plc.cpp.
References catalog, profinet::sim::VirtualPhoenixIoImage::inputs, ioImage, profinet::sim::VirtualPhoenixIoImage::outputs, and RequiredImageSize().
Here is the call graph for this function:| profinet::sim::VirtualPhoenixPlc::~VirtualPhoenixPlc | ( | ) |
Stop all device connections.
Definition at line 143 of file virtual_phoenix_plc.cpp.
References Stop().
Here is the call graph for this function:
|
delete |
| void profinet::sim::VirtualPhoenixPlc::Connect | ( | asio::io_context & | ioContext, |
| InMemoryEthernetBus & | bus, | ||
| VirtualAumaValve & | valve, | ||
| rt::IOCRConfig | inputIocr, | ||
| rt::IOCRConfig | outputIocr, | ||
| int | maxConsecutiveTimeouts = cyclic::DEFAULT_MAX_CONSECUTIVE_TIMEOUTS |
||
| ) |
Connect the PLC to one virtual AUMA device.
| bus | Shared virtual Layer-2 bus. |
| valve | Virtual AUMA endpoint. |
| inputIocr | Device-to-controller RTC1 configuration. |
| outputIocr | Controller-to-device RTC1 configuration. |
| maxConsecutiveTimeouts | Production controller watchdog threshold. |
Definition at line 148 of file virtual_phoenix_plc.cpp.
References connections, controllerMac, profinet::sim::InMemoryEthernetBus::CreateSocket(), profinet::rt::IOCRConfig::dataLength, profinet::sim::VirtualAumaValve::DeviceMac(), profinet::rt::ETHERTYPE_PROFINET, FindConnection(), ioContext, mutex, profinet::sim::VirtualAumaValve::Name(), profinet::rt::IOCRConfig::objects, rxSocket, and txSocket.
Referenced by profinet::sim::VirtualProfinetLab::Connect(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), 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:| std::size_t profinet::sim::VirtualPhoenixPlc::ConnectionCount | ( | ) | const |
Return the number of active AUMA connections.
Definition at line 420 of file virtual_phoenix_plc.cpp.
References connections, and mutex.
Referenced by profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), and profinet::sim::TEST().
Here is the caller graph for this function:| std::optional< cyclic::CyclicState > profinet::sim::VirtualPhoenixPlc::ConnectionState | ( | const std::string & | valveName | ) | const |
Return one connection state.
Definition at line 427 of file virtual_phoenix_plc.cpp.
References profinet::sim::VirtualPhoenixPlc::Connection::controller, FindConnection(), and mutex.
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:| std::optional< cyclic::CyclicStatsSnapshot > profinet::sim::VirtualPhoenixPlc::ConnectionStats | ( | const std::string & | valveName | ) | const |
Return one connection statistics snapshot.
Definition at line 439 of file virtual_phoenix_plc.cpp.
References profinet::sim::VirtualPhoenixPlc::Connection::controller, FindConnection(), and mutex.
Referenced by profinet::sim::TEST(), profinet::sim::TEST(), 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:
|
noexcept |
Return the PLC MAC address.
Definition at line 410 of file virtual_phoenix_plc.cpp.
References controllerMac.
|
private |
Decode one GSDML signal into the connector's double representation.
Definition at line 507 of file virtual_phoenix_plc.cpp.
References profinet::io::Boolean, profinet::io::IoSignal::byteLength, profinet::io::FloatingPoint, profinet::io::SignedInteger, profinet::io::IoSignal::textId, profinet::io::UnsignedInteger, profinet::io::Unsupported, and profinet::io::IoSignal::valueType.
Referenced by GetLocalInputValue(), GetLocalOutputValue(), and ReadInput().
Here is the caller graph for this function:| void profinet::sim::VirtualPhoenixPlc::Disconnect | ( | const std::string & | valveName | ) |
Disconnect a named AUMA connection.
| valveName | Valve simulator name. |
Definition at line 204 of file virtual_phoenix_plc.cpp.
References connections, and mutex.
Referenced by profinet::sim::TEST().
Here is the caller graph for this function:
|
private |
Encode one connector double into a device output image.
Definition at line 556 of file virtual_phoenix_plc.cpp.
References profinet::io::Boolean, profinet::io::IoSignal::byteLength, profinet::io::IoSignal::byteOffset, profinet::io::FloatingPoint, profinet::io::IoSignal::IsDoubleCompatible(), profinet::io::SignedInteger, profinet::io::IoSignal::textId, profinet::io::UnsignedInteger, and profinet::io::IoSignal::valueType.
Referenced by SetLocalInputValue(), SetLocalOutputValue(), and SetOutput().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Find a mutable connection by valve name.
Definition at line 475 of file virtual_phoenix_plc.cpp.
References connections.
Referenced by Connect(), ConnectionState(), ConnectionStats(), ReadInput(), and SetOutput().
Here is the caller graph for this function:
|
private |
Find a const connection by valve name.
Definition at line 488 of file virtual_phoenix_plc.cpp.
References connections.
|
staticprivate |
Find a unique signal in a connected device catalogue.
Definition at line 500 of file virtual_phoenix_plc.cpp.
References profinet::sim::VirtualAumaValve::SignalCatalog().
Referenced by ReadInput(), and SetOutput().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Return an input signal from the local Phoenix catalogue.
Definition at line 677 of file virtual_phoenix_plc.cpp.
References catalog, and profinet::io::Sensor.
Referenced by GetLocalInputBytes(), GetLocalInputValue(), SetLocalInputBytes(), and SetLocalInputValue().
Here is the caller graph for this function:
|
private |
Return an output signal from the local Phoenix catalogue.
Definition at line 682 of file virtual_phoenix_plc.cpp.
References profinet::io::Actuator, and catalog.
Referenced by GetLocalOutputBytes(), GetLocalOutputValue(), SetLocalOutputBytes(), and SetLocalOutputValue().
Here is the caller graph for this function:| std::optional< Bytes > profinet::sim::VirtualPhoenixPlc::GetLocalInputBytes | ( | std::string_view | signalTextId | ) | const |
Read raw bytes from the local Phoenix input process image.
| signalTextId | Phoenix GSDML input signal TextId. |
Definition at line 315 of file virtual_phoenix_plc.cpp.
References profinet::io::IoSignal::byteLength, profinet::io::IoSignal::byteOffset, FindLocalInputSignal(), profinet::sim::VirtualPhoenixIoImage::inputs, ioImage, and mutex.
Referenced by profinet::sim::TEST(), and profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| std::optional< double > profinet::sim::VirtualPhoenixPlc::GetLocalInputValue | ( | std::string_view | signalTextId | ) | const |
Read one typed Phoenix input signal.
| signalTextId | Phoenix GSDML input signal TextId. |
Definition at line 340 of file virtual_phoenix_plc.cpp.
References DecodeSignal(), FindLocalInputSignal(), profinet::sim::VirtualPhoenixIoImage::inputs, ioImage, and mutex.
Referenced by profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| std::optional< Bytes > profinet::sim::VirtualPhoenixPlc::GetLocalOutputBytes | ( | std::string_view | signalTextId | ) | const |
Read raw bytes from the local Phoenix output process image.
| signalTextId | Phoenix GSDML output signal TextId. |
Definition at line 369 of file virtual_phoenix_plc.cpp.
References profinet::io::IoSignal::byteLength, profinet::io::IoSignal::byteOffset, FindLocalOutputSignal(), ioImage, mutex, and profinet::sim::VirtualPhoenixIoImage::outputs.
Referenced by profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| std::optional< double > profinet::sim::VirtualPhoenixPlc::GetLocalOutputValue | ( | std::string_view | signalTextId | ) | const |
Read one typed Phoenix output signal.
| signalTextId | Phoenix GSDML output signal TextId. |
Definition at line 394 of file virtual_phoenix_plc.cpp.
References DecodeSignal(), FindLocalOutputSignal(), ioImage, mutex, and profinet::sim::VirtualPhoenixIoImage::outputs.
Referenced by profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:
|
noexcept |
Return the simulator instance name.
Definition at line 415 of file virtual_phoenix_plc.cpp.
References name.
|
delete |
| std::optional< double > profinet::sim::VirtualPhoenixPlc::ReadInput | ( | const std::string & | valveName, |
| std::string_view | signalTextId | ||
| ) | const |
Read a typed AUMA input signal using the production controller API.
| valveName | Connected AUMA simulator name. |
| signalTextId | GSDML signal TextId. |
Definition at line 269 of file virtual_phoenix_plc.cpp.
References profinet::sim::VirtualPhoenixPlc::Connection::controller, DecodeSignal(), FindConnection(), FindDeviceSignal(), profinet::sim::VirtualAumaValve::InputSlot(), profinet::sim::VirtualAumaValve::InputSubslot(), mutex, ResolveDeviceLocation(), profinet::io::Sensor, and profinet::sim::VirtualPhoenixPlc::Connection::valve.
Referenced by profinet::sim::TEST(), 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:
|
staticprivate |
Return the image size required by a GSDML catalogue.
Definition at line 662 of file virtual_phoenix_plc.cpp.
References profinet::io::IoSignalCatalog::Actuators(), and profinet::io::IoSignalCatalog::Sensors().
Referenced by VirtualPhoenixPlc().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Find a unique configured slot/subslot for an AUMA signal.
Definition at line 687 of file virtual_phoenix_plc.cpp.
References profinet::io::IoSignal::possibleSlots, profinet::io::IoSignal::possibleSubslots, and profinet::io::IoSignal::textId.
Referenced by ReadInput().
Here is the caller graph for this function:| void profinet::sim::VirtualPhoenixPlc::SetLocalInputBytes | ( | std::string_view | signalTextId, |
| const Bytes & | data | ||
| ) |
Set raw bytes in the local Phoenix input process image.
| signalTextId | Phoenix GSDML input signal TextId. |
| data | Bytes to copy into the signal's process-data region. |
Definition at line 297 of file virtual_phoenix_plc.cpp.
References profinet::io::IoSignal::byteLength, profinet::io::IoSignal::byteOffset, FindLocalInputSignal(), profinet::sim::VirtualPhoenixIoImage::inputs, ioImage, and mutex.
Referenced by profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| void profinet::sim::VirtualPhoenixPlc::SetLocalInputValue | ( | std::string_view | signalTextId, |
| double | value | ||
| ) |
Set one typed Phoenix input signal.
| signalTextId | Phoenix GSDML input signal TextId. |
| value | Connector-style numeric value. |
Definition at line 329 of file virtual_phoenix_plc.cpp.
References EncodeSignalValue(), FindLocalInputSignal(), profinet::sim::VirtualPhoenixIoImage::inputs, ioImage, and mutex.
Referenced by profinet::sim::TEST(), and profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| void profinet::sim::VirtualPhoenixPlc::SetLocalOutputBytes | ( | std::string_view | signalTextId, |
| const Bytes & | data | ||
| ) |
Set raw bytes in the local Phoenix output process image.
| signalTextId | Phoenix GSDML output signal TextId. |
| data | Bytes to copy into the signal's process-data region. |
Definition at line 351 of file virtual_phoenix_plc.cpp.
References profinet::io::IoSignal::byteLength, profinet::io::IoSignal::byteOffset, FindLocalOutputSignal(), ioImage, mutex, and profinet::sim::VirtualPhoenixIoImage::outputs.
Referenced by profinet::sim::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:| void profinet::sim::VirtualPhoenixPlc::SetLocalOutputValue | ( | std::string_view | signalTextId, |
| double | value | ||
| ) |
Set one typed Phoenix output signal.
| signalTextId | Phoenix GSDML output signal TextId. |
| value | Connector-style numeric value. |
Definition at line 383 of file virtual_phoenix_plc.cpp.
References EncodeSignalValue(), FindLocalOutputSignal(), ioImage, mutex, and profinet::sim::VirtualPhoenixIoImage::outputs.
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:| void profinet::sim::VirtualPhoenixPlc::SetOutput | ( | const std::string & | valveName, |
| std::string_view | signalTextId, | ||
| double | value | ||
| ) |
Set a typed AUMA actuator signal.
| valveName | Connected AUMA simulator name. |
| signalTextId | GSDML signal TextId. |
| value | Numeric connector value. |
Definition at line 244 of file virtual_phoenix_plc.cpp.
References profinet::io::Actuator, profinet::sim::VirtualPhoenixPlc::Connection::controller, EncodeSignalValue(), FindConnection(), FindDeviceSignal(), mutex, profinet::sim::VirtualPhoenixPlc::Connection::outputImage, profinet::sim::VirtualAumaValve::OutputSlot(), profinet::sim::VirtualAumaValve::OutputSubslot(), and profinet::sim::VirtualPhoenixPlc::Connection::valve.
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:
|
noexcept |
Return the Phoenix PLC's logical signal catalogue.
Definition at line 405 of file virtual_phoenix_plc.cpp.
References catalog.
Referenced by profinet::sim::TEST().
Here is the caller graph for this function:| std::string profinet::sim::VirtualPhoenixPlc::StatusReport | ( | ) | const |
Return a human-readable PLC and connection dashboard.
Definition at line 450 of file virtual_phoenix_plc.cpp.
References connections, controllerMac, profinet::Mac2String(), mutex, name, profinet::cyclic::ToString(), and profinet::sim::ToString().
Here is the call graph for this function:| void profinet::sim::VirtualPhoenixPlc::Stop | ( | ) |
Stop all active connections.
Definition at line 228 of file virtual_phoenix_plc.cpp.
References connections, and mutex.
Referenced by ~VirtualPhoenixPlc(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), and profinet::sim::TEST().
Here is the caller graph for this function:
|
private |
Definition at line 213 of file virtual_phoenix_plc.h.
Referenced by VirtualPhoenixPlc(), FindLocalInputSignal(), FindLocalOutputSignal(), and SignalCatalog().
|
private |
Definition at line 215 of file virtual_phoenix_plc.h.
Referenced by Connect(), ConnectionCount(), Disconnect(), FindConnection(), FindConnection(), StatusReport(), and Stop().
|
private |
Definition at line 212 of file virtual_phoenix_plc.h.
Referenced by Connect(), ControllerMac(), and StatusReport().
|
private |
Definition at line 211 of file virtual_phoenix_plc.h.
|
private |
Definition at line 216 of file virtual_phoenix_plc.h.
Referenced by VirtualPhoenixPlc(), GetLocalInputBytes(), GetLocalInputValue(), GetLocalOutputBytes(), GetLocalOutputValue(), SetLocalInputBytes(), SetLocalInputValue(), SetLocalOutputBytes(), and SetLocalOutputValue().
|
mutableprivate |
Definition at line 214 of file virtual_phoenix_plc.h.
Referenced by Connect(), ConnectionCount(), ConnectionState(), ConnectionStats(), Disconnect(), GetLocalInputBytes(), GetLocalInputValue(), GetLocalOutputBytes(), GetLocalOutputValue(), ReadInput(), SetLocalInputBytes(), SetLocalInputValue(), SetLocalOutputBytes(), SetLocalOutputValue(), SetOutput(), StatusReport(), and Stop().
|
private |
Definition at line 210 of file virtual_phoenix_plc.h.
Referenced by Name(), and StatusReport().