After acknowledgment an alarm is sent AckNotification.
This commit is contained in:
@@ -633,10 +633,11 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
BACNET_CHARACTER_STRING msgText;
|
||||
ANALOG_INPUT_DESCR *CurrentAI;
|
||||
unsigned int object_index;
|
||||
uint8_t FromState;
|
||||
uint8_t FromState = 0;
|
||||
uint8_t ToState;
|
||||
float ExceededLimit;
|
||||
float PresentVal;
|
||||
float ExceededLimit = 0.0f;
|
||||
float PresentVal = 0.0f;
|
||||
bool SendNotify = false;
|
||||
|
||||
|
||||
object_index = Analog_Input_Instance_To_Index(object_instance);
|
||||
@@ -649,6 +650,29 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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 */
|
||||
|
||||
characterstring_init_ansi(&msgText, "AckNotification");
|
||||
|
||||
/* Notify Type */
|
||||
event_data.notifyType = NOTIFY_ACK_NOTIFICATION;
|
||||
|
||||
/* Send EventNotification. */
|
||||
SendNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* actual Present_Value */
|
||||
PresentVal = Analog_Input_Present_Value(object_instance);
|
||||
FromState = CurrentAI->Event_State;
|
||||
@@ -778,12 +802,23 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
} /* switch (ToState) */
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Event_State for (Analog-Input,%d) goes from %s to %s.\n",
|
||||
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_INPUT),
|
||||
object_instance, bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
#endif /* PRINT_ENABLED) */
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAI->Notify_Type;
|
||||
|
||||
/* Send EventNotification. */
|
||||
SendNotify = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SendNotify)
|
||||
{
|
||||
/* Event Object Identifier */
|
||||
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT;
|
||||
event_data.eventObjectIdentifier.instance = object_instance;
|
||||
@@ -791,6 +826,8 @@ 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) {
|
||||
/* fill Event_Time_Stamps */
|
||||
switch (ToState)
|
||||
{
|
||||
@@ -810,6 +847,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Notification Class */
|
||||
event_data.notificationClass = CurrentAI->Notification_Class;
|
||||
@@ -821,17 +859,20 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
event_data.messageText = &msgText;
|
||||
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAI->Notify_Type;
|
||||
/* filled before */
|
||||
|
||||
/* From State */
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION)
|
||||
event_data.fromState = FromState;
|
||||
|
||||
/* To State */
|
||||
event_data.toState = CurrentAI->Event_State;
|
||||
|
||||
/* Event Values */
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
/* Value that exceeded a limit. */
|
||||
event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
|
||||
|
||||
/* Status_Flags of the referenced object. */
|
||||
bitstring_init(&event_data.notificationParams.outOfRange.statusFlags);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_IN_ALARM, CurrentAI->Event_State ? true : false);
|
||||
@@ -841,16 +882,18 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service);
|
||||
|
||||
/* Deadband used for limit checking. */
|
||||
event_data.notificationParams.outOfRange.deadband = CurrentAI->Deadband;
|
||||
|
||||
/* Limit that was exceeded. */
|
||||
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
|
||||
}
|
||||
|
||||
/* add data from notification class */
|
||||
Notification_Class_common_reporting_function(&event_data);
|
||||
|
||||
/* Ack required */
|
||||
if (event_data.ackRequired == true)
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true))
|
||||
{
|
||||
switch (event_data.toState)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,8 @@ extern "C" {
|
||||
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
|
||||
/* time to generate event notification */
|
||||
uint32_t Remaining_Time_Delay;
|
||||
/* AckNotification informations */
|
||||
ACK_NOTIFICATION Ack_notify_data;
|
||||
#endif
|
||||
} ANALOG_INPUT_DESCR;
|
||||
|
||||
|
||||
@@ -744,10 +744,11 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
BACNET_CHARACTER_STRING msgText;
|
||||
ANALOG_VALUE_DESCR *CurrentAV;
|
||||
unsigned int object_index;
|
||||
uint8_t FromState;
|
||||
uint8_t FromState = 0;
|
||||
uint8_t ToState;
|
||||
float ExceededLimit;
|
||||
float PresentVal;
|
||||
float ExceededLimit = 0.0f;
|
||||
float PresentVal = 0.0f;
|
||||
bool SendNotify = false;
|
||||
|
||||
|
||||
object_index = Analog_Value_Instance_To_Index(object_instance);
|
||||
@@ -760,6 +761,29 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
if (!CurrentAV->Limit_Enable)
|
||||
return; /* limits are not configured */
|
||||
|
||||
|
||||
if (CurrentAV->Ack_notify_data.bSendAckNotify) {
|
||||
/* clean bSendAckNotify flag */
|
||||
CurrentAV->Ack_notify_data.bSendAckNotify = false;
|
||||
/* copy toState */
|
||||
ToState = CurrentAV->Ack_notify_data.EventState;
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||
object_instance);
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
characterstring_init_ansi(&msgText, "AckNotification");
|
||||
|
||||
/* Notify Type */
|
||||
event_data.notifyType = NOTIFY_ACK_NOTIFICATION;
|
||||
|
||||
/* Send EventNotification. */
|
||||
SendNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* actual Present_Value */
|
||||
PresentVal = Analog_Value_Present_Value(object_instance);
|
||||
FromState = CurrentAV->Event_State;
|
||||
@@ -889,12 +913,23 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
} /* switch (ToState) */
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Event_State for (Analog-Value,%d) goes from %s to %s.\n",
|
||||
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||
object_instance, bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAV->Notify_Type;
|
||||
|
||||
/* Send EventNotification. */
|
||||
SendNotify = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SendNotify)
|
||||
{
|
||||
/* Event Object Identifier */
|
||||
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_VALUE;
|
||||
event_data.eventObjectIdentifier.instance = object_instance;
|
||||
@@ -902,6 +937,8 @@ void Analog_Value_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) {
|
||||
/* fill Event_Time_Stamps */
|
||||
switch (ToState)
|
||||
{
|
||||
@@ -921,6 +958,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Notification Class */
|
||||
event_data.notificationClass = CurrentAV->Notification_Class;
|
||||
@@ -932,17 +970,20 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
event_data.messageText = &msgText;
|
||||
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAV->Notify_Type;
|
||||
/* filled before */
|
||||
|
||||
/* From State */
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION)
|
||||
event_data.fromState = FromState;
|
||||
|
||||
/* To State */
|
||||
event_data.toState = CurrentAV->Event_State;
|
||||
|
||||
/* Event Values */
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
/* Value that exceeded a limit. */
|
||||
event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
|
||||
|
||||
/* Status_Flags of the referenced object. */
|
||||
bitstring_init(&event_data.notificationParams.outOfRange.statusFlags);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_IN_ALARM, CurrentAV->Event_State ? true : false);
|
||||
@@ -952,16 +993,18 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service);
|
||||
|
||||
/* Deadband used for limit checking. */
|
||||
event_data.notificationParams.outOfRange.deadband = CurrentAV->Deadband;
|
||||
|
||||
/* Limit that was exceeded. */
|
||||
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
|
||||
}
|
||||
|
||||
/* add data from notification class */
|
||||
Notification_Class_common_reporting_function(&event_data);
|
||||
|
||||
/* Ack required */
|
||||
if (event_data.ackRequired == true)
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true))
|
||||
{
|
||||
switch (event_data.toState)
|
||||
{
|
||||
@@ -1088,7 +1131,7 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
@@ -1110,7 +1153,7 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
@@ -1132,7 +1175,7 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
@@ -1145,6 +1188,11 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Need to send AckNotification. */
|
||||
CurrentAV->Ack_notify_data.bSendAckNotify = true;
|
||||
CurrentAV->Ack_notify_data.EventState = alarmack_data->eventStateAcked;
|
||||
|
||||
/* Return OK */
|
||||
return 1;
|
||||
}
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
|
||||
@@ -60,6 +60,8 @@ extern "C" {
|
||||
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
|
||||
/* time to generate event notification */
|
||||
uint32_t Remaining_Time_Delay;
|
||||
/* AckNotification informations */
|
||||
ACK_NOTIFICATION Ack_notify_data;
|
||||
#endif
|
||||
} ANALOG_VALUE_DESCR;
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ typedef struct BACnet_Recipient {
|
||||
} BACNET_RECIPIENT;
|
||||
|
||||
|
||||
|
||||
/* BACnetDestination structure */
|
||||
typedef struct BACnet_Destination {
|
||||
uint8_t ValidDays;
|
||||
@@ -73,6 +72,7 @@ typedef struct BACnet_Destination {
|
||||
bool ConfirmedNotify;
|
||||
} BACNET_DESTINATION;
|
||||
|
||||
|
||||
/* Structure containing configuration for a Notification Class */
|
||||
typedef struct Notification_Class_info {
|
||||
uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */
|
||||
@@ -88,6 +88,13 @@ typedef struct Acked_info {
|
||||
} ACKED_INFO;
|
||||
|
||||
|
||||
/* Information needed to send AckNotification */
|
||||
typedef struct Ack_Notification {
|
||||
bool bSendAckNotify; /* true if need to send AckNotification */
|
||||
uint8_t EventState;
|
||||
} ACK_NOTIFICATION;
|
||||
|
||||
|
||||
|
||||
void Notification_Class_Property_Lists(
|
||||
const int **pRequired,
|
||||
|
||||
Reference in New Issue
Block a user