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:
Steve Karg
2021-04-22 08:33:04 -05:00
committed by GitHub
parent 2277ff903a
commit a7bc145c43
19 changed files with 966 additions and 99 deletions
+38 -3
View File
@@ -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))