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
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. */