Handling of GetAlarmSummary service.
This commit is contained in:
@@ -131,6 +131,9 @@ void Analog_Input_Init(
|
||||
Analog_Input_Event_Information);
|
||||
/* Set handler for AcknowledgeAlarm function */
|
||||
handler_alarm_ack_set(OBJECT_ANALOG_INPUT, Analog_Input_Alarm_Ack);
|
||||
/* Set handler for GetAlarmSummary Service */
|
||||
handler_get_alarm_summary_set(OBJECT_ANALOG_INPUT,
|
||||
Analog_Input_Alarm_Summary);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1118,6 +1121,44 @@ int Analog_Input_Alarm_Ack(
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Analog_Input_Alarm_Summary(
|
||||
unsigned index,
|
||||
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data)
|
||||
{
|
||||
|
||||
/* check index */
|
||||
if (index < MAX_ANALOG_INPUTS) {
|
||||
/* Event_State is not equal to NORMAL and
|
||||
Notify_Type property value is ALARM */
|
||||
if((AI_Descr[index].Event_State != EVENT_STATE_NORMAL) &&
|
||||
(AI_Descr[index].Notify_Type == NOTIFY_ALARM)){
|
||||
/* Object Identifier */
|
||||
getalarm_data->objectIdentifier.type = OBJECT_ANALOG_INPUT;
|
||||
getalarm_data->objectIdentifier.instance =
|
||||
Analog_Input_Index_To_Instance(index);
|
||||
/* Alarm State */
|
||||
getalarm_data->alarmState = AI_Descr[index].Event_State;
|
||||
/* Acknowledged Transitions */
|
||||
bitstring_init(&getalarm_data->acknowledgedTransitions);
|
||||
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_OFFNORMAL,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_FAULT,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_NORMAL,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
|
||||
return 1; /* active alarm */
|
||||
}
|
||||
else
|
||||
return 0; /* no active alarm at this index */
|
||||
} else
|
||||
return -1; /* end of list */
|
||||
}
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "nc.h"
|
||||
#include "getevent.h"
|
||||
#include "alarm_ack.h"
|
||||
#include "get_alarm_sum.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -124,6 +125,10 @@ extern "C" {
|
||||
int Analog_Input_Alarm_Ack(
|
||||
BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
int Analog_Input_Alarm_Summary(
|
||||
unsigned index,
|
||||
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data);
|
||||
#endif
|
||||
|
||||
void Analog_Input_Init(
|
||||
|
||||
@@ -134,6 +134,9 @@ void Analog_Value_Init(
|
||||
Analog_Value_Event_Information);
|
||||
/* Set handler for AcknowledgeAlarm function */
|
||||
handler_alarm_ack_set(OBJECT_ANALOG_VALUE, Analog_Value_Alarm_Ack);
|
||||
/* Set handler for GetAlarmSummary Service */
|
||||
handler_get_alarm_summary_set(OBJECT_ANALOG_VALUE,
|
||||
Analog_Value_Alarm_Summary);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1220,6 +1223,44 @@ int Analog_Value_Alarm_Ack(
|
||||
/* Return OK */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Analog_Value_Alarm_Summary(
|
||||
unsigned index,
|
||||
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data)
|
||||
{
|
||||
|
||||
/* check index */
|
||||
if (index < MAX_ANALOG_VALUES) {
|
||||
/* Event_State is not equal to NORMAL and
|
||||
Notify_Type property value is ALARM */
|
||||
if((AV_Descr[index].Event_State != EVENT_STATE_NORMAL) &&
|
||||
(AV_Descr[index].Notify_Type == NOTIFY_ALARM)){
|
||||
/* Object Identifier */
|
||||
getalarm_data->objectIdentifier.type = OBJECT_ANALOG_VALUE;
|
||||
getalarm_data->objectIdentifier.instance =
|
||||
Analog_Value_Index_To_Instance(index);
|
||||
/* Alarm State */
|
||||
getalarm_data->alarmState = AV_Descr[index].Event_State;
|
||||
/* Acknowledged Transitions */
|
||||
bitstring_init(&getalarm_data->acknowledgedTransitions);
|
||||
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_OFFNORMAL,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_FAULT,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_NORMAL,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
|
||||
return 1; /* active alarm */
|
||||
}
|
||||
else
|
||||
return 0; /* no active alarm at this index */
|
||||
} else
|
||||
return -1; /* end of list */
|
||||
}
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "nc.h"
|
||||
#include "alarm_ack.h"
|
||||
#include "getevent.h"
|
||||
#include "get_alarm_sum.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -113,6 +114,10 @@ extern "C" {
|
||||
int Analog_Value_Alarm_Ack(
|
||||
BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
int Analog_Value_Alarm_Summary(
|
||||
unsigned index,
|
||||
BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data);
|
||||
#endif
|
||||
|
||||
void Analog_Value_Init(
|
||||
|
||||
Reference in New Issue
Block a user