upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
BACNETUTIL Class Reference

UPM Utility API for BACnet. More...

Detailed Description

This class implements some common access functions that are useful to any driver making use of the bacnetmstp driver.

It provides some basic functionality for reading and writing a proprty (with and without relability checking) as well as access to error conditions. It is intended to be inherited by your driver class.

Data Structures

struct  binaryData_t
 
struct  multiStateData_t
 

Public Member Functions

 BACNETUTIL (uint32_t targetDeviceObjectID)
 
virtual ~BACNETUTIL ()
 
virtual void initMaster (std::string port, int baudRate, int deviceInstanceNumber, int macAddr, int maxMaster=DEFAULT_MAX_MASTER, int maxInfoFrames=1)
 
virtual void setDebug (bool enable)
 
virtual float getAnalogValue (uint32_t objInstance)
 
virtual void setAnalogValue (uint32_t objInstance, float value)
 
virtual float getAnalogInput (uint32_t objInstance)
 
virtual std::string getAnalogValueUnits (uint32_t objInstance)
 
virtual std::string getAnalogInputUnits (uint32_t objInstance)
 
virtual bool getBinaryInput (uint32_t objInstance)
 
virtual std::string lookupBinaryInputText (uint32_t objInstance, bool value)
 
virtual std::string getBinaryInputText (uint32_t objInstance)
 
virtual bool getBinaryValue (uint32_t objInstance)
 
virtual void setBinaryValue (uint32_t objInstance, bool value)
 
virtual std::string lookupBinaryValueText (uint32_t objInstance, bool value)
 
virtual std::string getBinaryValueText (uint32_t objInstance)
 
virtual unsigned int getMultiStateValue (uint32_t objInstance)
 
virtual std::string lookupMultiStateValueText (uint32_t objInstance, unsigned int value)
 
virtual std::string getMultiStateValueText (uint32_t objInstance)
 
virtual unsigned int getMultiStateValueMaxStates (uint32_t objInstance)
 
virtual void setMultiStateValue (uint32_t objInstance, unsigned int value)
 
virtual void checkReliability (bool enable)
 
virtual std::string getDeviceDescription ()
 
virtual std::string getDeviceLocation ()
 
virtual bool setDeviceLocation (std::string location)
 
virtual std::string getDeviceName ()
 
virtual bool setDeviceName (std::string name)
 
virtual std::string getAllErrorString ()
 
virtual BACNETMSTP::BACERR_TYPE_T getErrorType ()
 
virtual uint8_t getRejectReason ()
 
virtual std::string getRejectString ()
 
virtual uint8_t getAbortReason ()
 
virtual std::string getAbortString ()
 
virtual BACNET_ERROR_CLASS getErrorClass ()
 
virtual BACNET_ERROR_CODE getErrorCode ()
 
virtual std::string getErrorString ()
 
virtual std::string getUPMErrorString ()
 

Protected Types

typedef std::map< uint32_t, binaryData_tbinaryInfo_t
 
typedef std::map< uint32_t, multiStateData_tmultiStateInfo_t
 
typedef std::map< uint32_t, std::string > avCacheMap_t
 
typedef std::map< uint32_t, std::string > aiCacheMap_t
 

Protected Member Functions

virtual void updateMultiStateValueInfo (uint32_t objInstance)
 
virtual void deleteMultiStateValueInfo (uint32_t objInstance)
 
virtual void updateBinaryValueInfo (uint32_t objInstance)
 
virtual void deleteBinaryValueInfo (uint32_t objInstance)
 
virtual void updateBinaryInputInfo (uint32_t objInstance)
 
virtual void deleteBinaryInputInfo (uint32_t objInstance)
 

Protected Attributes

bool m_debugging
 
bool m_checkReliability
 
uint32_t m_targetDeviceObjectID
 
BACNETMSTPm_instance
 
bool m_initialized
 
binaryInfo_t m_bvInfo
 
binaryInfo_t m_biInfo
 
multiStateInfo_t m_msvInfo
 
avCacheMap_t m_avUnitCache
 
aiCacheMap_t m_aiUnitCache
 

Constructor & Destructor Documentation

BACNETUTIL ( uint32_t  targetDeviceObjectID)

BACNETUTIL constructor

Here is the call graph for this function:

~BACNETUTIL ( )
virtual

BACNETUTIL Destructor

Member Function Documentation

void initMaster ( std::string  port,
int  baudRate,
int  deviceInstanceNumber,
int  macAddr,
int  maxMaster = DEFAULT_MAX_MASTER,
int  maxInfoFrames = 1 
)
virtual

