Feature/add bacnet binary lighting object (#522)

* Added Binary Lighting Output object example.

* Changed piface example app to support binary-lighting-output object type and blink warn

* Changed example device object to not create objects when device object-table is overridden

* Fixed unit testing for device object
This commit is contained in:
Steve Karg
2024-01-29 09:41:40 -06:00
committed by GitHub
parent 34b1d24bb7
commit 6cb875aae6
20 changed files with 2342 additions and 91 deletions
+17 -7
View File
@@ -2206,13 +2206,23 @@ int bacapp_snprintf_value(
break;
case PROP_PRESENT_VALUE:
case PROP_RELINQUISH_DEFAULT:
if (object_type < OBJECT_PROPRIETARY_MIN) {
ret_val = snprintf(str, str_len, "%s",
bactext_binary_present_value_name(
value->type.Enumerated));
} else {
ret_val = snprintf(str, str_len, "%lu",
(unsigned long)value->type.Enumerated);
switch (object_type) {
case OBJECT_BINARY_INPUT:
case OBJECT_BINARY_OUTPUT:
case OBJECT_BINARY_VALUE:
ret_val = snprintf(str, str_len, "%s",
bactext_binary_present_value_name(
value->type.Enumerated));
break;
case OBJECT_BINARY_LIGHTING_OUTPUT:
ret_val = snprintf(str, str_len, "%s",
bactext_binary_lighting_pv_name(
value->type.Enumerated));
break;
default:
ret_val = snprintf(str, str_len, "%lu",
(unsigned long)value->type.Enumerated);
break;
}
break;
case PROP_RELIABILITY:
+2 -1
View File
@@ -1079,7 +1079,7 @@ typedef enum {
PROP_STATE_EXAMPLE_TWO = 257
} BACNET_PROPERTY_STATES;
typedef enum {
typedef enum BACnetReliability {
RELIABILITY_NO_FAULT_DETECTED = 0,
RELIABILITY_NO_SENSOR = 1,
RELIABILITY_OVER_RANGE = 2,
@@ -2106,6 +2106,7 @@ typedef enum BACnetBinaryLightingPV {
BINARY_LIGHTING_PV_WARN_OFF = 3,
BINARY_LIGHTING_PV_WARN_RELINQUISH = 4,
BINARY_LIGHTING_PV_STOP = 5,
BINARY_LIGHTING_PV_MAX = 6,
/* -- Enumerated values 0-63 are reserved for definition by ASHRAE.
-- Enumerated values 64-255 may be used by others
-- subject to the procedures and constraints described in Clause 23. */
+30 -1
View File
@@ -1750,12 +1750,41 @@ const char *bactext_lighting_operation_name(unsigned index)
}
}
bool bactext_bactext_lighting_operation_strtol(const char *search_name, unsigned *found_index)
bool bactext_lighting_operation_strtol(const char *search_name, unsigned *found_index)
{
return bactext_strtol_index(
bacnet_lighting_operation_names, search_name, found_index);
}
INDTEXT_DATA bacnet_binary_lighting_pv_names[] = {
{ BINARY_LIGHTING_PV_OFF, "off" },
{ BINARY_LIGHTING_PV_ON, "on" },
{ BINARY_LIGHTING_PV_WARN, "warn" },
{ BINARY_LIGHTING_PV_WARN_OFF, "warn-off" },
{ BINARY_LIGHTING_PV_WARN_RELINQUISH, "warn-relinquish" },
{ BINARY_LIGHTING_PV_STOP, "stop" },
{ 0, NULL }
};
const char *bactext_binary_lighting_pv_name(unsigned index)
{
if (index < BINARY_LIGHTING_PV_PROPRIETARY_MIN) {
return indtext_by_index_default(
bacnet_binary_lighting_pv_names, index, ASHRAE_Reserved_String);
} else if (index <= BINARY_LIGHTING_PV_PROPRIETARY_MAX) {
return Vendor_Proprietary_String;
} else {
return "Invalid BACnetBinaryLightingPV";
}
}
bool bactext_binary_lighting_pv_names_strtol(const char *search_name,
unsigned *found_index)
{
return bactext_strtol_index(
bacnet_binary_lighting_pv_names, search_name, found_index);
}
INDTEXT_DATA bacnet_color_operation_names[] = { { BACNET_COLOR_OPERATION_NONE,
"none" },
{ BACNET_COLOR_OPERATION_FADE_TO_COLOR, "fade-to-color" },
+10 -1
View File
@@ -201,7 +201,16 @@ extern "C" {
unsigned index);
BACNET_STACK_EXPORT
bool bactext_bactext_lighting_operation_strtol(
bool bactext_lighting_operation_strtol(
const char *search_name,
unsigned *found_index);
BACNET_STACK_EXPORT
const char *bactext_binary_lighting_pv_name(
unsigned index);
BACNET_STACK_EXPORT
bool bactext_binary_lighting_pv_names_strtol(
const char *search_name,
unsigned *found_index);
File diff suppressed because it is too large Load Diff
+161
View File
@@ -0,0 +1,161 @@
/**
* @file
* @author Steve Karg
* @date 2023
* @brief Binary Lighting Output object
*
* SPDX-License-Identifier: MIT
*/
#ifndef BINARY_LIGHTING_OUTPUT_H
#define BINARY_LIGHTING_OUTPUT_H
#include <stdbool.h>
#include <stdint.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#include "bacnet/bacerror.h"
#include "bacnet/rp.h"
#include "bacnet/wp.h"
/**
* @brief Callback for write value request
* @param object_instance - object-instance number of the object
* @param old_value - value prior to write
* @param value - value of the write
*/
typedef void (*binary_lighting_output_write_value_callback)(
uint32_t object_instance,
BACNET_BINARY_LIGHTING_PV old_value,
BACNET_BINARY_LIGHTING_PV value);
/**
* @brief Callback for blink warning notification
* @param object_instance - object-instance number of the object
*/
typedef void (*binary_lighting_output_blink_warn_callback)(
uint32_t object_instance);
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Property_Lists(
const int **pRequired, const int **pOptional, const int **pProprietary);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Valid_Instance(uint32_t object_instance);
BACNET_STACK_EXPORT
unsigned Binary_Lighting_Output_Count(void);
BACNET_STACK_EXPORT
uint32_t Binary_Lighting_Output_Index_To_Instance(unsigned index);
BACNET_STACK_EXPORT
unsigned Binary_Lighting_Output_Instance_To_Index(uint32_t instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Object_Instance_Add(uint32_t instance);
BACNET_STACK_EXPORT
BACNET_BINARY_LIGHTING_PV Binary_Lighting_Output_Present_Value(
uint32_t object_instance);
BACNET_STACK_EXPORT
unsigned Binary_Lighting_Output_Present_Value_Priority(
uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Present_Value_Set(uint32_t object_instance,
BACNET_BINARY_LIGHTING_PV value,
unsigned priority);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Present_Value_Relinquish(
uint32_t object_instance, unsigned priority);
BACNET_STACK_EXPORT
BACNET_BINARY_LIGHTING_PV Binary_Lighting_Output_Relinquish_Default(
uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Relinquish_Default_Set(
uint32_t object_instance, BACNET_BINARY_LIGHTING_PV value);
BACNET_STACK_EXPORT
BACNET_RELIABILITY Binary_Lighting_Output_Reliability(
uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Reliability_Set(
uint32_t object_instance, BACNET_RELIABILITY value);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Object_Name(
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Name_Set(uint32_t object_instance, char *new_name);
BACNET_STACK_EXPORT
char *Binary_Lighting_Output_Description(uint32_t instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Description_Set(uint32_t instance, char *new_name);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Out_Of_Service(uint32_t instance);
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Out_Of_Service_Set(
uint32_t instance, bool oos_flag);
BACNET_STACK_EXPORT
BACNET_BINARY_LIGHTING_PV Binary_Lighting_Output_Lighting_Command_Target_Value(
uint32_t object_instance);
BACNET_STACK_EXPORT
unsigned Binary_Lighting_Output_Lighting_Command_Target_Priority(
uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Lighting_Command_Set(
uint32_t object_instance, BACNET_BINARY_LIGHTING_PV value, unsigned priority);
BACNET_STACK_EXPORT
BACNET_BINARY_LIGHTING_PV Binary_Lighting_Output_Feedback_Value(
uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Feedback_Value_Set(
uint32_t object_instance, BACNET_BINARY_LIGHTING_PV value);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Blink_Warn_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Blink_Warn_Enable_Set(
uint32_t object_instance, bool enable);
BACNET_STACK_EXPORT
uint32_t Binary_Lighting_Output_Egress_Time(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Egress_Time_Set(
uint32_t object_instance, uint32_t seconds);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Egress_Active(uint32_t object_instance);
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Timer(
uint32_t object_instance, uint16_t milliseconds);
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Write_Value_Callback_Set(
binary_lighting_output_write_value_callback cb);
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Blink_Warn_Callback_Set(
binary_lighting_output_blink_warn_callback cb);
BACNET_STACK_EXPORT
uint32_t Binary_Lighting_Output_Create(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Delete(uint32_t object_instance);
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Cleanup(void);
BACNET_STACK_EXPORT
void Binary_Lighting_Output_Init(void);
BACNET_STACK_EXPORT
int Binary_Lighting_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata);
BACNET_STACK_EXPORT
bool Binary_Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+24 -5
View File
@@ -51,6 +51,9 @@
#include "bacnet/basic/object/ao.h"
#include "bacnet/basic/object/av.h"
#include "bacnet/basic/object/bi.h"
#if (BACNET_PROTOCOL_REVISION >= 16)
#include "bacnet/basic/object/blo.h"
#endif
#include "bacnet/basic/object/bo.h"
#include "bacnet/basic/object/bv.h"
#include "bacnet/basic/object/channel.h"
@@ -267,6 +270,20 @@ static object_functions_t My_Object_Table[] = {
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
Channel_Create, Channel_Delete, NULL /* Timer */ },
#endif
#if (BACNET_PROTOCOL_REVISION >= 16)
{ OBJECT_BINARY_LIGHTING_OUTPUT, Binary_Lighting_Output_Init,
Binary_Lighting_Output_Count, Binary_Lighting_Output_Index_To_Instance,
Binary_Lighting_Output_Valid_Instance,
Binary_Lighting_Output_Object_Name,
Binary_Lighting_Output_Read_Property,
Binary_Lighting_Output_Write_Property,
Binary_Lighting_Output_Property_Lists, NULL /* ReadRangeInfo */,
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
NULL /* COV Clear */, NULL /* Intrinsic Reporting */,
NULL /* Add_List_Element */, NULL /* Remove_List_Element */,
Binary_Lighting_Output_Create, Binary_Lighting_Output_Delete,
Binary_Lighting_Output_Timer },
#endif
#if (BACNET_PROTOCOL_REVISION >= 24)
{ OBJECT_COLOR, Color_Init, Color_Count, Color_Index_To_Instance,
Color_Valid_Instance, Color_Object_Name, Color_Read_Property,
@@ -2201,12 +2218,14 @@ void Device_Init(object_functions_t *object_table)
pObject++;
}
/* create some dynamically created objects as examples */
pObject = Object_Table;
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Create) {
pObject->Object_Create(BACNET_MAX_INSTANCE);
if (!object_table) {
pObject = Object_Table;
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Create) {
pObject->Object_Create(BACNET_MAX_INSTANCE);
}
pObject++;
}
pObject++;
}
#if (BACNET_PROTOCOL_REVISION >= 14)
Channel_Write_Property_Internal_Callback_Set(Device_Write_Property);
-4
View File
@@ -48,10 +48,6 @@
/* me! */
#include "bacnet/basic/object/lo.h"
#ifndef MAX_LIGHTING_OUTPUTS
#define MAX_LIGHTING_OUTPUTS 8
#endif
struct object_data {
float Present_Value;
float Tracking_Value;
+1 -1
View File
@@ -25,7 +25,7 @@
#define KEYLIST_H
#include "bacnet/bacnet_stack_exports.h"
#include "key.h"
#include "bacnet/basic/sys/key.h"
/* This is a key sorted linked list data library that */
/* uses a key or index to access the data. */