Fixed write-property to object-name property in demo application to fix for BTL 135.1-2009-9.22.2.8 - Reading an object name and writing it straight back gives a 'duplicate name' error. Thank you, Ed!

This commit is contained in:
skarg
2013-01-14 16:29:42 +00:00
parent ac84fc430f
commit af5d529001
2 changed files with 39 additions and 13 deletions
+15 -8
View File
@@ -1425,6 +1425,8 @@ bool Device_Write_Property_Local(
bool status = false; /* return value */
int len = 0;
BACNET_APPLICATION_DATA_VALUE value;
int object_type = 0;
uint32_t object_instance = 0;
int temp;
/* decode the some of the request */
@@ -1515,15 +1517,20 @@ bool Device_Write_Property_Local(
characterstring_capacity(&My_Object_Name), false,
&wp_data->error_class, &wp_data->error_code);
if (status) {
/* All the object names in a device must be unique.
Disallow setting the Device Object Name to any objects in
the device. */
/* All the object names in a device must be unique */
if (Device_Valid_Object_Name(&value.type.Character_String,
NULL, NULL)) {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else {
&object_type, &object_instance)) {
if ((object_type == wp_data->object_type) &&
(object_instance == wp_data->object_instance)) {
/* okay to set my name as the same name */
status = true;
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
}
}
if (status) {
Device_Set_Object_Name(&value.type.Character_String);
}
}
+24 -5
View File
@@ -35,6 +35,7 @@
#include "config.h" /* the custom stuff */
#include "rp.h"
#include "wp.h"
#include "device.h"
#include "ms-input.h"
#include "handlers.h"
@@ -623,6 +624,8 @@ bool Multistate_Input_Write_Property(
BACNET_APPLICATION_DATA_VALUE value;
uint32_t max_states = 0;
uint32_t array_index = 0;
int object_type = 0;
uint32_t object_instance = 0;
/* decode the first chunk of the request */
len =
@@ -645,11 +648,27 @@ bool Multistate_Input_Write_Property(
switch (wp_data->object_property) {
case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = Multistate_Input_Object_Name_Write(
wp_data->object_instance,
&value.type.Character_String,
&wp_data->error_class,
&wp_data->error_code);
/* All the object names in a device must be unique */
if (Device_Valid_Object_Name(&value.type.Character_String,
&object_type, &object_instance)) {
if ((object_type == wp_data->object_type) &&
(object_instance == wp_data->object_instance)) {
status = true;
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
}
} else {
status = true;
}
if (status) {
status = Multistate_Input_Object_Name_Write(
wp_data->object_instance,
&value.type.Character_String,
&wp_data->error_class,
&wp_data->error_code);
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;