22 #ifndef LELY_COCPP_SLAVE_HPP_
23 #define LELY_COCPP_SLAVE_HPP_
62 const ::std::string& dcf_bin =
"", uint8_t
id = 0xff);
66 const ::std::string& dcf_txt,
67 const ::std::string& dcf_bin =
"", uint8_t
id = 0xff)
68 :
BasicSlave(nullptr, timer, chan, dcf_txt, dcf_bin,
id) {}
111 Set(::std::forward<T>(value));
138 const ::std::type_info&
140 return slave_->
Type(idx_, subidx_);
154 const ::std::type_info&
155 Type(::std::error_code& ec)
const noexcept {
156 return slave_->
Type(idx_, subidx_, ec);
173 return id_ ? slave_->
TpdoGet<T>(id_, idx_, subidx_)
174 : slave_->
Get<T>(idx_, subidx_);
191 Get(::std::error_code& ec)
const noexcept {
192 return id_ ? slave_->
TpdoGet<T>(id_, idx_, subidx_, ec)
193 : slave_->
Get<T>(idx_, subidx_, ec);
211 slave_->
TpdoSet(id_, idx_, subidx_, ::std::forward<T>(value));
213 slave_->
Set(idx_, subidx_, ::std::forward<T>(value));
231 Set(T&& value, ::std::error_code& ec) noexcept {
233 slave_->
TpdoSet(id_, idx_, subidx_, ::std::forward<T>(value), ec);
235 slave_->
Set(idx_, subidx_, ::std::forward<T>(value), ec);
250 Set(
const void* p, ::std::size_t n) {
251 if (!id_) slave_->
Set(idx_, subidx_, p, n);
265 Set(
const void* p, ::std::size_t n, ::std::error_code& ec) noexcept {
266 if (!id_) slave_->
Set(idx_, subidx_, p, n, ec);
302 slave_->
SetEvent(idx_, subidx_, ec);
307 uint8_t subidx) noexcept
308 : slave_(slave), idx_(idx), subidx_(subidx), id_(
id) {}
348 const ::std::type_info&
350 return slave_->
Type(idx_, subidx_);
365 const ::std::type_info&
366 Type(::std::error_code& ec)
const {
367 return slave_->
Type(idx_, subidx_, ec);
385 return id_ ? (is_rpdo_ ? slave_->
RpdoGet<T>(id_, idx_, subidx_)
386 : slave_->
TpdoGet<T>(id_, idx_, subidx_))
387 : slave_->
Get<T>(idx_, subidx_);
405 Get(::std::error_code& ec)
const noexcept {
406 return id_ ? (is_rpdo_ ? slave_->
RpdoGet<T>(id_, idx_, subidx_, ec)
407 : slave_->
TpdoGet<T>(id_, idx_, subidx_, ec))
408 : slave_->
Get<T>(idx_, subidx_, ec);
413 uint8_t subidx,
bool is_rpdo) noexcept
424 uint8_t is_rpdo_ : 1;
451 return SubObject(slave_, id_, idx_, subidx);
472 Object(
BasicSlave* slave, uint8_t
id, uint16_t idx) noexcept
473 : slave_(slave), idx_(idx), id_(
id) {}
509 ConstObject(
const BasicSlave* slave, uint8_t
id, uint16_t idx,
510 bool is_rpdo) noexcept
511 : slave_(slave), idx_(idx), id_(
id), is_rpdo_(is_rpdo) {}
513 const BasicSlave* slave_;
516 uint8_t is_rpdo_ : 1;
543 : slave_(slave), id_(
id) {}
568 return Object(slave_, id_, idx);
587 : slave_(slave), id_(
id) {}
632 ::std::error_code(uint16_t idx, uint8_t subidx, T& new_val, T old_val),
633 ::std::error_code(uint16_t idx, uint8_t subidx, T& new_val)>::type;
704 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnRead(
719 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnRead(
721 ::std::error_code& ec);
736 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnRead(
751 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnRead(
753 ::std::error_code& ec);
769 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnWrite(
785 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnWrite(
787 ::std::error_code& ec);
802 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnWrite(
817 typename ::std::enable_if<detail::is_canopen_type<T>::value>::type
OnWrite(
819 ::std::error_code& ec);
820 #ifndef DOXYGEN_SHOULD_SKIP_THIS
837 #ifdef DOXYGEN_SHOULD_SKIP_THIS
842 ::std::unique_ptr<Impl_> impl_;
An accessor providing read-only access to a CANopen object in a local object dictionary.
ConstSubObject operator[](uint8_t subidx) const noexcept
Returns an accessor object that provides read-only access to the specified CANopen sub-object in the ...
An accessor providing read-only access to a CANopen sub-object in a local object dictionary.
T Get(::std::error_code &ec) const noexcept
Reads the value of the sub-object.
T Get() const
Reads the value of the sub-object.
const ::std::type_info & Type(::std::error_code &ec) const
Returns the type of the sub-object.
const ::std::type_info & Type() const
Returns the type of the sub-object.
A mutator providing read/write access to a CANopen object in a local object dictionary.
ConstSubObject operator[](uint8_t subidx) const noexcept
Returns an accessor object that provides read-only access to the specified CANopen sub-object in the ...
SubObject operator[](uint8_t subidx) noexcept
Returns a mutator object that provides read/write access to the specified CANopen sub-object in the l...
An accessor providing read-only access to RPDO-mapped objects in a remote object dictionary.
ConstObject operator[](uint16_t idx) const noexcept
Returns an accessor object that provides read-only access to the specified RPDO-mapped object in the ...
A mutator providing read/write access to a CANopen sub-object in a local object dictionary.
T Get(::std::error_code &ec) const noexcept
Reads the value of the sub-object.
T Get() const
Reads the value of the sub-object.
void Set(const void *p, ::std::size_t n, ::std::error_code &ec) noexcept
Writes an OCTET_STRING or DOMAIN value to the sub-object.
void Set(T &&value, ::std::error_code &ec) noexcept
Writes a value to the sub-object.
void Set(const void *p, ::std::size_t n)
Writes an OCTET_STRING or DOMAIN value to the sub-object.
void SetEvent()
Checks if the sub-object can be mapped into a PDO and, if so, triggers the transmission of every acyc...
void SetEvent(::std::error_code &ec) noexcept
Checks if the sub-object can be mapped into a PDO and, if so, triggers the transmission of every acyc...
SubObject & operator=(T &&value)
Sets the value of the sub-object.
const ::std::type_info & Type(::std::error_code &ec) const noexcept
Returns the type of the sub-object.
const ::std::type_info & Type() const
Returns the type of the sub-object.
void Set(T &&value)
Writes a value to the sub-object.
A mutator providing read/write access to TPDO-mapped objects in a remote object dictionary.
Object operator[](uint16_t idx) noexcept
Returns a mutator object that provides read/write access to the specified TPDO-mapped object in the r...
ConstObject operator[](uint16_t idx) const noexcept
Returns an accessor object that provides read-only access to the specified TPDO-mapped object in the ...
The base class for CANopen slaves.
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnWrite(uint16_t idx, ::std::function< OnWriteSignature< T >> ind, ::std::error_code &ec)
Registers a callback function to be invoked on write (SDO download) access to each member of the spec...
BasicSlave(ev_exec_t *exec, io::TimerBase &timer, io::CanChannelBase &chan, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
Creates a new CANopen slave.
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnWrite(uint16_t idx, uint8_t subidx, ::std::function< OnWriteSignature< T >> ind)
Registers a callback function to be invoked on write (SDO download) access to the specified CANopen s...
BasicSlave(io::TimerBase &timer, io::CanChannelBase &chan, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
Creates a new CANopen slave.
virtual void OnLifeGuarding(bool occurred) noexcept
The function invoked when a life guarding event occurs or is resolved.
ConstObject operator[](::std::ptrdiff_t idx) const noexcept
Returns an accessor object that provides read-only access to the specified CANopen object in the loca...
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnRead(uint16_t idx, ::std::function< OnReadSignature< T >> ind)
Registers a callback function to be invoked on read (SDO upload) access to each member of the specifi...
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnWrite(uint16_t idx, uint8_t subidx, ::std::function< OnWriteSignature< T >> ind, ::std::error_code &ec)
Registers a callback function to be invoked on write (SDO download) access to the specified CANopen s...
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnRead(uint16_t idx, ::std::function< OnReadSignature< T >> ind, ::std::error_code &ec)
Registers a callback function to be invoked on read (SDO upload) access to each member of the specifi...
Object operator[](::std::ptrdiff_t idx) noexcept
Returns a mutator object that provides read/write access to the specified CANopen object in the local...
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnRead(uint16_t idx, uint8_t subidx, ::std::function< OnReadSignature< T >> ind, ::std::error_code &ec)
Registers a callback function to be invoked on read (SDO upload) access to the specified CANopen sub-...
TpdoMapped TpdoMapped(uint8_t id) noexcept
Returns a mutator object that provides read/write access to TPDO-mapped objects in the remote object ...
::std::error_code(uint16_t idx, uint8_t subdx, T &value) OnReadSignature
The signature of the callback function invoked on read (SDO upload) access to the local object dictio...
RpdoMapped RpdoMapped(uint8_t id) const noexcept
Returns an accessor object that provides read-only access to RPDO-mapped objects in the remote object...
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnRead(uint16_t idx, uint8_t subidx, ::std::function< OnReadSignature< T >> ind)
Registers a callback function to be invoked on read (SDO upload) access to the specified CANopen sub-...
typename ::std::conditional< detail::is_canopen_basic< T >::value, ::std::error_code(uint16_t idx, uint8_t subidx, T &new_val, T old_val), ::std::error_code(uint16_t idx, uint8_t subidx, T &new_val)>::type OnWriteSignature
The signature of the callback function invoked on write (SDO download) access to the local object dic...
void OnLifeGuarding(::std::function< void(bool)> on_life_guarding)
Registers the function to be invoked when a life guarding event occurs or is resolved.
typename ::std::enable_if< detail::is_canopen_type< T >::value >::type OnWrite(uint16_t idx, ::std::function< OnWriteSignature< T >> ind)
Registers a callback function to be invoked on write (SDO download) access to each member of the spec...
typename ::std::enable_if< detail::is_canopen_basic< T >::value, T >::type TpdoGet(uint8_t id, uint16_t idx, uint8_t subidx) const
Reads the value of a TPDO-mapped sub-object in the local object dictionary that will be written to an...
typename ::std::enable_if< detail::is_canopen_type< T >::value, T >::type Get(uint16_t idx, uint8_t subidx) const
Reads the value of a sub-object.
typename ::std::enable_if< detail::is_canopen_basic< T >::value >::type Set(uint16_t idx, uint8_t subidx, T value)
Writes a CANopen basic value to a sub-object.
typename ::std::enable_if< detail::is_canopen_basic< T >::value, T >::type RpdoGet(uint8_t id, uint16_t idx, uint8_t subidx) const
Reads the value of a sub-object in a remote object dictionary by reading the corresponding PDO-mapped...
const ::std::type_info & Type(uint16_t idx, uint8_t subidx) const
Returns the type of a sub-object.
void SetEvent(uint16_t idx, uint8_t subidx)
Checks if the specified sub-object in the local object dictionary can be mapped into a PDO and,...
void TpdoSetEvent(uint8_t id, uint16_t idx, uint8_t subidx)
Triggers the transmission of every event-driven, asynchronous Transmit-PDO which is mapped into the s...
uint8_t id() const noexcept
Returns the node-ID.
typename ::std::enable_if< detail::is_canopen_basic< T >::value >::type TpdoSet(uint8_t id, uint16_t idx, uint8_t subidx, T value)
Writes a value to a sub-object in a remote object dictionary by writing to the corresponding PDO-mapp...
The base class for CANopen nodes.
A reference to an abstract CAN channel.
A reference to an abstract timer.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
This header file is part of the C++ CANopen application library; it contains the CANopen node declara...
If T is one of the CANopen basic types, provides the member constant value equal to true.