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)...);
130 return f.
get().value();
146 typename ::std::enable_if<!::std::is_void<T>::value, T>::type
148 GetLoop().wait(f, ec);
150 return f.
get().value();
151 }
catch (const ::std::system_error& e) {
177 void USleep(uint_least64_t usec);
184 void USleep(uint_least64_t usec, ::std::error_code& ec) noexcept;
194 return Wait(AsyncRead<T>(idx, subidx));
205 RunRead(uint16_t idx, uint8_t subidx, ::std::error_code& ec) {
206 return Wait(AsyncRead<T>(idx, subidx), ec);
217 const ::std::chrono::milliseconds& timeout) {
218 return Wait(AsyncRead<T>(idx, subidx, timeout));
239 const ::std::chrono::milliseconds& timeout, ::std::error_code& ec) {
240 return Wait(AsyncRead<T>(idx, subidx, timeout), ec);
250 RunWrite(uint16_t idx, uint8_t subidx, T&& value) {
251 Wait(AsyncWrite(idx, subidx, ::std::forward<T>(value)));
262 RunWrite(uint16_t idx, uint8_t subidx, T&& value, ::std::error_code& ec) {
263 Wait(AsyncWrite(idx, subidx, ::std::forward<T>(value)), ec);
274 const ::std::chrono::milliseconds& timeout) {
275 Wait(AsyncWrite(idx, subidx, ::std::forward<T>(value), timeout));
295 const ::std::chrono::milliseconds& timeout, ::std::error_code& ec) {
296 Wait(AsyncWrite(idx, subidx, ::std::forward<T>(value), timeout), ec);
301 ::std::unique_ptr<Impl_> impl_;
308 #endif // LELY_COAPP_LOOP_DRIVER_HPP_ void Defer(F &&f, Args &&... args)
Schedules the specified Callable object for execution by the event loop for this driver.
An asynchronous CANopen master.
The base class for drivers for remote CANopen nodes.
The exception thrown when retrieving the result of a future which is not ready or does not contain a ...
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)...
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...
The internal implementation of lely::canopen::LoopDriver.
T Wait(SdoFuture< T > f)
Waits for the specified future to become ready by running pending tasks on the dedicated event loop o...
A CANopen driver running its own dedicated event loop in a separate thread.
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...
A base class for lely::canopen::LoopDriver, containing an event loop and the associated executor...
ev::Executor GetStrand() const noexcept
Returns the strand executor associated with the event loop of the driver.
This header file is part of the C++ CANopen application library; it contains the remote node driver i...
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...
This header file is part of the event library; it contains the C++ interface for the strand executor...
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...
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 ...
An abstract task executor. This class is a wrapper around ev_exec_t*.
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...
result_type & get()
Returns the result of a ready future.
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.
ev::Loop & GetLoop() noexcept
Returns a reference to the dedicated event loop of the driver.
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...
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...
Executor get_executor() const noexcept