This function initializes the underlying BACNETMSTP Master singleton in the event it has not already been initialized. If the BACNETMSTP Master singleton has already been initialized, then this call will be ignored.

Parameters
portThe serial port that the RS-485 interface is connected to.
baudRateThe baudrate of the RS-485 interface. All devices on a BACnet RS-485 bus must run at the same baudrate. Valid values are 9600, 19200, 38400, 57600, 76800, and 115200.
deviceInstanceNumberThis is the unique Device Object Instance number that will be used for our BACnet Master in order to communicate over the BACnet interface. This number must be between 1-4194302 and must be unique on the BACnet network.
macAddrThis is the MAC address of our BACnet Master. It must be unique on the BACnet segment, and must be between 1-127.
maxMasterThis specifies to our Master the maximum MAC address used by any other Masters on the BACnet network. This must be between 1-127, the default is 127. Do not change this unless you know what you are doing or you could introduce token passing errors on the BACnet network.
maxInfoFramesThis number specifies the maximum number of transmissions (like requests for data) our Master is allowed to make before passing the token to the next Master. The default is 1.

Here is the call graph for this function:

void setDebug ( bool  enable)
virtual

Enable some debugging output in this module as well as the BACNETMSTP module. Debugging is disabled by default.

Parameters
enabletrue to enable, false to disable.

Here is the call graph for this function:

Here is the caller graph for this function:

float getAnalogValue ( uint32_t  objInstance)
virtual

Retrieve the Present_Value property of an Analog Value object. If checkReliability() has been enabled, then the Reliability property of the object will be retrieved first. If the Reliability property is anything other than RELIABILITY_NO_FAULT_DETECTED, then the method will throw. Reliability checking is disabled by default for performance reasons.

Parameters
objInstanceThe Analog Value Object instance.
Returns
The floating point value requested.

Here is the call graph for this function:

Here is the caller graph for this function:

void setAnalogValue ( uint32_t  objInstance,
float  value 
)
virtual

Set the Present_Value property of an Analog Value object. This method will throw on an error.

Parameters
objInstanceThe Analog Value Object instance.
valueThe data value to write.

Here is the call graph for this function:

Here is the caller graph for this function:

float getAnalogInput ( uint32_t  objInstance)
virtual

Retrieve the Present_Value property of an Analog Input object. If checkReliability() has been enabled, then the Reliability property of the object will be retrieved first. If the Reliability property is anything other than RELIABILITY_NO_FAULT_DETECTED, then the method will throw. Reliability checking is disabled by default for performance reasons.

Parameters
objInstanceThe Analog Input Object instance.
Returns
the floating point value requested.

Here is the call graph for this function:

Here is the caller graph for this function:

string getAnalogValueUnits ( uint32_t  objInstance)
virtual

Query an Analog Value object for the unit code, translate it into a string and cache the result for future use. Return the BACnet text for the Unit enumeration. Unit enumerations are things like 'kilowatt-hours', 'volts', etc. For Objects which do not have a Units property defined for them, or for which Units has no meaning, 'no-units' will typically be returned and cached for the object.

Parameters
objInstanceThe Analog Value Object instance.
Returns
A string representing the Object's Unit property.

Here is the call graph for this function:

string getAnalogInputUnits ( uint32_t  objInstance)
virtual

Query an Analog Input object for the unit code, translate it into a string and cache the result for future use. Return the BACnet text for the Unit enumeration. Unit enumerations are things like 'kilowatt-hours', 'volts', etc. For Objects which do not have a Units property defined for them, or for which Units has no meaning, 'no-units' will typically be returned and cached for the object.

Parameters
objInstanceThe Analog Input Object instance.
Returns
A string representing the Object's Unit property.

Here is the call graph for this function:

bool getBinaryInput ( uint32_t  objInstance)
virtual

Retrieve the Present_Value property of a Binary Input object. If checkReliability() has been enabled, then the Reliability property of the object will be retrieved first. If the Reliability property is anything other than RELIABILITY_NO_FAULT_DETECTED, then the method will throw. Reliability checking is disabled by default for performance reasons.

Parameters
objInstanceThe Object Instance number to query
Returns
the boolean point value requested

Here is the call graph for this function:

Here is the caller graph for this function:

string lookupBinaryInputText ( uint32_t  objInstance,
bool  value 
)
virtual

Lookup (retrieve if necessary) the Inactive_Text and Active_Text properties of a Binary Input object. These text properties are optional and can provide a string representing a given state (true/false) that can be more informational than just the boolean value the object represents. This is useful in applications that display this data to a user for example. If this text is not present in the object (as it is not required), then a string representation of the value will be returned instead ("active" and "inactive").

