Feature/alarm ack application (#164)
* Added alarm-ack application * fix error and simple ack handling for event notification * Added ack-alarm application * Update CMake for ack-alarm * update example objects for alarm and events * Allow repeated ack-alarm for same transition * add event state API. Fix COV event state. * add event state API to AV. Fix COV event state. * Use event time for ack notification * Enable notifications for all transitions by default. For testing. * Use unconfirmed device notification to 4194303 for testing. * initialize local vars Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
+113
-51
@@ -41,6 +41,13 @@
|
||||
#include "bacnet/timestamp.h"
|
||||
#include "bacnet/basic/object/ai.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
#ifndef MAX_ANALOG_INPUTS
|
||||
#define MAX_ANALOG_INPUTS 4
|
||||
#endif
|
||||
@@ -222,6 +229,28 @@ bool Analog_Input_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, gets the event-state property value
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
*
|
||||
* @return event-state property value
|
||||
*/
|
||||
unsigned Analog_Input_Event_State(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0;
|
||||
unsigned state = EVENT_STATE_NORMAL;
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
index = Analog_Input_Instance_To_Index(object_instance);
|
||||
if (index < MAX_ANALOG_INPUTS) {
|
||||
state = AI_Descr[index].Event_State;
|
||||
}
|
||||
#endif
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool Analog_Input_Change_Of_Value(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0;
|
||||
@@ -275,8 +304,13 @@ bool Analog_Input_Encode_Value_List(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, false);
|
||||
if (Analog_Input_Event_State(object_instance) == EVENT_STATE_NORMAL) {
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, false);
|
||||
} else {
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, true);
|
||||
}
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(
|
||||
@@ -408,12 +442,9 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
|
||||
case PROP_STATUS_FLAGS:
|
||||
bitstring_init(&bit_string);
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
|
||||
CurrentAI->Event_State ? true : false);
|
||||
#else
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
#endif
|
||||
Analog_Input_Event_State(rpdata->object_instance) !=
|
||||
EVENT_STATE_NORMAL);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
@@ -423,13 +454,9 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_STATE:
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], CurrentAI->Event_State);
|
||||
#else
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
#endif
|
||||
encode_application_enumerated(&apdu[0],
|
||||
Analog_Input_Event_State(rpdata->object_instance));
|
||||
break;
|
||||
|
||||
case PROP_RELIABILITY:
|
||||
@@ -810,37 +837,33 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
{
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
BACNET_EVENT_NOTIFICATION_DATA event_data;
|
||||
BACNET_CHARACTER_STRING msgText;
|
||||
ANALOG_INPUT_DESCR *CurrentAI;
|
||||
unsigned int object_index;
|
||||
BACNET_EVENT_NOTIFICATION_DATA event_data = { 0 };
|
||||
BACNET_CHARACTER_STRING msgText = { 0 };
|
||||
ANALOG_INPUT_DESCR *CurrentAI = NULL;
|
||||
unsigned int object_index = 0;
|
||||
uint8_t FromState = 0;
|
||||
uint8_t ToState;
|
||||
uint8_t ToState = 0;
|
||||
float ExceededLimit = 0.0f;
|
||||
float PresentVal = 0.0f;
|
||||
bool SendNotify = false;
|
||||
|
||||
object_index = Analog_Input_Instance_To_Index(object_instance);
|
||||
if (object_index < MAX_ANALOG_INPUTS)
|
||||
if (object_index < MAX_ANALOG_INPUTS) {
|
||||
CurrentAI = &AI_Descr[object_index];
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
|
||||
}
|
||||
/* check limits */
|
||||
if (!CurrentAI->Limit_Enable)
|
||||
if (!CurrentAI->Limit_Enable) {
|
||||
return; /* limits are not configured */
|
||||
}
|
||||
|
||||
if (CurrentAI->Ack_notify_data.bSendAckNotify) {
|
||||
/* clean bSendAckNotify flag */
|
||||
CurrentAI->Ack_notify_data.bSendAckNotify = false;
|
||||
/* copy toState */
|
||||
ToState = CurrentAI->Ack_notify_data.EventState;
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_INPUT), object_instance);
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
PRINTF("Analog-Input[%d]: Send AckNotification.\n", object_instance);
|
||||
characterstring_init_ansi(&msgText, "AckNotification");
|
||||
|
||||
/* Notify Type */
|
||||
@@ -983,14 +1006,10 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
ExceededLimit = 0;
|
||||
break;
|
||||
} /* switch (ToState) */
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_INPUT), object_instance,
|
||||
PRINTF("Analog-Input[%d]: Event_State goes from %s to %s.\n",
|
||||
object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAI->Notify_Type;
|
||||
|
||||
@@ -1006,25 +1025,49 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* Time Stamp */
|
||||
event_data.timeStamp.tag = TIME_STAMP_DATETIME;
|
||||
Device_getCurrentDateTime(&event_data.timeStamp.value.dateTime);
|
||||
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
Device_getCurrentDateTime(&event_data.timeStamp.value.dateTime);
|
||||
/* fill Event_Time_Stamps */
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
datetime_copy(
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL],
|
||||
&event_data.timeStamp.value.dateTime);
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
datetime_copy(
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT],
|
||||
&event_data.timeStamp.value.dateTime);
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
datetime_copy(
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL],
|
||||
&event_data.timeStamp.value.dateTime);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* fill event_data timeStamp */
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL]);
|
||||
break;
|
||||
case EVENT_STATE_FAULT:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT]);
|
||||
break;
|
||||
case EVENT_STATE_NORMAL:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1058,7 +1101,8 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
&event_data.notificationParams.outOfRange.statusFlags);
|
||||
bitstring_set_bit(
|
||||
&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_IN_ALARM, CurrentAI->Event_State ? true : false);
|
||||
STATUS_FLAG_IN_ALARM,
|
||||
CurrentAI->Event_State != EVENT_STATE_NORMAL);
|
||||
bitstring_set_bit(
|
||||
&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_FAULT, false);
|
||||
@@ -1077,11 +1121,23 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
/* add data from notification class */
|
||||
PRINTF("Analog-Input[%d]: Notification Class[%d]-%s "
|
||||
"%u/%u/%u-%u:%u:%u.%u!\n",
|
||||
object_instance, event_data.notificationClass,
|
||||
bactext_event_type_name(event_data.eventType),
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.year,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.month,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.day,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.hour,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.min,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.sec,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.hundredths);
|
||||
Notification_Class_common_reporting_function(&event_data);
|
||||
|
||||
/* Ack required */
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true)) {
|
||||
PRINTF("Analog-Input[%d]: Ack Required!\n", object_instance);
|
||||
switch (event_data.toState) {
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
@@ -1221,10 +1277,12 @@ int Analog_Input_Alarm_Ack(
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
/* Send ack notification */
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
|
||||
true;
|
||||
} else if (alarmack_data->eventStateAcked ==
|
||||
CurrentAI->Event_State) {
|
||||
/* Send ack notification */
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
@@ -1245,10 +1303,12 @@ int Analog_Input_Alarm_Ack(
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
/* Send ack notification */
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
|
||||
true;
|
||||
} else if (alarmack_data->eventStateAcked ==
|
||||
CurrentAI->Event_State) {
|
||||
/* Send ack notification */
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
@@ -1269,10 +1329,12 @@ int Analog_Input_Alarm_Ack(
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
/* Send ack notification */
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
|
||||
true;
|
||||
} else if (alarmack_data->eventStateAcked ==
|
||||
CurrentAI->Event_State) {
|
||||
/* Send ack notification */
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
|
||||
@@ -140,6 +140,11 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
bool oos_flag);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Analog_Input_Event_State(uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Input_Event_State_Set(uint32_t object_instance, unsigned state);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Input_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
|
||||
@@ -290,6 +290,28 @@ bool Analog_Value_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, gets the event-state property value
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
*
|
||||
* @return event-state property value
|
||||
*/
|
||||
unsigned Analog_Value_Event_State(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0;
|
||||
unsigned state = EVENT_STATE_NORMAL;
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
index = Analog_Value_Instance_To_Index(object_instance);
|
||||
if (index < MAX_ANALOG_VALUES) {
|
||||
state = AV_Descr[index].Event_State;
|
||||
}
|
||||
#endif
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given object instance-number, determines if the COV flag
|
||||
* has been triggered.
|
||||
@@ -356,8 +378,13 @@ bool Analog_Value_Encode_Value_List(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, false);
|
||||
if (Analog_Value_Event_State(object_instance) == EVENT_STATE_NORMAL) {
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, false);
|
||||
} else {
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, true);
|
||||
}
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(
|
||||
@@ -497,12 +524,9 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
|
||||
case PROP_STATUS_FLAGS:
|
||||
bitstring_init(&bit_string);
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
|
||||
CurrentAV->Event_State ? true : false);
|
||||
#else
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
#endif
|
||||
Analog_Value_Event_State(rpdata->object_instance) !=
|
||||
EVENT_STATE_NORMAL);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
@@ -1155,7 +1179,8 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
&event_data.notificationParams.outOfRange.statusFlags);
|
||||
bitstring_set_bit(
|
||||
&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_IN_ALARM, CurrentAV->Event_State ? true : false);
|
||||
STATUS_FLAG_IN_ALARM,
|
||||
CurrentAV->Event_State != EVENT_STATE_NORMAL);
|
||||
bitstring_set_bit(
|
||||
&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_FAULT, false);
|
||||
@@ -1322,6 +1347,9 @@ int Analog_Value_Alarm_Ack(
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
|
||||
true;
|
||||
} else if (alarmack_data->eventStateAcked ==
|
||||
CurrentAV->Event_State) {
|
||||
/* Send ack notification */
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
@@ -1346,6 +1374,9 @@ int Analog_Value_Alarm_Ack(
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
|
||||
true;
|
||||
} else if (alarmack_data->eventStateAcked ==
|
||||
CurrentAV->Event_State) {
|
||||
/* Send ack notification */
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
@@ -1370,6 +1401,9 @@ int Analog_Value_Alarm_Ack(
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
|
||||
true;
|
||||
} else if (alarmack_data->eventStateAcked ==
|
||||
CurrentAV->Event_State) {
|
||||
/* Send ack notification */
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
|
||||
@@ -117,6 +117,14 @@ extern "C" {
|
||||
float Analog_Value_Present_Value(
|
||||
uint32_t object_instance);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned Analog_Value_Event_State(
|
||||
uint32_t object_instance);
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Value_Event_State_Set(
|
||||
uint32_t object_instance,
|
||||
unsigned state);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool Analog_Value_Change_Of_Value(
|
||||
uint32_t instance);
|
||||
|
||||
@@ -46,6 +46,14 @@
|
||||
#include "bacnet/basic/tsm/tsm.h"
|
||||
#include "bacnet/wp.h"
|
||||
#include "bacnet/basic/object/nc.h"
|
||||
#include "bacnet/datalink/datalink.h"
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
#ifndef MAX_NOTIFICATION_CLASSES
|
||||
#define MAX_NOTIFICATION_CLASSES 2
|
||||
@@ -89,7 +97,29 @@ void Notification_Class_Init(void)
|
||||
NC_Info[NotifyIdx].Priority[TRANSITION_TO_FAULT] =
|
||||
255; /* The lowest priority for Normal message. */
|
||||
NC_Info[NotifyIdx].Priority[TRANSITION_TO_NORMAL] =
|
||||
255; /* The lowest priority for Normal message. */
|
||||
255; /* PRINTF lowest priority for Normal message. */
|
||||
/* configure for every day, all day long */
|
||||
for (unsigned i = 0; i < MAX_BACNET_DAYS_OF_WEEK; i++) {
|
||||
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1<<i);
|
||||
}
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hour = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.min = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.sec = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hour = 23;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.min = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.sec = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->Transitions =
|
||||
TRANSITION_TO_OFFNORMAL_MASKED |
|
||||
TRANSITION_TO_FAULT_MASKED |
|
||||
TRANSITION_TO_NORMAL_MASKED;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->Recipient.RecipientType =
|
||||
RECIPIENT_TYPE_DEVICE;
|
||||
NC_Info[NotifyIdx].Recipient_List->Recipient._.DeviceIdentifier =
|
||||
4194303;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -862,6 +892,8 @@ void Notification_Class_common_reporting_function(
|
||||
}
|
||||
|
||||
/* send notifications for active recipients */
|
||||
PRINTF("Notification Class[%u]: send notifications\n",
|
||||
event_data->notificationClass);
|
||||
/* pointer to first recipient */
|
||||
pBacDest = &CurrentNotify->Recipient_List[0];
|
||||
for (index = 0; index < NC_MAX_RECIPIENTS; index++, pBacDest++) {
|
||||
@@ -869,7 +901,7 @@ void Notification_Class_common_reporting_function(
|
||||
if (pBacDest->Recipient.RecipientType == RECIPIENT_TYPE_NOTINITIALIZED)
|
||||
break; /* recipient doesn't defined - end of list */
|
||||
|
||||
if (IsRecipientActive(pBacDest, event_data->toState) == true) {
|
||||
if (IsRecipientActive(pBacDest, event_data->toState)) {
|
||||
BACNET_ADDRESS dest;
|
||||
uint32_t device_id;
|
||||
unsigned max_apdu;
|
||||
@@ -881,7 +913,8 @@ void Notification_Class_common_reporting_function(
|
||||
if (pBacDest->Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) {
|
||||
/* send notification to the specified device */
|
||||
device_id = pBacDest->Recipient._.DeviceIdentifier;
|
||||
|
||||
PRINTF("Notification Class[%u]: send notification to %u\n",
|
||||
event_data->notificationClass, (unsigned)device_id);
|
||||
if (pBacDest->ConfirmedNotify == true)
|
||||
Send_CEvent_Notify(device_id, event_data);
|
||||
else if (address_get_by_device(device_id, &max_apdu, &dest))
|
||||
@@ -889,6 +922,8 @@ void Notification_Class_common_reporting_function(
|
||||
Handler_Transmit_Buffer, event_data, &dest);
|
||||
} else if (pBacDest->Recipient.RecipientType ==
|
||||
RECIPIENT_TYPE_ADDRESS) {
|
||||
PRINTF("Notification Class[%u]: send notification to ADDR\n",
|
||||
event_data->notificationClass);
|
||||
/* send notification to the address indicated */
|
||||
if (pBacDest->ConfirmedNotify == true) {
|
||||
if (address_get_device_id(&dest, &device_id))
|
||||
|
||||
Reference in New Issue
Block a user