After acknowledgment an alarm is sent AckNotification.

This commit is contained in:
k001a
2011-07-23 17:18:25 +00:00
parent c1d7633a8d
commit c37aa9ea90
5 changed files with 425 additions and 323 deletions
+202 -159
View File
@@ -633,10 +633,11 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
BACNET_CHARACTER_STRING msgText; BACNET_CHARACTER_STRING msgText;
ANALOG_INPUT_DESCR *CurrentAI; ANALOG_INPUT_DESCR *CurrentAI;
unsigned int object_index; unsigned int object_index;
uint8_t FromState; uint8_t FromState = 0;
uint8_t ToState; uint8_t ToState;
float ExceededLimit; float ExceededLimit = 0.0f;
float PresentVal; float PresentVal = 0.0f;
bool SendNotify = false;
object_index = Analog_Input_Instance_To_Index(object_instance); object_index = Analog_Input_Instance_To_Index(object_instance);
@@ -649,141 +650,175 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
if (!CurrentAI->Limit_Enable) if (!CurrentAI->Limit_Enable)
return; /* limits are not configured */ return; /* limits are not configured */
/* actual Present_Value */
PresentVal = Analog_Input_Present_Value(object_instance); if (CurrentAI->Ack_notify_data.bSendAckNotify) {
FromState = CurrentAI->Event_State; /* clean bSendAckNotify flag */
switch (CurrentAI->Event_State) 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
{ {
case EVENT_STATE_NORMAL: /* actual Present_Value */
/* A TO-OFFNORMAL event is generated under these conditions: PresentVal = Analog_Input_Present_Value(object_instance);
(a) the Present_Value must exceed the High_Limit for a minimum FromState = CurrentAI->Event_State;
period of time, specified in the Time_Delay property, and switch (CurrentAI->Event_State)
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAI->High_Limit) &&
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_HIGH_LIMIT;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->Low_Limit) &&
((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_LOW_LIMIT;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
break;
case EVENT_STATE_HIGH_LIMIT:
/* Once exceeded, the Present_Value must fall below the High_Limit minus
the Deadband before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->High_Limit - CurrentAI->Deadband) &&
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_NORMAL;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
break;
case EVENT_STATE_LOW_LIMIT:
/* Once the Present_Value has fallen below the Low_Limit,
the Present_Value must exceed the Low_Limit plus the Deadband
before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAI->Low_Limit + CurrentAI->Deadband) &&
((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_NORMAL;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
break;
default:
return; /* shouldn't happen */
} /* switch (FromState) */
ToState = CurrentAI->Event_State;
if (FromState != ToState)
{
/* Event_State has changed.
Need to fill only the basic parameters of this type of event.
Other parameters will be filled in common function. */
switch (ToState)
{ {
case EVENT_STATE_NORMAL:
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the High_Limit for a minimum
period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAI->High_Limit) &&
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_HIGH_LIMIT;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->Low_Limit) &&
((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_LOW_LIMIT;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
break;
case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_HIGH_LIMIT:
ExceededLimit = CurrentAI->High_Limit; /* Once exceeded, the Present_Value must fall below the High_Limit minus
characterstring_init_ansi(&msgText, the Deadband before a TO-NORMAL event is generated under these conditions:
"Goes to high limit"); (a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAI->High_Limit - CurrentAI->Deadband) &&
((CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAI->Remaining_Time_Delay)
CurrentAI->Event_State = EVENT_STATE_NORMAL;
else
CurrentAI->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
break; break;
case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_LOW_LIMIT:
ExceededLimit = CurrentAI->Low_Limit; /* Once the Present_Value has fallen below the Low_Limit,
characterstring_init_ansi(&msgText, the Present_Value must exceed the Low_Limit plus the Deadband
"Goes to low limit"); before a TO-NORMAL event is generated under these conditions:
break; (a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
case EVENT_STATE_NORMAL: (b) the LowLimitEnable flag must be set in the Limit_Enable property, and
if(FromState == EVENT_STATE_HIGH_LIMIT) { (c) the TO-NORMAL flag must be set in the Event_Enable property. */
ExceededLimit = CurrentAI->High_Limit; if ((PresentVal > CurrentAI->Low_Limit + CurrentAI->Deadband) &&
characterstring_init_ansi(&msgText, ((CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
"Back to normal state from high limit"); ((CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
} {
else { if(!CurrentAI->Remaining_Time_Delay)
ExceededLimit = CurrentAI->Low_Limit; CurrentAI->Event_State = EVENT_STATE_NORMAL;
characterstring_init_ansi(&msgText, else
"Back to normal state from low limit"); CurrentAI->Remaining_Time_Delay--;
break;
} }
/* value of the object is still in the same event state */
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
break; break;
default: default:
ExceededLimit = 0; return; /* shouldn't happen */
break; } /* switch (FromState) */
} /* switch (ToState) */
ToState = CurrentAI->Event_State;
if (FromState != ToState)
{
/* Event_State has changed.
Need to fill only the basic parameters of this type of event.
Other parameters will be filled in common function. */
switch (ToState)
{
case EVENT_STATE_HIGH_LIMIT:
ExceededLimit = CurrentAI->High_Limit;
characterstring_init_ansi(&msgText,
"Goes to high limit");
break;
case EVENT_STATE_LOW_LIMIT:
ExceededLimit = CurrentAI->Low_Limit;
characterstring_init_ansi(&msgText,
"Goes to low limit");
break;
case EVENT_STATE_NORMAL:
if(FromState == EVENT_STATE_HIGH_LIMIT) {
ExceededLimit = CurrentAI->High_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from high limit");
}
else {
ExceededLimit = CurrentAI->Low_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from low limit");
}
break;
default:
ExceededLimit = 0;
break;
} /* switch (ToState) */
#if PRINT_ENABLED #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",
object_instance, bactext_event_state_name(FromState), bactext_object_type_name(OBJECT_ANALOG_INPUT),
bactext_event_state_name(ToState)); 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 Object Identifier */
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT; event_data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT;
event_data.eventObjectIdentifier.instance = object_instance; event_data.eventObjectIdentifier.instance = object_instance;
@@ -791,24 +826,27 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
/* Time Stamp */ /* Time Stamp */
event_data.timeStamp.tag = TIME_STAMP_DATETIME; event_data.timeStamp.tag = TIME_STAMP_DATETIME;
Device_getCurrentDateTime(&event_data.timeStamp.value.dateTime); 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;
break;
case EVENT_STATE_FAULT: if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT] = /* fill Event_Time_Stamps */
event_data.timeStamp.value.dateTime; switch (ToState)
break; {
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL: case EVENT_STATE_FAULT:
CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL] = CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT] =
event_data.timeStamp.value.dateTime; event_data.timeStamp.value.dateTime;
break; break;
case EVENT_STATE_NORMAL:
CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
event_data.timeStamp.value.dateTime;
break;
}
} }
/* Notification Class */ /* Notification Class */
@@ -821,36 +859,41 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
event_data.messageText = &msgText; event_data.messageText = &msgText;
/* Notify Type */ /* Notify Type */
event_data.notifyType = CurrentAI->Notify_Type; /* filled before */
/* From State */ /* From State */
event_data.fromState = FromState; if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION)
event_data.fromState = FromState;
/* To State */ /* To State */
event_data.toState = CurrentAI->Event_State; event_data.toState = CurrentAI->Event_State;
/* Event Values */ /* Event Values */
event_data.notificationParams.outOfRange.exceedingValue = PresentVal; if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
/* Value that exceeded a limit. */
bitstring_init(&event_data.notificationParams.outOfRange.statusFlags); event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, /* Status_Flags of the referenced object. */
STATUS_FLAG_IN_ALARM, CurrentAI->Event_State ? true : false); bitstring_init(&event_data.notificationParams.outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_FAULT, false); STATUS_FLAG_IN_ALARM, CurrentAI->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OVERRIDDEN, false); STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service); STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
event_data.notificationParams.outOfRange.deadband = CurrentAI->Deadband; STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit; event_data.notificationParams.outOfRange.deadband = CurrentAI->Deadband;
/* Limit that was exceeded. */
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
}
/* add data from notification class */ /* add data from notification class */
Notification_Class_common_reporting_function(&event_data); Notification_Class_common_reporting_function(&event_data);
/* Ack required */ /* Ack required */
if (event_data.ackRequired == true) if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
(event_data.ackRequired == true))
{ {
switch (event_data.toState) switch (event_data.toState)
{ {
+2
View File
@@ -56,6 +56,8 @@ extern "C" {
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION]; BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */ /* time to generate event notification */
uint32_t Remaining_Time_Delay; uint32_t Remaining_Time_Delay;
/* AckNotification informations */
ACK_NOTIFICATION Ack_notify_data;
#endif #endif
} ANALOG_INPUT_DESCR; } ANALOG_INPUT_DESCR;
+210 -162
View File
@@ -744,10 +744,11 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
BACNET_CHARACTER_STRING msgText; BACNET_CHARACTER_STRING msgText;
ANALOG_VALUE_DESCR *CurrentAV; ANALOG_VALUE_DESCR *CurrentAV;
unsigned int object_index; unsigned int object_index;
uint8_t FromState; uint8_t FromState = 0;
uint8_t ToState; uint8_t ToState;
float ExceededLimit; float ExceededLimit = 0.0f;
float PresentVal; float PresentVal = 0.0f;
bool SendNotify = false;
object_index = Analog_Value_Instance_To_Index(object_instance); object_index = Analog_Value_Instance_To_Index(object_instance);
@@ -760,141 +761,175 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
if (!CurrentAV->Limit_Enable) if (!CurrentAV->Limit_Enable)
return; /* limits are not configured */ return; /* limits are not configured */
/* actual Present_Value */
PresentVal = Analog_Value_Present_Value(object_instance); if (CurrentAV->Ack_notify_data.bSendAckNotify) {
FromState = CurrentAV->Event_State; /* clean bSendAckNotify flag */
switch (CurrentAV->Event_State) 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
{ {
case EVENT_STATE_NORMAL: /* actual Present_Value */
/* A TO-OFFNORMAL event is generated under these conditions: PresentVal = Analog_Value_Present_Value(object_instance);
(a) the Present_Value must exceed the High_Limit for a minimum FromState = CurrentAV->Event_State;
period of time, specified in the Time_Delay property, and switch (CurrentAV->Event_State)
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAV->High_Limit) &&
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_HIGH_LIMIT;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->Low_Limit) &&
((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_LOW_LIMIT;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
break;
case EVENT_STATE_HIGH_LIMIT:
/* Once exceeded, the Present_Value must fall below the High_Limit minus
the Deadband before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->High_Limit - CurrentAV->Deadband) &&
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_NORMAL;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
break;
case EVENT_STATE_LOW_LIMIT:
/* Once the Present_Value has fallen below the Low_Limit,
the Present_Value must exceed the Low_Limit plus the Deadband
before a TO-NORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAV->Low_Limit + CurrentAV->Deadband) &&
((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_NORMAL;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
break;
default:
return; /* shouldn't happen */
} /* switch (FromState) */
ToState = CurrentAV->Event_State;
if (FromState != ToState)
{
/* Event_State has changed.
Need to fill only the basic parameters of this type of event.
Other parameters will be filled in common function. */
switch (ToState)
{ {
case EVENT_STATE_NORMAL:
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the High_Limit for a minimum
period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-OFFNORMAL flag must be set in the Event_Enable property. */
if ((PresentVal > CurrentAV->High_Limit) &&
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_HIGH_LIMIT;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* A TO-OFFNORMAL event is generated under these conditions:
(a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the LowLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->Low_Limit) &&
((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_LOW_LIMIT;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
break;
case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_HIGH_LIMIT:
ExceededLimit = CurrentAV->High_Limit; /* Once exceeded, the Present_Value must fall below the High_Limit minus
characterstring_init_ansi(&msgText, the Deadband before a TO-NORMAL event is generated under these conditions:
"Goes to high limit"); (a) the Present_Value must fall below the High_Limit minus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
(b) the HighLimitEnable flag must be set in the Limit_Enable property, and
(c) the TO-NORMAL flag must be set in the Event_Enable property. */
if ((PresentVal < CurrentAV->High_Limit - CurrentAV->Deadband) &&
((CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) == EVENT_HIGH_LIMIT_ENABLE) &&
((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
{
if(!CurrentAV->Remaining_Time_Delay)
CurrentAV->Event_State = EVENT_STATE_NORMAL;
else
CurrentAV->Remaining_Time_Delay--;
break;
}
/* value of the object is still in the same event state */
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
break; break;
case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_LOW_LIMIT:
ExceededLimit = CurrentAV->Low_Limit; /* Once the Present_Value has fallen below the Low_Limit,
characterstring_init_ansi(&msgText, the Present_Value must exceed the Low_Limit plus the Deadband
"Goes to low limit"); before a TO-NORMAL event is generated under these conditions:
break; (a) the Present_Value must exceed the Low_Limit plus the Deadband
for a minimum period of time, specified in the Time_Delay property, and
case EVENT_STATE_NORMAL: (b) the LowLimitEnable flag must be set in the Limit_Enable property, and
if(FromState == EVENT_STATE_HIGH_LIMIT) { (c) the TO-NORMAL flag must be set in the Event_Enable property. */
ExceededLimit = CurrentAV->High_Limit; if ((PresentVal > CurrentAV->Low_Limit + CurrentAV->Deadband) &&
characterstring_init_ansi(&msgText, ((CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) == EVENT_LOW_LIMIT_ENABLE) &&
"Back to normal state from high limit"); ((CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL))
} {
else { if(!CurrentAV->Remaining_Time_Delay)
ExceededLimit = CurrentAV->Low_Limit; CurrentAV->Event_State = EVENT_STATE_NORMAL;
characterstring_init_ansi(&msgText, else
"Back to normal state from low limit"); CurrentAV->Remaining_Time_Delay--;
break;
} }
/* value of the object is still in the same event state */
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
break; break;
default: default:
ExceededLimit = 0; return; /* shouldn't happen */
break; } /* switch (FromState) */
} /* switch (ToState) */
ToState = CurrentAV->Event_State;
if (FromState != ToState)
{
/* Event_State has changed.
Need to fill only the basic parameters of this type of event.
Other parameters will be filled in common function. */
switch (ToState)
{
case EVENT_STATE_HIGH_LIMIT:
ExceededLimit = CurrentAV->High_Limit;
characterstring_init_ansi(&msgText,
"Goes to high limit");
break;
case EVENT_STATE_LOW_LIMIT:
ExceededLimit = CurrentAV->Low_Limit;
characterstring_init_ansi(&msgText,
"Goes to low limit");
break;
case EVENT_STATE_NORMAL:
if(FromState == EVENT_STATE_HIGH_LIMIT) {
ExceededLimit = CurrentAV->High_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from high limit");
}
else {
ExceededLimit = CurrentAV->Low_Limit;
characterstring_init_ansi(&msgText,
"Back to normal state from low limit");
}
break;
default:
ExceededLimit = 0;
break;
} /* switch (ToState) */
#if PRINT_ENABLED #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",
object_instance, bactext_event_state_name(FromState), bactext_object_type_name(OBJECT_ANALOG_VALUE),
bactext_event_state_name(ToState)); object_instance, bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
#endif /* PRINT_ENABLED */ #endif /* PRINT_ENABLED */
/* Notify Type */
event_data.notifyType = CurrentAV->Notify_Type;
/* Send EventNotification. */
SendNotify = true;
}
}
if (SendNotify)
{
/* Event Object Identifier */ /* Event Object Identifier */
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_VALUE; event_data.eventObjectIdentifier.type = OBJECT_ANALOG_VALUE;
event_data.eventObjectIdentifier.instance = object_instance; event_data.eventObjectIdentifier.instance = object_instance;
@@ -902,24 +937,27 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
/* Time Stamp */ /* Time Stamp */
event_data.timeStamp.tag = TIME_STAMP_DATETIME; event_data.timeStamp.tag = TIME_STAMP_DATETIME;
Device_getCurrentDateTime(&event_data.timeStamp.value.dateTime); Device_getCurrentDateTime(&event_data.timeStamp.value.dateTime);
/* fill Event_Time_Stamps */
switch (ToState)
{
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT: if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
CurrentAV->Event_Time_Stamps[TRANSITION_TO_FAULT] = /* fill Event_Time_Stamps */
event_data.timeStamp.value.dateTime; switch (ToState)
break; {
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL: case EVENT_STATE_FAULT:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] = CurrentAV->Event_Time_Stamps[TRANSITION_TO_FAULT] =
event_data.timeStamp.value.dateTime; event_data.timeStamp.value.dateTime;
break; break;
case EVENT_STATE_NORMAL:
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
event_data.timeStamp.value.dateTime;
break;
}
} }
/* Notification Class */ /* Notification Class */
@@ -932,36 +970,41 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
event_data.messageText = &msgText; event_data.messageText = &msgText;
/* Notify Type */ /* Notify Type */
event_data.notifyType = CurrentAV->Notify_Type; /* filled before */
/* From State */ /* From State */
event_data.fromState = FromState; if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION)
event_data.fromState = FromState;
/* To State */ /* To State */
event_data.toState = CurrentAV->Event_State; event_data.toState = CurrentAV->Event_State;
/* Event Values */ /* Event Values */
event_data.notificationParams.outOfRange.exceedingValue = PresentVal; if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
/* Value that exceeded a limit. */
bitstring_init(&event_data.notificationParams.outOfRange.statusFlags); event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, /* Status_Flags of the referenced object. */
STATUS_FLAG_IN_ALARM, CurrentAV->Event_State ? true : false); bitstring_init(&event_data.notificationParams.outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_FAULT, false); STATUS_FLAG_IN_ALARM, CurrentAV->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OVERRIDDEN, false); STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags, bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service); STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
event_data.notificationParams.outOfRange.deadband = CurrentAV->Deadband; STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit; event_data.notificationParams.outOfRange.deadband = CurrentAV->Deadband;
/* Limit that was exceeded. */
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
}
/* add data from notification class */ /* add data from notification class */
Notification_Class_common_reporting_function(&event_data); Notification_Class_common_reporting_function(&event_data);
/* Ack required */ /* Ack required */
if (event_data.ackRequired == true) if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
(event_data.ackRequired == true))
{ {
switch (event_data.toState) switch (event_data.toState)
{ {
@@ -1088,7 +1131,7 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
return -1; return -1;
} }
/* FIXME: Send ack notification */ /* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true; CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} }
else { else {
@@ -1110,7 +1153,7 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
return -1; return -1;
} }
/* FIXME: Send ack notification */ /* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true; CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
} }
else { else {
@@ -1132,7 +1175,7 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
return -1; return -1;
} }
/* FIXME: Send ack notification */ /* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true; CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
} }
else { else {
@@ -1145,6 +1188,11 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
return -2; return -2;
} }
/* Need to send AckNotification. */
CurrentAV->Ack_notify_data.bSendAckNotify = true;
CurrentAV->Ack_notify_data.EventState = alarmack_data->eventStateAcked;
/* Return OK */
return 1; return 1;
} }
#endif /* defined(INTRINSIC_REPORTING) */ #endif /* defined(INTRINSIC_REPORTING) */
+2
View File
@@ -60,6 +60,8 @@ extern "C" {
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION]; BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
/* time to generate event notification */ /* time to generate event notification */
uint32_t Remaining_Time_Delay; uint32_t Remaining_Time_Delay;
/* AckNotification informations */
ACK_NOTIFICATION Ack_notify_data;
#endif #endif
} ANALOG_VALUE_DESCR; } ANALOG_VALUE_DESCR;
+8 -1
View File
@@ -61,7 +61,6 @@ typedef struct BACnet_Recipient {
} BACNET_RECIPIENT; } BACNET_RECIPIENT;
/* BACnetDestination structure */ /* BACnetDestination structure */
typedef struct BACnet_Destination { typedef struct BACnet_Destination {
uint8_t ValidDays; uint8_t ValidDays;
@@ -73,6 +72,7 @@ typedef struct BACnet_Destination {
bool ConfirmedNotify; bool ConfirmedNotify;
} BACNET_DESTINATION; } BACNET_DESTINATION;
/* Structure containing configuration for a Notification Class */ /* Structure containing configuration for a Notification Class */
typedef struct Notification_Class_info { typedef struct Notification_Class_info {
uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */ uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */
@@ -88,6 +88,13 @@ typedef struct Acked_info {
} 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( void Notification_Class_Property_Lists(
const int **pRequired, const int **pRequired,