KaCanOpen
 All Classes Functions Variables Typedefs Enumerations Pages
Public Types | Public Member Functions | Public Attributes | List of all members
kaco::Entry Class Reference

This class represents an entry in the object dictionary of a device. More...

#include <entry.h>

Collaboration diagram for kaco::Entry:
Collaboration graph
[legend]

Public Types

using ValueChangedCallback = std::function< void(const Value &value) >
 type of a callback for a value changed event Important: Never call add_value_changed_callback() from within (-> deadlock)!
 

Public Member Functions

 Entry ()
 Constructs an empty entry.
 
 Entry (const uint16_t _index, const uint8_t _subindex, const std::string &_name, const Type _type, const AccessType _access_type)
 Standard constructor. More...
 
 Entry (const Entry &other)=delete
 copy constructor
 
 Entry (Entry &&other)=default
 move constructor
 
Entryoperator= (const Entry &other)=delete
 copy assignment
 
Entryoperator= (Entry &&other)=default
 move assignment
 
void set_value (const Value &value)
 Sets the value. More...
 
const Valueget_value () const
 Returns the value. More...
 
bool valid () const
 Returns if the value is set/valid. More...
 
Type get_type () const
 Returns the data type. More...
 
void add_value_changed_callback (ValueChangedCallback callback)
 Registers a given function to be called when the value is changed. More...
 
void print () const
 Prints relevant information concerning this entry on standard output - name, index, possibly value, ... This is used by Device::print_dictionary() More...
 
bool operator< (const Entry &other) const
 Compares entries by index and subindex. This can be used for sorting the dictionary. More...
 

Public Attributes

uint16_t index
 index in dictionary
 
uint8_t subindex
 subindex in dictionary. if is_array==true, this variable is not used
 
std::string name
 Human-readable name Should be escaped for consitency using Utils::escape().
 
Type type
 Data type of the value.
 
AccessType access_type
 Accessibility of the entry.
 
ReadAccessMethod read_access_method = ReadAccessMethod::sdo
 Standard method for reading this entry. Used by Device::get_entry().
 
WriteAccessMethod write_access_method = WriteAccessMethod::sdo
 Standard method for writing this entry. Used by Device::set_entry().
 
bool disabled
 Disables this entry. This is used when a device reports "Object does not exist in the object dictionary".
 
bool is_generic = false
 This is set to true, if the entry has been created through a default CiA EDS file. This means that it's not guaranteed that the entry actually exists in the current device. For manually added entries and entries from manufacturer-specific EDS files, this is set to false.
 

Detailed Description

This class represents an entry in the object dictionary of a device.

Todo:

Add missing fields like high and low limit.

Array type entries are currently not used and may be deleted in future.

Definition at line 53 of file entry.h.

Constructor & Destructor Documentation

kaco::Entry::Entry ( const uint16_t  _index,
const uint8_t  _subindex,
const std::string &  _name,
const Type  _type,
const AccessType  _access_type 
)

Standard constructor.

Parameters
_indexIndex
_subindexSub-index
_nameName
_typeData type
_access_typeAccess rights

Definition at line 50 of file entry.cpp.

Member Function Documentation

void kaco::Entry::add_value_changed_callback ( ValueChangedCallback  callback)

Registers a given function to be called when the value is changed.

Remarks
thread-safe

Definition at line 110 of file entry.cpp.

Type kaco::Entry::get_type ( ) const

Returns the data type.

Remarks
thread-safe

Definition at line 106 of file entry.cpp.

const Value & kaco::Entry::get_value ( ) const

Returns the value.

Exceptions
canopen_errorif value isn't valid.
Remarks
thread-safe

Definition at line 94 of file entry.cpp.

bool kaco::Entry::operator< ( const Entry other) const

Compares entries by index and subindex. This can be used for sorting the dictionary.

Remarks
thread-safe

Definition at line 136 of file entry.cpp.

void kaco::Entry::print ( ) const

Prints relevant information concerning this entry on standard output - name, index, possibly value, ... This is used by Device::print_dictionary()

Remarks
not thread-safe due to std::cout

Definition at line 115 of file entry.cpp.

void kaco::Entry::set_value ( const Value value)

Sets the value.

Exceptions
canopen_errorif types don't match.
Remarks
thread-safe

Definition at line 63 of file entry.cpp.

bool kaco::Entry::valid ( ) const

Returns if the value is set/valid.

Remarks
thread-safe

Definition at line 102 of file entry.cpp.


The documentation for this class was generated from the following files: