22#ifndef LELY_COAPP_LOOP_DRIVER_HPP_
23#define LELY_COAPP_LOOP_DRIVER_HPP_
108 template <class F, class... Args>
111 GetStrand().
post(::std::forward<F>(f), ::std::forward<Args>(args)...);
131 return f.get().value();
133 util::throw_error_code(
"Wait", ::std::errc::operation_canceled);
150 typename ::std::enable_if<!::std::is_void<T>::value, T>::type
154 return f.get().value();
155 }
catch (const ::std::system_error& e) {
180 void USleep(uint_least64_t usec);
186 void USleep(uint_least64_t usec, ::std::error_code& ec);
196 return Wait(AsyncRead<T>(idx, subidx));
207 RunRead(uint16_t idx, uint8_t subidx, ::std::error_code& ec) {
208 return Wait(AsyncRead<T>(idx, subidx), ec);
219 const ::std::chrono::milliseconds& timeout) {
220 return Wait(AsyncRead<T>(idx, subidx, timeout));
241 const ::std::chrono::milliseconds& timeout, ::std::error_code& ec) {
242 return Wait(AsyncRead<T>(idx, subidx, timeout), ec);
252 RunWrite(uint16_t idx, uint8_t subidx, T&& value) {
264 RunWrite(uint16_t idx, uint8_t subidx, T&& value, ::std::error_code& ec) {
276 const ::std::chrono::milliseconds& timeout) {
297 const ::std::chrono::milliseconds& timeout, ::std::error_code& ec) {
298 Wait(
AsyncWrite(idx, subidx, ::std::forward<T>(value), timeout), ec);
303 ::std::unique_ptr<Impl_> impl_;
An asynchronous CANopen master.
The base class for drivers for remote CANopen nodes.
SdoFuture< void > AsyncWrite(uint16_t idx, uint8_t subidx, T &&value)
Equivalent to AsyncWrite(uint16_t idx, uint8_t subidx, T&& value, const ::std::chrono::milliseconds& ...
BasicMaster & master
A reference to the master with which this driver is registered.
A CANopen driver running its own dedicated event loop in a separate thread.
void USleep(uint_least64_t usec)
Runs the event loop for usec microseconds.
void RunWrite(uint16_t idx, uint8_t subidx, T &&value, ::std::error_code &ec)
Equivalent to RunWrite(uint16_t idx, uint8_t subidx, T&& value, const ::std::chrono::milliseconds& ti...
T RunRead(uint16_t idx, uint8_t subidx)
Equivalent to RunRead(uint16_t idx, uint8_t subidx, ::std::error_code& ec), except that it throws lel...
typename::std::enable_if<!::std::is_void< T >::value, T >::type Wait(SdoFuture< T > f, ::std::error_code &ec)
Waits for the specified future to become ready by running pending tasks on the dedicated event loop o...
T RunRead(uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous read (SDO upload) operation and runs the event loop until the operation is com...
void RunWrite(uint16_t idx, uint8_t subidx, T &&value)
Equivalent to RunWrite(uint16_t idx, uint8_t subidx, T&& value, ::std::error_code& ec),...
T RunRead(uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds &timeout)
Equivalent to RunRead(uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds& timeout,...
T Wait(SdoFuture< T > f)
Waits for the specified future to become ready by running pending tasks on the dedicated event loop o...
T RunRead(uint16_t idx, uint8_t subidx, ::std::error_code &ec)
Equivalent to RunRead(uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds& timeout,...
void Join()
Stops the dedicated event loop of the driver and waits until the thread running the event loop finish...
void Defer(F &&f, Args &&... args)
Schedules the specified Callable object for execution by the event loop for this driver.
void RunWrite(uint16_t idx, uint8_t subidx, T &&value, const ::std::chrono::milliseconds &timeout)
Equivalent to RunWrite(uint16_t idx, uint8_t subidx, T&& value, const ::std::chrono::milliseconds& ti...
ev::Executor GetStrand() const noexcept
Returns the strand executor associated with the event loop of the driver.
ev::Future< void, void > AsyncStoppped() noexcept
Returns a future which becomes ready once the dedicated event loop of the driver is stopped and the t...
void RunWrite(uint16_t idx, uint8_t subidx, T &&value, const ::std::chrono::milliseconds &timeout, ::std::error_code &ec)
Queues an asynchronous write (SDO download) operation and runs the event loop until the operation is ...
ev::Loop & GetLoop() noexcept
Returns a reference to the dedicated event loop of the driver.
~LoopDriver()
Stops the event loop and terminates the thread in which it was running before destroying the driver.
A base class for lely::canopen::LoopDriver, containing an event loop and the associated executor.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
void post(ev_task &task) noexcept
Executor get_executor() const noexcept
::std::size_t wait(ev_future_t *future)
The exception thrown when retrieving the result of a future which is not ready or does not contain a ...
This header file is part of the C++ CANopen application library; it contains the remote node driver i...
This header file is part of the event library; it contains the C++ interface for the polling event lo...
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
This header file is part of the event library; it contains the C++ interface for the strand executor.