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
+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