Changed RR handler to call Device_Objects_RR_Info directly.

Removed handler_rr_object_set and associated info. 
Simplified parameter passing to rr info functions by passing ptr to BACnet_Read_Range_Data.
This commit is contained in:
petermcs
2010-02-18 11:12:38 +00:00
parent d7d22234d4
commit 9c9e4b9603
7 changed files with 29 additions and 58 deletions
+3 -11
View File
@@ -36,20 +36,12 @@
#include "npdu.h"
#include "abort.h"
#include "readrange.h"
#include "device.h"
/** @file h_rr.c Handles Read Range requests. */
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
static get_rr_info_fn get_rr_info;
void handler_rr_object_set(
get_rr_info_fn pFunction1)
{
get_rr_info = pFunction1;
}
/* Encodes the property APDU and returns the length,
or sets the error, and returns -1 */
int Encode_RR_payload(
@@ -65,9 +57,9 @@ int Encode_RR_payload(
pRequest->error_code = ERROR_CODE_OTHER;
/* handle each object type */
info_fn_ptr = *get_rr_info(pRequest->object_type);
info_fn_ptr = Device_Objects_RR_Info(pRequest->object_type);
if ((get_rr_info != NULL) && (info_fn_ptr(pRequest->object_instance, pRequest->object_property, &PropInfo, &pRequest->error_class, &pRequest->error_code) != false)) {
if ((info_fn_ptr != NULL) && (info_fn_ptr(pRequest, &PropInfo) != false)) {
/* We try and do some of the more generic error checking here to cut down on duplication of effort */
if((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) {/* First index is 1 so can't accept 0 */
+9 -15
View File
@@ -1395,8 +1395,6 @@ void Device_Init(
{
struct object_functions *pObject = NULL;
handler_rr_object_set(Device_Objects_RR_Info);
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Init) {
@@ -1407,16 +1405,12 @@ void Device_Init(
}
bool DeviceGetRRInfo(
uint32_t object, /* Which particular object - obviously not important for device object */
BACNET_PROPERTY_ID property, /* Which property */
RR_PROP_INFO *pInfo, /* Where to put the information */
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
RR_PROP_INFO *pInfo) /* Where to put the response */
{
bool status = false; /* return value */
object = object;
switch(property) {
switch(pRequest->object_property) {
case PROP_VT_CLASSES_SUPPORTED:
case PROP_ACTIVE_VT_SESSIONS:
case PROP_LIST_OF_SESSION_KEYS:
@@ -1426,8 +1420,8 @@ bool DeviceGetRRInfo(
case PROP_RESTART_NOTIFICATION_RECIPIENTS:
case PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS:
pInfo->RequestTypes = RR_BY_POSITION;
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
pRequest->error_class = ERROR_CLASS_PROPERTY;
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
break;
case PROP_DEVICE_ADDRESS_BINDING:
@@ -1438,12 +1432,12 @@ bool DeviceGetRRInfo(
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
pInfo->RequestTypes = RR_BY_POSITION;
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
pRequest->error_class = ERROR_CLASS_PROPERTY;
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
break;
default:
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
pRequest->error_class = ERROR_CLASS_SERVICES;
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
break;
}
+8 -11
View File
@@ -907,22 +907,19 @@ void TrendLog_Init(
}
bool TrendLogGetRRInfo(
uint32_t Object, /* Which particular object */
BACNET_PROPERTY_ID Property, /* Which property */
RR_PROP_INFO *pInfo, /* Where to put the information */
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
RR_PROP_INFO *pInfo) /* Where to put the information */
{
if(Object >= MAX_TREND_LOGS) {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
} else if(Property == PROP_LOG_BUFFER) {
if(pRequest->object_instance >= MAX_TREND_LOGS) {
pRequest->error_class = ERROR_CLASS_OBJECT;
pRequest->error_code = ERROR_CODE_UNKNOWN_OBJECT;
} else if(pRequest->object_property == PROP_LOG_BUFFER) {
pInfo->RequestTypes = RR_BY_POSITION | RR_BY_TIME | RR_BY_SEQUENCE;
pInfo->Handler = rr_trend_log_encode;
return(true);
} else {
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
pRequest->error_class = ERROR_CLASS_SERVICES;
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
}
return(false);
+5 -5
View File
@@ -73,6 +73,9 @@ extern "C" {
bool Device_Reinitialize(
BACNET_REINITIALIZE_DEVICE_DATA *rd_data);
rr_info_function Device_Objects_RR_Info(
BACNET_OBJECT_TYPE object_type);
void Device_Property_Lists(
const int **pRequired,
const int **pOptional,
@@ -174,11 +177,8 @@ extern "C" {
BACNET_WRITE_PROPERTY_DATA * wp_data);
bool DeviceGetRRInfo(
uint32_t Object, /* Which particular object - obviously not important for device object */
BACNET_PROPERTY_ID Property, /* Which property */
RR_PROP_INFO *pInfo, /* Where to put the information */
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code);
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
RR_PROP_INFO *pInfo); /* Where to put the information */
#ifdef __cplusplus
-3
View File
@@ -80,9 +80,6 @@ extern "C" {
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data);
void handler_rr_object_set(
get_rr_info_fn pFunction1);
void handler_read_property_ack(
uint8_t * service_request,
uint16_t service_len,
+2 -8
View File
@@ -127,14 +127,8 @@ typedef struct rrpropertyinfo {
/* Function pointer for ReadRange information retrieval function */
typedef bool (*rr_info_function) (
uint32_t Object, /* Which particular object instance (we know the type implicetly) */
BACNET_PROPERTY_ID Property, /* Which property */
RR_PROP_INFO *pInfo, /* Where to write the response to */
BACNET_ERROR_CLASS *error_class, /* Somewhere to write error responses to */
BACNET_ERROR_CODE *error_code);
typedef rr_info_function (*get_rr_info_fn) (
BACNET_OBJECT_TYPE object_type);
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
RR_PROP_INFO *pInfo); /* Where to write the response to */
int rr_encode_apdu(
uint8_t * apdu,
+2 -5
View File
@@ -97,11 +97,8 @@ extern "C" {
BACNET_READ_RANGE_DATA *pRequest);
bool TrendLogGetRRInfo(
uint32_t Object, /* Which particular object */
BACNET_PROPERTY_ID Property, /* Which property */
RR_PROP_INFO *pInfo, /* Where to put the information */
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code);
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
RR_PROP_INFO *pInfo); /* Where to put the information */
int rr_trend_log_encode(
uint8_t *apdu,