22#ifndef LELY_COCPP_SLAVE_HPP_
23#define LELY_COCPP_SLAVE_HPP_
111 return Set(::std::forward<T>(value));
137 const ::std::type_info&
139 return slave_->
Type(idx_, subidx_);
153 const ::std::type_info&
154 Type(::std::error_code& ec)
const noexcept {
155 return slave_->
Type(idx_, subidx_, ec);
172 return id_ ? slave_->
TpdoGet<T>(id_, idx_, subidx_)
173 : slave_->
Get<T>(idx_, subidx_);
190 Get(::std::error_code& ec)
const noexcept {
191 return id_ ? slave_->
TpdoGet<T>(id_, idx_, subidx_, ec)
192 : slave_->
Get<T>(idx_, subidx_, ec);
212 slave_->
TpdoSet(id_, idx_, subidx_, ::std::forward<T>(value));
214 slave_->
Set(idx_, subidx_, ::std::forward<T>(value));
235 Set(T&& value, ::std::error_code& ec)
noexcept {
237 slave_->
TpdoSet(id_, idx_, subidx_, ::std::forward<T>(value), ec);
239 slave_->
Set(idx_, subidx_, ::std::forward<T>(value), ec);
257 Set(
const void* p, ::std::size_t n) {
258 if (!id_) slave_->
Set(idx_, subidx_, p, n);
275 Set(
const void* p, ::std::size_t n, ::std::error_code& ec)
noexcept {
276 if (!id_) slave_->
Set(idx_, subidx_, p, n, ec);
313 slave_->
SetEvent(idx_, subidx_, ec);
319 : slave_(
slave), idx_(idx), subidx_(subidx), id_(
id) {}
359 const ::std::type_info&
361 return slave_->Type(idx_, subidx_);
376 const ::std::type_info&
377 Type(::std::error_code& ec)
const {
378 return slave_->Type(idx_, subidx_, ec);
396 return id_ ? (is_rpdo_ ? slave_->RpdoGet<T>(id_, idx_, subidx_)
397 : slave_->TpdoGet<T>(id_, idx_, subidx_))
398 : slave_->Get<T>(idx_, subidx_);
416 Get(::std::error_code& ec)
const noexcept {
417 return id_ ? (is_rpdo_ ? slave_->RpdoGet<T>(id_, idx_, subidx_, ec)
418 : slave_->TpdoGet<T>(id_, idx_, subidx_, ec))
419 : slave_->Get<T>(idx_, subidx_, ec);
463 return SubObject(slave_, id_, idx_, subidx);
486 : slave_(
slave), idx_(idx), id_(
id) {}
525 : slave_(
slave), idx_(idx), id_(
id), is_rpdo_(
is_rpdo) {}
527 const BasicSlave* slave_;
558 : slave_(
slave), id_(
id) {}
584 return Object(slave_, id_, idx);
604 : slave_(
slave), id_(
id) {}
725 typename ::std::enable_if<is_canopen<T>::value>::type
OnRead(
740 typename ::std::enable_if<is_canopen<T>::value>::type
OnRead(
742 ::std::error_code& ec);
757 typename ::std::enable_if<is_canopen<T>::value>::type
OnRead(
772 typename ::std::enable_if<is_canopen<T>::value>::type
OnRead(
774 ::std::error_code& ec);
790 typename ::std::enable_if<is_canopen<T>::value>::type
OnWrite(
806 typename ::std::enable_if<is_canopen<T>::value>::type
OnWrite(
808 ::std::error_code& ec);
823 typename ::std::enable_if<is_canopen<T>::value>::type
OnWrite(
838 typename ::std::enable_if<is_canopen<T>::value>::type
OnWrite(
840 ::std::error_code& ec);
843 using Device::OnWrite;
861 ::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.
const ::std::type_info & Type() const
Returns the type 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.
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.
const ::std::type_info & Type(::std::error_code &ec) const noexcept
Returns the type of the sub-object.
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.
SubObject & Set(const void *p, ::std::size_t n, ::std::error_code &ec) noexcept
Writes an OCTET_STRING or DOMAIN value to the sub-object.
SubObject & Set(T &&value)
Writes a value to the sub-object.
const ::std::type_info & Type() const
Returns the type of 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 & Set(const void *p, ::std::size_t n)
Writes an OCTET_STRING or DOMAIN value to the sub-object.
SubObject & Set(T &&value, ::std::error_code &ec) noexcept
Writes a value to the sub-object.
SubObject & operator=(T &&value)
Sets the value of 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< is_canopen< 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-...
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...
Object operator[](::std::ptrdiff_t idx) noexcept
Returns a mutator object that provides read/write access to the specified CANopen object in the local...
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...
typename ::std::conditional< 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...
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< is_canopen< 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...
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< 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...
const ::std::type_info & Type(uint16_t idx, uint8_t subidx) const
Returns the type of a sub-object.
typename::std::enable_if< is_canopen< T >::value >::type Set(uint16_t idx, uint8_t subidx, const T &value)
Writes a CANopen value to a sub-object.
typename::std::enable_if< is_canopen< T >::value, T >::type Get(uint16_t idx, uint8_t subidx) const
Reads the value 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,...
typename::std::enable_if< 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...
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.
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.