IoT::CANopen

class Object

File Information

Library: IoT/CANopen
Package: CANopen
Header: IoT/CANopen/Object.h

Description

This class implements an object in the Object Dictionary.

Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

Known Derived Classes: VarObject, ArrayObject, SDOParameterObject

Member Summary

Member Functions: access, code, copy, read, structure, type, write, writeImpl

Inherited Functions: duplicate, referenceCount, release

Types

Ptr

typedef Poco::AutoPtr < Object > Ptr;

Enumerations

Access

Object access attributes.

OBJ_ACCESS_RW = 0x01

Read and write access.

OBJ_ACCESS_WO = 0x02

Write only access.

OBJ_ACCESS_RO = 0x03

Read only access.

OBJ_ACCESS_CONST = 0x04

Read only access, value is constant.

ObjectCode

The object code shall denote what kind of object is at a particular index in the object dictionary.

OBJ_NULL = 0x00

An object with no data fields.

OBJ_DOMAIN = 0x02

Large variable amount of data e.g. executable program code.

OBJ_DEFTYPE = 0x05

Denotes a type definition such as a BOOLEAN, UNSIGNED16, FLOAT and so on.

OBJ_DEFSTRUCT = 0x06

Defines a new record type.

OBJ_VAR = 0x07

A single value such as an UNSIGNED8, BOOLEAN, FLOAT, INTEGER16, VISIBLE STRING, etc.

OBJ_ARRAY = 0x08

A multiple data field object where each data field is a simple variable of the same basic data type e.g. array of UNSIGNED16 etc. Sub-index 0 is of UNSIGNED8 and therefore not part of the ARRAY data

OBJ_RECORD = 0x09

A multiple data field object where the data fields may be any combination of simple variables. Sub-index 0 is of UNSIGNED8 and sub-index 255 is of UNSIGNED32 and therefore not part of the RECORD data

PredefinedType

Predefined data types.

OBJ_TYPE_BOOLEAN = 0x0001

OBJ_TYPE_INTEGER8 = 0x0002

OBJ_TYPE_INTEGER16 = 0x0003

OBJ_TYPE_INTEGER32 = 0x0004

OBJ_TYPE_UNSIGNED8 = 0x0005

OBJ_TYPE_UNSIGNED16 = 0x0006

OBJ_TYPE_UNSIGNED32 = 0x0007

OBJ_TYPE_REAL32 = 0x0008

OBJ_TYPE_VISIBLE_STRING = 0x0009

OBJ_TYPE_OCTET_STRING = 0x000A

OBJ_TYPE_UNICODE_STRING = 0x000B

OBJ_TYPE_TIME_OF_DAY = 0x000C

OBJ_TYPE_TIME_DIFFERENCE = 0x000D

OBJ_TYPE_DOMAIN = 0x000F

OBJ_TYPE_INTEGER24 = 0x0010

OBJ_TYPE_REAL64 = 0x0011

OBJ_TYPE_INTEGER40 = 0x0012

OBJ_TYPE_INTEGER48 = 0x0013

OBJ_TYPE_INTEGER56 = 0x0014

OBJ_TYPE_INTEGER64 = 0x0015

OBJ_TYPE_UNSIGNED24 = 0x0016

OBJ_TYPE_UNSIGNED40 = 0x0018

OBJ_TYPE_UNSIGNED48 = 0x0019

OBJ_TYPE_UNSIGNED56 = 0x001A

OBJ_TYPE_UNSIGNED64 = 0x001B

OBJ_TYPE_PDO_COMMUNICATION_PARAMETER = 0x0020

OBJ_TYPE_PDO_MAPPING = 0x0021

OBJ_TYPE_SDO_PARAMETER = 0x0022

OBJ_TYPE_IDENTITY = 0x0023

Constructors

Object

Object();

Creates and default-initializes an Object.

Destructor

~Object virtual

~Object();

Destroys the Object.

Member Functions

access virtual

virtual Access access() const = 0;

Returns the access attribute for the object.

code virtual

virtual ObjectCode code() const = 0;

Returns the kind of object.

read virtual

virtual SDO::AbortCode read(
    Poco::UInt8 subIndex,
    std::vector < char > & data
) const;

Copies the value of the object into the given data buffer. The vector will be resized accordingly.

The buffer will then be used for a SDO upload operation.

Returns SDO::SDO_SUCCESS (0) if successful, or an abort code if an error occurs.

The default implementation returns SDO::SDO_ABORT_INVALID_ACCESS.

structure

Poco::UInt32 structure() const;

Returns the structure of the object, which in CANopen terms is the ObjectCode combined with the type. Bits 0-7 contain the ObjectCode and bits 8-23 contain the type. Bits 24-31 are reserved and should be 0.

The same value can also be obtained by reading sub-index 0xFF.

type virtual

virtual Poco::UInt16 type() const = 0;

Returns the type of the object. The returned value is the index of the type in the object dictionary.

For predefined types, see the PredefinedType enumeration.

write virtual

virtual SDO::AbortCode write(
    Poco::UInt8 subIndex,
    std::size_t size,
    const char * data
);

Writes the contents of the given data buffer to the object.

The data buffer is typically the result of a SDO download or MPDO transmission.

Returns SDO::SDO_SUCCESS (0) if successful, or a SDO abort code if an error occurs.

The default implementation returns SDO::SDO_ABORT_INVALID_ACCESS.

write virtual

virtual SDO::AbortCode write(
    Poco::UInt8 subIndex,
    const std::vector < char > & data
);

Writes the contents of the given data buffer to the object. The vector must not be empty.

The data buffer is typically the result of a SDO download or MPDO transmission.

Returns SDO::SDO_SUCCESS (0) if successful, or an abort code if an error occurs.

The default implementation calls write(subIndex, data.size(), &data[0]).

copy protected static inline

template < typename T > static void copy(
    std::vector < char > & data,
    T value
);

copy protected static inline

template < typename T > static void copy(
    T & value,
    std::size_t size,
    const char * data
);

copy protected static inline

static void copy(
    std::vector < char > & data,
    const std::string & value
);

copy protected static inline

static void copy(
    std::string & value,
    std::size_t size,
    const char * data
);

writeImpl protected inline

template < typename T > SDO::AbortCode writeImpl(
    T & value,
    Poco::UInt8 subIndex,
    std::size_t size,
    const char * data
);

Variables

modified

Poco::BasicEvent < const Poco::UInt8 > modified;

Fired when the object has been modified by a call to write(), which usually happens as a result of a SDO download or MPDO.

The event argument is the sub-index of the modified element (1..n).

This event is only fired if the object has actually been modified.

written

Poco::BasicEvent < const Poco::UInt8 > written;

Fired when the object has been written to by a call to write(), which usually happens as a result of a SDO download or MPDO.

The event argument is the sub-index of the written element (1..n).

Note that the value of the object may not have been modified.

Securely control IoT edge devices from anywhere   Connect a Device