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)...);
150 typename ::std::enable_if<!::std::is_void<T>::value, T>::type
155 }
catch (const ::std::system_error& e) {
158 ec = ::std::make_error_code(::std::errc::operation_canceled);
180 void USleep(uint_least64_t usec);
186 void USleep(uint_least64_t usec, ::std::error_code& ec);
207 RunRead(uint16_t idx, uint8_t subidx, ::std::error_code& ec) {
219 const ::std::chrono::milliseconds& timeout) {
241 const ::std::chrono::milliseconds& timeout, ::std::error_code& 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.
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& ...
SdoFuture< T > AsyncRead(uint16_t idx, uint8_t subidx)
Equivalent to AsyncRead(uint16_t idx, uint8_t subidx, const ::std::chrono::milliseconds& timeout),...
BasicDriver(ev_exec_t *exec, BasicMaster &master, uint8_t id)
Creates a new driver for a remote CANopen node and registers it with the master.
BasicMaster & master
A reference to the master with which this driver is registered.
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,...
LoopDriver(AsyncMaster &master, uint8_t id)
Creates a new CANopen driver and starts a new event loop in a separate thread to execute event handle...
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
result_type & get()
Returns the result of a ready future.
::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 ...
value_type & value()
Returns a reference to the value if *this contains a value, and throws an exception if *this contains...
This header file is part of the C++ CANopen application library; it contains the remote node driver i...
void throw_error_code(::std::errc e)
Throws an std::system_error exception corresponding to the specified error code.
This header file is part of the event library; it contains the C++ interface for the polling event lo...
The namespace for implementation details of the C++ CANopen application library.
The namespace for the C++ CANopen application library.
ev::Future< T, ::std::exception_ptr > SdoFuture
A helper alias template for the type of future used to retrieve the result of an asynchronous SDO req...
This header file is part of the event library; it contains the C++ interface for the strand executor.