22#ifndef LELY_COCPP_SLAVE_HPP_
23#define LELY_COCPP_SLAVE_HPP_
49 BasicSlave(aio::TimerBase& timer, aio::CanBusBase& bus,
50 const ::std::string& dcf_txt, const ::std::string& dcf_bin =
"",
67 SubObject(
const SubObject&) =
default;
68 SubObject(SubObject&&) =
default;
70 SubObject& operator=(
const SubObject&) =
default;
71 SubObject& operator=(SubObject&&) =
default;
86 Set(::std::forward<T>(value));
113 const ::std::type_info&
115 return slave_->Type(idx_, subidx_);
130 const ::std::type_info&
131 Type(::std::error_code& ec)
const {
132 return slave_->Type(idx_, subidx_, ec);
148 return slave_->Get<T>(idx_, subidx_);
165 Get(::std::error_code& ec)
const {
166 return slave_->Get<T>(idx_, subidx_, ec);
182 slave_->Set(idx_, subidx_, ::std::forward<T>(value));
200 Set(T&& value, ::std::error_code& ec) {
201 slave_->Set(idx_, subidx_, ::std::forward<T>(value), ec);
217 Set(
const void* p, ::std::size_t n) {
218 slave_->Set(idx_, subidx_, p, n);
233 Set(
const void* p, ::std::size_t n, ::std::error_code& ec) {
234 slave_->Set(idx_, subidx_, p, n, ec);
239 : slave_(slave), idx_(idx), subidx_(subidx) {}
250 class ConstSubObject {
252 friend class ConstObject;
278 const ::std::type_info&
280 return slave_->Type(idx_, subidx_);
295 const ::std::type_info&
296 Type(::std::error_code& ec)
const {
297 return slave_->Type(idx_, subidx_, ec);
313 return slave_->Get<T>(idx_, subidx_);
330 Get(::std::error_code& ec)
const {
331 return slave_->Get<T>(idx_, subidx_, ec);
336 : slave_(slave), idx_(idx), subidx_(subidx) {}
348 friend class BasicSlave;
391 friend class BasicSlave;
410 : slave_(slave), idx_(idx) {}
455 ::std::error_code(uint16_t idx, uint8_t subidx, T& new_val, T old_val),
456 ::std::error_code(uint16_t idx, uint8_t subidx, T& new_val)>::type;
495 typename ::std::enable_if<detail::IsCanopenType<T>::value>::type
OnRead(
510 typename ::std::enable_if<detail::IsCanopenType<T>::value>::type
OnRead(
512 ::std::error_code& ec);
528 typename ::std::enable_if<detail::IsCanopenType<T>::value>::type
OnWrite(
544 typename ::std::enable_if<detail::IsCanopenType<T>::value>::type
OnWrite(
546 ::std::error_code& ec);
548#ifndef DOXYGEN_SHOULD_SKIP_THIS
567 ::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
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.
const ::std::type_info & Type() const
Returns the type of the sub-object.
T Get(::std::error_code &ec) const
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.
A mutator providing read/write access to a CANopen object in a local object dictionary.
SubObject operator[](uint8_t subidx)
Returns a mutator object that provides read/write access to the specified CANopen sub-object in the l...
ConstSubObject operator[](uint8_t subidx) const
Returns an accessor object that provides read-only access to the specified CANopen sub-object in the ...
A mutator providing read/write access to a CANopen sub-object in a local object dictionary.
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.
T Get(::std::error_code &ec) const
Reads the value of the sub-object.
void Set(const void *p, ::std::size_t n)
Writes an OCTET_STRING or DOMAIN value to the sub-object.
void Set(T &&value, ::std::error_code &ec)
Writes a value to the sub-object.
void Set(const void *p, ::std::size_t n, ::std::error_code &ec)
Writes an OCTET_STRING or DOMAIN value to the sub-object.
SubObject & operator=(T &&value)
Sets the value of the sub-object.
void Set(T &&value)
Writes a value to the sub-object.
The base class for CANopen slaves.
BasicSlave(aio::TimerBase &timer, aio::CanBusBase &bus, 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.
Object operator[](uint16_t idx)
Returns a mutator object that provides read/write access to the specified CANopen object in the local...
typename::std::enable_if< detail::IsCanopenType< 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...
ConstObject operator[](uint16_t idx) const
Returns an accessor object that provides read-only access to the specified CANopen object in the loca...
typename ::std::conditional< detail::IsCanopenBasic< 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...
::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::enable_if< detail::IsCanopenType< 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-...
Node(aio::TimerBase &timer, aio::CanBusBase &bus, const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff)
Creates a new CANopen node.
Namespace for the C++ CANopen application library.
Global namespace for the Lely Industries N.V. libraries.
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.