Parameters
objInstanceThe Object Instance number of the object
valueThe value you want to lookup the text representation for.
Returns
The string representing the value.

Here is the caller graph for this function:

string getBinaryInputText ( uint32_t  objInstance)
virtual

Return a string representation of the Present_Value property of a BinaryInput object. This method just calls getBinaryInput() on the object, uses lookupBinaryInputText() to lookup the corresponding text value, and returns the result.

Parameters
objInstanceThe Object Instance number of the object.
Returns
The string representing the value.

Here is the call graph for this function:

bool getBinaryValue ( uint32_t  objInstance)
virtual

Retrieve the Present_Value property of a Binary Value object. If checkReliability() has been enabled, then the Reliability property of the object will be retrieved first. If the Reliability property is anything other than RELIABILITY_NO_FAULT_DETECTED, then the method will throw. Reliability checking is disabled by default for performance reasons.

Parameters
objInstanceThe Object Instance number to query
Returns
the boolean point value requested

Here is the call graph for this function:

Here is the caller graph for this function:

void setBinaryValue ( uint32_t  objInstance,
bool  value 
)
virtual

Set the Present_Value property of a Binary Value object. This method will throw on an error.

Parameters
objInstanceThe Analog Value Object instance.
valueThe data value to write

Here is the call graph for this function:

Here is the caller graph for this function:

string lookupBinaryValueText ( uint32_t  objInstance,
bool  value 
)
virtual

Lookup (retrieve if necessary) the Inactive_Text and Active_Text properties of a Binary Value object. These text properties are optional and can provide a string representing a given state (true/false) that can be more informational than just the boolean value the object represents. This is useful in applications that display this data to a user for example. If this text is not present in the object (as it is not required), then a string representation of the value will be returned instead ("active" and "inactive").

Parameters
objInstanceThe Object Instance number of the object.
valueThe value you want to lookup the text representation for.
Returns
The string representing the value.

Here is the caller graph for this function:

string getBinaryValueText ( uint32_t  objInstance)
virtual

Return a string representation of the Present_Value property of a Binary Value object. This method just calls getBinaryValue() on the object, uses lookupBinaryValueText() to lookup the corresponding text value, and returns the result.

Parameters
objInstanceThe Object Instance number of the object.
Returns
The string representing the value.

Here is the call graph for this function:

unsigned int getMultiStateValue ( uint32_t  objInstance)
virtual

Retrieve the Present_Value property of a Multi State Value object. If checkReliability() has been enabled, then the Reliability property of the object will be retrieved first. If the Reliability property is anything other than RELIABILITY_NO_FAULT_DETECTED, then the method will throw. Reliability checking is disabled by default for performance reasons.

Parameters
objInstanceThe Object Instance number to query.
Returns
The Present_Value property of the object.

Here is the call graph for this function:

Here is the caller graph for this function:

string lookupMultiStateValueText ( uint32_t  objInstance,
unsigned int  value 
)
virtual

Lookup (retrieve if necessary) the State_Text strings corresponding to the supplied value of a MultiStateValue object. State_Text is an optional property that can provide strings representing a given state that can be more informational than just the unsigned integer the object represents. This is useful in applications that display this data to a user for example. If this text is not present in the object (as it is not required), then a string representation of the integer value will be returned instead.

Parameters
objInstanceThe Object Instance number of the object.
valueThe value you want to lookup the text representation for.
Returns
The string representing the value.

Here is the caller graph for this function:

string getMultiStateValueText ( uint32_t  objInstance)
virtual

Return a string representation of the Present_Value property of a MultiStateValue object. This method just calls getMultiStateValue() on the object, uses lookupMultiStateValueText() to lookup the corresponding State_Text value, and returns the result.

Parameters
objInstanceThe Object Instance number of the object.
Returns
The string representing the value.

Here is the call graph for this function:

unsigned int getMultiStateValueMaxStates ( uint32_t  objInstance)
virtual

Return the maximum legal value of a Multi State Value Object. The value represents the highest value the Present_Value porperty of the object will allow.

Parameters
objInstanceThe Object Instance number of the object.
Returns
The highest Present_Value the object supports.
void setMultiStateValue ( uint32_t  objInstance,
unsigned int  value 
)
virtual

Set the Present_Value property of a Multi State Value object. The value provided must not be 0, and must not exceed the object's Number_Of_States property. Use getMultiStateValueMaxStates() to determine the maximum value the object supports. This method will throw on an error.

Parameters
objInstanceThe MultiStateValue Object instance.
valueThe data value to write.

