ecdev::GenericIoProfile
Protocol-agnostic digital/analog I/O profile. More...
#include <generic_io_profile.hpp>
Inherits from ecdev::IDeviceProfile, ecdev::IIoProfile, IDeviceLifecycle
Inherited by ecdev::CiA401IoProfile
Public Functions
| Name | |
|---|---|
| virtual void | writeOutputs(ProcessImage & image, std::uint64_t cycle_count) override Write output PDO values for this cycle. |
| virtual void | setDigitalOutput(std::size_t channel, bool value) override Command a digital output channel; out-of-range is a no-op. |
| virtual void | setAnalogOutput(std::size_t channel, std::int32_t value) override Command an analog output channel (raw counts); out-of-range is a no-op. |
| virtual void | resolveTopology(const ProcessImage & image) override Resolve the static channel/PDO topology from the ENI-derived process image. |
| virtual void | readInputs(const ProcessImage & image, bool wkc_valid, bool operational) override Read input PDO values captured this cycle. |
| virtual const char * | profileName() const override Stable identifier for diagnostics (e.g. |
| virtual std::size_t | digitalOutputCount() const override |
| virtual bool | digitalOutput(std::size_t ch) const override |
| virtual std::size_t | digitalInputCount() const override |
| virtual bool | digitalInput(std::size_t channel) const override Read a digital input/output channel; out-of-range returns false. |
| virtual std::string | configurePreOp(ISlaveServices & svc, ProcessImage & image) override Perform CoE / SDO configuration while the slave is in PRE_OP (bus not cycling). |
| virtual IIoProfile * | asIo() override Query whether this profile exposes digital/analog I/O channels. |
| virtual std::size_t | analogOutputCount() const override |
| virtual std::int32_t | analogOutput(std::size_t ch) const override |
| virtual std::size_t | analogInputCount() const override |
| virtual std::int32_t | analogInput(std::size_t channel) const override Read an analog input/output channel (raw counts); out-of-range returns 0. |
Public Attributes
| Name | |
|---|---|
| constexpr std::size_t | kMaxDigital |
| constexpr std::size_t | kMaxAnalog |
Additional inherited members
Public Functions inherited from ecdev::IDeviceProfile
| Name | |
|---|---|
| ~IDeviceProfile() override =default | |
| 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 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 IEncoderProfile * | asEncoder() Query whether this profile exposes position/velocity encoder readings. |
Public Functions inherited from ecdev::IIoProfile
| Name | |
|---|---|
| virtual | ~IIoProfile() =default |
Detailed Description
class ecdev::GenericIoProfile;
Protocol-agnostic digital/analog I/O profile.
Exposes a slave's mapped process data as typed channels through [IIoProfile](/lxmaster/api/classes/IIoProfile), which the IoModule facade wraps – with no dependence on CoE, a specific CiA profile, or any vendor object layout. Works for simple (non-CoE) terminals (e.g. Beckhoff EL2xxx/EL1xxx) as well as CoE I/O.
Channel model (purely structural, from the process image):
- A PDO object in the CiA 401 digital area (0x6000-0x63FF) is treated as packed booleans and expanded to one digital channel per bit.
- Any other 1-bit entry is a single digital channel (e.g. Beckhoff 0x7000:01 BOOL outputs).
- Any wider entry is a scalar analog channel (8/16/32-bit). Direction follows the PDO (RxPDO = output, TxPDO = input).
Subclasses (e.g. [CiA401IoProfile](/lxmaster/api/classes/CiA401IoProfile)) may override [profileName()](/lxmaster/api/classes/GenericIoProfile#function-profilename) and add device-class specific setup; the channel logic here is shared.
Public Functions Documentation
function writeOutputs
virtual void writeOutputs(
ProcessImage & image,
std::uint64_t cycle_count
) override
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).
Reimplements: ecdev::IDeviceProfile::writeOutputs
Called on the RT cyclic thread every cycle while OPERATIONAL.
function setDigitalOutput
inline virtual void setDigitalOutput(
std::size_t channel,
bool value
) override
Command a digital output channel; out-of-range is a no-op.
Reimplements: ecdev::IIoProfile::setDigitalOutput
function setAnalogOutput
inline virtual void setAnalogOutput(
std::size_t channel,
std::int32_t value
) override
Command an analog output channel (raw counts); out-of-range is a no-op.
Reimplements: ecdev::IIoProfile::setAnalogOutput
function resolveTopology
inline virtual void resolveTopology(
const ProcessImage & image
) override
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.
Reimplements: ecdev::IDeviceProfile::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
virtual void readInputs(
const ProcessImage & image,
bool wkc_valid,
bool operational
) override
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.
Reimplements: ecdev::IDeviceProfile::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
inline virtual const char * profileName() const override
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).
Reimplements: ecdev::IDeviceProfile::profileName
"CiA402-drive").
function digitalOutputCount
inline virtual std::size_t digitalOutputCount() const override
Reimplements: ecdev::IIoProfile::digitalOutputCount
function digitalOutput
inline virtual bool digitalOutput(
std::size_t ch
) const override
Reimplements: ecdev::IIoProfile::digitalOutput
function digitalInputCount
inline virtual std::size_t digitalInputCount() const override
Reimplements: ecdev::IIoProfile::digitalInputCount
function digitalInput
inline virtual bool digitalInput(
std::size_t channel
) const override
Read a digital input/output channel; out-of-range returns false.
Reimplements: ecdev::IIoProfile::digitalInput
function configurePreOp
virtual std::string configurePreOp(
ISlaveServices & svc,
ProcessImage & image
) override
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.
Reimplements: ecdev::IDeviceProfile::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 asIo
inline virtual IIoProfile * asIo() override
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.
Reimplements: ecdev::IDeviceProfile::asIo
function analogOutputCount
inline virtual std::size_t analogOutputCount() const override
Reimplements: ecdev::IIoProfile::analogOutputCount
function analogOutput
inline virtual std::int32_t analogOutput(
std::size_t ch
) const override
Reimplements: ecdev::IIoProfile::analogOutput
function analogInputCount
inline virtual std::size_t analogInputCount() const override
Reimplements: ecdev::IIoProfile::analogInputCount
function analogInput
inline virtual std::int32_t analogInput(
std::size_t channel
) const override
Read an analog input/output channel (raw counts); out-of-range returns 0.
Reimplements: ecdev::IIoProfile::analogInput
Public Attributes Documentation
variable kMaxDigital
static constexpr std::size_t kMaxDigital = 256;
variable kMaxAnalog
static constexpr std::size_t kMaxAnalog = 64;
Updated on 2026-07-13 at 20:44:41 +0000