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

Reads the datapoint descriptions from the baos server and stores the datapoint descriptions internally. More...

#include <BaosDatapointDescriptions.h>

Public Types

typedef std::map< unsigned int, BaosDatapointDescriptionDescriptions
 

Public Member Functions

 BaosDatapointDescriptions (std::shared_ptr< BaosConnector > connector)
 Creates a empty BaosDatapointDescriptions object. More...
 
 ~BaosDatapointDescriptions ()
 Destroys the Baos Datapoint Descriptions object. More...
 
void clear ()
 Clears the internally stored values. More...
 
void erase (unsigned short startId, unsigned short count)
 Clears the internally stored values from datapoint ids between startId and (startId + count) - 1. More...
 
void readFromDevice ()
 Reads all datapoint descriptions from the baos server when it is possible to determine how many datapoints have been allocated. More...
 
void readFromDevice (unsigned short startId, unsigned short count)
 Requests a range of datapoint descriptions from the baos server. More...
 
unsigned short getCount () const
 Returns the number of datapoint descriptors. More...
 
const BaosDatapointDescriptionat (unsigned int id) const
 Returns a single datapoint description by id. More...
 
const BaosDatapointDescriptionget (unsigned int id) const
 Returns a single datapoint description by id. More...
 
bool has (unsigned int id) const
 Returns true if a datapoint description is found with this id. More...
 
const DescriptionsgetDescriptions () const
 Returns the datapoint descriptions. More...
 
std::vector< BaosDatapointDescriptiongetList () const
 Returns the list of datapoint descriptions. More...
 

Detailed Description

Reads the datapoint descriptions from the baos server and stores the datapoint descriptions internally.

This retrieval can be done with readFromDevice.

// Read datapoint descriptions
void readDatapointDescriptions(BaosConnector::Ptr connector)
{
try
{
BaosDatapointDescriptions baosDatapointDescriptions(connector);
baosDatapointDescriptions.readFromDevice();
const BaosDatapointDescriptions::Descriptions descriptions = baosDatapointDescriptions.getDescriptions();
const unsigned int count = descriptions.size();
std::cout << count << " items found" << std::endl;
for (const auto& item : descriptions)
{
const BaosDatapointDescription& desc = item.second;
std::cout << std::endl;
std::cout << "Datapoint id: " << desc.getId() << std::endl;
std::cout << "Datapoint type: " << desc.getDatapointType() << std::endl;
}
}
catch (Exception& exception)
{
std::cerr << exception.displayText() << std::endl;
}
}
Examples:
BaosDatapointDescription.cpp, BaosMultiThreaded.cpp, BaosSerial.cpp, and BaosUsb.cpp.

Member Typedef Documentation

Constructor & Destructor Documentation

BaosDatapointDescriptions::BaosDatapointDescriptions ( std::shared_ptr< BaosConnector connector)

Creates a empty BaosDatapointDescriptions object.

Note
The description will not read automatic in the constructor. You need call readFromDevice for initial reading.
BaosDatapointDescriptions::~BaosDatapointDescriptions ( )

Destroys the Baos Datapoint Descriptions object.

Member Function Documentation

const BaosDatapointDescription & BaosDatapointDescriptions::at ( unsigned int  id) const

Returns a single datapoint description by id.

If a corresponding description is not found with this id an exception is throw

Deprecated:
use get instead
void BaosDatapointDescriptions::clear ( )

Clears the internally stored values.

void BaosDatapointDescriptions::erase ( unsigned short  startId,
unsigned short  count 
)

Clears the internally stored values from datapoint ids between startId and (startId + count) - 1.

const BaosDatapointDescription & BaosDatapointDescriptions::get ( unsigned int  id) const

Returns a single datapoint description by id.

If a corresponding description is not found with this id an exception is throw

unsigned short BaosDatapointDescriptions::getCount ( ) const

Returns the number of datapoint descriptors.

const BaosDatapointDescriptions::Descriptions & BaosDatapointDescriptions::getDescriptions ( ) const

Returns the datapoint descriptions.

Examples:
BaosDatapointDescription.cpp, and BaosMultiThreaded.cpp.
std::vector< BaosDatapointDescription > BaosDatapointDescriptions::getList ( ) const

Returns the list of datapoint descriptions.

bool BaosDatapointDescriptions::has ( unsigned int  id) const

Returns true if a datapoint description is found with this id.

void BaosDatapointDescriptions::readFromDevice ( )

Reads all datapoint descriptions from the baos server when it is possible to determine how many datapoints have been allocated.

This is either via the protocol version (i.e. protocol version 1.2 has a max of 250 datapoints) or via the server item getMaxDatapoints. If the limit can not be found we try to read a max of 1000 datapoints. The block size is calculated with the server item current buffer size.

Examples:
BaosDatapointDescription.cpp, and BaosMultiThreaded.cpp.
void BaosDatapointDescriptions::readFromDevice ( unsigned short  startId,
unsigned short  count 
)

Requests a range of datapoint descriptions from the baos server.

Before the new values are read the current values from the request range are erased.

Parameters
startIdthe id of the first datapoint
countthe number of datapoints to read
Returns
the datapoint id of the last get descriptions

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