Here is the call graph for this function:

virtual void checkReliability ( bool  enable)
inlinevirtual

Enable or disable reliability checking. When retrieving data, the Present_Value property is returned. There is also an optional property called Reliability that can be checked to ensure that the Present_Value property is currently valid.

Enabling Reliability Checking has the data retrieval functions check for a RELIABILITY_NO_FAULT_DETECTED value for the Reliability property before querying the Present_Value property. If anything other than RELIABILITY_NO_FAULT_DETECTED is set, then the method will throw.

This checking is disabled by default since it will double the number of queries needed to retrieve a given value. In addition, since it is an optional property, calling it for an object that does not support it will also throw. However, if you need to ensure that the values returned are always completely valid as determined by the device firmware, and the objects you are querying support the reliability property, you can enable this.

Parameters
enabletrue to check Reliability before returning a value, false otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

string getDeviceDescription ( )
virtual

Query the Device Object of the device and return it's Description property. This typically contains information like the Vendor, model and serial number of a device.

Returns
A string containing the Device Object's Description property.

Here is the call graph for this function:

Here is the caller graph for this function:

string getDeviceLocation ( )
virtual

Query the Device Object of the device and return it's Location property. This typically contains a string indication of a customer specific value. Use setLocation() to change.

Returns
A string containing the Device Object's Location property.

Here is the call graph for this function:

Here is the caller graph for this function:

bool setDeviceLocation ( std::string  location)
virtual

Set the Device Object's Location property. This must be a string containing no more than 63 characters. Not all devices allow setting the location.

Parameters
locationThe new location to set, if supported.
Returns
true if the operation succeeded, otherwise false.

Here is the call graph for this function:

Here is the caller graph for this function:

string getDeviceName ( )
virtual

Query the Device Object of the device and return it's Name property. This should contain a unique string value. Use setName() to change. Note, according to the spec, the Device Object Name must be unique within a given BACnet network.

Returns
A string containing the Object's Name property.

Here is the call graph for this function:

Here is the caller graph for this function:

bool setDeviceName ( std::string  name)
virtual

Set the Device Object's Name property. This must be a string containing at least one character and no more than 63 characters. Note, according to the spec, the Device Object Name must be unique within a given BACnet network.

Parameters
nameThe name to set.
Returns
true if the operation succeeded, false otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

string getAllErrorString ( )
virtual

This is a utility function that will return a string reporting on the various types of errors that can occur in BACnet operation.

Returns
A string containing the last error message.

Here is the call graph for this function:

Here is the caller graph for this function:

BACNETMSTP::BACERR_TYPE_T getErrorType ( )
virtual

Return an enumration of the last error type to occur. The value returned will be one of the BACNETMSTP::BACERR_TYPE_T values.

Returns
The last error type to occur, one of the BACNETMSTP::BACERR_TYPE_T values.

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t getRejectReason ( )
virtual

In the event of a BACnet Reject error, return the error code.

Returns
The Reject error code.

Here is the call graph for this function:

Here is the caller graph for this function:

string getRejectString ( )
virtual

In the event of a BACnet Reject error, return the error string.

Returns
The Reject error string.

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t getAbortReason ( )
virtual

In the event of a BACnet Abort error, return the Abort reason code.

Returns
The Abort reason code.

Here is the call graph for this function:

Here is the caller graph for this function:

string getAbortString ( )
virtual

In the event of a BACnet Abort error, return the Abort string.

Returns
The Abort error string.

Here is the call graph for this function:

Here is the caller graph for this function:

BACNET_ERROR_CLASS getErrorClass ( )
virtual

In the event of a general BACnet error, return the BACnet error class.

Returns
One of the BACNET_ERROR_CLASS error class codes

Here is the call graph for this function:

Here is the caller graph for this function:

BACNET_ERROR_CODE getErrorCode ( )
virtual

In the event of a general BACnet error, return the BACnet error code.

Returns
One of the BACNET_ERROR_CODE error codes

Here is the call graph for this function:

Here is the caller graph for this function:

string getErrorString ( )
virtual

In the event of a general BACnet error, return the BACnet error string.

Returns
A string representing the BACnet error class and code.

Here is the call graph for this function:

Here is the caller graph for this function:

string getUPMErrorString ( )
virtual

In the event of a non-BACnet UPM error, return a string describing the error.

Returns
A string representing the UPM error.

Here is the call graph for this function:

Here is the caller graph for this function:

Inheritance diagram for BACNETUTIL:
Inheritance graph
[legend]
Collaboration diagram for BACNETUTIL:
Collaboration graph
[legend]

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