Acknowledge Alarm for Analog-Input and Analog-Value objects.
Moved initialization of handlers to GetEventInformations to specific init object.
This commit is contained in:
@@ -122,6 +122,13 @@ void Analog_Input_Init(
|
||||
datetime_wildcard_set(&AI_Descr[i].Event_Time_Stamps[j]);
|
||||
AI_Descr[i].Acked_Transitions[j].bIsAcked = true;
|
||||
}
|
||||
|
||||
/* Set handler for GetEventInformation function */
|
||||
handler_get_event_information_set(OBJECT_ANALOG_INPUT,
|
||||
Analog_Input_Event_Information);
|
||||
/* Set handler for AcknowledgeAlarm function */
|
||||
handler_alarm_ack_set(OBJECT_ANALOG_INPUT,
|
||||
Analog_Input_Alarm_Ack);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -873,10 +880,10 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
int Analog_Input_Event_Information(unsigned index,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
|
||||
{
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
bool IsNotAckedTransitions;
|
||||
bool IsActiveEvent;
|
||||
int i;
|
||||
@@ -934,10 +941,104 @@ int Analog_Input_Event_Information(unsigned index,
|
||||
}
|
||||
else
|
||||
return 0; /* no active event at this index */
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
}
|
||||
|
||||
|
||||
int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
ANALOG_INPUT_DESCR *CurrentAI;
|
||||
unsigned int object_index;
|
||||
|
||||
|
||||
object_index = Analog_Input_Instance_To_Index(
|
||||
alarmack_data->eventObjectIdentifier.instance);
|
||||
|
||||
if (object_index < MAX_ANALOG_INPUTS)
|
||||
CurrentAI = &AI_Descr[object_index];
|
||||
else {
|
||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (alarmack_data->eventStateAcked)
|
||||
{
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
if(CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
|
||||
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
if(datetime_compare(&CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
|
||||
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
|
||||
{
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
if(CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false) {
|
||||
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
if(datetime_compare(&CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
|
||||
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
|
||||
{
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
if(CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) {
|
||||
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
if(datetime_compare(&CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
|
||||
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
|
||||
{
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
#include <assert.h>
|
||||
|
||||
@@ -113,6 +113,9 @@ extern "C" {
|
||||
int Analog_Input_Event_Information(unsigned index,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data);
|
||||
|
||||
int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
void Analog_Input_Init(
|
||||
void);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "bacapp.h"
|
||||
#include "bactext.h"
|
||||
#include "config.h" /* the custom stuff */
|
||||
#include "alarm_ack.h"
|
||||
#include "getevent.h"
|
||||
#include "wp.h"
|
||||
#include "rp.h"
|
||||
@@ -131,6 +132,13 @@ void Analog_Value_Init(
|
||||
datetime_wildcard_set(&AV_Descr[i].Event_Time_Stamps[j]);
|
||||
AV_Descr[i].Acked_Transitions[j].bIsAcked = true;
|
||||
}
|
||||
|
||||
/* Set handler for GetEventInformation function */
|
||||
handler_get_event_information_set(OBJECT_ANALOG_VALUE,
|
||||
Analog_Value_Event_Information);
|
||||
/* Set handler for AcknowledgeAlarm function */
|
||||
handler_alarm_ack_set(OBJECT_ANALOG_VALUE,
|
||||
Analog_Value_Alarm_Ack);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -983,10 +991,10 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
int Analog_Value_Event_Information(unsigned index,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
|
||||
{
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
bool IsNotAckedTransitions;
|
||||
bool IsActiveEvent;
|
||||
int i;
|
||||
@@ -1044,9 +1052,102 @@ int Analog_Value_Event_Information(unsigned index,
|
||||
}
|
||||
else
|
||||
return 0; /* no active event at this index */
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
}
|
||||
|
||||
int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
ANALOG_VALUE_DESCR *CurrentAV;
|
||||
unsigned int object_index;
|
||||
|
||||
|
||||
object_index = Analog_Value_Instance_To_Index(
|
||||
alarmack_data->eventObjectIdentifier.instance);
|
||||
|
||||
if (object_index < MAX_ANALOG_VALUES)
|
||||
CurrentAV = &AV_Descr[object_index];
|
||||
else {
|
||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (alarmack_data->eventStateAcked)
|
||||
{
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
if(CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
|
||||
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
if(datetime_compare(&CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
|
||||
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
|
||||
{
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
if(CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false) {
|
||||
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
if(datetime_compare(&CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
|
||||
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
|
||||
{
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
if(CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) {
|
||||
if(alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME){
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
if(datetime_compare(&CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
|
||||
&alarmack_data->eventTimeStamp.value.dateTime) > 0)
|
||||
{
|
||||
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: Send ack notification */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
@@ -100,6 +100,9 @@ extern "C" {
|
||||
int Analog_Value_Event_Information(unsigned index,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data);
|
||||
|
||||
int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
void Analog_Value_Init(
|
||||
void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user