Added function to determine if an object property is a BACnetARRAY. (#642)
* Added function to determine if an object property is a BACnetARRAY. Added property test for BACnetARRAY members.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "bacnet/npdu.h"
|
||||
#include "bacnet/abort.h"
|
||||
#include "bacnet/proplist.h"
|
||||
#include "bacnet/property.h"
|
||||
#include "bacnet/reject.h"
|
||||
#include "bacnet/rp.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
@@ -66,14 +67,6 @@ static const int Properties_Optional[] = {
|
||||
static const int Properties_Proprietary[] = {
|
||||
-1
|
||||
};
|
||||
|
||||
/* standard properties that are arrays for this object,
|
||||
but not necessary supported in this object */
|
||||
static const int BACnetARRAY_Properties[] = {
|
||||
PROP_SUBORDINATE_LIST, PROP_SUBORDINATE_ANNOTATIONS, PROP_SUBORDINATE_TAGS,
|
||||
PROP_SUBORDINATE_NODE_TYPES, PROP_SUBORDINATE_RELATIONSHIPS, PROP_TAGS,
|
||||
-1
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
/**
|
||||
@@ -633,16 +626,6 @@ int Structured_View_Subordinate_Relationships_Element_Encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if the object property is a BACnetARRAY property
|
||||
* @param object_property - object-property to be checked
|
||||
* @return true if the property is a BACnetARRAY property
|
||||
*/
|
||||
static bool BACnetARRAY_Property(int object_property)
|
||||
{
|
||||
return property_list_member(BACnetARRAY_Properties, object_property);
|
||||
}
|
||||
|
||||
/**
|
||||
* ReadProperty handler for this object. For the given ReadProperty
|
||||
* data, the application_data is loaded or the error flags are set.
|
||||
@@ -660,12 +643,12 @@ int Structured_View_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
uint32_t count = 0;
|
||||
uint8_t *apdu = NULL;
|
||||
uint16_t apdu_max = 0;
|
||||
bool is_array = false;
|
||||
|
||||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||
(rpdata->application_data_len == 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
apdu = rpdata->application_data;
|
||||
apdu_max = rpdata->application_data_len;
|
||||
switch (rpdata->object_property) {
|
||||
@@ -775,7 +758,9 @@ int Structured_View_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
}
|
||||
/* only array properties can have array options */
|
||||
if ((apdu_len >= 0) && (!BACnetARRAY_Property(rpdata->object_property)) &&
|
||||
is_array = property_list_bacnet_array_member(
|
||||
rpdata->object_type, rpdata->object_property);
|
||||
if ((apdu_len >= 0) && (!is_array) &&
|
||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
|
||||
@@ -63,9 +63,10 @@ static const int Time_Value_Properties_Proprietary[] = { -1 };
|
||||
|
||||
/* standard properties that are arrays for this object,
|
||||
but not necessary supported in this object */
|
||||
static const int BACnetARRAY_Properties[] = { PROP_EVENT_TIME_STAMPS,
|
||||
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
|
||||
PROP_VALUE_SOURCE_ARRAY, PROP_COMMAND_TIME_ARRAY, PROP_TAGS, -1 };
|
||||
static const int BACnetARRAY_Properties[] = {
|
||||
PROP_PRIORITY_ARRAY, PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
|
||||
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_VALUE_SOURCE_ARRAY,
|
||||
PROP_COMMAND_TIME_ARRAY, PROP_TAGS, -1 };
|
||||
|
||||
/**
|
||||
* Returns the list of required, optional, and proprietary properties.
|
||||
|
||||
+103
-33
@@ -1,36 +1,14 @@
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2012 Steve Karg
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
/**
|
||||
* @file
|
||||
* @brief Static sets of BACnet Property members for each object type
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2012
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
@@ -45,6 +23,10 @@
|
||||
#define BACNET_PROPERTY_LISTS 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_PROPERTY_ARRAY_LISTS
|
||||
#define BACNET_PROPERTY_ARRAY_LISTS 0
|
||||
#endif
|
||||
|
||||
#if BACNET_PROPERTY_LISTS
|
||||
/** @file property.c List of Required and Optional object properties */
|
||||
/* note: the PROP_PROPERTY_LIST is NOT included in these lists, on purpose */
|
||||
@@ -416,6 +398,19 @@ static const int Color_Properties_Optional[] = { PROP_RELIABILITY,
|
||||
PROP_AUDITABLE_OPERATIONS, PROP_TAGS, PROP_PROFILE_LOCATION,
|
||||
PROP_PROFILE_NAME, -1 };
|
||||
|
||||
static const int Color_Temperature_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_COLOR_COMMAND,
|
||||
PROP_IN_PROGRESS, PROP_DEFAULT_COLOR_TEMPERATURE, PROP_DEFAULT_FADE_TIME,
|
||||
PROP_DEFAULT_RAMP_RATE, PROP_DEFAULT_STEP_INCREMENT, -1
|
||||
};
|
||||
|
||||
static const int Color_Temperature_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_MIN_PRES_VALUE, PROP_MAX_PRES_VALUE,
|
||||
PROP_TRANSITION, PROP_VALUE_SOURCE, PROP_AUDIT_LEVEL,
|
||||
PROP_AUDITABLE_OPERATIONS, PROP_TAGS, PROP_PROFILE_LOCATION,
|
||||
PROP_PROFILE_NAME, -1 };
|
||||
|
||||
static const int Credential_Data_Input_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_RELIABILITY,
|
||||
@@ -1166,6 +1161,9 @@ const int *property_list_optional(BACNET_OBJECT_TYPE object_type)
|
||||
case OBJECT_COLOR:
|
||||
pList = Color_Properties_Optional;
|
||||
break;
|
||||
case OBJECT_COLOR_TEMPERATURE:
|
||||
pList = Color_Temperature_Properties_Optional;
|
||||
break;
|
||||
case OBJECT_CREDENTIAL_DATA_INPUT:
|
||||
pList = Credential_Data_Input_Properties_Optional;
|
||||
break;
|
||||
@@ -1374,6 +1372,9 @@ const int *property_list_required(BACNET_OBJECT_TYPE object_type)
|
||||
case OBJECT_COLOR:
|
||||
pList = Color_Properties_Required;
|
||||
break;
|
||||
case OBJECT_COLOR_TEMPERATURE:
|
||||
pList = Color_Temperature_Properties_Required;
|
||||
break;
|
||||
case OBJECT_CREDENTIAL_DATA_INPUT:
|
||||
pList = Credential_Data_Input_Properties_Required;
|
||||
break;
|
||||
@@ -1595,3 +1596,72 @@ unsigned property_list_special_count(
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BACNET_PROPERTY_ARRAY_LISTS
|
||||
/* standard properties that are arrays
|
||||
but not necessary supported in every object */
|
||||
|
||||
/* clang format off */
|
||||
static const int Properties_BACnetARRAY[] = {
|
||||
PROP_AUTHENTICATION_FACTORS, PROP_ASSIGNED_ACCESS_RIGHTS,
|
||||
PROP_PRIORITY_ARRAY, PROP_VALUE_SOURCE_ARRAY, PROP_COMMAND_TIME_ARRAY,
|
||||
PROP_ALARM_VALUES, PROP_FAULT_VALUES,
|
||||
PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
|
||||
PROP_EVENT_MESSAGE_TEXTS_CONFIG,
|
||||
PROP_SUPPORTED_FORMATS, PROP_SUPPORTED_FORMAT_CLASSES,
|
||||
PROP_SUBORDINATE_LIST, PROP_SUBORDINATE_ANNOTATIONS, PROP_SUBORDINATE_TAGS,
|
||||
PROP_SUBORDINATE_NODE_TYPES, PROP_SUBORDINATE_RELATIONSHIPS,
|
||||
PROP_GROUP_MEMBERS, PROP_GROUP_MEMBER_NAMES,
|
||||
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES, PROP_EXECUTION_DELAY,
|
||||
PROP_CONTROL_GROUPS, PROP_BIT_TEXT, PROP_PORT_FILTER,
|
||||
PROP_NOTIFICATION_CLASS, PROP_STATE_CHANGE_VALUES,
|
||||
PROP_LINK_SPEEDS, PROP_IP_DNS_SERVER, PROP_IPV6_DNS_SERVER,
|
||||
PROP_FLOOR_TEXT, PROP_CAR_DOOR_TEXT, PROP_ASSIGNED_LANDING_CALLS,
|
||||
PROP_MAKING_CAR_CALL, PROP_REGISTERED_CAR_CALL, PROP_CAR_DOOR_STATUS,
|
||||
PROP_CAR_DOOR_COMMAND, PROP_LANDING_DOOR_STATUS,
|
||||
PROP_STAGES, PROP_STAGE_NAMES, PROP_TARGET_REFERENCES,
|
||||
PROP_MONITORED_OBJECTS, PROP_TAGS, -1
|
||||
};
|
||||
/* clang format on */
|
||||
|
||||
/**
|
||||
* Function that returns the list of Required properties
|
||||
* of known standard objects.
|
||||
*
|
||||
* @param object_type - enumerated BACNET_OBJECT_TYPE
|
||||
* @return returns a pointer to a '-1' terminated array of
|
||||
* type 'int' that contain BACnet object properties for the given object
|
||||
* type.
|
||||
*/
|
||||
const int *property_list_bacnet_array(void)
|
||||
{
|
||||
return Properties_BACnetARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if the object property is a BACnetARRAY property
|
||||
* @param object_type - object-type to be checked
|
||||
* @param object_property - object-property to be checked
|
||||
* @return true if the property is a BACnetARRAY property
|
||||
*/
|
||||
bool property_list_bacnet_array_member(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID object_property)
|
||||
{
|
||||
switch (object_type) {
|
||||
case OBJECT_GLOBAL_GROUP:
|
||||
switch (object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
/* special - the only present-value that is an array! */
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return property_list_member(Properties_BACnetARRAY, object_property);
|
||||
}
|
||||
#endif
|
||||
|
||||
+21
-25
@@ -1,28 +1,16 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#ifndef PROPERTY_H
|
||||
#define PROPERTY_H
|
||||
/**
|
||||
* @file
|
||||
* @brief Static sets of BACnet Property members for each object type
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date 2012
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_PROPERTY_H
|
||||
#define BACNET_PROPERTY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -58,6 +46,14 @@ extern "C" {
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID special_property);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
const int *property_list_bacnet_array(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
bool property_list_bacnet_array_member(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID object_property);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in New Issue
Block a user