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);