Fixed up Device_Object_Name_Copy().
Revised Routed_Device_Name() and Add_Routed_Device() to use BACNET_CHARACTER_STRING.
This commit is contained in:
@@ -132,7 +132,7 @@ static object_functions_t Object_Table[] = {
|
|||||||
Load_Control_Index_To_Instance, Load_Control_Valid_Instance,
|
Load_Control_Index_To_Instance, Load_Control_Valid_Instance,
|
||||||
Load_Control_Object_Name, Load_Control_Read_Property,
|
Load_Control_Object_Name, Load_Control_Read_Property,
|
||||||
Load_Control_Write_Property, Load_Control_Property_Lists,
|
Load_Control_Write_Property, Load_Control_Property_Lists,
|
||||||
NULL, NULL, NULL}, {
|
NULL, NULL, NULL, NULL}, {
|
||||||
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
|
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
|
||||||
Multistate_Output_Count,
|
Multistate_Output_Count,
|
||||||
Multistate_Output_Index_To_Instance,
|
Multistate_Output_Index_To_Instance,
|
||||||
@@ -160,7 +160,7 @@ static object_functions_t Object_Table[] = {
|
|||||||
NULL, NULL, NULL, NULL}, {
|
NULL, NULL, NULL, NULL}, {
|
||||||
#endif
|
#endif
|
||||||
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL}
|
NULL, NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -863,7 +863,7 @@ bool Device_Valid_Object_Name(
|
|||||||
/** Determine if we have an object of this type and instance number.
|
/** Determine if we have an object of this type and instance number.
|
||||||
* @param object_type [in] The desired BACNET_OBJECT_TYPE
|
* @param object_type [in] The desired BACNET_OBJECT_TYPE
|
||||||
* @param object_instance [in] The object instance number to be looked up.
|
* @param object_instance [in] The object instance number to be looked up.
|
||||||
* @return The Object Name or else NULL if not found
|
* @return True if found, else False if no such Object in this device.
|
||||||
*/
|
*/
|
||||||
bool Device_Valid_Object_Id(
|
bool Device_Valid_Object_Id(
|
||||||
int object_type,
|
int object_type,
|
||||||
@@ -880,34 +880,23 @@ bool Device_Valid_Object_Id(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** copy a child object object_name value.
|
/** Copy a child object's object_name value, given its ID.
|
||||||
* @param object_type [out] The BACNET_OBJECT_TYPE of the matching Object.
|
* @param object_type [in] The BACNET_OBJECT_TYPE of the child Object.
|
||||||
* @param object_instance [out] The object instance number of the matching Object.
|
* @param object_instance [in] The object instance number of the child Object.
|
||||||
* @param object_name [in] The desired Object Name to look for.
|
* @param object_name [out] The Object Name found for this child Object.
|
||||||
* @return True on success or else False if not found.
|
* @return True on success or else False if not found.
|
||||||
*/
|
*/
|
||||||
bool Device_Object_Name_Copy(
|
bool Device_Object_Name_Copy(
|
||||||
int object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
BACNET_CHARACTER_STRING * object_name)
|
BACNET_CHARACTER_STRING * object_name)
|
||||||
{
|
{
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int type = 0;
|
|
||||||
uint32_t instance;
|
|
||||||
unsigned max_objects = 0, i = 0;
|
|
||||||
bool check_id = false;
|
|
||||||
|
|
||||||
max_objects = Device_Object_List_Count();
|
pObject = Device_Objects_Find_Functions(object_type);
|
||||||
for (i = 0; i < max_objects; i++) {
|
if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
|
||||||
check_id = Device_Object_List_Identifier(i, &type, &instance);
|
found = pObject->Object_Name(object_instance, object_name);
|
||||||
if (check_id) {
|
|
||||||
pObject = Device_Objects_Find_Functions(type);
|
|
||||||
if ((pObject != NULL) && (pObject->Object_Name != NULL)) {
|
|
||||||
found = pObject->Object_Name(instance, object_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
@@ -1633,7 +1622,7 @@ void Routing_Device_Init(
|
|||||||
struct object_functions *pDevObject = NULL;
|
struct object_functions *pDevObject = NULL;
|
||||||
|
|
||||||
/* Initialize with our preset strings */
|
/* Initialize with our preset strings */
|
||||||
Add_Routed_Device(first_object_instance, My_Object_Name, Description);
|
Add_Routed_Device(first_object_instance, &My_Object_Name, Description);
|
||||||
|
|
||||||
/* Now substitute our routed versions of the main object functions. */
|
/* Now substitute our routed versions of the main object functions. */
|
||||||
pDevObject = &Object_Table[0];
|
pDevObject = &Object_Table[0];
|
||||||
|
|||||||
@@ -66,10 +66,11 @@ typedef uint32_t(
|
|||||||
|
|
||||||
/** Provides the BACnet Object_Name for a given object instance of this type.
|
/** Provides the BACnet Object_Name for a given object instance of this type.
|
||||||
* @ingroup ObjHelpers
|
* @ingroup ObjHelpers
|
||||||
* @param [in] The object instance number to be looked up.
|
* @param object_instance [in] The object instance number to be looked up.
|
||||||
* @return Pointer to a string containing the unique Object_Name. This string
|
* @param object_name [in,out] Pointer to a character_string structure that
|
||||||
* is temporary and should be copied upon the return. It is
|
* will hold a copy of the object name if this is a valid object_instance.
|
||||||
* allocated by the system and does not need to be freed.
|
* @return True if the object_instance is valid and object_name has been
|
||||||
|
* filled with a copy of the Object's name.
|
||||||
*/
|
*/
|
||||||
typedef bool(
|
typedef bool(
|
||||||
*object_name_function)
|
*object_name_function)
|
||||||
@@ -254,9 +255,9 @@ extern "C" {
|
|||||||
BACNET_CHARACTER_STRING * object_name);
|
BACNET_CHARACTER_STRING * object_name);
|
||||||
bool Device_Set_Object_Name(
|
bool Device_Set_Object_Name(
|
||||||
BACNET_CHARACTER_STRING * object_name);
|
BACNET_CHARACTER_STRING * object_name);
|
||||||
/* copy a child object name */
|
/* Copy a child object name, given its ID. */
|
||||||
bool Device_Object_Name_Copy(
|
bool Device_Object_Name_Copy(
|
||||||
int object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
BACNET_CHARACTER_STRING * object_name);
|
BACNET_CHARACTER_STRING * object_name);
|
||||||
|
|
||||||
@@ -352,7 +353,7 @@ extern "C" {
|
|||||||
|
|
||||||
uint16_t Add_Routed_Device(
|
uint16_t Add_Routed_Device(
|
||||||
uint32_t Object_Instance,
|
uint32_t Object_Instance,
|
||||||
const char *Object_Name,
|
BACNET_CHARACTER_STRING *Object_Name,
|
||||||
const char *Description);
|
const char *Description);
|
||||||
DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
|
DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
|
||||||
int idx);
|
int idx);
|
||||||
@@ -378,8 +379,9 @@ extern "C" {
|
|||||||
unsigned index);
|
unsigned index);
|
||||||
bool Routed_Device_Valid_Object_Instance_Number(
|
bool Routed_Device_Valid_Object_Instance_Number(
|
||||||
uint32_t object_id);
|
uint32_t object_id);
|
||||||
char *Routed_Device_Name(
|
bool Routed_Device_Name(
|
||||||
uint32_t object_instance);
|
uint32_t object_instance,
|
||||||
|
BACNET_CHARACTER_STRING * object_name);
|
||||||
uint32_t Routed_Device_Object_Instance_Number(
|
uint32_t Routed_Device_Object_Instance_Number(
|
||||||
void);
|
void);
|
||||||
bool Routed_Device_Set_Object_Instance_Number(
|
bool Routed_Device_Set_Object_Instance_Number(
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ uint16_t iCurrent_Device_Idx = 0;
|
|||||||
*/
|
*/
|
||||||
uint16_t Add_Routed_Device(
|
uint16_t Add_Routed_Device(
|
||||||
uint32_t Object_Instance,
|
uint32_t Object_Instance,
|
||||||
const char *sObject_Name,
|
BACNET_CHARACTER_STRING *sObject_Name,
|
||||||
const char *sDescription)
|
const char *sDescription)
|
||||||
{
|
{
|
||||||
int i = Num_Managed_Devices;
|
int i = Num_Managed_Devices;
|
||||||
@@ -127,8 +127,8 @@ uint16_t Add_Routed_Device(
|
|||||||
pDev->bacObj.mObject_Type = OBJECT_DEVICE;
|
pDev->bacObj.mObject_Type = OBJECT_DEVICE;
|
||||||
pDev->bacObj.Object_Instance_Number = Object_Instance;
|
pDev->bacObj.Object_Instance_Number = Object_Instance;
|
||||||
if (sObject_Name != NULL)
|
if (sObject_Name != NULL)
|
||||||
Routed_Device_Set_Object_Name(CHARACTER_UTF8, sObject_Name,
|
Routed_Device_Set_Object_Name(sObject_Name->encoding,
|
||||||
strlen(sObject_Name));
|
sObject_Name->value, sObject_Name->length);
|
||||||
else
|
else
|
||||||
Routed_Device_Set_Object_Name(CHARACTER_UTF8, "No Name",
|
Routed_Device_Set_Object_Name(CHARACTER_UTF8, "No Name",
|
||||||
strlen("No Name"));
|
strlen("No Name"));
|
||||||
@@ -401,12 +401,13 @@ bool Routed_Device_Valid_Object_Instance_Number(
|
|||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Routed_Device_Name(
|
bool Routed_Device_Name(
|
||||||
uint32_t object_instance)
|
uint32_t object_instance,
|
||||||
|
BACNET_CHARACTER_STRING * object_name)
|
||||||
{
|
{
|
||||||
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
|
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
|
||||||
if (object_instance == pDev->bacObj.Object_Instance_Number) {
|
if (object_instance == pDev->bacObj.Object_Instance_Number) {
|
||||||
return pDev->bacObj.Object_Name;
|
return characterstring_init_ansi(object_name, pDev->bacObj.Object_Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -550,7 +551,7 @@ bool Routed_Device_Set_Object_Instance_Number(
|
|||||||
bool Routed_Device_Set_Object_Name(
|
bool Routed_Device_Set_Object_Name(
|
||||||
uint8_t encoding,
|
uint8_t encoding,
|
||||||
const char *value,
|
const char *value,
|
||||||
size_t length);
|
size_t length)
|
||||||
{
|
{
|
||||||
bool status = false; /*return value */
|
bool status = false; /*return value */
|
||||||
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
|
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
|
||||||
|
|||||||
Reference in New Issue
Block a user