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:
@@ -1425,6 +1425,8 @@ bool Device_Write_Property_Local(
|
|||||||
bool status = false; /* return value */
|
bool status = false; /* return value */
|
||||||
int len = 0;
|
int len = 0;
|
||||||
BACNET_APPLICATION_DATA_VALUE value;
|
BACNET_APPLICATION_DATA_VALUE value;
|
||||||
|
int object_type = 0;
|
||||||
|
uint32_t object_instance = 0;
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
/* decode the some of the request */
|
/* decode the some of the request */
|
||||||
@@ -1515,15 +1517,20 @@ bool Device_Write_Property_Local(
|
|||||||
characterstring_capacity(&My_Object_Name), false,
|
characterstring_capacity(&My_Object_Name), false,
|
||||||
&wp_data->error_class, &wp_data->error_code);
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
if (status) {
|
if (status) {
|
||||||
/* All the object names in a device must be unique.
|
/* All the object names in a device must be unique */
|
||||||
Disallow setting the Device Object Name to any objects in
|
|
||||||
the device. */
|
|
||||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||||
NULL, NULL)) {
|
&object_type, &object_instance)) {
|
||||||
status = false;
|
if ((object_type == wp_data->object_type) &&
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
(object_instance == wp_data->object_instance)) {
|
||||||
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
|
/* okay to set my name as the same name */
|
||||||
} else {
|
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);
|
Device_Set_Object_Name(&value.type.Character_String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "config.h" /* the custom stuff */
|
#include "config.h" /* the custom stuff */
|
||||||
#include "rp.h"
|
#include "rp.h"
|
||||||
#include "wp.h"
|
#include "wp.h"
|
||||||
|
#include "device.h"
|
||||||
#include "ms-input.h"
|
#include "ms-input.h"
|
||||||
#include "handlers.h"
|
#include "handlers.h"
|
||||||
|
|
||||||
@@ -623,6 +624,8 @@ bool Multistate_Input_Write_Property(
|
|||||||
BACNET_APPLICATION_DATA_VALUE value;
|
BACNET_APPLICATION_DATA_VALUE value;
|
||||||
uint32_t max_states = 0;
|
uint32_t max_states = 0;
|
||||||
uint32_t array_index = 0;
|
uint32_t array_index = 0;
|
||||||
|
int object_type = 0;
|
||||||
|
uint32_t object_instance = 0;
|
||||||
|
|
||||||
/* decode the first chunk of the request */
|
/* decode the first chunk of the request */
|
||||||
len =
|
len =
|
||||||
@@ -645,11 +648,27 @@ bool Multistate_Input_Write_Property(
|
|||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||||
status = Multistate_Input_Object_Name_Write(
|
/* All the object names in a device must be unique */
|
||||||
wp_data->object_instance,
|
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||||
&value.type.Character_String,
|
&object_type, &object_instance)) {
|
||||||
&wp_data->error_class,
|
if ((object_type == wp_data->object_type) &&
|
||||||
&wp_data->error_code);
|
(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 {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||||
|
|||||||
Reference in New Issue
Block a user