ecdev::IDeviceProfile
Device-class behaviour plugged onto a [GenericEniDevice]. More...
#include <device_profile.hpp>
Inherits from IDeviceLifecycle
Inherited by ecdev::CiA402DriveProfile, ecdev::CiA406EncoderProfile, ecdev::GenericIoProfile
Public Functions
| Name | |
|---|---|
| ~IDeviceProfile() override =default | |
| virtual void | writeOutputs(ProcessImage & image, std::uint64_t cycle_count) Write output PDO values for this cycle. |
| virtual void | resolveTopology(const ProcessImage & image) Resolve the static channel/PDO topology from the ENI-derived process image. |
| virtual void | readInputs(const ProcessImage & image, bool wkc_valid, bool operational) Read input PDO values captured this cycle. |
| virtual const char * | profileName() const =0 Stable identifier for diagnostics (e.g. |
| virtual void | primeOutputs(ProcessImage & image) Prime output PDO bytes to safe values immediately before the bus enters SAFE_OP (outputs start being transmitted). |
| virtual std::string | prepareSafeOp(ISlaveServices & svc, ProcessImage & image) Final configuration step before OPERATIONAL: the slave is in SAFE_OP and the PDO IOmap is live but outputs are not yet driven. |
| virtual std::string | configurePreOp(ISlaveServices & svc, ProcessImage & image) Perform CoE / SDO configuration while the slave is in PRE_OP (bus not cycling). |
| virtual void | captureExitDiagnostics(ISlaveServices & svc) End-of-run hook called after the RT thread has joined; safe to perform SDO reads. |
| virtual IMotionProfile * | asMotion() Query whether this profile drives a motion (servo) axis. |
| virtual IIoProfile * | asIo() Query whether this profile exposes digital/analog I/O channels. |
| virtual IEncoderProfile * | asEncoder() Query whether this profile exposes position/velocity encoder readings. |
Detailed Description
class ecdev::IDeviceProfile;
Device-class behaviour plugged onto a [GenericEniDevice].
A profile understands the PDO semantics of one EtherCAT device class (CiA 402 drive, CiA 401 digital/analog I/O, CiA 406 encoder, ...) and nothing about the backend, the ENI XML, or the master. It interacts with the world through exactly two narrow contracts:
[ISlaveServices]for setup-time SDO / register / PDO-pulse work (NOT on the RT path).[ProcessImage]for per-cycle reads/writes of mapped objects (RT path).
Selection is done by a [ProfileRegistry](/lxmaster/api/classes/ProfileRegistry); a new device class is added by registering a new profile, with no change to the generic device or the orchestration layer.
Threading: configurePreOp/prepareSafeOp/shutdown hooks run on the bring-up/shutdown thread while the bus is not in OPERATIONAL; writeOutputs/readInputs run on the RT cyclic thread. A profile that exposes data to application threads must do so through its own lock-free state (e.g. atomics), exactly as the facades expect.
Public Functions Documentation
function ~IDeviceProfile
~IDeviceProfile() override =default
function writeOutputs
inline virtual void writeOutputs(
ProcessImage & image,
std::uint64_t cycle_count
)
Write output PDO values for this cycle.
Parameters:
- image Live PDO byte map for this slave's output objects; write target values into it.
- cycle_count Total RT cycles executed since
start()(monotonically increasing).
Reimplemented by: ecdev::CiA402DriveProfile::writeOutputs, ecdev::GenericIoProfile::writeOutputs
Called on the RT cyclic thread every cycle while OPERATIONAL.
function resolveTopology
inline virtual void resolveTopology(
const ProcessImage & image
)
Resolve the static channel/PDO topology from the ENI-derived process image.
Parameters:
- image ENI-derived process image carrying the PDO geometry for this slave.
Reimplemented by: ecdev::GenericIoProfile::resolveTopology
Called once when the profile is attached to its device (during binding, before start()), so facade capability queries such as IIoProfile::digitalOutputCount() are valid as soon as the bus is bound — before any live PRE_OP SDO work. The image carries only ENI geometry here (it is not yet bound to the live IOmap), which is all a structural resolve needs. Default: no-op. Idempotent: configurePreOp may resolve again from the same image during start().
function readInputs
inline virtual void readInputs(
const ProcessImage & image,
bool wkc_valid,
bool operational
)
Read input PDO values captured this cycle.
Parameters:
- image Live PDO byte map for this slave's input objects.
- wkc_valid False when the work counter dropped this cycle — the slave may not have responded and input data may be stale.
- operational False during the OP-entry cooldown cycles after the master enters OPERATIONAL. Motion commands should be suppressed until this is true.
Reimplemented by: ecdev::CiA402DriveProfile::readInputs, ecdev::CiA406EncoderProfile::readInputs, ecdev::GenericIoProfile::readInputs
Called on the RT cyclic thread every cycle while OPERATIONAL. Profiles should guard state updates on wkc_valid and operational to avoid acting on stale data.
function profileName
virtual const char * profileName() const =0
Stable identifier for diagnostics (e.g.
Return: A null-terminated string literal naming this profile class. Must be stable for the lifetime of the profile object (a string literal in practice).
Reimplemented by: ecdev::CiA401IoProfile::profileName, ecdev::CiA402DriveProfile::profileName, ecdev::CiA406EncoderProfile::profileName, ecdev::GenericIoProfile::profileName
"CiA402-drive").
function primeOutputs
inline virtual void primeOutputs(
ProcessImage & image
)
Prime output PDO bytes to safe values immediately before the bus enters SAFE_OP (outputs start being transmitted).
Parameters:
- image Live PDO byte map; write safe initial output values into it.
Reimplemented by: ecdev::CiA402DriveProfile::primeOutputs
For example, a CiA402 profile writes a Shutdown controlword here so the drive sees a valid initial state before the RT cycle starts. Called on the bring-up thread.
function prepareSafeOp
inline virtual std::string prepareSafeOp(
ISlaveServices & svc,
ProcessImage & image
)
Final configuration step before OPERATIONAL: the slave is in SAFE_OP and the PDO IOmap is live but outputs are not yet driven.
Parameters:
- svc Slave services handle for SDO reads/writes.
- image Live process image (IOmap is mapped but outputs are not yet driven).
Return: Empty string on success; a non-empty human-readable reason string aborts bring-up.
Reimplemented by: ecdev::CiA402DriveProfile::prepareSafeOp
Use this for last-moment readiness checks or any SDO writes that must happen after the IOmap is mapped. Called on the bring-up thread; never on the RT thread.
function configurePreOp
inline virtual std::string configurePreOp(
ISlaveServices & svc,
ProcessImage & image
)
Perform CoE / SDO configuration while the slave is in PRE_OP (bus not cycling).
Parameters:
- svc Slave services handle for SDO reads/writes and register access.
- image Process image for this slave; resolve PDO entry handles here for later cyclic use.
Return: Empty string on success; a non-empty human-readable reason string aborts bring-up.
Reimplemented by: ecdev::CiA402DriveProfile::configurePreOp, ecdev::CiA406EncoderProfile::configurePreOp, ecdev::GenericIoProfile::configurePreOp
Resolve process-image handles (PDO objects) for use in the cyclic path. Called on the bring-up thread; never on the RT thread.
function captureExitDiagnostics
inline virtual void captureExitDiagnostics(
ISlaveServices & svc
)
End-of-run hook called after the RT thread has joined; safe to perform SDO reads.
Parameters:
- svc Slave services handle available for post-run SDO reads (e.g. fault codes).
Reimplemented by: ecdev::CiA402DriveProfile::captureExitDiagnostics
function asMotion
inline virtual IMotionProfile * asMotion()
Query whether this profile drives a motion (servo) axis.
Return: A non-null IMotionProfile* if so (used to back an Axis facade handle), or null if this profile does not implement the motion contract.
Reimplemented by: ecdev::CiA402DriveProfile::asMotion
function asIo
inline virtual IIoProfile * asIo()
Query whether this profile exposes digital/analog I/O channels.
Return: A non-null IIoProfile* if so (used to back an IoModule facade handle), or null if this profile does not implement the I/O contract.
Reimplemented by: ecdev::GenericIoProfile::asIo
function asEncoder
inline virtual IEncoderProfile * asEncoder()
Query whether this profile exposes position/velocity encoder readings.
Return: A non-null IEncoderProfile* if so (used to back an Encoder facade handle), or null if this profile does not implement the encoder contract.
Reimplemented by: ecdev::CiA406EncoderProfile::asEncoder
Updated on 2026-07-13 at 20:44:41 +0000