BAOS SDK  18.2.0
Public Types | Public Member Functions | List of all members
kdrive::baos::BaosDatapoint Class Reference

The Baos Datapoint class is used to get and set a datapoint value. More...

#include <BaosDatapoint.h>

Public Types

enum  TransmissionStatus { TransmissionIdleOk = 0, TransmissionIdleError, TransmissionInProgress, TransmissionRequest }
 
typedef std::shared_ptr< BaosDatapointPtr
 

Public Member Functions

 BaosDatapoint ()
 
 BaosDatapoint (std::shared_ptr< BaosConnector > connector, unsigned short id)
 This is the standard constructor you will use to create a BaosDatapoint class. More...
 
 BaosDatapoint (std::shared_ptr< BaosConnector > connector, const ServerItem &serverItem)
 Creates a Baos Datapoint Object associated with a single Datapoint on the baos device. More...
 
 ~BaosDatapoint ()
 Destroys the Baos Datapoint. More...
 
void setId (unsigned short id)
 Sets the datapoint id. More...
 
unsigned short getId () const
 Returns the datapoint id. More...
 
const BaosDatapointDescriptiongetDatapointDescription () const
 Gets the datapoint description from the device. More...
 
void setCommand (unsigned char command)
 Sets the Command. More...
 
unsigned char getCommand () const
 Returns the currently set Command. More...
 
void readNewValueViaBus ()
 requests a read value from the bus for this datapoint This uses the set datapoint value service with command set to ReadNewValueViaBus (just for this call) and this function has no lasting effect on the value of the command. More...
 
void clearTransmissionState ()
 requests that the transmission state is cleared. More...
 
void setData (const std::vector< unsigned char > &data)
 Sets the value of the datapoint on the remote BAOS device associated with the current id. More...
 
const std::vector< unsigned char > & getData ()
 Reads the value of the datapoint on the remote BAOS device associated with the current id. More...
 
void clearData ()
 Clears the internal data. More...
 
bool isValidFlag () const
 Returns true: Object has already been received Returns false: false Object value is unknown. More...
 
bool isUpdate () const
 Returns true: Value is updated from the bus Returns false: Value was not updated. More...
 
bool isDataRequest () const
 Returns true: Data request Returns false: Idle/response. More...
 
int getTransmissionStatus () const
 Returns one of the following transmission status values: TransmissionIdleOk TransmissionIdleError TransmissionInProgress TransmissionRequest. More...
 
std::string getDescriptionString ()
 Get the Description String associated with the datapoint. More...
 
const ServerItemgetServerItem () const
 Returns the associated server item. More...
 
void enableCache (bool cacheEnabled)
 enable the data cache More...
 
void disableCache ()
 disable the cache More...
 
void setBoolean (bool value)
 set Datapoint DPT-1 More...
 
bool getBoolean ()
 get Datapoint DPT-1 More...
 
void set1BitControl (bool control, bool value)
 set Datapoint DPT-2 More...
 
bool get1BitControl ()
 get Datapoint DPT-2 (control) More...
 
bool get1BitControlValue ()
 get Datapoint DPT-2 (value) More...
 
void set3BitControl (bool control, unsigned char value)
 set Datapoint DPT-3 More...
 
bool get3BitControl ()
 get Datapoint DPT-3 (control) More...
 
unsigned char get3BitControlValue ()
 get Datapoint DPT-3 (value) More...
 
void setCharacterSet (unsigned char value)
 set Datapoint DPT-4 More...
 
unsigned char getCharacterSet ()
 get Datapoint DPT-4 More...
 
void set8BitUnsigned (unsigned char value)
 set Datapoint DPT-5 More...
 
unsigned char get8BitUnsigned ()
 get Datapoint DPT-5 More...
 
void set8BitSigned (char value)
 set Datapoint DPT-6 More...
 
char get8BitSigned ()
 get Datapoint DPT-6 More...
 
void set2OctetUnsigned (unsigned short value)
 set Datapoint DPT-7 More...
 
