Skip to main content

EtherCATMaster

The core class of the EtherCAT master: it manages initialization, state management, slave control and PDO communication for the whole EtherCAT network.

Class structure​

EtherCATMaster                                    // master instance
│
├── GetConfig() → MasterConfig& // communication configuration
├── GetDiagnostics() → Diagnostics& // master diagnostics
│
├── GetSlave(n) → Slave& // slave list
│ │
│ ├── GetCoE() → CoE& // CANopen over EtherCAT
│ ├── GetSoE() → SoE& // Servo over EtherCAT
│ ├── GetFoE() → FoE& // File over EtherCAT
│ ├── GetEoE() → EoE& // Ethernet over EtherCAT
│ ├── GetAoE() → AoE& // ADS over EtherCAT
│ ├── GetVoE() → VoE& // Vendor over EtherCAT
│ ├── GetFSoE() → FSoE& // functional safety protocol
│ ├── GetCiA402() → CiA402& // servo drive profile
│ └── GetMDP() → MDP* // modular device (may be null)
│
└── Events() → MasterEvents& // event collection (register with On*()/SetPDOCallbackSync())
├── SetPDOCallbackSync // PDO cycle notification (delivered by a separate worker; not part of a safety loop)
├── OnStateChanged // master state changed
├── OnSlaveStateChanged // slave state changed
├── OnSlaveLost / OnSlaveDiscovered // hot-plug (offline / online)
├── OnSlaveOfflineDetailed / OnSlaveOfflineDisputed // offline with rich context / conflicting evidence
├── OnPDOFrameLoss // PDO frame loss
├── OnDCSyncLost / OnDCSyncRestored // DC sync lost / restored edge
├── OnDcEventRaised // unified DC event stream
├── OnSdoError / OnWkcShortageOccurred // SDO failure / WKC shortage edge
├── OnNicLinkChanged // master physical port link edge
├── OnRedundancyModeChanged // redundancy mode changed
└── OnSlaveIdentityMismatch / OnSlavePortLinkChanged // identity mismatch / port link

Only the common entry points are listed above; the full event list (including OnError / OnWarning / OnEmergency / OnSlavePreOpReconfig) is in Events and callbacks.

Protocol instances (CoE, SoE and so on) are created lazily on demand, and the getters do not throw; only GetMDP() returns nullptr when the slave does not support MDP. All events are multi-subscriber std::vector<std::function>; register them with On*() / SetPDOCallbackSync(), never by assigning with =.