Merge pull request #81 from se-apc/dc_Analogs_Event_Detection_Enable (#854)

Dc analogs event detection enable

Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
Co-authored-by: dcmaverick <150046088+dcmaverick@users.noreply.github.com>
This commit is contained in:
Tomasz Kazimierz Motyl
2024-11-13 14:37:08 +00:00
committed by GitHub
parent ab74620449
commit 35d49a14ee
4 changed files with 244 additions and 1 deletions
+61 -1
View File
@@ -44,6 +44,7 @@ static const int Properties_Optional[] = {
PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS, PROP_HIGH_LIMIT,
PROP_LOW_LIMIT, PROP_DEADBAND, PROP_LIMIT_ENABLE, PROP_EVENT_ENABLE,
PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS,
PROP_EVENT_DETECTION_ENABLE,
#endif
-1
};
@@ -303,10 +304,11 @@ const char *Analog_Input_Name_ASCII(uint32_t object_instance)
unsigned Analog_Input_Event_State(uint32_t object_instance)
{
unsigned state = EVENT_STATE_NORMAL;
#if defined(INTRINSIC_REPORTING)
#if !defined(INTRINSIC_REPORTING)
struct analog_input_descr *pObject;
pObject = Analog_Input_Object(object_instance);
if (pObject) {
state = pObject->Event_State;
}
@@ -317,6 +319,52 @@ unsigned Analog_Input_Event_State(uint32_t object_instance)
return state;
}
#if defined(INTRINSIC_REPORTING)
/**
* For a given object instance-number, gets the event-detection-enable property
* value
*
* @param object_instance - object-instance number of the object
*
* @return event-detection-enable property value
*/
bool Analog_Input_Event_Detection_Enable(uint32_t object_instance)
{
bool retval = false;
struct analog_input_descr *pObject = Analog_Input_Object(object_instance);
if (pObject) {
retval = pObject->Event_Detection_Enable;
}
return retval;
}
/**
* For a given object instance-number, sets the event-detection-enable property
* value
*
* @param object_instance - object-instance number of the object
*
* @return event-detection-enable property value
*/
bool Analog_Input_Event_Detection_Enable_Set(
uint32_t object_instance, bool value)
{
bool retval = false;
struct analog_input_descr *pObject = Analog_Input_Object(object_instance);
if (pObject) {
pObject->Event_Detection_Enable = value;
retval = true;
}
return retval;
}
#endif
/**
* @brief For a given object instance-number, returns the description
* @param object_instance - object-instance number of the object
@@ -760,6 +808,10 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
: false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_EVENT_DETECTION_ENABLE:
apdu_len = encode_application_boolean(
&apdu[0], pObject->Event_Detection_Enable);
break;
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(
@@ -1014,6 +1066,12 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
if (!CurrentAI) {
return;
}
/* check whether Intrinsic reporting is enabled */
if (!CurrentAI->Event_Detection_Enable) {
return; /* limits are not configured */
}
if (CurrentAI->Ack_notify_data.bSendAckNotify) {
/* clean bSendAckNotify flag */
CurrentAI->Ack_notify_data.bSendAckNotify = false;
@@ -1601,6 +1659,8 @@ uint32_t Analog_Input_Create(uint32_t object_instance)
pObject->Changed = false;
pObject->Event_State = EVENT_STATE_NORMAL;
#if defined(INTRINSIC_REPORTING)
pObject->Event_Detection_Enable = true;
pObject->Time_Delay = 0;
/* notification class not connected */
pObject->Notification_Class = BACNET_MAX_INSTANCE;
/* initialize Event time stamps using wildcards
+60
View File
@@ -42,6 +42,7 @@ typedef struct analog_input_descr {
float Deadband;
unsigned Limit_Enable : 2;
unsigned Event_Enable : 3;
unsigned Event_Detection_Enable : 1;
unsigned Notify_Type : 1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
@@ -132,6 +133,65 @@ BACNET_STACK_EXPORT
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance);
#if defined(INTRINSIC_REPORTING)
BACNET_STACK_EXPORT
uint32_t Analog_Input_Time_Delay(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Time_Delay_Set(uint32_t object_instance, uint32_t time_delay);
BACNET_STACK_EXPORT
uint32_t Analog_Input_Notification_Class(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Notification_Class_Set(
uint32_t object_instance, uint32_t notification_class);
BACNET_STACK_EXPORT
float Analog_Input_High_Limit(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_High_Limit_Set(uint32_t object_instance, float high_limit);
BACNET_STACK_EXPORT
float Analog_Input_Low_Limit(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Low_Limit_Set(uint32_t object_instance, float low_limit);
BACNET_STACK_EXPORT
float Analog_Input_Deadband(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Deadband_Set(uint32_t object_instance, float deadband);
BACNET_STACK_EXPORT
BACNET_LIMIT_ENABLE Analog_Input_Limit_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Limit_Enable_Set(
uint32_t object_instance, BACNET_LIMIT_ENABLE limit_enable);
BACNET_STACK_EXPORT
BACNET_EVENT_ENABLE Analog_Input_Event_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Event_Detection_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Event_Detection_Enable_Set(
uint32_t object_instance, bool value);
BACNET_STACK_EXPORT
bool Analog_Input_Event_Enable_Set(
uint32_t object_instance, BACNET_EVENT_ENABLE event_enable);
BACNET_STACK_EXPORT
BACNET_NOTIFY_TYPE Analog_Input_Notify_Type(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Input_Notify_Type_Set(
uint32_t object_instance, BACNET_NOTIFY_TYPE notify_type);
BACNET_STACK_EXPORT
int Analog_Input_Event_Information(
unsigned index, BACNET_GET_EVENT_INFORMATION_DATA *getevent_data);
+63
View File
@@ -47,6 +47,7 @@ static const int Analog_Value_Properties_Optional[] = {
PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS, PROP_HIGH_LIMIT,
PROP_LOW_LIMIT, PROP_DEADBAND, PROP_LIMIT_ENABLE, PROP_EVENT_ENABLE,
PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS,
PROP_EVENT_DETECTION_ENABLE,
#endif
-1
};
@@ -325,6 +326,57 @@ unsigned Analog_Value_Event_State(uint32_t object_instance)
return state;
}
/**
* For a given object instance-number, gets the event-detection-enable property
* value
*
* @param object_instance - object-instance number of the object
*
* @return event-detection-enable property value
*/
bool Analog_Value_Event_Detection_Enable(uint32_t object_instance)
{
bool retval = false;
#if !defined(INTRINSIC_REPORTING)
(void)object_instance;
#else
struct analog_value_descr *pObject = Analog_Value_Object(object_instance);
if (pObject) {
retval = pObject->Event_Detection_Enable;
}
#endif
return retval;
}
/**
* For a given object instance-number, sets the event-detection-enable property
* value
*
* @param object_instance - object-instance number of the object
*
* @return event-detection-enable property value
*/
bool Analog_Value_Event_Detection_Enable_Set(
uint32_t object_instance, bool value)
{
bool retval = false;
#if !defined(INTRINSIC_REPORTING)
(void)object_instance;
(void)value;
#else
struct analog_value_descr *pObject = Analog_Value_Object(object_instance);
if (pObject) {
pObject->Event_Detection_Enable = value;
retval = true;
}
#endif
return retval;
}
/**
* @brief For a given object instance-number, returns the description
* @param object_instance - object-instance number of the object
@@ -778,6 +830,10 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
: false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
case PROP_EVENT_DETECTION_ENABLE:
apdu_len = encode_application_boolean(
&apdu[0], CurrentAV->Event_Detection_Enable);
break;
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(
@@ -1049,6 +1105,12 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
if (!CurrentAV) {
return;
}
/* check whether Intrinsic reporting is enabled */
if (!CurrentAV->Event_Detection_Enable) {
return; /* limits are not configured */
}
if (CurrentAV->Ack_notify_data.bSendAckNotify) {
/* clean bSendAckNotify flag */
CurrentAV->Ack_notify_data.bSendAckNotify = false;
@@ -1655,6 +1717,7 @@ uint32_t Analog_Value_Create(uint32_t object_instance)
pObject->Changed = false;
pObject->Event_State = EVENT_STATE_NORMAL;
#if defined(INTRINSIC_REPORTING)
pObject->Event_Detection_Enable = true;
/* notification class not connected */
pObject->Notification_Class = BACNET_MAX_INSTANCE;
/* initialize Event time stamps using wildcards
+60
View File
@@ -44,6 +44,7 @@ typedef struct analog_value_descr {
float Deadband;
unsigned Limit_Enable : 2;
unsigned Event_Enable : 3;
unsigned Event_Detection_Enable : 1;
unsigned Notify_Type : 1;
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
@@ -133,6 +134,65 @@ BACNET_STACK_EXPORT
void Analog_Value_Intrinsic_Reporting(uint32_t object_instance);
#if defined(INTRINSIC_REPORTING)
BACNET_STACK_EXPORT
uint32_t Analog_Value_Time_Delay(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Time_Delay_Set(uint32_t object_instance, uint32_t time_delay);
BACNET_STACK_EXPORT
uint32_t Analog_Value_Notification_Class(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Notification_Class_Set(
uint32_t object_instance, uint32_t notification_class);
BACNET_STACK_EXPORT
float Analog_Value_High_Limit(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_High_Limit_Set(uint32_t object_instance, float high_limit);
BACNET_STACK_EXPORT
float Analog_Value_Low_Limit(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Low_Limit_Set(uint32_t object_instance, float low_limit);
BACNET_STACK_EXPORT
float Analog_Value_Deadband(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Deadband_Set(uint32_t object_instance, float deadband);
BACNET_STACK_EXPORT
BACNET_LIMIT_ENABLE Analog_Value_Limit_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Limit_Enable_Set(
uint32_t object_instance, BACNET_LIMIT_ENABLE limit_enable);
BACNET_STACK_EXPORT
BACNET_EVENT_ENABLE Analog_Value_Event_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Event_Enable_Set(
uint32_t object_instance, BACNET_EVENT_ENABLE event_enable);
BACNET_STACK_EXPORT
bool Analog_Value_Event_Detection_Enable(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Event_Detection_Enable_Set(
uint32_t object_instance, bool value);
BACNET_STACK_EXPORT
BACNET_NOTIFY_TYPE Analog_Value_Notify_Type(uint32_t object_instance);
BACNET_STACK_EXPORT
bool Analog_Value_Notify_Type_Set(
uint32_t object_instance, BACNET_NOTIFY_TYPE notify_type);
BACNET_STACK_EXPORT
int Analog_Value_Event_Information(
unsigned index, BACNET_GET_EVENT_INFORMATION_DATA *getevent_data);