Indented project.
This commit is contained in:
+264
-231
@@ -108,7 +108,7 @@ void Analog_Input_Init(
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
|
||||
AI_Descr[i].Present_Value = 0.0f;
|
||||
AI_Descr[i].Present_Value = 0.0f;
|
||||
AI_Descr[i].Out_Of_Service = false;
|
||||
AI_Descr[i].Units = UNITS_PERCENT;
|
||||
AI_Descr[i].Reliability = RELIABILITY_NO_FAULT_DETECTED;
|
||||
@@ -127,8 +127,7 @@ void Analog_Input_Init(
|
||||
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);
|
||||
handler_alarm_ack_set(OBJECT_ANALOG_INPUT, Analog_Input_Alarm_Ack);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -207,7 +206,7 @@ void Analog_Input_Present_Value_Set(
|
||||
|
||||
bool Analog_Input_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
unsigned int index;
|
||||
@@ -277,50 +276,61 @@ int Analog_Input_Read_Property(
|
||||
bitstring_init(&bit_string);
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
|
||||
CurrentAI->Event_State ? true : false);
|
||||
CurrentAI->Event_State ? true : false);
|
||||
#else
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
#endif
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
CurrentAI->Out_Of_Service);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_STATE:
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
CurrentAI->Event_State);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
CurrentAI->Event_State);
|
||||
#else
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
EVENT_STATE_NORMAL);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PROP_RELIABILITY:
|
||||
apdu_len = encode_application_enumerated(&apdu[0], CurrentAI->Reliability);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
CurrentAI->Reliability);
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
apdu_len = encode_application_boolean(&apdu[0], CurrentAI->Out_Of_Service);
|
||||
apdu_len =
|
||||
encode_application_boolean(&apdu[0],
|
||||
CurrentAI->Out_Of_Service);
|
||||
break;
|
||||
|
||||
case PROP_UNITS:
|
||||
apdu_len = encode_application_enumerated(&apdu[0], CurrentAI->Units);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], CurrentAI->Units);
|
||||
break;
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
apdu_len = encode_application_unsigned(&apdu[0], CurrentAI->Time_Delay);
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0], CurrentAI->Time_Delay);
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
apdu_len = encode_application_unsigned(&apdu[0], CurrentAI->Notification_Class);
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
CurrentAI->Notification_Class);
|
||||
break;
|
||||
|
||||
case PROP_HIGH_LIMIT:
|
||||
apdu_len = encode_application_real(&apdu[0], CurrentAI->High_Limit);
|
||||
apdu_len =
|
||||
encode_application_real(&apdu[0], CurrentAI->High_Limit);
|
||||
break;
|
||||
|
||||
case PROP_LOW_LIMIT:
|
||||
@@ -334,21 +344,26 @@ int Analog_Input_Read_Property(
|
||||
case PROP_LIMIT_ENABLE:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, 0,
|
||||
(CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE ) ? true : false );
|
||||
(CurrentAI->
|
||||
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
|
||||
bitstring_set_bit(&bit_string, 1,
|
||||
(CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false );
|
||||
(CurrentAI->
|
||||
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0],&bit_string);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_ENABLE:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
|
||||
(CurrentAI->
|
||||
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
|
||||
(CurrentAI->
|
||||
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
|
||||
(CurrentAI->
|
||||
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
@@ -356,62 +371,69 @@ int Analog_Input_Read_Property(
|
||||
case PROP_ACKED_TRANSITIONS:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
CurrentAI->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
CurrentAI->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_TIME_STAMPS:
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (rpdata->array_index == 0)
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
MAX_BACNET_EVENT_TRANSITION);
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
MAX_BACNET_EVENT_TRANSITION);
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
for (i = 0; i < MAX_BACNET_EVENT_TRANSITION; i++) {;
|
||||
len = encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len += encode_application_date(&apdu[apdu_len + len],
|
||||
&CurrentAI->Event_Time_Stamps[i].date);
|
||||
len += encode_application_time(&apdu[apdu_len + len],
|
||||
&CurrentAI->Event_Time_Stamps[i].time);
|
||||
len += encode_closing_tag(&apdu[apdu_len + len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len =
|
||||
encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len +=
|
||||
encode_application_date(&apdu[apdu_len + len],
|
||||
&CurrentAI->Event_Time_Stamps[i].date);
|
||||
len +=
|
||||
encode_application_time(&apdu[apdu_len + len],
|
||||
&CurrentAI->Event_Time_Stamps[i].time);
|
||||
len +=
|
||||
encode_closing_tag(&apdu[apdu_len + len],
|
||||
TIME_STAMP_DATETIME);
|
||||
|
||||
/* add it if we have room */
|
||||
if ((apdu_len + len) < MAX_APDU)
|
||||
apdu_len += len;
|
||||
else {
|
||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
|
||||
apdu_len = encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
apdu_len += encode_application_date(&apdu[apdu_len],
|
||||
&CurrentAI->Event_Time_Stamps[rpdata->array_index].date);
|
||||
apdu_len += encode_application_time(&apdu[apdu_len],
|
||||
&CurrentAI->Event_Time_Stamps[rpdata->array_index].time);
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
}
|
||||
else {
|
||||
} else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
|
||||
apdu_len =
|
||||
encode_opening_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
|
||||
apdu_len +=
|
||||
encode_application_date(&apdu[apdu_len],
|
||||
&CurrentAI->Event_Time_Stamps[rpdata->array_index].date);
|
||||
apdu_len +=
|
||||
encode_application_time(&apdu[apdu_len],
|
||||
&CurrentAI->Event_Time_Stamps[rpdata->array_index].time);
|
||||
apdu_len +=
|
||||
encode_closing_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
|
||||
} else {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
break;
|
||||
@@ -436,11 +458,10 @@ int Analog_Input_Read_Property(
|
||||
break;
|
||||
}
|
||||
/* only array properties can have array options */
|
||||
if ((apdu_len >= 0) &&
|
||||
(rpdata->object_property != PROP_EVENT_TIME_STAMPS) &&
|
||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||
if ((apdu_len >= 0) && (rpdata->object_property != PROP_EVENT_TIME_STAMPS)
|
||||
&& (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -449,7 +470,7 @@ int Analog_Input_Read_Property(
|
||||
|
||||
/* returns true if successful */
|
||||
bool Analog_Input_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
unsigned int object_index = 0;
|
||||
@@ -465,7 +486,7 @@ bool Analog_Input_Write_Property(
|
||||
if (len < 0) {
|
||||
/* error while decoding - a value larger than we can handle */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -484,11 +505,10 @@ bool Analog_Input_Write_Property(
|
||||
if (status) {
|
||||
if (CurrentAI->Out_Of_Service == true) {
|
||||
Analog_Input_Present_Value_Set(wp_data->object_instance,
|
||||
value.type.Real);
|
||||
}
|
||||
else {
|
||||
value.type.Real);
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
@@ -570,13 +590,12 @@ bool Analog_Input_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
|
||||
if (status) {
|
||||
if(value.type.Bit_String.bits_used == 2) {
|
||||
if (value.type.Bit_String.bits_used == 2) {
|
||||
CurrentAI->Limit_Enable = value.type.Bit_String.value[0];
|
||||
}
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -587,13 +606,12 @@ bool Analog_Input_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
|
||||
if (status) {
|
||||
if(value.type.Bit_String.bits_used == 3) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentAI->Event_Enable = value.type.Bit_String.value[0];
|
||||
}
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -604,13 +622,12 @@ bool Analog_Input_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
|
||||
if (status) {
|
||||
if(value.type.Bit_String.bits_used > NOTIFY_EVENT) {
|
||||
if (value.type.Bit_String.bits_used > NOTIFY_EVENT) {
|
||||
CurrentAI->Event_Enable = value.type.Enumerated;
|
||||
}
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -618,7 +635,7 @@ bool Analog_Input_Write_Property(
|
||||
|
||||
default:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -626,7 +643,8 @@ bool Analog_Input_Write_Property(
|
||||
}
|
||||
|
||||
|
||||
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
void Analog_Input_Intrinsic_Reporting(
|
||||
uint32_t object_instance)
|
||||
{
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
BACNET_EVENT_NOTIFICATION_DATA event_data;
|
||||
@@ -637,7 +655,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
uint8_t ToState;
|
||||
float ExceededLimit = 0.0f;
|
||||
float PresentVal = 0.0f;
|
||||
bool SendNotify = false;
|
||||
bool SendNotify = false;
|
||||
|
||||
|
||||
object_index = Analog_Input_Instance_To_Index(object_instance);
|
||||
@@ -648,7 +666,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* check limits */
|
||||
if (!CurrentAI->Limit_Enable)
|
||||
return; /* limits are not configured */
|
||||
return; /* limits are not configured */
|
||||
|
||||
|
||||
if (CurrentAI->Ack_notify_data.bSendAckNotify) {
|
||||
@@ -659,8 +677,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_INPUT),
|
||||
object_instance);
|
||||
bactext_object_type_name(OBJECT_ANALOG_INPUT), object_instance);
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
characterstring_init_ansi(&msgText, "AckNotification");
|
||||
@@ -670,25 +687,23 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* Send EventNotification. */
|
||||
SendNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* actual Present_Value */
|
||||
PresentVal = Analog_Input_Present_Value(object_instance);
|
||||
FromState = CurrentAI->Event_State;
|
||||
switch (CurrentAI->Event_State)
|
||||
{
|
||||
FromState = CurrentAI->Event_State;
|
||||
switch (CurrentAI->Event_State) {
|
||||
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. */
|
||||
(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->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--;
|
||||
@@ -696,15 +711,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
(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->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--;
|
||||
@@ -717,15 +733,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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)
|
||||
(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--;
|
||||
@@ -739,15 +756,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
/* 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)
|
||||
(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--;
|
||||
@@ -758,41 +776,36 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
break;
|
||||
|
||||
default:
|
||||
return; /* shouldn't happen */
|
||||
} /* switch (FromState) */
|
||||
return; /* shouldn't happen */
|
||||
} /* switch (FromState) */
|
||||
|
||||
ToState = CurrentAI->Event_State;
|
||||
|
||||
if (FromState != ToState)
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
ExceededLimit = CurrentAI->High_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Goes to 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");
|
||||
characterstring_init_ansi(&msgText, "Goes to low limit");
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
if(FromState == EVENT_STATE_HIGH_LIMIT) {
|
||||
if (FromState == EVENT_STATE_HIGH_LIMIT) {
|
||||
ExceededLimit = CurrentAI->High_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Back to normal state from high limit");
|
||||
}
|
||||
else {
|
||||
"Back to normal state from high limit");
|
||||
} else {
|
||||
ExceededLimit = CurrentAI->Low_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Back to normal state from low limit");
|
||||
"Back to normal state from low limit");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -803,9 +816,9 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
#if PRINT_ENABLED
|
||||
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));
|
||||
bactext_object_type_name(OBJECT_ANALOG_INPUT), object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
/* Notify Type */
|
||||
@@ -817,8 +830,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
|
||||
if (SendNotify)
|
||||
{
|
||||
if (SendNotify) {
|
||||
/* Event Object Identifier */
|
||||
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT;
|
||||
event_data.eventObjectIdentifier.instance = object_instance;
|
||||
@@ -829,22 +841,21 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
/* fill Event_Time_Stamps */
|
||||
switch (ToState)
|
||||
{
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -871,50 +882,57 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
/* Event Values */
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
/* Value that exceeded a limit. */
|
||||
event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
|
||||
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);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_OUT_OF_SERVICE, CurrentAI->Out_Of_Service);
|
||||
bitstring_init(&event_data.notificationParams.outOfRange.
|
||||
statusFlags);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.
|
||||
statusFlags, STATUS_FLAG_IN_ALARM,
|
||||
CurrentAI->Event_State ? true : false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.
|
||||
statusFlags, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.
|
||||
statusFlags, 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;
|
||||
event_data.notificationParams.outOfRange.deadband =
|
||||
CurrentAI->Deadband;
|
||||
/* Limit that was exceeded. */
|
||||
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
|
||||
event_data.notificationParams.outOfRange.exceededLimit =
|
||||
ExceededLimit;
|
||||
}
|
||||
|
||||
/* add data from notification class */
|
||||
Notification_Class_common_reporting_function(&event_data);
|
||||
|
||||
/* Ack required */
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true))
|
||||
{
|
||||
switch (event_data.toState)
|
||||
{
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true)) {
|
||||
switch (event_data.toState) {
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = false;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked = false;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
Time_Stamp = event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = false;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
|
||||
bIsAcked = false;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
|
||||
Time_Stamp = event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = false;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
|
||||
bIsAcked = false;
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
|
||||
Time_Stamp = event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -924,12 +942,13 @@ 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)
|
||||
int Analog_Input_Event_Information(
|
||||
unsigned index,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
|
||||
{
|
||||
bool IsNotAckedTransitions;
|
||||
bool IsActiveEvent;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
|
||||
/* check index */
|
||||
@@ -939,63 +958,75 @@ int Analog_Input_Event_Information(unsigned index,
|
||||
|
||||
/* Acked_Transitions property, which has at least one of the bits
|
||||
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
|
||||
IsNotAckedTransitions = (AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) |
|
||||
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) |
|
||||
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
|
||||
}
|
||||
else
|
||||
return -1; /* end of list */
|
||||
IsNotAckedTransitions =
|
||||
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked ==
|
||||
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
|
||||
bIsAcked ==
|
||||
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
|
||||
bIsAcked == false);
|
||||
} else
|
||||
return -1; /* end of list */
|
||||
|
||||
if ((IsActiveEvent) || (IsNotAckedTransitions)) {
|
||||
/* Object Identifier */
|
||||
getevent_data->objectIdentifier.type = OBJECT_ANALOG_INPUT;
|
||||
getevent_data->objectIdentifier.instance = Analog_Input_Index_To_Instance(index);
|
||||
getevent_data->objectIdentifier.instance =
|
||||
Analog_Input_Index_To_Instance(index);
|
||||
/* Event State */
|
||||
getevent_data->eventState = AI_Descr[index].Event_State;
|
||||
/* Acknowledged Transitions */
|
||||
bitstring_init(&getevent_data->acknowledgedTransitions);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_NORMAL,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_OFFNORMAL,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_FAULT,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_NORMAL,
|
||||
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
/* Event Time Stamps */
|
||||
for (i = 0; i < 3; i++) {
|
||||
getevent_data->eventTimeStamps[i].tag = TIME_STAMP_DATETIME;
|
||||
getevent_data->eventTimeStamps[i].value.dateTime =
|
||||
AI_Descr[index].Event_Time_Stamps[i];
|
||||
AI_Descr[index].Event_Time_Stamps[i];
|
||||
}
|
||||
/* Notify Type */
|
||||
getevent_data->notifyType = AI_Descr[index].Notify_Type;
|
||||
/* Event Enable */
|
||||
bitstring_init(&getevent_data->eventEnable);
|
||||
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
|
||||
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
|
||||
(AI_Descr[index].
|
||||
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
|
||||
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
|
||||
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
|
||||
(AI_Descr[index].
|
||||
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
|
||||
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
|
||||
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
|
||||
(AI_Descr[index].
|
||||
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
|
||||
/* Event Priorities */
|
||||
Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class,
|
||||
getevent_data->eventPriorities);
|
||||
getevent_data->eventPriorities);
|
||||
|
||||
return 1; /* active event */
|
||||
}
|
||||
else
|
||||
return 0; /* no active event at this index */
|
||||
return 1; /* active event */
|
||||
} else
|
||||
return 0; /* no active event at this index */
|
||||
}
|
||||
|
||||
|
||||
int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code)
|
||||
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);
|
||||
object_index =
|
||||
Analog_Input_Instance_To_Index(alarmack_data->eventObjectIdentifier.
|
||||
instance);
|
||||
|
||||
if (object_index < MAX_ANALOG_INPUTS)
|
||||
CurrentAI = &AI_Descr[object_index];
|
||||
@@ -1004,71 +1035,73 @@ int Analog_Input_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (alarmack_data->eventStateAcked)
|
||||
{
|
||||
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){
|
||||
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)
|
||||
{
|
||||
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 {
|
||||
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){
|
||||
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)
|
||||
{
|
||||
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 {
|
||||
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){
|
||||
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)
|
||||
{
|
||||
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 {
|
||||
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
|
||||
true;
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -42,20 +42,20 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct analog_input_descr {
|
||||
uint8_t Event_State : 3;
|
||||
float Present_Value;
|
||||
uint8_t Event_State:3;
|
||||
float Present_Value;
|
||||
BACNET_RELIABILITY Reliability;
|
||||
bool Out_Of_Service;
|
||||
uint8_t Units;
|
||||
bool Out_Of_Service;
|
||||
uint8_t Units;
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
uint32_t Time_Delay;
|
||||
uint32_t Notification_Class;
|
||||
float High_Limit;
|
||||
float Low_Limit;
|
||||
float Deadband;
|
||||
uint8_t Limit_Enable : 2;
|
||||
uint8_t Event_Enable : 3;
|
||||
uint8_t Notify_Type : 1;
|
||||
float High_Limit;
|
||||
float Low_Limit;
|
||||
float Deadband;
|
||||
uint8_t Limit_Enable:2;
|
||||
uint8_t Event_Enable:3;
|
||||
uint8_t Notify_Type:1;
|
||||
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
|
||||
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
|
||||
/* time to generate event notification */
|
||||
@@ -83,7 +83,7 @@ extern "C" {
|
||||
|
||||
bool Analog_Input_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Analog_Input_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
@@ -112,14 +112,17 @@ extern "C" {
|
||||
float value);
|
||||
|
||||
/* note: header of Intrinsic_Reporting function is required
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
void Analog_Input_Intrinsic_Reporting(uint32_t object_instance);
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
void Analog_Input_Intrinsic_Reporting(
|
||||
uint32_t object_instance);
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
int Analog_Input_Event_Information(unsigned index,
|
||||
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,
|
||||
int Analog_Input_Alarm_Ack(
|
||||
BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ bool Analog_Output_Present_Value_Relinquish(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Analog_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -447,11 +447,11 @@ bool Analog_Output_Write_Property(
|
||||
if (status) {
|
||||
level = AO_LEVEL_NULL;
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Analog_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
status =
|
||||
Analog_Output_Present_Value_Relinquish(wp_data->
|
||||
object_instance, wp_data->priority);
|
||||
Analog_Output_Present_Value_Relinquish
|
||||
(wp_data->object_instance, wp_data->priority);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
@@ -491,10 +491,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ extern "C" {
|
||||
|
||||
bool Analog_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Analog_Output_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
|
||||
+261
-232
@@ -133,8 +133,7 @@ void Analog_Value_Init(
|
||||
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);
|
||||
handler_alarm_ack_set(OBJECT_ANALOG_VALUE, Analog_Value_Alarm_Ack);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -196,8 +195,7 @@ bool Analog_Value_Present_Value_Set(
|
||||
CurrentAV = &AV_Descr[index];
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */ ) &&
|
||||
(value >= 0.0) && (value <= 100.0))
|
||||
{
|
||||
(value >= 0.0) && (value <= 100.0)) {
|
||||
CurrentAV->Priority_Array[priority - 1] = (uint8_t) value;
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
@@ -240,7 +238,7 @@ float Analog_Value_Present_Value(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Analog_Value_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -310,24 +308,26 @@ int Analog_Value_Read_Property(
|
||||
bitstring_init(&bit_string);
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
|
||||
CurrentAV->Event_State ? true : false);
|
||||
CurrentAV->Event_State ? true : false);
|
||||
#else
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false);
|
||||
#endif
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
CurrentAV->Out_Of_Service);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_STATE:
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
CurrentAV->Event_State);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
CurrentAV->Event_State);
|
||||
#else
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
EVENT_STATE_NORMAL);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -337,7 +337,8 @@ int Analog_Value_Read_Property(
|
||||
break;
|
||||
|
||||
case PROP_UNITS:
|
||||
apdu_len = encode_application_enumerated(&apdu[0], CurrentAV->Units);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], CurrentAV->Units);
|
||||
break;
|
||||
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
@@ -363,7 +364,7 @@ int Analog_Value_Read_Property(
|
||||
apdu_len += len;
|
||||
else {
|
||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
@@ -371,11 +372,11 @@ int Analog_Value_Read_Property(
|
||||
} else {
|
||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (CurrentAV->Priority_Array[rpdata->array_index - 1]
|
||||
== ANALOG_LEVEL_NULL)
|
||||
== ANALOG_LEVEL_NULL)
|
||||
apdu_len = encode_application_null(&apdu[0]);
|
||||
else {
|
||||
real_value = CurrentAV->Priority_Array
|
||||
[rpdata->array_index - 1];
|
||||
real_value =
|
||||
CurrentAV->Priority_Array[rpdata->array_index - 1];
|
||||
apdu_len =
|
||||
encode_application_real(&apdu[0], real_value);
|
||||
}
|
||||
@@ -394,15 +395,19 @@ int Analog_Value_Read_Property(
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
apdu_len = encode_application_unsigned(&apdu[0], CurrentAV->Time_Delay);
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0], CurrentAV->Time_Delay);
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
apdu_len = encode_application_unsigned(&apdu[0], CurrentAV->Notification_Class);
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
CurrentAV->Notification_Class);
|
||||
break;
|
||||
|
||||
case PROP_HIGH_LIMIT:
|
||||
apdu_len = encode_application_real(&apdu[0], CurrentAV->High_Limit);
|
||||
apdu_len =
|
||||
encode_application_real(&apdu[0], CurrentAV->High_Limit);
|
||||
break;
|
||||
|
||||
case PROP_LOW_LIMIT:
|
||||
@@ -416,21 +421,26 @@ int Analog_Value_Read_Property(
|
||||
case PROP_LIMIT_ENABLE:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, 0,
|
||||
(CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE ) ? true : false );
|
||||
(CurrentAV->
|
||||
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
|
||||
bitstring_set_bit(&bit_string, 1,
|
||||
(CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false );
|
||||
(CurrentAV->
|
||||
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0],&bit_string);
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_ENABLE:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
|
||||
(CurrentAV->
|
||||
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
|
||||
(CurrentAV->
|
||||
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
|
||||
(CurrentAV->
|
||||
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
@@ -438,62 +448,69 @@ int Analog_Value_Read_Property(
|
||||
case PROP_ACKED_TRANSITIONS:
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
CurrentAV->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
CurrentAV->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_TIME_STAMPS:
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (rpdata->array_index == 0)
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
MAX_BACNET_EVENT_TRANSITION);
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
MAX_BACNET_EVENT_TRANSITION);
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
for (i = 0; i < MAX_BACNET_EVENT_TRANSITION; i++) {;
|
||||
len = encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len += encode_application_date(&apdu[apdu_len + len],
|
||||
&CurrentAV->Event_Time_Stamps[i].date);
|
||||
len += encode_application_time(&apdu[apdu_len + len],
|
||||
&CurrentAV->Event_Time_Stamps[i].time);
|
||||
len += encode_closing_tag(&apdu[apdu_len + len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len =
|
||||
encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
len +=
|
||||
encode_application_date(&apdu[apdu_len + len],
|
||||
&CurrentAV->Event_Time_Stamps[i].date);
|
||||
len +=
|
||||
encode_application_time(&apdu[apdu_len + len],
|
||||
&CurrentAV->Event_Time_Stamps[i].time);
|
||||
len +=
|
||||
encode_closing_tag(&apdu[apdu_len + len],
|
||||
TIME_STAMP_DATETIME);
|
||||
|
||||
/* add it if we have room */
|
||||
if ((apdu_len + len) < MAX_APDU)
|
||||
apdu_len += len;
|
||||
else {
|
||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
|
||||
apdu_len = encode_opening_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
apdu_len += encode_application_date(&apdu[apdu_len],
|
||||
&CurrentAV->Event_Time_Stamps[rpdata->array_index].date);
|
||||
apdu_len += encode_application_time(&apdu[apdu_len],
|
||||
&CurrentAV->Event_Time_Stamps[rpdata->array_index].time);
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len],
|
||||
TIME_STAMP_DATETIME);
|
||||
}
|
||||
else {
|
||||
} else if (rpdata->array_index <= MAX_BACNET_EVENT_TRANSITION) {
|
||||
apdu_len =
|
||||
encode_opening_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
|
||||
apdu_len +=
|
||||
encode_application_date(&apdu[apdu_len],
|
||||
&CurrentAV->Event_Time_Stamps[rpdata->array_index].date);
|
||||
apdu_len +=
|
||||
encode_application_time(&apdu[apdu_len],
|
||||
&CurrentAV->Event_Time_Stamps[rpdata->array_index].time);
|
||||
apdu_len +=
|
||||
encode_closing_tag(&apdu[apdu_len], TIME_STAMP_DATETIME);
|
||||
} else {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
break;
|
||||
@@ -501,17 +518,16 @@ int Analog_Value_Read_Property(
|
||||
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
/* only array properties can have array options */
|
||||
if ((apdu_len >= 0) &&
|
||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||
(rpdata->object_property != PROP_EVENT_TIME_STAMPS) &&
|
||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -677,13 +693,12 @@ bool Analog_Value_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
|
||||
if (status) {
|
||||
if(value.type.Bit_String.bits_used == 2) {
|
||||
if (value.type.Bit_String.bits_used == 2) {
|
||||
CurrentAV->Limit_Enable = value.type.Bit_String.value[0];
|
||||
}
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -694,13 +709,12 @@ bool Analog_Value_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
|
||||
if (status) {
|
||||
if(value.type.Bit_String.bits_used == 3) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentAV->Event_Enable = value.type.Bit_String.value[0];
|
||||
}
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -711,13 +725,12 @@ bool Analog_Value_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
|
||||
if (status) {
|
||||
if(value.type.Bit_String.bits_used > NOTIFY_EVENT) {
|
||||
if (value.type.Bit_String.bits_used > NOTIFY_EVENT) {
|
||||
CurrentAV->Event_Enable = value.type.Enumerated;
|
||||
}
|
||||
else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -725,7 +738,7 @@ bool Analog_Value_Write_Property(
|
||||
|
||||
default:
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -733,7 +746,8 @@ bool Analog_Value_Write_Property(
|
||||
}
|
||||
|
||||
|
||||
void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
void Analog_Value_Intrinsic_Reporting(
|
||||
uint32_t object_instance)
|
||||
{
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
BACNET_EVENT_NOTIFICATION_DATA event_data;
|
||||
@@ -744,7 +758,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
uint8_t ToState;
|
||||
float ExceededLimit = 0.0f;
|
||||
float PresentVal = 0.0f;
|
||||
bool SendNotify = false;
|
||||
bool SendNotify = false;
|
||||
|
||||
|
||||
object_index = Analog_Value_Instance_To_Index(object_instance);
|
||||
@@ -755,7 +769,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* check limits */
|
||||
if (!CurrentAV->Limit_Enable)
|
||||
return; /* limits are not configured */
|
||||
return; /* limits are not configured */
|
||||
|
||||
|
||||
if (CurrentAV->Ack_notify_data.bSendAckNotify) {
|
||||
@@ -766,8 +780,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||
object_instance);
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance);
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
characterstring_init_ansi(&msgText, "AckNotification");
|
||||
@@ -777,25 +790,23 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* Send EventNotification. */
|
||||
SendNotify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* actual Present_Value */
|
||||
PresentVal = Analog_Value_Present_Value(object_instance);
|
||||
FromState = CurrentAV->Event_State;
|
||||
switch (CurrentAV->Event_State)
|
||||
{
|
||||
FromState = CurrentAV->Event_State;
|
||||
switch (CurrentAV->Event_State) {
|
||||
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. */
|
||||
(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->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--;
|
||||
@@ -803,15 +814,16 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
(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->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--;
|
||||
@@ -824,15 +836,16 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
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)
|
||||
(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--;
|
||||
@@ -846,15 +859,16 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
/* 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)
|
||||
(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--;
|
||||
@@ -865,41 +879,36 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
break;
|
||||
|
||||
default:
|
||||
return; /* shouldn't happen */
|
||||
} /* switch (FromState) */
|
||||
return; /* shouldn't happen */
|
||||
} /* switch (FromState) */
|
||||
|
||||
ToState = CurrentAV->Event_State;
|
||||
|
||||
if (FromState != ToState)
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
ExceededLimit = CurrentAV->High_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Goes to 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");
|
||||
characterstring_init_ansi(&msgText, "Goes to low limit");
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
if(FromState == EVENT_STATE_HIGH_LIMIT) {
|
||||
if (FromState == EVENT_STATE_HIGH_LIMIT) {
|
||||
ExceededLimit = CurrentAV->High_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Back to normal state from high limit");
|
||||
}
|
||||
else {
|
||||
"Back to normal state from high limit");
|
||||
} else {
|
||||
ExceededLimit = CurrentAV->Low_Limit;
|
||||
characterstring_init_ansi(&msgText,
|
||||
"Back to normal state from low limit");
|
||||
"Back to normal state from low limit");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -910,9 +919,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
#if PRINT_ENABLED
|
||||
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));
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
/* Notify Type */
|
||||
@@ -924,8 +933,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
}
|
||||
|
||||
|
||||
if (SendNotify)
|
||||
{
|
||||
if (SendNotify) {
|
||||
/* Event Object Identifier */
|
||||
event_data.eventObjectIdentifier.type = OBJECT_ANALOG_VALUE;
|
||||
event_data.eventObjectIdentifier.instance = object_instance;
|
||||
@@ -936,22 +944,21 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
/* fill Event_Time_Stamps */
|
||||
switch (ToState)
|
||||
{
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
CurrentAV->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
CurrentAV->Event_Time_Stamps[TRANSITION_TO_FAULT] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -978,50 +985,57 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
/* Event Values */
|
||||
if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) {
|
||||
/* Value that exceeded a limit. */
|
||||
event_data.notificationParams.outOfRange.exceedingValue = PresentVal;
|
||||
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);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.statusFlags,
|
||||
STATUS_FLAG_OUT_OF_SERVICE, CurrentAV->Out_Of_Service);
|
||||
bitstring_init(&event_data.notificationParams.outOfRange.
|
||||
statusFlags);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.
|
||||
statusFlags, STATUS_FLAG_IN_ALARM,
|
||||
CurrentAV->Event_State ? true : false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.
|
||||
statusFlags, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&event_data.notificationParams.outOfRange.
|
||||
statusFlags, 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;
|
||||
event_data.notificationParams.outOfRange.deadband =
|
||||
CurrentAV->Deadband;
|
||||
/* Limit that was exceeded. */
|
||||
event_data.notificationParams.outOfRange.exceededLimit = ExceededLimit;
|
||||
event_data.notificationParams.outOfRange.exceededLimit =
|
||||
ExceededLimit;
|
||||
}
|
||||
|
||||
/* add data from notification class */
|
||||
Notification_Class_common_reporting_function(&event_data);
|
||||
|
||||
/* Ack required */
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true))
|
||||
{
|
||||
switch (event_data.toState)
|
||||
{
|
||||
if ((event_data.notifyType != NOTIFY_ACK_NOTIFICATION) &&
|
||||
(event_data.ackRequired == true)) {
|
||||
switch (event_data.toState) {
|
||||
case EVENT_STATE_OFFNORMAL:
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = false;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked = false;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
Time_Stamp = event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_FAULT:
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = false;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
|
||||
bIsAcked = false;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
|
||||
Time_Stamp = event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
|
||||
case EVENT_STATE_NORMAL:
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = false;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
|
||||
event_data.timeStamp.value.dateTime;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
|
||||
bIsAcked = false;
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
|
||||
Time_Stamp = event_data.timeStamp.value.dateTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1031,12 +1045,13 @@ 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)
|
||||
int Analog_Value_Event_Information(
|
||||
unsigned index,
|
||||
BACNET_GET_EVENT_INFORMATION_DATA * getevent_data)
|
||||
{
|
||||
bool IsNotAckedTransitions;
|
||||
bool IsActiveEvent;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
|
||||
/* check index */
|
||||
@@ -1046,62 +1061,74 @@ int Analog_Value_Event_Information(unsigned index,
|
||||
|
||||
/* Acked_Transitions property, which has at least one of the bits
|
||||
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
|
||||
IsNotAckedTransitions = (AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) |
|
||||
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == false) |
|
||||
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
|
||||
}
|
||||
else
|
||||
return -1; /* end of list */
|
||||
IsNotAckedTransitions =
|
||||
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked ==
|
||||
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
|
||||
bIsAcked ==
|
||||
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
|
||||
bIsAcked == false);
|
||||
} else
|
||||
return -1; /* end of list */
|
||||
|
||||
if ((IsActiveEvent) || (IsNotAckedTransitions)) {
|
||||
/* Object Identifier */
|
||||
getevent_data->objectIdentifier.type = OBJECT_ANALOG_VALUE;
|
||||
getevent_data->objectIdentifier.instance = Analog_Value_Index_To_Instance(index);
|
||||
getevent_data->objectIdentifier.instance =
|
||||
Analog_Value_Index_To_Instance(index);
|
||||
/* Event State */
|
||||
getevent_data->eventState = AV_Descr[index].Event_State;
|
||||
/* Acknowledged Transitions */
|
||||
bitstring_init(&getevent_data->acknowledgedTransitions);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_NORMAL,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_OFFNORMAL,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
|
||||
bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_FAULT,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
|
||||
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
|
||||
TRANSITION_TO_NORMAL,
|
||||
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
|
||||
/* Event Time Stamps */
|
||||
for (i = 0; i < 3; i++) {
|
||||
getevent_data->eventTimeStamps[i].tag = TIME_STAMP_DATETIME;
|
||||
getevent_data->eventTimeStamps[i].value.dateTime =
|
||||
AV_Descr[index].Event_Time_Stamps[i];
|
||||
AV_Descr[index].Event_Time_Stamps[i];
|
||||
}
|
||||
/* Notify Type */
|
||||
getevent_data->notifyType = AV_Descr[index].Notify_Type;
|
||||
/* Event Enable */
|
||||
bitstring_init(&getevent_data->eventEnable);
|
||||
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
|
||||
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false );
|
||||
(AV_Descr[index].
|
||||
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
|
||||
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
|
||||
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT ) ? true : false );
|
||||
(AV_Descr[index].
|
||||
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
|
||||
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
|
||||
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL ) ? true : false );
|
||||
(AV_Descr[index].
|
||||
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
|
||||
/* Event Priorities */
|
||||
Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class,
|
||||
getevent_data->eventPriorities);
|
||||
getevent_data->eventPriorities);
|
||||
|
||||
return 1; /* active event */
|
||||
}
|
||||
else
|
||||
return 0; /* no active event at this index */
|
||||
return 1; /* active event */
|
||||
} else
|
||||
return 0; /* no active event at this index */
|
||||
}
|
||||
|
||||
int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code)
|
||||
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);
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(alarmack_data->eventObjectIdentifier.
|
||||
instance);
|
||||
|
||||
if (object_index < MAX_ANALOG_VALUES)
|
||||
CurrentAV = &AV_Descr[object_index];
|
||||
@@ -1110,71 +1137,73 @@ int Analog_Value_Alarm_Ack(BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (alarmack_data->eventStateAcked)
|
||||
{
|
||||
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){
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
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){
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
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){
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/* Clean transitions flag. */
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true;
|
||||
}
|
||||
else {
|
||||
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
|
||||
true;
|
||||
} else {
|
||||
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
|
||||
return -1;
|
||||
}
|
||||
@@ -1205,10 +1234,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,23 +43,23 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct analog_value_descr {
|
||||
uint8_t Event_State : 3;
|
||||
bool Out_Of_Service;
|
||||
uint8_t Units;
|
||||
uint8_t Event_State:3;
|
||||
bool Out_Of_Service;
|
||||
uint8_t Units;
|
||||
/* Here is our Priority Array. They are supposed to be Real, but */
|
||||
/* we don't have that kind of memory, so we will use a single byte */
|
||||
/* and load a Real for returning the value when asked. */
|
||||
uint8_t Priority_Array[BACNET_MAX_PRIORITY];
|
||||
float Relinquish_Default;
|
||||
uint8_t Priority_Array[BACNET_MAX_PRIORITY];
|
||||
float Relinquish_Default;
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
uint32_t Time_Delay;
|
||||
uint32_t Notification_Class;
|
||||
float High_Limit;
|
||||
float Low_Limit;
|
||||
float Deadband;
|
||||
uint8_t Limit_Enable : 2;
|
||||
uint8_t Event_Enable : 3;
|
||||
uint8_t Notify_Type : 1;
|
||||
float High_Limit;
|
||||
float Low_Limit;
|
||||
float Deadband;
|
||||
uint8_t Limit_Enable:2;
|
||||
uint8_t Event_Enable:3;
|
||||
uint8_t Notify_Type:1;
|
||||
ACKED_INFO Acked_Transitions[MAX_BACNET_EVENT_TRANSITION];
|
||||
BACNET_DATE_TIME Event_Time_Stamps[MAX_BACNET_EVENT_TRANSITION];
|
||||
/* time to generate event notification */
|
||||
@@ -85,7 +85,7 @@ extern "C" {
|
||||
|
||||
bool Analog_Value_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
int Analog_Value_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
@@ -101,15 +101,17 @@ extern "C" {
|
||||
uint32_t object_instance);
|
||||
|
||||
/* note: header of Intrinsic_Reporting function is required
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
even when INTRINSIC_REPORTING is not defined */
|
||||
void Analog_Value_Intrinsic_Reporting(
|
||||
uint32_t object_instance);
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
int Analog_Value_Event_Information(unsigned index,
|
||||
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,
|
||||
int Analog_Value_Alarm_Ack(
|
||||
BACNET_ALARM_ACK_DATA * alarmack_data,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ void BACfile_Property_Lists(
|
||||
return;
|
||||
}
|
||||
|
||||
static char * bacfile_name(
|
||||
static char *bacfile_name(
|
||||
uint32_t instance)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
@@ -114,7 +114,7 @@ static char * bacfile_name(
|
||||
|
||||
bool bacfile_object_name(
|
||||
uint32_t instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
bool status = false;
|
||||
char *filename = NULL;
|
||||
@@ -491,15 +491,13 @@ bool bacfile_read_ack_stream_data(
|
||||
found = true;
|
||||
pFile = fopen(pFilename, "rb");
|
||||
if (pFile) {
|
||||
(void) fseek(pFile, data->type.stream.fileStartPosition,
|
||||
SEEK_SET);
|
||||
(void) fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
|
||||
if (fwrite(octetstring_value(&data->fileData),
|
||||
octetstring_length(&data->fileData), 1,
|
||||
pFile) != 1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to write to %s (%lu)!\n",
|
||||
pFilename, (unsigned long) instance);
|
||||
#endif
|
||||
octetstring_length(&data->fileData), 1, pFile) != 1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to write to %s (%lu)!\n", pFilename,
|
||||
(unsigned long) instance);
|
||||
#endif
|
||||
}
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ extern "C" {
|
||||
const int **pProprietary);
|
||||
bool bacfile_object_name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool bacfile_valid_instance(
|
||||
uint32_t object_instance);
|
||||
uint32_t bacfile_count(
|
||||
|
||||
@@ -233,10 +233,10 @@ bool Binary_Input_Encode_Value_List(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM,
|
||||
false);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String, STATUS_FLAG_FAULT,
|
||||
false);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, false);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_OVERRIDDEN, false);
|
||||
if (Binary_Input_Out_Of_Service(object_instance)) {
|
||||
@@ -292,7 +292,7 @@ static void Binary_Input_Out_Of_Service_Set(
|
||||
|
||||
bool Binary_Input_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -494,10 +494,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ extern "C" {
|
||||
|
||||
bool Binary_Input_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Binary_Input_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
|
||||
@@ -179,7 +179,7 @@ BACNET_BINARY_PV Binary_Output_Present_Value(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Binary_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -376,8 +376,8 @@ bool Binary_Output_Write_Property(
|
||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||
level = (BACNET_BINARY_PV) value.type.Enumerated;
|
||||
object_index =
|
||||
Binary_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Binary_Output_Level[object_index][priority] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
@@ -403,8 +403,8 @@ bool Binary_Output_Write_Property(
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
object_index =
|
||||
Binary_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
@@ -455,10 +455,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ extern "C" {
|
||||
|
||||
bool Binary_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Binary_Output_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
|
||||
@@ -176,7 +176,7 @@ static BACNET_BINARY_PV Binary_Value_Present_Value(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Binary_Value_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -359,8 +359,8 @@ bool Binary_Value_Write_Property(
|
||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||
level = (BACNET_BINARY_PV) value.type.Enumerated;
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Binary_Value_Level[object_index][priority] = level;
|
||||
/* Note: you could set the physical output here if we
|
||||
@@ -386,8 +386,8 @@ bool Binary_Value_Write_Property(
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Binary_Value_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
@@ -437,10 +437,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
|
||||
bool Binary_Value_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
void Binary_Value_Init(
|
||||
void);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "apdu.h"
|
||||
#include "wp.h" /* WriteProperty handling */
|
||||
#include "rp.h" /* ReadProperty handling */
|
||||
#include "dcc.h" /* DeviceCommunicationControl handling */
|
||||
#include "dcc.h" /* DeviceCommunicationControl handling */
|
||||
#include "version.h"
|
||||
#include "device.h" /* me */
|
||||
#include "handlers.h"
|
||||
@@ -86,72 +86,81 @@ extern bool Routed_Device_Write_Property_Local(
|
||||
|
||||
static object_functions_t Object_Table[] = {
|
||||
{
|
||||
OBJECT_DEVICE, NULL, Device_Count, /* don't init - recursive! */
|
||||
OBJECT_DEVICE, NULL, Device_Count, /* don't init - recursive! */
|
||||
Device_Index_To_Instance, Device_Valid_Object_Instance_Number,
|
||||
Device_Object_Name, Device_Read_Property_Local,
|
||||
Device_Write_Property_Local, Device_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||
Analog_Input_Object_Name, Analog_Input_Read_Property,
|
||||
Analog_Input_Write_Property, Analog_Input_Property_Lists,
|
||||
NULL, NULL, NULL, Analog_Input_Intrinsic_Reporting}, {
|
||||
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||
NULL, NULL, NULL, Analog_Input_Intrinsic_Reporting}, {
|
||||
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||
Analog_Value_Object_Name, Analog_Value_Read_Property,
|
||||
Analog_Value_Write_Property, Analog_Value_Property_Lists,
|
||||
NULL, NULL, NULL, Analog_Value_Intrinsic_Reporting}, {
|
||||
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||
NULL, NULL, NULL, Analog_Value_Intrinsic_Reporting}, {
|
||||
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||
Binary_Input_Object_Name, Binary_Input_Read_Property,
|
||||
NULL, Binary_Input_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
|
||||
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
|
||||
Binary_Value_Object_Name, Binary_Value_Read_Property,
|
||||
Binary_Value_Write_Property, Binary_Value_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
OBJECT_NOTIFICATION_CLASS, Notification_Class_Init, Notification_Class_Count,
|
||||
Notification_Class_Index_To_Instance, Notification_Class_Valid_Instance,
|
||||
OBJECT_NOTIFICATION_CLASS, Notification_Class_Init,
|
||||
Notification_Class_Count,
|
||||
Notification_Class_Index_To_Instance,
|
||||
Notification_Class_Valid_Instance,
|
||||
Notification_Class_Object_Name, Notification_Class_Read_Property,
|
||||
Notification_Class_Write_Property, Notification_Class_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
Notification_Class_Write_Property,
|
||||
Notification_Class_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
#endif
|
||||
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init, Life_Safety_Point_Count,
|
||||
Life_Safety_Point_Index_To_Instance, Life_Safety_Point_Valid_Instance,
|
||||
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init,
|
||||
Life_Safety_Point_Count,
|
||||
Life_Safety_Point_Index_To_Instance,
|
||||
Life_Safety_Point_Valid_Instance,
|
||||
Life_Safety_Point_Object_Name, Life_Safety_Point_Read_Property,
|
||||
Life_Safety_Point_Write_Property, Life_Safety_Point_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count,
|
||||
Load_Control_Index_To_Instance, Load_Control_Valid_Instance,
|
||||
Load_Control_Object_Name, Load_Control_Read_Property,
|
||||
Load_Control_Write_Property, Load_Control_Property_Lists,
|
||||
NULL, NULL, NULL}, {
|
||||
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init, Multistate_Output_Count,
|
||||
Multistate_Output_Index_To_Instance, Multistate_Output_Valid_Instance,
|
||||
NULL, NULL, NULL}, {
|
||||
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
|
||||
Multistate_Output_Count,
|
||||
Multistate_Output_Index_To_Instance,
|
||||
Multistate_Output_Valid_Instance,
|
||||
Multistate_Output_Object_Name, Multistate_Output_Read_Property,
|
||||
Multistate_Output_Write_Property, Multistate_Output_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init, Multistate_Input_Count,
|
||||
Multistate_Input_Index_To_Instance, Multistate_Input_Valid_Instance,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init,
|
||||
Multistate_Input_Count,
|
||||
Multistate_Input_Index_To_Instance,
|
||||
Multistate_Input_Valid_Instance,
|
||||
Multistate_Input_Object_Name, Multistate_Input_Read_Property,
|
||||
Multistate_Input_Write_Property, Multistate_Input_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
|
||||
Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance,
|
||||
Trend_Log_Object_Name, Trend_Log_Read_Property,
|
||||
Trend_Log_Write_Property, Trend_Log_Property_Lists,
|
||||
TrendLogGetRRInfo, NULL, NULL, NULL}, {
|
||||
TrendLogGetRRInfo, NULL, NULL, NULL}, {
|
||||
#if defined(BACFILE)
|
||||
OBJECT_FILE, bacfile_init, bacfile_count,
|
||||
OBJECT_FILE, bacfile_init, bacfile_count,
|
||||
bacfile_index_to_instance, bacfile_valid_instance,
|
||||
bacfile_object_name, bacfile_read_property,
|
||||
bacfile_write_property, BACfile_Property_Lists,
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
NULL, NULL, NULL, NULL}, {
|
||||
#endif
|
||||
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL}
|
||||
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -474,7 +483,7 @@ bool Device_Valid_Object_Instance_Number(
|
||||
|
||||
bool Device_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -486,7 +495,7 @@ bool Device_Object_Name(
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -816,7 +825,7 @@ bool Device_Object_List_Identifier(
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Valid_Object_Name(
|
||||
BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_CHARACTER_STRING * object_name1,
|
||||
int *object_type,
|
||||
uint32_t * object_instance)
|
||||
{
|
||||
@@ -835,7 +844,7 @@ bool Device_Valid_Object_Name(
|
||||
pObject = Device_Objects_Find_Functions(type);
|
||||
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
|
||||
(pObject->Object_Name(instance, &object_name2) &&
|
||||
characterstring_same(object_name1, &object_name2))) {
|
||||
characterstring_same(object_name1, &object_name2))) {
|
||||
found = true;
|
||||
if (object_type) {
|
||||
*object_type = type;
|
||||
@@ -860,7 +869,7 @@ bool Device_Valid_Object_Id(
|
||||
int object_type,
|
||||
uint32_t object_instance)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
bool status = false; /* return value */
|
||||
struct object_functions *pObject = NULL;
|
||||
|
||||
pObject = Device_Objects_Find_Functions(object_type);
|
||||
@@ -880,7 +889,7 @@ bool Device_Valid_Object_Id(
|
||||
bool Device_Object_Name_Copy(
|
||||
int object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
struct object_functions *pObject = NULL;
|
||||
bool found = false;
|
||||
@@ -960,7 +969,8 @@ int tm_isdst Daylight Savings flag.
|
||||
}
|
||||
}
|
||||
|
||||
void Device_getCurrentDateTime(BACNET_DATE_TIME * DateTime)
|
||||
void Device_getCurrentDateTime(
|
||||
BACNET_DATE_TIME * DateTime)
|
||||
{
|
||||
Update_Current_Time();
|
||||
|
||||
@@ -1265,8 +1275,8 @@ bool Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* FIXME: we could send an I-Am broadcast to let the world know */
|
||||
} else {
|
||||
status = false;
|
||||
@@ -1299,8 +1309,8 @@ bool Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_Vendor_Identifier((uint16_t) value.type.
|
||||
Unsigned_Int);
|
||||
Device_Set_Vendor_Identifier((uint16_t) value.
|
||||
type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
@@ -1325,15 +1335,14 @@ bool Device_Write_Property_Local(
|
||||
case PROP_OBJECT_NAME:
|
||||
status =
|
||||
WPValidateString(&value,
|
||||
characterstring_capacity(&My_Object_Name),
|
||||
false,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
characterstring_capacity(&My_Object_Name), false,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique.
|
||||
Disallow setting the Device Object Name to any objects in
|
||||
the device. */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
NULL, NULL)) {
|
||||
NULL, NULL)) {
|
||||
status = false;
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
|
||||
@@ -1347,8 +1356,8 @@ bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Location(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Location(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1358,8 +1367,8 @@ bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Description(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Description(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1368,8 +1377,8 @@ bool Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Device_Set_Model_Name(characterstring_value(&value.type.
|
||||
Character_String),
|
||||
Device_Set_Model_Name(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
break;
|
||||
@@ -1381,8 +1390,8 @@ bool Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
dlmstp_set_max_info_frames((uint8_t) value.type.
|
||||
Unsigned_Int);
|
||||
dlmstp_set_max_info_frames((uint8_t) value.
|
||||
type.Unsigned_Int);
|
||||
} else {
|
||||
status = false;
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -1464,9 +1473,9 @@ bool Device_Write_Property(
|
||||
* @return True if the object instance supports this feature and value changed.
|
||||
*/
|
||||
bool Device_Encode_Value_List(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list)
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list)
|
||||
{
|
||||
bool status = false; /* Ever the pessamist! */
|
||||
struct object_functions *pObject = NULL;
|
||||
@@ -1476,9 +1485,8 @@ bool Device_Encode_Value_List(
|
||||
if (pObject->Object_Valid_Instance &&
|
||||
pObject->Object_Valid_Instance(object_instance)) {
|
||||
if (pObject->Object_Value_List) {
|
||||
status = pObject->Object_Value_List(
|
||||
object_instance,
|
||||
value_list);
|
||||
status =
|
||||
pObject->Object_Value_List(object_instance, value_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1488,29 +1496,27 @@ bool Device_Encode_Value_List(
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
void Device_local_reporting(void)
|
||||
void Device_local_reporting(
|
||||
void)
|
||||
{
|
||||
struct object_functions *pObject;
|
||||
struct object_functions *pObject;
|
||||
uint32_t objects_count;
|
||||
uint32_t object_instance;
|
||||
int object_type;
|
||||
int object_type;
|
||||
uint32_t idx;
|
||||
|
||||
objects_count = Device_Object_List_Count();
|
||||
|
||||
/* loop for all objects */
|
||||
for (idx = 1; idx < objects_count; idx++)
|
||||
{
|
||||
Device_Object_List_Identifier(idx, &object_type,
|
||||
&object_instance);
|
||||
for (idx = 1; idx < objects_count; idx++) {
|
||||
Device_Object_List_Identifier(idx, &object_type, &object_instance);
|
||||
|
||||
pObject = Device_Objects_Find_Functions(object_type);
|
||||
if (pObject != NULL) {
|
||||
if (pObject->Object_Valid_Instance &&
|
||||
pObject->Object_Valid_Instance(object_instance)) {
|
||||
if (pObject->Object_Intrinsic_Reporting) {
|
||||
pObject->Object_Intrinsic_Reporting(
|
||||
object_instance);
|
||||
pObject->Object_Intrinsic_Reporting(object_instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1555,7 +1561,7 @@ void Device_Init(
|
||||
characterstring_init_ansi(&My_Object_Name, "SimpleServer");
|
||||
/* we don't use the object table passed in
|
||||
since there is extra stuff we don't need in there. */
|
||||
(void)object_table;
|
||||
(void) object_table;
|
||||
pObject = &Object_Table[0];
|
||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||
if (pObject->Object_Init) {
|
||||
@@ -1653,10 +1659,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1668,11 +1674,11 @@ bool WPValidateString(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
iMaxLen=iMaxLen;
|
||||
bEmptyAllowed=bEmptyAllowed;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
iMaxLen = iMaxLen;
|
||||
bEmptyAllowed = bEmptyAllowed;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1681,8 +1687,8 @@ int handler_cov_encode_subscriptions(
|
||||
uint8_t * apdu,
|
||||
int max_apdu)
|
||||
{
|
||||
apdu=apdu;
|
||||
max_apdu=max_apdu;
|
||||
apdu = apdu;
|
||||
max_apdu = max_apdu;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ typedef uint32_t(
|
||||
*/
|
||||
typedef bool(
|
||||
*object_name_function)
|
||||
(
|
||||
(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
/** Look in the table of objects of this type, and see if this is a valid
|
||||
* instance number.
|
||||
@@ -116,9 +116,9 @@ typedef bool(
|
||||
* @ingroup ObjHelpers
|
||||
* @param [in] Object instance.
|
||||
*/
|
||||
typedef void(
|
||||
typedef void (
|
||||
*object_intrinsic_reporting_function) (
|
||||
uint32_t object_instance);
|
||||
uint32_t object_instance);
|
||||
|
||||
|
||||
/** Defines the group of object helper functions for any supported Object.
|
||||
@@ -213,7 +213,8 @@ extern "C" {
|
||||
rr_info_function Device_Objects_RR_Info(
|
||||
BACNET_OBJECT_TYPE object_type);
|
||||
|
||||
void Device_getCurrentDateTime(BACNET_DATE_TIME * DateTime);
|
||||
void Device_getCurrentDateTime(
|
||||
BACNET_DATE_TIME * DateTime);
|
||||
|
||||
void Device_Property_Lists(
|
||||
const int **pRequired,
|
||||
@@ -250,14 +251,14 @@ extern "C" {
|
||||
|
||||
bool Device_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Device_Set_Object_Name(
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
/* copy a child object name */
|
||||
bool Device_Object_Name_Copy(
|
||||
int object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
BACNET_DEVICE_STATUS Device_System_Status(
|
||||
void);
|
||||
@@ -316,7 +317,7 @@ extern "C" {
|
||||
void);
|
||||
|
||||
bool Device_Valid_Object_Name(
|
||||
BACNET_CHARACTER_STRING *object_name,
|
||||
BACNET_CHARACTER_STRING * object_name,
|
||||
int *object_type,
|
||||
uint32_t * object_instance);
|
||||
bool Device_Valid_Object_Id(
|
||||
@@ -338,7 +339,8 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
void Device_local_reporting(void);
|
||||
void Device_local_reporting(
|
||||
void);
|
||||
#endif
|
||||
|
||||
/* Prototypes for Routing functionality in the Device Object.
|
||||
@@ -411,11 +413,11 @@ extern "C" {
|
||||
* - The interface between the implemented Objects and the BAC-stack services,
|
||||
* specifically the handlers, which are mediated through function calls to
|
||||
* the Device object.
|
||||
*//** @defgroup ObjHelpers Object Helper Functions
|
||||
*//** @defgroup ObjHelpers Object Helper Functions
|
||||
* @ingroup ObjFrmwk
|
||||
* This section describes the function templates for the helper functions that
|
||||
* provide common object support.
|
||||
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||
* @ingroup ObjFrmwk
|
||||
* This section describes the fairly limited set of functions that link the
|
||||
* BAC-stack handlers to the BACnet Object instances. All of these calls are
|
||||
|
||||
@@ -127,14 +127,10 @@ uint16_t Add_Routed_Device(
|
||||
pDev->bacObj.mObject_Type = OBJECT_DEVICE;
|
||||
pDev->bacObj.Object_Instance_Number = Object_Instance;
|
||||
if (sObject_Name != NULL)
|
||||
Routed_Device_Set_Object_Name(
|
||||
CHARACTER_UTF8,
|
||||
sObject_Name,
|
||||
Routed_Device_Set_Object_Name(CHARACTER_UTF8, sObject_Name,
|
||||
strlen(sObject_Name));
|
||||
else
|
||||
Routed_Device_Set_Object_Name(
|
||||
CHARACTER_UTF8,
|
||||
"No Name",
|
||||
Routed_Device_Set_Object_Name(CHARACTER_UTF8, "No Name",
|
||||
strlen("No Name"));
|
||||
if (sDescription != NULL)
|
||||
Routed_Device_Set_Description(sDescription, strlen(sDescription));
|
||||
@@ -488,8 +484,8 @@ bool Routed_Device_Write_Property_Local(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Routed_Device_Set_Object_Instance_Number(value.
|
||||
type.Object_Id.instance))) {
|
||||
(Routed_Device_Set_Object_Instance_Number(value.type.
|
||||
Object_Id.instance))) {
|
||||
/* FIXME: we could send an I-Am broadcast to let the world know */
|
||||
} else {
|
||||
status = false;
|
||||
@@ -503,8 +499,8 @@ bool Routed_Device_Write_Property_Local(
|
||||
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
Routed_Device_Set_Object_Name(
|
||||
characterstring_encoding(&value.type.Character_String),
|
||||
Routed_Device_Set_Object_Name(characterstring_encoding(&value.
|
||||
type.Character_String),
|
||||
characterstring_value(&value.type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
}
|
||||
@@ -559,8 +555,7 @@ bool Routed_Device_Set_Object_Name(
|
||||
bool status = false; /*return value */
|
||||
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
|
||||
|
||||
if ((encoding == CHARACTER_UTF8) &&
|
||||
(length < MAX_DEV_NAME_LEN)) {
|
||||
if ((encoding == CHARACTER_UTF8) && (length < MAX_DEV_NAME_LEN)) {
|
||||
/* Make the change and update the database revision */
|
||||
memmove(pDev->bacObj.Object_Name, value, length);
|
||||
pDev->bacObj.Object_Name[length] = 0;
|
||||
|
||||
@@ -274,7 +274,7 @@ static BACNET_SHED_STATE Load_Control_Present_Value(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Load_Control_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
|
||||
@@ -54,7 +54,7 @@ extern "C" {
|
||||
|
||||
bool Load_Control_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
void Load_Control_Init(
|
||||
void);
|
||||
|
||||
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
|
||||
object_index =
|
||||
Lighting_Output_Instance_To_Index(rpdata->object_instance);
|
||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Lighting_Output_Level[object_index][rpdata->
|
||||
array_index - 1] == LIGHTING_LEVEL_NULL)
|
||||
if (Lighting_Output_Level[object_index][rpdata->array_index
|
||||
- 1] == LIGHTING_LEVEL_NULL)
|
||||
apdu_len = encode_application_null(&apdu[0]);
|
||||
else {
|
||||
real_value = Lighting_Output_Level[object_index]
|
||||
@@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property(
|
||||
if (status) {
|
||||
level = LIGHTING_LEVEL_NULL;
|
||||
object_index =
|
||||
Lighting_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Lighting_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
status =
|
||||
Lighting_Output_Present_Value_Relinquish(wp_data->
|
||||
object_instance, wp_data->priority);
|
||||
Lighting_Output_Present_Value_Relinquish
|
||||
(wp_data->object_instance, wp_data->priority);
|
||||
if (wp_data->priority == 6) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Lighting_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Lighting_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Lighting_Output_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
}
|
||||
@@ -612,10 +612,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ static BACNET_LIFE_SAFETY_STATE Life_Safety_Point_Present_Value(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Life_Safety_Point_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -218,7 +218,8 @@ int Life_Safety_Point_Read_Property(
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_DESCRIPTION:
|
||||
Life_Safety_Point_Object_Name(rpdata->object_instance, &char_string);
|
||||
Life_Safety_Point_Object_Name(rpdata->object_instance,
|
||||
&char_string);
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
@@ -324,8 +325,8 @@ bool Life_Safety_Point_Write_Property(
|
||||
if (status) {
|
||||
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Life_Safety_Point_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Life_Safety_Point_Mode[object_index] =
|
||||
value.type.Enumerated;
|
||||
} else {
|
||||
@@ -341,8 +342,8 @@ bool Life_Safety_Point_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Life_Safety_Point_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Life_Safety_Point_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
}
|
||||
@@ -368,10 +369,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
uint32_t object_instance);
|
||||
bool Life_Safety_Point_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
void Life_Safety_Point_Init(
|
||||
void);
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ bool Multistate_Input_Description_Set(
|
||||
|
||||
bool Multistate_Input_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
bool status = false;
|
||||
@@ -348,7 +348,8 @@ int Multistate_Input_Read_Property(
|
||||
/* note: Name and Description don't have to be the same.
|
||||
You could make Description writable and different */
|
||||
case PROP_OBJECT_NAME:
|
||||
Multistate_Input_Object_Name(rpdata->object_instance, &char_string);
|
||||
Multistate_Input_Object_Name(rpdata->object_instance,
|
||||
&char_string);
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
@@ -403,8 +404,8 @@ int Multistate_Input_Read_Property(
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
object_index =
|
||||
Multistate_Input_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Input_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
|
||||
characterstring_init_ansi(&char_string,
|
||||
Multistate_Input_State_Text(rpdata->object_instance,
|
||||
@@ -425,8 +426,8 @@ int Multistate_Input_Read_Property(
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Multistate_Input_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Input_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
|
||||
characterstring_init_ansi(&char_string,
|
||||
Multistate_Input_State_Text(rpdata->object_instance,
|
||||
@@ -486,8 +487,8 @@ bool Multistate_Input_Write_Property(
|
||||
if (status) {
|
||||
if (Out_Of_Service[object_index]) {
|
||||
status =
|
||||
Multistate_Input_Present_Value_Set(wp_data->
|
||||
object_instance, value.type.Unsigned_Int);
|
||||
Multistate_Input_Present_Value_Set
|
||||
(wp_data->object_instance, value.type.Unsigned_Int);
|
||||
if (!status) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
@@ -505,8 +506,8 @@ bool Multistate_Input_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Multistate_Input_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Input_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Out_Of_Service[object_index] = value.type.Boolean;
|
||||
}
|
||||
break;
|
||||
@@ -531,10 +532,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ extern "C" {
|
||||
|
||||
bool Multistate_Input_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Multistate_Input_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
|
||||
@@ -182,7 +182,7 @@ static uint32_t Multistate_Output_Present_Value(
|
||||
/* note: the object name must be unique within this device */
|
||||
bool Multistate_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -224,7 +224,8 @@ int Multistate_Output_Read_Property(
|
||||
You could make Description writable and different */
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_DESCRIPTION:
|
||||
Multistate_Output_Object_Name(rpdata->object_instance, &char_string);
|
||||
Multistate_Output_Object_Name(rpdata->object_instance,
|
||||
&char_string);
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
@@ -267,8 +268,8 @@ int Multistate_Output_Read_Property(
|
||||
/* into one packet. */
|
||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
if (Multistate_Output_Level[object_index][i] ==
|
||||
@@ -293,8 +294,8 @@ int Multistate_Output_Read_Property(
|
||||
}
|
||||
} else {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(rpdata->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(rpdata->object_instance);
|
||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Multistate_Output_Level[object_index]
|
||||
[rpdata->array_index - 1] == MULTISTATE_NULL)
|
||||
@@ -376,8 +377,8 @@ bool Multistate_Output_Write_Property(
|
||||
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
|
||||
level = value.type.Unsigned_Int;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority--;
|
||||
Multistate_Output_Level[object_index][priority] =
|
||||
(uint8_t) level;
|
||||
@@ -404,8 +405,8 @@ bool Multistate_Output_Write_Property(
|
||||
if (status) {
|
||||
level = MULTISTATE_NULL;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
@@ -431,8 +432,8 @@ bool Multistate_Output_Write_Property(
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
if (status) {
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Multistate_Output_Instance_To_Index
|
||||
(wp_data->object_instance);
|
||||
Multistate_Output_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
}
|
||||
@@ -458,10 +459,10 @@ bool WPValidateArgType(
|
||||
BACNET_ERROR_CLASS * pErrorClass,
|
||||
BACNET_ERROR_CODE * pErrorCode)
|
||||
{
|
||||
pValue=pValue;
|
||||
ucExpectedTag=ucExpectedTag;
|
||||
pErrorClass=pErrorClass;
|
||||
pErrorCode=pErrorCode;
|
||||
pValue = pValue;
|
||||
ucExpectedTag = ucExpectedTag;
|
||||
pErrorClass = pErrorClass;
|
||||
pErrorCode = pErrorCode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
|
||||
bool Multistate_Output_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
void Multistate_Output_Init(
|
||||
void);
|
||||
|
||||
+929
-889
File diff suppressed because it is too large
Load Diff
@@ -38,11 +38,11 @@ extern "C" {
|
||||
/* max "length" of recipient_list */
|
||||
#define NC_MAX_RECIPIENTS 10
|
||||
/* Recipient types */
|
||||
typedef enum {
|
||||
RECIPIENT_TYPE_NOTINITIALIZED = 0,
|
||||
RECIPIENT_TYPE_DEVICE = 1,
|
||||
RECIPIENT_TYPE_ADDRESS = 2
|
||||
} NC_RECIPIENT_TYPE;
|
||||
typedef enum {
|
||||
RECIPIENT_TYPE_NOTINITIALIZED = 0,
|
||||
RECIPIENT_TYPE_DEVICE = 1,
|
||||
RECIPIENT_TYPE_ADDRESS = 2
|
||||
} NC_RECIPIENT_TYPE;
|
||||
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
@@ -53,47 +53,47 @@ BACnetRecipient ::= CHOICE {
|
||||
address [1] BACnetAddress
|
||||
}
|
||||
*/
|
||||
typedef struct BACnet_Recipient {
|
||||
uint8_t RecipientType; /* Type of Recipient */
|
||||
union {
|
||||
uint32_t DeviceIdentifier;
|
||||
BACNET_ADDRESS Address;
|
||||
} _;
|
||||
} BACNET_RECIPIENT;
|
||||
typedef struct BACnet_Recipient {
|
||||
uint8_t RecipientType; /* Type of Recipient */
|
||||
union {
|
||||
uint32_t DeviceIdentifier;
|
||||
BACNET_ADDRESS Address;
|
||||
} _;
|
||||
} BACNET_RECIPIENT;
|
||||
|
||||
|
||||
/* BACnetDestination structure */
|
||||
typedef struct BACnet_Destination {
|
||||
uint8_t ValidDays;
|
||||
BACNET_TIME FromTime;
|
||||
BACNET_TIME ToTime;
|
||||
BACNET_RECIPIENT Recipient;
|
||||
uint32_t ProcessIdentifier;
|
||||
uint8_t Transitions;
|
||||
bool ConfirmedNotify;
|
||||
} BACNET_DESTINATION;
|
||||
typedef struct BACnet_Destination {
|
||||
uint8_t ValidDays;
|
||||
BACNET_TIME FromTime;
|
||||
BACNET_TIME ToTime;
|
||||
BACNET_RECIPIENT Recipient;
|
||||
uint32_t ProcessIdentifier;
|
||||
uint8_t Transitions;
|
||||
bool ConfirmedNotify;
|
||||
} BACNET_DESTINATION;
|
||||
|
||||
|
||||
/* Structure containing configuration for a Notification Class */
|
||||
typedef struct Notification_Class_info {
|
||||
uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */
|
||||
uint8_t Ack_Required; /* BACnetEventTransitionBits */
|
||||
BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */
|
||||
} NOTIFICATION_CLASS_INFO;
|
||||
typedef struct Notification_Class_info {
|
||||
uint8_t Priority[3]; /* BACnetARRAY[3] of Unsigned */
|
||||
uint8_t Ack_Required; /* BACnetEventTransitionBits */
|
||||
BACNET_DESTINATION Recipient_List[NC_MAX_RECIPIENTS]; /* List of BACnetDestination */
|
||||
} NOTIFICATION_CLASS_INFO;
|
||||
|
||||
|
||||
/* Indicates whether the transaction has been confirmed */
|
||||
typedef struct Acked_info {
|
||||
bool bIsAcked; /* true when transitions is acked */
|
||||
BACNET_DATE_TIME Time_Stamp;/* time stamp of when a alarm was generated */
|
||||
} ACKED_INFO;
|
||||
typedef struct Acked_info {
|
||||
bool bIsAcked; /* true when transitions is acked */
|
||||
BACNET_DATE_TIME Time_Stamp; /* time stamp of when a alarm was generated */
|
||||
} ACKED_INFO;
|
||||
|
||||
|
||||
/* Information needed to send AckNotification */
|
||||
typedef struct Ack_Notification {
|
||||
bool bSendAckNotify; /* true if need to send AckNotification */
|
||||
uint8_t EventState;
|
||||
} ACK_NOTIFICATION;
|
||||
typedef struct Ack_Notification {
|
||||
bool bSendAckNotify; /* true if need to send AckNotification */
|
||||
uint8_t EventState;
|
||||
} ACK_NOTIFICATION;
|
||||
|
||||
|
||||
|
||||
@@ -102,43 +102,46 @@ typedef struct Ack_Notification {
|
||||
const int **pOptional,
|
||||
const int **pProprietary);
|
||||
|
||||
void Notification_Class_Init(void);
|
||||
void Notification_Class_Init(
|
||||
void);
|
||||
|
||||
bool Notification_Class_Valid_Instance(
|
||||
uint32_t object_instance);
|
||||
unsigned Notification_Class_Count(void);
|
||||
uint32_t Notification_Class_Index_To_Instance(unsigned index);
|
||||
uint32_t object_instance);
|
||||
unsigned Notification_Class_Count(
|
||||
void);
|
||||
uint32_t Notification_Class_Index_To_Instance(
|
||||
unsigned index);
|
||||
unsigned Notification_Class_Instance_To_Index(
|
||||
uint32_t object_instance);
|
||||
uint32_t object_instance);
|
||||
bool Notification_Class_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
int Notification_Class_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
|
||||
bool Notification_Class_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||
|
||||
void Notification_Class_Get_Priorities(
|
||||
uint32_t Object_Instance, uint32_t *pPriorityArray);
|
||||
uint32_t Object_Instance,
|
||||
uint32_t * pPriorityArray);
|
||||
|
||||
void Notification_Class_common_reporting_function(
|
||||
BACNET_EVENT_NOTIFICATION_DATA * event_data);
|
||||
BACNET_EVENT_NOTIFICATION_DATA * event_data);
|
||||
|
||||
void Notification_Class_find_recipient(void);
|
||||
void Notification_Class_find_recipient(
|
||||
void);
|
||||
#endif /* defined(INTRINSIC_REPORTING) */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define NOTIFICATION_CLASS_OBJ_FUNCTIONS \
|
||||
OBJECT_NOTIFICATION_CLASS, Notification_Class_Init, Notification_Class_Count, \
|
||||
Notification_Class_Index_To_Instance, Notification_Class_Valid_Instance, \
|
||||
Notification_Class_Object_Name, Notification_Class_Read_Property, \
|
||||
Notification_Class_Write_Property, Notification_Class_Property_Lists, \
|
||||
NULL, NULL, NULL
|
||||
|
||||
#endif /* NC_H */
|
||||
|
||||
@@ -259,7 +259,7 @@ void Trend_Log_Init(
|
||||
*/
|
||||
bool Trend_Log_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
{
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
bool status = false;
|
||||
@@ -736,9 +736,9 @@ bool Trend_Log_Write_Property(
|
||||
if (wp_data->application_data_len != 0) {
|
||||
iOffset += len;
|
||||
len =
|
||||
bacapp_decode_context_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||
bacapp_decode_context_data(&wp_data->application_data
|
||||
[iOffset], wp_data->application_data_len, &value,
|
||||
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||
if ((len == 0) || ((value.context_tag != 2) &&
|
||||
(value.context_tag != 3))) {
|
||||
/* Bad decode or wrong tag */
|
||||
@@ -755,8 +755,8 @@ bool Trend_Log_Write_Property(
|
||||
if (wp_data->application_data_len != 0) {
|
||||
iOffset += len;
|
||||
len =
|
||||
bacapp_decode_context_data(&wp_data->
|
||||
application_data[iOffset],
|
||||
bacapp_decode_context_data
|
||||
(&wp_data->application_data[iOffset],
|
||||
wp_data->application_data_len, &value,
|
||||
PROP_LOG_DEVICE_OBJECT_PROPERTY);
|
||||
if ((len == 0) || (value.context_tag != 3)) {
|
||||
@@ -1098,8 +1098,8 @@ int rr_trend_log_encode(
|
||||
pRequest->ItemCount = 0; /* Start out with nothing */
|
||||
|
||||
/* Bail out now if nowt - should never happen for a Trend Log but ... */
|
||||
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
|
||||
ulRecordCount == 0)
|
||||
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->
|
||||
object_instance)].ulRecordCount == 0)
|
||||
return (0);
|
||||
|
||||
if ((pRequest->RequestType == RR_BY_POSITION) ||
|
||||
|
||||
@@ -141,7 +141,7 @@ extern "C" {
|
||||
|
||||
bool Trend_Log_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name);
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
|
||||
int Trend_Log_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||
|
||||
Reference in New Issue
Block a user