Bugfix/basic object features cleanup (#614)

* Fixed compile warnings in basic objects

* Added API for setting multi state text with null-terminated name lists in basic objects
This commit is contained in:
Steve Karg
2024-04-03 16:57:36 -05:00
committed by GitHub
parent 7520930dc1
commit 41c11b23d3
7 changed files with 197 additions and 0 deletions
+2
View File
@@ -78,6 +78,7 @@ static struct analog_input_descr *Analog_Input_Object(uint32_t object_instance)
return Keylist_Data(Object_List, object_instance);
}
#if defined(INTRINSIC_REPORTING)
/**
* @brief Gets an object from the list using its index in the list
* @param index - index of the object in the list
@@ -87,6 +88,7 @@ static struct analog_input_descr *Analog_Input_Object_Index(int index)
{
return Keylist_Data_Index(Object_List, index);
}
#endif
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need validate that the */
+2
View File
@@ -81,6 +81,7 @@ static struct analog_value_descr *Analog_Value_Object(uint32_t object_instance)
return Keylist_Data(Object_List, object_instance);
}
#if defined(INTRINSIC_REPORTING)
/**
* @brief Gets an object from the list using its index in the list
* @param index - index of the object in the list
@@ -90,6 +91,7 @@ static struct analog_value_descr *Analog_Value_Object_Index(int index)
{
return Keylist_Data_Index(Object_List, index);
}
#endif
/**
* @brief Determines if a given Analog Value instance is valid
+132
View File
@@ -221,6 +221,25 @@ void Binary_Input_Out_Of_Service_Set(uint32_t object_instance, bool value)
return;
}
/**
* @brief For a given object instance-number, returns the reliability property value
* @param object_instance - object-instance number of the object
* @return reliability property value
*/
BACNET_RELIABILITY Binary_Input_Reliability(
uint32_t object_instance)
{
BACNET_RELIABILITY value = RELIABILITY_NO_FAULT_DETECTED;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
value = pObject->Reliability;
}
return value;
}
/**
* @brief For a given object, gets the Fault status flag
* @param object_instance - object-instance number of the object
@@ -239,6 +258,36 @@ static bool Binary_Input_Object_Fault(struct object_data *pObject)
return fault;
}
/**
* For a given object instance-number, sets the reliability
*
* @param object_instance - object-instance number of the object
* @param value - reliability enumerated value
*
* @return true if values are within range and property is set.
*/
bool Binary_Input_Reliability_Set(
uint32_t object_instance, BACNET_RELIABILITY value)
{
struct object_data *pObject;
bool status = false;
bool fault = false;
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
if (value <= 255) {
fault = Binary_Input_Object_Fault(pObject);
pObject->Reliability = value;
if (fault != Binary_Input_Object_Fault(pObject)) {
pObject->Change_Of_Value = true;
}
status = true;
}
}
return status;
}
/**
* @brief For a given object instance-number, gets the Fault status flag
* @param object_instance - object-instance number of the object
@@ -534,6 +583,89 @@ bool Binary_Input_Description_Set(uint32_t object_instance, char *new_name)
return status;
}
/**
* @brief For a given object instance-number, returns the inactive-text property value
* @param object_instance - object-instance number of the object
* @return inactive-text property value
*/
char *Binary_Input_Inactive_Text(
uint32_t object_instance)
{
char *name = NULL;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
name = (char *)pObject->Inactive_Text;
}
return name;
}
/**
* @brief For a given object instance-number, sets the inactive-text property value
* @param object_instance - object-instance number of the object
* @param new_name - holds the inactive-text to be set
* @return true if the inactive-text property value was set
*/
bool Binary_Input_Inactive_Text_Set(
uint32_t object_instance,
char *new_name)
{
bool status = false;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
pObject->Inactive_Text = new_name;
status = true;
}
return status;
}
/**
* @brief For a given object instance-number, returns the active-text property value
* @param object_instance - object-instance number of the object
* @return active-text property value
*/
char *Binary_Input_Active_Text(
uint32_t object_instance)
{
char *name = NULL;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
name = (char *)pObject->Active_Text;
}
return name;
}
/**
* @brief For a given object instance-number, sets the active-text property value
* @param object_instance - object-instance number of the object
* @param new_name - holds the active-text to be set
* @return true if the active-text property value was set
*/
bool Binary_Input_Active_Text_Set(
uint32_t object_instance,
char *new_name)
{
bool status = false;
struct object_data *pObject;
pObject = Binary_Input_Object(object_instance);
if (pObject) {
pObject->Inactive_Text = new_name;
status = true;
}
return status;
}
/**
* ReadProperty handler for this object. For the given ReadProperty
* data, the application_data is loaded or the error flags are set.
+49
View File
@@ -221,6 +221,25 @@ void Binary_Value_Out_Of_Service_Set(uint32_t object_instance, bool value)
return;
}
/**
* @brief For a given object instance-number, returns the reliability property value
* @param object_instance - object-instance number of the object
* @return reliability property value
*/
BACNET_RELIABILITY Binary_Value_Reliability(
uint32_t object_instance)
{
BACNET_RELIABILITY value = RELIABILITY_NO_FAULT_DETECTED;
struct object_data *pObject;
pObject = Binary_Value_Object(object_instance);
if (pObject) {
value = pObject->Reliability;
}
return value;
}
/**
* @brief For a given object, gets the Fault status flag
* @param object_instance - object-instance number of the object
@@ -239,6 +258,36 @@ static bool Binary_Value_Object_Fault(struct object_data *pObject)
return fault;
}
/**
* For a given object instance-number, sets the reliability
*
* @param object_instance - object-instance number of the object
* @param value - reliability enumerated value
*
* @return true if values are within range and property is set.
*/
bool Binary_Value_Reliability_Set(
uint32_t object_instance, BACNET_RELIABILITY value)
{
struct object_data *pObject;
bool status = false;
bool fault = false;
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
if (value <= 255) {
fault = Binary_Value_Object_Fault(pObject);
pObject->Reliability = value;
if (fault != Binary_Value_Object_Fault(pObject)) {
pObject->Change_Of_Value = true;
}
status = true;
}
}
return status;
}
/**
* @brief For a given object instance-number, gets the Fault status flag
* @param object_instance - object-instance number of the object
+4
View File
@@ -119,6 +119,10 @@ extern "C" {
BACNET_RELIABILITY value);
BACNET_STACK_EXPORT
bool Multistate_Input_State_Text_List_Set(
uint32_t object_instance,
const char *state_text_list);
BACNET_STACK_EXPORT
bool Multistate_Input_State_Text_Set(
uint32_t object_instance,
uint32_t state_index,
+4
View File
@@ -139,6 +139,10 @@ extern "C" {
char *text_string);
BACNET_STACK_EXPORT
bool Multistate_Output_State_Text_List_Set(
uint32_t object_instance,
const char *state_text_list);
BACNET_STACK_EXPORT
bool Multistate_Output_State_Text_Set(
uint32_t object_instance,
uint32_t state_index,
+4
View File
@@ -110,6 +110,10 @@ extern "C" {
char *text_string);
BACNET_STACK_EXPORT
bool Multistate_Value_State_Text_List_Set(
uint32_t object_instance,
const char *state_text_list);
BACNET_STACK_EXPORT
bool Multistate_Value_State_Text_Set(
uint32_t object_instance,
uint32_t state_index,