22 #ifndef LELY_COAPP_NODE_HPP_ 23 #define LELY_COAPP_NODE_HPP_ 74 return static_cast<NmtState>(
static_cast<int>(lhs) & static_cast<int>(rhs));
79 return static_cast<NmtState>(
static_cast<int>(lhs) | static_cast<int>(rhs));
84 return static_cast<NmtState>(
static_cast<int>(lhs) ^ static_cast<int>(rhs));
89 return static_cast<NmtState>(~static_cast<
int>(lhs));
94 return lhs = lhs & rhs;
99 return lhs = lhs | rhs;
104 return lhs = lhs ^ rhs;
119 using duration = io::TimerBase::duration;
120 using time_point = io::TimerBase::time_point;
143 const ::std::string& dcf_txt, const ::std::string& dcf_bin =
"",
148 const ::std::string& dcf_txt, const ::std::string& dcf_bin =
"",
150 :
Node(nullptr, timer, chan, dcf_txt, dcf_bin, id) {}
153 Node& operator=(
const Node&) =
delete;
190 *io::make_timer_queue_wait_wrapper(exec, ::std::forward<F>(f)));
205 *io::make_timer_queue_wait_wrapper(exec, ::std::forward<F>(f)));
210 typename ::std::enable_if<!::std::is_base_of<
213 SubmitWait(t,
nullptr, ::std::forward<F>(f));
218 typename ::std::enable_if<!::std::is_base_of<
219 io_tqueue_wait, typename ::std::decay<F>::type>::value>::type
221 SubmitWait(d,
nullptr, ::std::forward<F>(f));
237 ev_exec_t* exec,
const time_point& t, io_tqueue_wait** pwait =
nullptr);
252 ev_exec_t* exec,
const duration& d, io_tqueue_wait** pwait =
nullptr);
256 AsyncWait(
const time_point& t, io_tqueue_wait** pwait =
nullptr) {
257 return AsyncWait(
nullptr, t, pwait);
262 AsyncWait(
const duration& d, io_tqueue_wait** pwait =
nullptr) {
263 return AsyncWait(
nullptr, d, pwait);
274 bool CancelWait(io_tqueue_wait& wait) noexcept;
283 bool AbortWait(io_tqueue_wait& wait) noexcept;
304 ::std::chrono::milliseconds delay);
321 void OnCanError(::std::function<
void(
io::CanError)> on_can_error);
340 void ConfigHeartbeat(uint8_t
id, const ::std::chrono::milliseconds& ms,
341 ::std::error_code& ec);
353 void ConfigHeartbeat(uint8_t
id, const ::std::chrono::milliseconds& ms);
361 void OnCommand(::std::function<
void(
NmtCommand)> on_command);
369 void OnHeartbeat(::std::function<
void(uint8_t,
bool)> on_heartbeat);
378 void OnState(::std::function<
void(uint8_t,
NmtState)> on_state);
388 ::std::function<
void(
int, ::std::error_code,
const void*, ::std::size_t)>
398 void OnRpdoError(::std::function<
void(
int, uint16_t, uint8_t)> on_rpdo_error);
408 ::std::function<
void(
int, ::std::error_code,
const void*, ::std::size_t)>
417 void OnSync(::std::function<
void(uint8_t,
const time_point&)> on_sync);
426 void OnSyncError(::std::function<
void(uint16_t, uint8_t)> on_sync_error);
435 ::std::function<
void(const ::std::chrono::system_clock::time_point&)>
445 ::std::function<
void(uint8_t, uint16_t, uint8_t, uint8_t[5])> on_emcy);
454 void OnSwitchBitrate(::std::function<
void(
int, ::std::chrono::milliseconds)>
466 void lock()
override;
467 void unlock()
override;
479 CANNet* net()
const noexcept;
515 CONMT* nmt()
const noexcept;
526 void Error(uint16_t eec, uint8_t er,
527 const uint8_t msef[5] =
nullptr) noexcept;
536 void RpdoRtr(
int num = 0) noexcept;
546 void TpdoEvent(
int num = 0) noexcept;
553 #ifndef DOXYGEN_SHOULD_SKIP_THIS 626 OnRpdo(
int num, ::std::error_code ec,
const void* p,
627 ::std::size_t n) noexcept {
673 OnTpdo(
int num, ::std::error_code ec,
const void* p,
674 ::std::size_t n) noexcept {
690 OnSync(uint8_t cnt,
const time_point& t) noexcept {
715 OnTime(const ::std::chrono::system_clock::time_point& abs_time) noexcept {
728 OnEmcy(uint8_t
id, uint16_t eec, uint8_t er, uint8_t msef[5]) noexcept {
760 virtual void OnStore(uint8_t
id,
int bitrate);
762 #ifdef DOXYGEN_SHOULD_SKIP_THIS 767 ::std::unique_ptr<Impl_> impl_;
774 #endif // LELY_COAPP_NODE_HPP_ A reference to an abstract timer.
virtual void OnState(uint8_t id, NmtState st) noexcept
The function invoked when an NMT state change or boot-up event is detected for a remote node by the h...
virtual void OnTpdo(int num, ::std::error_code ec, const void *p, ::std::size_t n) noexcept
The function invoked after a Transmit-PDO is sent or an error occurs.
TpdoEventMutex tpdo_event_mutex
The mutex used to postpone the transmission of acyclic and event-driven PDOs.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
virtual void OnSyncError(uint16_t eec, uint8_t er) noexcept
The function invoked when the data length of a received SYNC message does not match.
This header file is part of the C++ CANopen application library; it contains the CANopen device descr...
virtual void OnSwitchBitrate(int bitrate, ::std::chrono::milliseconds delay) noexcept
The function invoked when the LSS master activates the bit rate of all CANopen devices in the network...
A refence to an I/O context. This class is a wrapper around io_ctx_t*.
virtual void OnTime(const ::std::chrono::system_clock::time_point &abs_time) noexcept
The function invoked when a TIME message is received.
This header file is part of the I/O library; it contains the C++ interface for the timer queue...
NmtCommand
The NMT command specifiers.
typename ::std::enable_if<!::std::is_base_of< io_tqueue_wait, typename ::std::decay< F >::type >::value >::type SubmitWait(const duration &d, F &&f)
Equivalent to SubmitWait(d, nullptr, f).
A wait operation suitable for use with a timer queue.
virtual void OnSync(uint8_t cnt, const time_point &t) noexcept
The function invoked when a SYNC message is sent/received.
The base class for CANopen LSS masters.
Node(io::TimerBase &timer, io::CanChannelBase &chan, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
Creates a new CANopen node.
CanState
The states of a CAN node, depending on the TX/RX error count.
void SubmitWait(const duration &d, ev_exec_t *exec, F &&f)
Submits a wait operation.
ev::Future< void, ::std::exception_ptr > AsyncWait(const duration &d, io_tqueue_wait **pwait=nullptr)
Equivalent to AsyncWait(nullptr, d, pwait).
virtual void OnHeartbeat(uint8_t id, bool occurred) noexcept
The function invoked when a heartbeat timeout event occurs or is resolved.
CanError
The error flags of a CAN bus, which are not mutually exclusive.
The mask to get/set the toggle bit from an NMT state.
ev::Future< void, ::std::exception_ptr > AsyncWait(const time_point &t, io_tqueue_wait **pwait=nullptr)
Equivalent to AsyncWait(nullptr, t, pwait).
A CAN network interface. This class is a wrapper around io_can_net_t*.
An abstract interface conforming to the BasicLockable concept.
virtual void OnCanError(io::CanError error) noexcept
The function invoked when an error is detected on the CAN bus.
The type of objects thrown as exceptions to report a system error with an associated error code...
virtual void OnCommand(NmtCommand cs) noexcept
The function invoked when an NMT command is received from the master.
void SubmitWait(const time_point &t, ev_exec_t *exec, F &&f)
Submits a wait operation.
An abstract clock. This class is a wrapper around io_clock_t*.
This header file is part of the I/O library; it contains the C++ interface for the timer queue...
A mutex-like object that can be used to postpone the transmission of acyclic and event-driven Transmi...
virtual void OnRpdo(int num, ::std::error_code ec, const void *p, ::std::size_t n) noexcept
The function invoked when a Receive-PDO is processed.
An abstract task executor. This class is a wrapper around ev_exec_t*.
An opaque CANopen NMT master/slave service type.
The CANopen device description.
A reference to an abstract CAN controller.
virtual void OnEmcy(uint8_t id, uint16_t eec, uint8_t er, uint8_t msef[5]) noexcept
The function invoked when an EMCY message is received.
An opaque CAN network interface type.
The base class for CANopen nodes.
virtual void OnRpdoError(int num, uint16_t eec, uint8_t er) noexcept
The function invoked when a Receive-PDO length mismatch or timeout error occurs.
typename ::std::enable_if<!::std::is_base_of< io_tqueue_wait, typename ::std::decay< F >::type >::value >::type SubmitWait(const time_point &t, F &&f)
Equivalent to SubmitWait(t, nullptr, f).
A reference to an abstract CAN channel.
The internal implementation of the CANopen node.