Lely core libraries
2.3.4
|
Go to the documentation of this file.
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_;
310 #endif // LELY_COAPP_LOOP_DRIVER_HPP_
void post(ev_task &task) noexcept
BasicMaster & master
A reference to the master with which this driver is registered.
The base class for drivers for remote CANopen nodes.
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...
An asynchronous CANopen master.
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 ...
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& ...
Executor get_executor() const noexcept
A CANopen driver running its own dedicated event loop in a separate thread.
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, 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),...
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)
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...
An abstract task executor. This class is a wrapper around #ev_exec_t*.
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,...
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.
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 exception thrown when retrieving the result of a future which is not ready or does not contain a ...
void Defer(F &&f, Args &&... args)
Schedules the specified Callable object for execution by the event loop for this driver.
void USleep(uint_least64_t usec)
Runs the event loop for usec microseconds.
::std::size_t wait(ev_future_t *future)
ev::Loop & GetLoop() noexcept
Returns a reference to the dedicated event loop of the driver.
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
~LoopDriver()
Stops the event loop and terminates the thread in which it was running before destroying the driver.
void Join()
Stops the dedicated event loop of the driver and waits until the thread running the event loop finish...
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...