unsigned short get2OctetUnsigned ()
 get Datapoint DPT-7 More...
 
void set2OctetSigned (short value)
 set Datapoint DPT-8 More...
 
short get2OctetSigned ()
 get Datapoint DPT-8 More...
 
void set2OctetFloat (unsigned char msb, unsigned char lsb)
 set Datapoint DPT-9 More...
 
unsigned char get2OctetFloatMsb ()
 get Datapoint DPT-9 (msb) More...
 
unsigned char get2OctetFloatLsb ()
 get Datapoint DPT-9 (lsb) More...
 
void set2OctetFloat (float f)
 set Datapoint DPT-9, converts a standard IEEE float to a KNX 2 byte float More...
 
float get2OctetFloat ()
 get Datapoint DPT-9, converts a KNX 2 byte float to a standard IEEE float More...
 
void setTimeLocal ()
 set Datapoint DPT-10 (local time) More...
 
void setTimeUTC ()
 set Datapoint DPT-10 (utc time) More...
 
void setTime (int day, int hour, int minute, int second)
 set Datapoint DPT-10 More...
 
int getTimeDay ()
 get Datapoint DPT-10 (day) More...
 
int getTimeHour ()
 get Datapoint DPT-10 (hour) More...
 
int getTimeMinute ()
 get Datapoint DPT-10 (minute) More...
 
int getTimeSecond ()
 get Datapoint DPT-10 (second) More...
 
void setDateLocal ()
 set Datapoint DPT-11 (local) More...
 
void setDateUTC ()
 set Datapoint DPT-11 (utc) More...
 
void setDate (int year, int month, int day)
 set Datapoint DPT-11 More...
 
int getDateYear ()
 get Datapoint DPT-11 (year) More...
 
int getDateMonth ()
 get Datapoint DPT-11 (month) More...
 
int getDateDay ()
 get Datapoint DPT-11 (day) More...
 
void set4OctetUnsigned (unsigned int value)
 set Datapoint DPT-12 More...
 
unsigned int get4OctetUnsigned ()
 get Datapoint DPT-12 More...
 
void set4OctetSigned (int value)
 set Datapoint DPT-13 More...
 
int get4OctetSigned ()
 get Datapoint DPT-13 More...
 
void set4OctetFloat (float value)
 set Datapoint DPT-14 More...
 
float get4OctetFloat ()
 get Datapoint DPT-14 More...
 
void setAccess (unsigned int accessCode, bool error, bool permission, bool direction, bool encrypted, unsigned char index)
 set Datapoint DPT-15 More...
 
unsigned int getAccessCode ()
 get Datapoint DPT-15 (code) More...
 
bool getAccessError ()
 get Datapoint DPT-15 (error) More...
 
bool getAccessPermission ()
 get Datapoint DPT-15 (permission) More...
 
bool getAccessDirection ()
 get Datapoint DPT-15 (direction) More...
 
bool getAccessEncrypted ()
 get Datapoint DPT-15 (encrypted) More...
 
unsigned char getAccessIndex ()
 get Datapoint DPT-15 (index) More...
 
void setString (const std::string &str)
 set Datapoint DPT-16 More...
 
std::string getString ()
 get Datapoint DPT-16 More...
 

Detailed Description

The Baos Datapoint class is used to get and set a datapoint value.

The BAOS device holds the datapoint as a byte array (between 1 and 14 bytes) and the BaosDatapoint class provides conversion routines from this raw byte stream to typed values, such as Boolean, 8 Bit Signed, 2 Octet Unsigned etc. Internally it uses the BaosDatapointDescription to ensure that the conversion is type safe, that is, it compares the length of the datapoint value in the description with the length of the requested type and if these lengths do not match an exception will be raised. Note: it is possible to convert to/from types of the same length. i.e. if the datapoint value length is 2 bytes all the 2 octet conversion functions will be valid.

