From 9c9e4b96036a1482b22f44a3b65b9be65f79d8ac Mon Sep 17 00:00:00 2001 From: petermcs Date: Thu, 18 Feb 2010 11:12:38 +0000 Subject: [PATCH] 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. --- bacnet-stack/demo/handler/h_rr.c | 14 +++----------- bacnet-stack/demo/object/device.c | 24 +++++++++--------------- bacnet-stack/demo/object/trendlog.c | 19 ++++++++----------- bacnet-stack/include/device.h | 10 +++++----- bacnet-stack/include/handlers.h | 3 --- bacnet-stack/include/readrange.h | 10 ++-------- bacnet-stack/include/trendlog.h | 7 ++----- 7 files changed, 29 insertions(+), 58 deletions(-) diff --git a/bacnet-stack/demo/handler/h_rr.c b/bacnet-stack/demo/handler/h_rr.c index 6f29dabf..901cdbf9 100644 --- a/bacnet-stack/demo/handler/h_rr.c +++ b/bacnet-stack/demo/handler/h_rr.c @@ -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 */ diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index b39e1033..a95539ce 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -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; } diff --git a/bacnet-stack/demo/object/trendlog.c b/bacnet-stack/demo/object/trendlog.c index 82e8e247..ad9d1446 100644 --- a/bacnet-stack/demo/object/trendlog.c +++ b/bacnet-stack/demo/object/trendlog.c @@ -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); diff --git a/bacnet-stack/include/device.h b/bacnet-stack/include/device.h index c5febd85..2758045a 100644 --- a/bacnet-stack/include/device.h +++ b/bacnet-stack/include/device.h @@ -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 diff --git a/bacnet-stack/include/handlers.h b/bacnet-stack/include/handlers.h index da93ffd8..00b5b92f 100644 --- a/bacnet-stack/include/handlers.h +++ b/bacnet-stack/include/handlers.h @@ -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, diff --git a/bacnet-stack/include/readrange.h b/bacnet-stack/include/readrange.h index 8be7efd5..e0ba6b57 100644 --- a/bacnet-stack/include/readrange.h +++ b/bacnet-stack/include/readrange.h @@ -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, diff --git a/bacnet-stack/include/trendlog.h b/bacnet-stack/include/trendlog.h index 9ebc97c0..b63dda4c 100644 --- a/bacnet-stack/include/trendlog.h +++ b/bacnet-stack/include/trendlog.h @@ -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,