22#ifndef LELY_COAPP_DEVICE_HPP_
23#define LELY_COAPP_DEVICE_HPP_
61 Device(const ::std::string& dcf_txt, const ::std::string& dcf_bin =
"",
68 uint8_t
netid()
const noexcept;
71 uint8_t
id()
const noexcept;
86 typename ::std::enable_if<is_canopen<T>::value, T>::type
Read(
87 uint16_t idx, uint8_t subidx)
const;
101 typename ::std::enable_if<is_canopen<T>::value, T>::type
Read(
102 uint16_t idx, uint8_t subidx, ::std::error_code& ec)
const;
116 typename ::std::enable_if<is_canopen<T>::value>::type
Write(uint16_t idx,
131 typename ::std::enable_if<is_canopen<T>::value>::type
Write(
132 uint16_t idx, uint8_t subidx,
const T& value, ::std::error_code& ec);
145 void Write(uint16_t idx, uint8_t subidx,
const char* value);
157 void Write(uint16_t idx, uint8_t subidx,
const char* value,
158 ::std::error_code& ec);
172 void Write(uint16_t idx, uint8_t subidx,
const char16_t* value);
185 void Write(uint16_t idx, uint8_t subidx,
const char16_t* value,
186 ::std::error_code& ec);
200 void Write(uint16_t idx, uint8_t subidx,
const void* p, ::std::size_t n);
213 void Write(uint16_t idx, uint8_t subidx,
const void* p, ::std::size_t n,
214 ::std::error_code& ec);
229 void WriteDcf(
const uint8_t* begin,
const uint8_t* end);
243 void WriteDcf(
const uint8_t* begin,
const uint8_t* end,
244 ::std::error_code& ec);
267 void WriteDcf(
const char* path, ::std::error_code& ec);
280 void WriteEvent(uint16_t idx, uint8_t subidx);
293 void WriteEvent(uint16_t idx, uint8_t subidx, ::std::error_code& ec)
noexcept;
313 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
RpdoRead(
314 uint8_t
id, uint16_t idx, uint8_t subidx)
const;
333 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
RpdoRead(
334 uint8_t
id, uint16_t idx, uint8_t subidx, ::std::error_code& ec)
const;
355 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
TpdoRead(
356 uint8_t
id, uint16_t idx, uint8_t subidx)
const;
376 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
TpdoRead(
377 uint8_t
id, uint16_t idx, uint8_t subidx, ::std::error_code& ec)
const;
396 typename ::std::enable_if<is_canopen_basic<T>::value>::type
TpdoWrite(
397 uint8_t
id, uint16_t idx, uint8_t subidx, T value);
415 typename ::std::enable_if<is_canopen_basic<T>::value>::type
TpdoWrite(
416 uint8_t
id, uint16_t idx, uint8_t subidx, T value, ::std::error_code& ec);
449 ::std::error_code& ec)
noexcept;
458 void OnWrite(::std::function<
void(uint16_t, uint8_t)> on_write);
469 ::std::function<
void(uint8_t, uint16_t, uint8_t)> on_rpdo_write);
488 const ::std::type_info&
Type(uint16_t idx, uint8_t subidx)
const;
501 const ::std::type_info&
Type(uint16_t idx, uint8_t subidx,
502 ::std::error_code& ec)
const noexcept;
518 typename ::std::enable_if<is_canopen<T>::value, T>::type
Get(
519 uint16_t idx, uint8_t subidx)
const;
534 typename ::std::enable_if<is_canopen<T>::value, T>::type
Get(
535 uint16_t idx, uint8_t subidx, ::std::error_code& ec)
const noexcept;
550 typename ::std::enable_if<is_canopen<T>::value>::type
Set(uint16_t idx,
566 typename ::std::enable_if<is_canopen<T>::value>::type
Set(
567 uint16_t idx, uint8_t subidx,
const T& value,
568 ::std::error_code& ec)
noexcept;
582 void Set(uint16_t idx, uint8_t subidx,
const char* value);
595 void Set(uint16_t idx, uint8_t subidx,
const char* value,
596 ::std::error_code& ec)
noexcept;
611 void Set(uint16_t idx, uint8_t subidx,
const char16_t* value);
625 void Set(uint16_t idx, uint8_t subidx,
const char16_t* value,
626 ::std::error_code& ec)
noexcept;
641 void Set(uint16_t idx, uint8_t subidx,
const void* p, ::std::size_t n);
655 void Set(uint16_t idx, uint8_t subidx,
const void* p, ::std::size_t n,
656 ::std::error_code& ec)
noexcept;
671 const char*
GetUploadFile(uint16_t idx, uint8_t subidx)
const;
687 ::std::error_code& ec)
const noexcept;
702 void SetUploadFile(uint16_t idx, uint8_t subidx,
const char* filename);
717 void SetUploadFile(uint16_t idx, uint8_t subidx,
const char* filename,
718 ::std::error_code& ec)
noexcept;
749 ::std::error_code& ec)
const noexcept;
764 void SetDownloadFile(uint16_t idx, uint8_t subidx,
const char* filename);
779 void SetDownloadFile(uint16_t idx, uint8_t subidx,
const char* filename,
780 ::std::error_code& ec)
noexcept;
792 void SetEvent(uint16_t idx, uint8_t subidx);
807 void SetEvent(uint16_t idx, uint8_t subidx, ::std::error_code& ec)
noexcept;
828 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
RpdoGet(
829 uint8_t
id, uint16_t idx, uint8_t subidx)
const;
850 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
RpdoGet(
851 uint8_t
id, uint16_t idx, uint8_t subidx,
852 ::std::error_code& ec)
const noexcept;
874 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
TpdoGet(
875 uint8_t
id, uint16_t idx, uint8_t subidx)
const;
897 typename ::std::enable_if<is_canopen_basic<T>::value, T>::type
TpdoGet(
898 uint8_t
id, uint16_t idx, uint8_t subidx,
899 ::std::error_code& ec)
const noexcept;
919 typename ::std::enable_if<is_canopen_basic<T>::value>::type
TpdoSet(
920 uint8_t
id, uint16_t idx, uint8_t subidx, T value);
939 typename ::std::enable_if<is_canopen_basic<T>::value>::type
TpdoSet(
940 uint8_t
id, uint16_t idx, uint8_t subidx, T value,
941 ::std::error_code& ec)
noexcept;
958 void TpdoSetEvent(uint8_t
id, uint16_t idx, uint8_t subidx);
974 void TpdoSetEvent(uint8_t
id, uint16_t idx, uint8_t subidx,
975 ::std::error_code& ec)
noexcept;
1003 OnWrite(uint16_t , uint8_t )
noexcept {}
1019 OnRpdoWrite(uint8_t , uint16_t , uint8_t )
noexcept {}
1029 void RpdoWrite(uint8_t
id, uint16_t idx, uint8_t subidx);
1033 ::std::unique_ptr<Impl_> impl_;
The CANopen device description.
void RpdoWrite(uint8_t id, uint16_t idx, uint8_t subidx)
Invokes OnRpdoWrite() as if a value was written to an RPDO-mapped object in the local object dictiona...
uint8_t netid() const noexcept
Returns the network-ID.
void SetUploadFile(uint16_t idx, uint8_t subidx, const char *filename)
Sets the value of the UploadFile attribute of a sub-object, if present.
typename::std::enable_if< 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...
void TpdoWriteEvent(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...
void WriteDcf(const uint8_t *begin, const uint8_t *end)
Submits a series of SDO download requests to the local object dictionary.
void UpdateTpdoMapping()
Updates the mapping from remote RPDO-mapped sub-objects to local TPDO-mapped sub-objects.
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...
typename::std::enable_if< is_canopen< T >::value, T >::type Read(uint16_t idx, uint8_t subidx) const
Submits an SDO upload request to the local object dictionary.
void SetDownloadFile(uint16_t idx, uint8_t subidx, const char *filename)
Sets the value of the DownloadFile attribute of a sub-object, if present.
typename::std::enable_if< is_canopen_basic< T >::value >::type TpdoWrite(uint8_t id, uint16_t idx, uint8_t subidx, T value)
Writes a value to a sub-object in a remote object dictionary by submitting an SDO download request to...
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.
void UpdateRpdoMapping()
Updates the mapping from remote TPDO-mapped sub-objects to local RPDO-mapped sub-objects.
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,...
void WriteEvent(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...
Device(const ::std::string &dcf_txt, const ::std::string &dcf_bin="", uint8_t id=0xff, util::BasicLockable *mutex=nullptr)
Creates a new CANopen device description.
typename::std::enable_if< is_canopen< T >::value >::type Write(uint16_t idx, uint8_t subidx, const T &value)
Submits an SDO download request to the local object dictionary.
const char * GetDownloadFile(uint16_t idx, uint8_t subidx) const
Returns the value of the DownloadFile attribute of a sub-object, if present.
typename::std::enable_if< is_canopen_basic< T >::value, T >::type TpdoRead(uint8_t id, uint16_t idx, uint8_t subidx) const
Submits an SDO upload request to a TPDO-mapped sub-object in the local object dictionary,...
typename::std::enable_if< is_canopen_basic< T >::value, T >::type RpdoRead(uint8_t id, uint16_t idx, uint8_t subidx) const
Reads the value of a sub-object in a remote object dictionary by submitting an SDO upload request to ...
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...
__co_dev * dev() const noexcept
Returns a pointer to the internal CANopen device from <lely/co/dev.hpp>.
uint8_t id() const noexcept
Returns the node-ID.
const char * GetUploadFile(uint16_t idx, uint8_t subidx) const
Returns the value of the UploadFile attribute of a sub-object, if present.
An abstract interface conforming to the BasicLockable concept.
This header file is part of the C++ CANopen application library; it contains the CANopen type traits.
This header file is part of the utilities library; it contains the C++ mutual exclusion helper classe...
This header file is part of the C++ CANopen application library; it contains the SDO error declaratio...
The internal implementation of the CANopen device description.