Skip to content

DigitalInput

Source locationmrx/io/Io.hpp
#include <mrx/io/Io.hpp>
class mrx::io::DigitalInput

Inherits: QObject

An acquired digital input, released when the handle is destroyed.

Keep and use it in its Io’s thread; do not move either object to another thread while the input exists.

ReturnNameDescription
~DigitalInput override
boolread constRead synchronously; value is unchanged on failure.
QMetaObject::ConnectionlistenSubscribe to samples.

override
Source locationmrx/io/Io.hpp
~DigitalInput() override

const
Source locationmrx/io/Io.hpp
bool read(bool* value, QString* error = nullptr) const

Read synchronously; value is unchanged on failure.

Whether reading succeeded.

NameTypeDescription
valuebool*Non-null destination.
errorQString*Optional error.

Source locationmrx/io/Io.hpp
QMetaObject::Connection listen(QObject* context, const std::function<void(bool)>& handler, bool invert = false)

Subscribe to samples.

Disconnectable connection, or an invalid connection for invalid arguments or unavailable monitoring. Unavailable monitoring also emits monitoringError.

NameTypeDescription
contextQObject*Callback lifetime owner.
handlerconst std::function<void(bool)>&Sample handler.
invertboolInvert only this callback’s values.
ReturnNameDescription
voidsampledEmitted for every successful sample, including unchanged values.
voidmonitoringErrorEmitted and logged when monitoring fails or its Io is destroyed; synchronous reads remain available.

Source locationmrx/io/Io.hpp
void sampled(bool value)

Emitted for every successful sample, including unchanged values.

NameTypeDescription
valueboolSample value.

Source locationmrx/io/Io.hpp
void monitoringError(const QString& error)

Emitted and logged when monitoring fails or its Io is destroyed; synchronous reads remain available.

A failed read is retried at the next tick and reported once until it recovers.

NameTypeDescription
errorconst QString&Failure description.