The Datapoint description is read once from the remote device and cached in the DatapointDescriptionHolder singleton class. If the project is changed (i.e via ETS download) the cache should be cleared otherwise the old descriptions will be used! (i.e. if you lose the TCP/IP connection it's probably a good idea to clear the DatapointDescriptionHolder cache on re-connect). To completely disable the description cache disable the DatapointDescriptionHolder.

The Datapoint is associated with a specific id, which is configured in the ETS project. This id range is two bytes in length and depends on the BAOS version (and its associated database) as to the number of datapoints that are available.

The BaosDatapoint implements a data cache (which can be disabled). When the cache is enabled the first read returns the value from the remote device and subsequent reads simply use the cached data. Obviously if the data on the remote device changes the cached data will no longer represent the current state on the bus. The cache is only applicable to read requests. Write requests will overwrite the value of the stored data. Call clearData to force a read if the cache is enabled.

Examples:
BaosDatapointDescription.cpp, BaosEventListener.cpp, BaosLightSwitcher.cpp, and BaosMultiConnector.cpp.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
TransmissionIdleOk 
TransmissionIdleError 
TransmissionInProgress 
TransmissionRequest 

Constructor & Destructor Documentation

BaosDatapoint::BaosDatapoint ( )
BaosDatapoint::BaosDatapoint ( std::shared_ptr< BaosConnector connector,
unsigned short  id 
)

This is the standard constructor you will use to create a BaosDatapoint class.

You pass in the Connector class and the associated Datapoint Value id. This id should correspond to the id configured in the ETS project and is associated with a specific Group Value Address.

The data cache is disabled by default. See enableCache

Parameters
[in]connectorThe baos connector. This is a shared pointer and is held for the life of this class.
[in]idThe datapoint id. In the range of 1 to 1000 (for 772, for 770/771: 250).
BaosDatapoint::BaosDatapoint ( std::shared_ptr< BaosConnector connector,
const ServerItem serverItem 
)

Creates a Baos Datapoint Object associated with a single Datapoint on the baos device.

This is effectively the same as the standard structure however it is also possible to set the default datapoint value data in the server item.

The data cache is enabled by default if serverItem data is not empty. That is, subsequent reads will read the data given in serverItem.

Parameters
[in]connectorThe baos connector. This is a shared pointer and is held for the life of this class.
[in]serverItemContains the datapoint id. In the range of 1 to 1000 (for 772, for 770/771: 250). Also contains a default datapoint value in the data buffer.
BaosDatapoint::~BaosDatapoint ( )

Destroys the Baos Datapoint.

The connector will be released.

Member Function Documentation

void BaosDatapoint::clearData ( )

Clears the internal data.

If the cache is enabled this will empty the data cache, so the next read will read from the baos device, and not from the cache.

void BaosDatapoint::clearTransmissionState ( )

requests that the transmission state is cleared.

like readNewValueViaBus it has no lasting effect on the command

void BaosDatapoint::disableCache ( )

disable the cache

void BaosDatapoint::enableCache ( bool  cacheEnabled)

enable the data cache

bool BaosDatapoint::get1BitControl ( )

get Datapoint DPT-2 (control)

bool BaosDatapoint::get1BitControlValue ( )

get Datapoint DPT-2 (value)

float BaosDatapoint::get2OctetFloat ( )

get Datapoint DPT-9, converts a KNX 2 byte float to a standard IEEE float

unsigned char BaosDatapoint::get2OctetFloatLsb ( )

get Datapoint DPT-9 (lsb)

unsigned char BaosDatapoint::get2OctetFloatMsb ( )

get Datapoint DPT-9 (msb)

short BaosDatapoint::get2OctetSigned ( )

get Datapoint DPT-8

unsigned short BaosDatapoint::get2OctetUnsigned ( )

get Datapoint DPT-7

bool BaosDatapoint::get3BitControl ( )

get Datapoint DPT-3 (control)

unsigned char BaosDatapoint::get3BitControlValue ( )

get Datapoint DPT-3 (value)

float BaosDatapoint::get4OctetFloat ( )

get Datapoint DPT-14

int BaosDatapoint::get4OctetSigned ( )

get Datapoint DPT-13

unsigned int BaosDatapoint::get4OctetUnsigned ( )

get Datapoint DPT-12

char BaosDatapoint::get8BitSigned ( )

get Datapoint DPT-6

unsigned char BaosDatapoint::get8BitUnsigned ( )

get Datapoint DPT-5

unsigned int BaosDatapoint::getAccessCode ( )

get Datapoint DPT-15 (code)

bool BaosDatapoint::getAccessDirection ( )

get Datapoint DPT-15 (direction)

bool BaosDatapoint::getAccessEncrypted ( )

get Datapoint DPT-15 (encrypted)

bool BaosDatapoint::getAccessError ( )

get Datapoint DPT-15 (error)

unsigned char BaosDatapoint::getAccessIndex ( )

get Datapoint DPT-15 (index)

bool BaosDatapoint::getAccessPermission ( )

get Datapoint DPT-15 (permission)

bool BaosDatapoint::getBoolean ( )

get Datapoint DPT-1

Examples:
BaosLightSwitcher.cpp.
unsigned char BaosDatapoint::getCharacterSet ( )

get Datapoint DPT-4

unsigned char BaosDatapoint::getCommand ( ) const

Returns the currently set Command.

This is one of the BaosDatapointCommands

const std::vector< unsigned char > & BaosDatapoint::getData ( )

Reads the value of the datapoint on the remote BAOS device associated with the current id.

It returns the raw Big Endian encoded byte stream. The datapoint values which are less than 1 byte (Boolean etc) are encoded as outlined in the BAOS protocol specification. It is preferable to use the specific type conversion functions to get the data.

Returns
a copy of the big-endian encoded raw datapoint value data buffer
Examples:
BaosEventListener.cpp.
const BaosDatapointDescription & BaosDatapoint::getDatapointDescription ( ) const

Gets the datapoint description from the device.

int BaosDatapoint::getDateDay ( )

get Datapoint DPT-11 (day)

int BaosDatapoint::getDateMonth ( )

get Datapoint DPT-11 (month)

int BaosDatapoint::getDateYear ( )

get Datapoint DPT-11 (year)

Note
The year is in KNX DPT11 format: 0..99; >=90 : 20th century; <90 : 21th century <> e.g. 99 => 1999; 0 => 2000
std::string BaosDatapoint::getDescriptionString ( )

Get the Description String associated with the datapoint.

Examples:
BaosLightSwitcher.cpp.
unsigned short BaosDatapoint::getId ( ) const

Returns the datapoint id.

Examples:
BaosEventListener.cpp, and BaosMultiConnector.cpp.
const ServerItem & BaosDatapoint::getServerItem ( ) const

Returns the associated server item.

This contains the associated id and data buffer.

std::string BaosDatapoint::getString ( )

get Datapoint DPT-16

int BaosDatapoint::getTimeDay ( )

get Datapoint DPT-10 (day)

int BaosDatapoint::getTimeHour ( )

get Datapoint DPT-10 (hour)

int BaosDatapoint::getTimeMinute ( )

get Datapoint DPT-10 (minute)

int BaosDatapoint::getTimeSecond ( )

get Datapoint DPT-10 (second)

int BaosDatapoint::getTransmissionStatus ( ) const

Returns one of the following transmission status values: TransmissionIdleOk TransmissionIdleError TransmissionInProgress TransmissionRequest.

bool BaosDatapoint::isDataRequest ( ) const

Returns true: Data request Returns false: Idle/response.

bool BaosDatapoint::isUpdate ( ) const

Returns true: Value is updated from the bus Returns false: Value was not updated.

bool BaosDatapoint::isValidFlag ( ) const

Returns true: Object has already been received Returns false: false Object value is unknown.

void BaosDatapoint::readNewValueViaBus ( )

requests a read value from the bus for this datapoint This uses the set datapoint value service with command set to ReadNewValueViaBus (just for this call) and this function has no lasting effect on the value of the command.

void BaosDatapoint::set1BitControl ( bool  control,
bool  value 
)

set Datapoint DPT-2

void BaosDatapoint::set2OctetFloat ( unsigned char  msb,
unsigned char  lsb 
)

set Datapoint DPT-9

void BaosDatapoint::set2OctetFloat ( float  f)

set Datapoint DPT-9, converts a standard IEEE float to a KNX 2 byte float

void BaosDatapoint::set2OctetSigned ( short  value)

set Datapoint DPT-8

void BaosDatapoint::set2OctetUnsigned ( unsigned short  value)

set Datapoint DPT-7

void BaosDatapoint::set3BitControl ( bool  control,
unsigned char  value 
)

set Datapoint DPT-3

void BaosDatapoint::set4OctetFloat ( float  value)

set Datapoint DPT-14

void BaosDatapoint::set4OctetSigned ( int  value)

set Datapoint DPT-13

void BaosDatapoint::set4OctetUnsigned ( unsigned int  value)

set Datapoint DPT-12

void BaosDatapoint::set8BitSigned ( char  value)

set Datapoint DPT-6

void BaosDatapoint::set8BitUnsigned ( unsigned char  value)

set Datapoint DPT-5

void BaosDatapoint::setAccess ( unsigned int  accessCode,
bool  error,
bool  permission,
bool  direction,
bool  encrypted,
unsigned char  index 
)

set Datapoint DPT-15

void BaosDatapoint::setBoolean ( bool  value)

set Datapoint DPT-1

Examples:
BaosLightSwitcher.cpp.
void BaosDatapoint::setCharacterSet ( unsigned char  value)

set Datapoint DPT-4

void BaosDatapoint::setCommand ( unsigned char  command)

Sets the Command.

This is one of the BaosDatapointCommands. When a datapoint value is set on the remote device it is accompanied by a command. This command defaults to: Set new value and send on bus. If you need to change the command you can do so with this function. The list of commands can be found in the protocol specification on page 19 or in core/API

void BaosDatapoint::setData ( const std::vector< unsigned char > &  data)

Sets the value of the datapoint on the remote BAOS device associated with the current id.

This function also sends the command byte, which can be configured with setCommand. Note: the length of data should correspond to the datapoint value length configured in the ETS project. Although you can use the command directly it is preferable to use the specific type conversion functions such as setBoolean, set8BitUnsigned etc. You should only really ever need to use this function if a conversion function is not available. Note: the data should be encoded as Big Endian.

Parameters
[in]dataA big-endian encoded byte stream between 1 and 14 bytes
void BaosDatapoint::setDate ( int  year,
int  month,
int  day 
)

set Datapoint DPT-11

Note
The year is in KNX DPT11 format: 0..99; >=90 : 20th century; <90 : 21th century <> e.g. 99 => 1999; 0 => 2000
void BaosDatapoint::setDateLocal ( )

set Datapoint DPT-11 (local)

void BaosDatapoint::setDateUTC ( )

set Datapoint DPT-11 (utc)

void BaosDatapoint::setId ( unsigned short  id)

Sets the datapoint id.

You can use this when you need to dynamically change the id that this Datapoint object refers to in the remote BAOS device. For example, if you have several datapoints all of the same type (a Boolean type for example) with contiguous ids you can iterate over the ids and set their corresponding values on the remove device using the one BaosDatapoint object.

void BaosDatapoint::setString ( const std::string &  str)

set Datapoint DPT-16

void BaosDatapoint::setTime ( int  day,
int  hour,
int  minute,
int  second 
)

set Datapoint DPT-10

void BaosDatapoint::setTimeLocal ( )

set Datapoint DPT-10 (local time)

void BaosDatapoint::setTimeUTC ( )

set Datapoint DPT-10 (utc time)


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