diff --git a/demo/object/mso.c b/demo/object/mso.c index 0107d7f..492a5f0 100644 --- a/demo/object/mso.c +++ b/demo/object/mso.c @@ -59,7 +59,7 @@ unsigned max_multi_state_outputs_int = 0; /* will be relinquished (i.e. set to the NULL level). */ #define MULTI_STATE_LEVEL_NULL 255 -MULTI_STATE_OUTPUT_DESCR MSV_Descr[MAX_MULTI_STATE_OUTPUTS]; +MULTI_STATE_OUTPUT_DESCR MSO_Descr[MAX_MULTI_STATE_OUTPUTS]; /* These three arrays are used by the ReadPropertyMultiple handler */ static const int Multistate_Output_Properties_Required[] = { @@ -215,16 +215,16 @@ void Multistate_Output_Init( ucidisable = ucix_get_option_int(ctx, "bacnet_mo", idx_c, "disable", 0); if ((uciname != 0) && (ucidisable == 0)) { - memset(&MSV_Descr[i], 0x00, sizeof(MULTI_STATE_OUTPUT_DESCR)); + memset(&MSO_Descr[i], 0x00, sizeof(MULTI_STATE_OUTPUT_DESCR)); /* initialize all the analog output priority arrays to NULL */ for (j = 0; j < BACNET_MAX_PRIORITY; j++) { - MSV_Descr[i].Priority_Array[j] = MULTI_STATE_LEVEL_NULL; + MSO_Descr[i].Priority_Array[j] = MULTI_STATE_LEVEL_NULL; } - MSV_Descr[i].Instance=atoi(idx_cc); - MSV_Descr[i].Disable=false; + MSO_Descr[i].Instance=atoi(idx_cc); + MSO_Descr[i].Disable=false; sprintf(name, "%s", uciname); - ucix_string_copy(MSV_Descr[i].Object_Name, - sizeof(MSV_Descr[i].Object_Name), name); + ucix_string_copy(MSO_Descr[i].Object_Name, + sizeof(MSO_Descr[i].Object_Name), name); ucidescription = ucix_get_option(ctx, "bacnet_mo", idx_c, "description"); if (ucidescription != 0) { @@ -236,13 +236,13 @@ void Multistate_Output_Init( sprintf(description, "MV%lu no uci section configured", (unsigned long) i); } - ucix_string_copy(MSV_Descr[i].Object_Description, - sizeof(MSV_Descr[i].Object_Description), description); + ucix_string_copy(MSO_Descr[i].Object_Description, + sizeof(MSO_Descr[i].Object_Description), description); ucivalue = ucix_get_option_int(ctx, "bacnet_mo", idx_c, "value", 1); - MSV_Descr[i].Priority_Array[15] = (uint8_t) ucivalue; - MSV_Descr[i].Relinquish_Default = 1; //TODO read uci + MSO_Descr[i].Priority_Array[15] = (uint8_t) ucivalue; + MSO_Descr[i].Relinquish_Default = 1; //TODO read uci ucistate_n = ucix_get_list(ucistate, ctx, "bacnet_mo", idx_c, "state"); @@ -258,7 +258,7 @@ void Multistate_Output_Init( state[j] = ucistate[j]; } } - MSV_Descr[i].number_of_states = state_n; + MSO_Descr[i].number_of_states = state_n; ucialarmstate_n = ucix_get_list(ucialarmstate, ctx, "bacnet_mo", idx_c, "alarmstate"); @@ -276,18 +276,18 @@ void Multistate_Output_Init( l = 0; for (j = 0; j < state_n; j++) { if (state[j]) { - sprintf(MSV_Descr[i].State_Text[j], "%s", state[j]); + sprintf(MSO_Descr[i].State_Text[j], "%s", state[j]); } else { - sprintf(MSV_Descr[i].State_Text[j], "STATUS: %i", j); + sprintf(MSO_Descr[i].State_Text[j], "STATUS: %i", j); } for (k = 0; k < alarmstate_n; k++) { if (strcmp(state[j],alarmstate[k]) == 0) { - MSV_Descr[i].Alarm_Values[l] = j+1; + MSO_Descr[i].Alarm_Values[l] = j+1; l++; } } } - MSV_Descr[i].number_of_alarmstates = l; + MSO_Descr[i].number_of_alarmstates = l; #if defined(INTRINSIC_REPORTING) ucinc = ucix_get_option_int(ctx, "bacnet_mo", idx_c, "nc", ucinc_default); @@ -295,19 +295,19 @@ void Multistate_Output_Init( "event", ucievent_default); ucitime_delay = ucix_get_option_int(ctx, "bacnet_mo", idx_c, "time_delay", ucitime_delay_default); - MSV_Descr[i].Event_State = EVENT_STATE_NORMAL; + MSO_Descr[i].Event_State = EVENT_STATE_NORMAL; /* notification class not connected */ - if (ucinc > -1) MSV_Descr[i].Notification_Class = ucinc; - else MSV_Descr[i].Notification_Class = BACNET_MAX_INSTANCE; - if (ucievent > -1) MSV_Descr[i].Event_Enable = ucievent; - else MSV_Descr[i].Event_Enable = 0; - if (ucitime_delay > -1) MSV_Descr[i].Time_Delay = ucitime_delay; - else MSV_Descr[i].Time_Delay = 0; + if (ucinc > -1) MSO_Descr[i].Notification_Class = ucinc; + else MSO_Descr[i].Notification_Class = BACNET_MAX_INSTANCE; + if (ucievent > -1) MSO_Descr[i].Event_Enable = ucievent; + else MSO_Descr[i].Event_Enable = 0; + if (ucitime_delay > -1) MSO_Descr[i].Time_Delay = ucitime_delay; + else MSO_Descr[i].Time_Delay = 0; /* initialize Event time stamps using wildcards and set Acked_transitions */ for (j = 0; j < MAX_BACNET_EVENT_TRANSITION; j++) { - datetime_wildcard_set(&MSV_Descr[i].Event_Time_Stamps[j]); - MSV_Descr[i].Acked_Transitions[j].bIsAcked = true; + datetime_wildcard_set(&MSO_Descr[i].Event_Time_Stamps[j]); + MSO_Descr[i].Acked_Transitions[j].bIsAcked = true; } /* Set handler for GetEventInformation function */ @@ -320,7 +320,7 @@ void Multistate_Output_Init( handler_get_alarm_summary_set(OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Alarm_Summary); - MSV_Descr[i].Notify_Type = NOTIFY_ALARM; + MSO_Descr[i].Notify_Type = NOTIFY_ALARM; #endif i++; max_multi_state_outputs_int = i; @@ -341,13 +341,13 @@ void Multistate_Output_Init( unsigned Multistate_Output_Instance_To_Index( uint32_t object_instance) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; int index,instance,i; index = max_multi_state_outputs_int; for (i = 0; i < index; i++) { - CurrentMSV = &MSV_Descr[i]; - instance = CurrentMSV->Instance; - if (CurrentMSV->Instance == object_instance) { + CurrentMSO = &MSO_Descr[i]; + instance = CurrentMSO->Instance; + if (CurrentMSO->Instance == object_instance) { return i; } } @@ -360,10 +360,10 @@ unsigned Multistate_Output_Instance_To_Index( uint32_t Multistate_Output_Index_To_Instance( unsigned index) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; uint32_t instance; - CurrentMSV = &MSV_Descr[index]; - instance = CurrentMSV->Instance; + CurrentMSO = &MSO_Descr[index]; + instance = CurrentMSO->Instance; return instance; } @@ -381,7 +381,7 @@ unsigned Multistate_Output_Count( bool Multistate_Output_Valid_Instance( uint32_t object_instance) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ index = Multistate_Output_Instance_To_Index(object_instance); if (index == MAX_MULTI_STATE_OUTPUTS) { @@ -390,8 +390,8 @@ bool Multistate_Output_Valid_Instance( #endif return false; } - CurrentMSV = &MSV_Descr[index]; - if (CurrentMSV->Disable == false) + CurrentMSO = &MSO_Descr[index]; + if (CurrentMSO->Disable == false) return true; return false; @@ -400,20 +400,20 @@ bool Multistate_Output_Valid_Instance( uint32_t Multistate_Output_Present_Value( uint32_t object_instance) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; uint32_t value = MULTI_STATE_RELINQUISH_DEFAULT; unsigned index = 0; /* offset from instance lookup */ unsigned i = 0; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; /* When all the priorities are level null, the present value returns */ /* the Relinquish Default value */ - value = CurrentMSV->Relinquish_Default; + value = CurrentMSO->Relinquish_Default; for (i = 0; i < BACNET_MAX_PRIORITY; i++) { - if (CurrentMSV->Priority_Array[i] != MULTI_STATE_LEVEL_NULL) { - value = CurrentMSV->Priority_Array[i]; + if (CurrentMSO->Priority_Array[i] != MULTI_STATE_LEVEL_NULL) { + value = CurrentMSO->Priority_Array[i]; break; } } @@ -427,18 +427,18 @@ bool Multistate_Output_Present_Value_Set( uint32_t value, uint8_t priority) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ bool status = false; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; if (priority && (priority <= BACNET_MAX_PRIORITY) && (priority != 6 /* reserved */ ) && (value > 0) && - (value <= CurrentMSV->number_of_states)) { -// CurrentMSV->Present_Value = (uint8_t) value; - CurrentMSV->Priority_Array[priority - 1] = (uint8_t) value; + (value <= CurrentMSO->number_of_states)) { +// CurrentMSO->Present_Value = (uint8_t) value; + CurrentMSO->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 priorities are set. @@ -446,7 +446,7 @@ bool Multistate_Output_Present_Value_Set( physical output. This comment may apply to the main loop (i.e. check out of service before changing output) */ if (priority == 8) { - CurrentMSV->Priority_Array[15] = (uint8_t) value; + CurrentMSO->Priority_Array[15] = (uint8_t) value; } status = true; } @@ -457,14 +457,14 @@ bool Multistate_Output_Present_Value_Set( bool Multistate_Output_Out_Of_Service( uint32_t object_instance) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ bool value = false; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - value = CurrentMSV->Out_Of_Service; + CurrentMSO = &MSO_Descr[index]; + value = CurrentMSO->Out_Of_Service; } return value; @@ -474,13 +474,13 @@ void Multistate_Output_Out_Of_Service_Set( uint32_t object_instance, bool value) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - CurrentMSV->Out_Of_Service = value; + CurrentMSO = &MSO_Descr[index]; + CurrentMSO->Out_Of_Service = value; } return; @@ -490,13 +490,13 @@ void Multistate_Output_Reliability_Set( uint32_t object_instance, uint8_t value) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - CurrentMSV->Reliability = value; + CurrentMSO = &MSO_Descr[index]; + CurrentMSO->Reliability = value; } return; @@ -505,14 +505,14 @@ void Multistate_Output_Reliability_Set( uint8_t Multistate_Output_Reliability( uint32_t object_instance) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ uint8_t value = 0; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - value = CurrentMSV->Reliability; + CurrentMSO = &MSO_Descr[index]; + value = CurrentMSO->Reliability; } return value; @@ -521,14 +521,14 @@ uint8_t Multistate_Output_Reliability( static char *Multistate_Output_Description( uint32_t object_instance) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ char *pName = NULL; /* return value */ if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - pName = CurrentMSV->Object_Description; + CurrentMSO = &MSO_Descr[index]; + pName = CurrentMSO->Object_Description; } return pName; @@ -538,25 +538,25 @@ bool Multistate_Output_Description_Set( uint32_t object_instance, char *new_name) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ size_t i = 0; /* loop counter */ bool status = false; /* return value */ if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; status = true; if (new_name) { - for (i = 0; i < sizeof(CurrentMSV->Object_Description); i++) { - CurrentMSV->Object_Description[i] = new_name[i]; + for (i = 0; i < sizeof(CurrentMSO->Object_Description); i++) { + CurrentMSO->Object_Description[i] = new_name[i]; if (new_name[i] == 0) { break; } } } else { - for (i = 0; i < sizeof(CurrentMSV->Object_Description); i++) { - CurrentMSV->Object_Description[i] = 0; + for (i = 0; i < sizeof(CurrentMSO->Object_Description); i++) { + CurrentMSO->Object_Description[i] = 0; } } } @@ -570,7 +570,7 @@ static bool Multistate_Output_Description_Write( BACNET_ERROR_CLASS *error_class, BACNET_ERROR_CODE *error_code) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ size_t length = 0; uint8_t encoding = 0; @@ -580,20 +580,20 @@ static bool Multistate_Output_Description_Write( if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; length = characterstring_length(char_string); - if (length <= sizeof(CurrentMSV->Object_Description)) { + if (length <= sizeof(CurrentMSO->Object_Description)) { encoding = characterstring_encoding(char_string); if (encoding == CHARACTER_UTF8) { status = characterstring_ansi_copy( - CurrentMSV->Object_Description, - sizeof(CurrentMSV->Object_Description), + CurrentMSO->Object_Description, + sizeof(CurrentMSO->Object_Description), char_string); if (!status) { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; } else { - sprintf(idx_cc,"%d",CurrentMSV->Instance); + sprintf(idx_cc,"%d",CurrentMSO->Instance); idx_c = idx_cc; if(ctx) { ucix_add_option(ctx, "bacnet_mo", idx_c, @@ -623,14 +623,14 @@ bool Multistate_Output_Object_Name( uint32_t object_instance, BACNET_CHARACTER_STRING * object_name) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ bool status = false; if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - status = characterstring_init_ansi(object_name, CurrentMSV->Object_Name); + CurrentMSO = &MSO_Descr[index]; + status = characterstring_init_ansi(object_name, CurrentMSO->Object_Name); } return status; @@ -641,26 +641,26 @@ bool Multistate_Output_Name_Set( uint32_t object_instance, char *new_name) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ size_t i = 0; /* loop counter */ bool status = false; /* return value */ if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; status = true; /* FIXME: check to see if there is a matching name */ if (new_name) { - for (i = 0; i < sizeof(CurrentMSV->Object_Name); i++) { - CurrentMSV->Object_Name[i] = new_name[i]; + for (i = 0; i < sizeof(CurrentMSO->Object_Name); i++) { + CurrentMSO->Object_Name[i] = new_name[i]; if (new_name[i] == 0) { break; } } } else { - for (i = 0; i < sizeof(CurrentMSV->Object_Name); i++) { - CurrentMSV->Object_Name[i] = 0; + for (i = 0; i < sizeof(CurrentMSO->Object_Name); i++) { + CurrentMSO->Object_Name[i] = 0; } } } @@ -674,7 +674,7 @@ static bool Multistate_Output_Object_Name_Write( BACNET_ERROR_CLASS *error_class, BACNET_ERROR_CODE *error_code) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ size_t length = 0; uint8_t encoding = 0; @@ -684,20 +684,20 @@ static bool Multistate_Output_Object_Name_Write( if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; length = characterstring_length(char_string); - if (length <= sizeof(CurrentMSV->Object_Name)) { + if (length <= sizeof(CurrentMSO->Object_Name)) { encoding = characterstring_encoding(char_string); if (encoding == CHARACTER_UTF8) { status = characterstring_ansi_copy( - CurrentMSV->Object_Name, - sizeof(CurrentMSV->Object_Name), + CurrentMSO->Object_Name, + sizeof(CurrentMSO->Object_Name), char_string); if (!status) { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; } else { - sprintf(idx_cc,"%d",CurrentMSV->Instance); + sprintf(idx_cc,"%d",CurrentMSO->Instance); idx_c = idx_cc; if(ctx) { ucix_add_option(ctx, "bacnet_mo", idx_c, @@ -727,16 +727,16 @@ static char *Multistate_Output_State_Text( uint32_t object_instance, uint32_t state_index) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ char *pName = NULL; /* return value */ if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - if ((state_index > 0) && (state_index <= CurrentMSV->number_of_states)) { + CurrentMSO = &MSO_Descr[index]; + if ((state_index > 0) && (state_index <= CurrentMSO->number_of_states)) { state_index--; - pName = CurrentMSV->State_Text[state_index]; + pName = CurrentMSO->State_Text[state_index]; } } @@ -748,27 +748,27 @@ bool Multistate_Output_State_Text_Set( uint32_t state_index, char *new_name) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ size_t i = 0; /* loop counter */ bool status = false; /* return value */ if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - if ((state_index > 0) && (state_index <= CurrentMSV->number_of_states)) { + CurrentMSO = &MSO_Descr[index]; + if ((state_index > 0) && (state_index <= CurrentMSO->number_of_states)) { state_index--; status = true; if (new_name) { - for (i = 0; i < sizeof(CurrentMSV->State_Text[state_index]); i++) { - CurrentMSV->State_Text[state_index][i] = new_name[i]; + for (i = 0; i < sizeof(CurrentMSO->State_Text[state_index]); i++) { + CurrentMSO->State_Text[state_index][i] = new_name[i]; if (new_name[i] == 0) { break; } } } else { - for (i = 0; i < sizeof(CurrentMSV->State_Text[state_index]); i++) { - CurrentMSV->State_Text[state_index][i] = 0; + for (i = 0; i < sizeof(CurrentMSO->State_Text[state_index]); i++) { + CurrentMSO->State_Text[state_index][i] = 0; } } } @@ -784,7 +784,7 @@ static bool Multistate_Output_State_Text_Write( BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index = 0; /* offset from instance lookup */ size_t length = 0; uint8_t encoding = 0; @@ -797,26 +797,26 @@ static bool Multistate_Output_State_Text_Write( if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; - sprintf(idx_cc,"%d",CurrentMSV->Instance); + CurrentMSO = &MSO_Descr[index]; + sprintf(idx_cc,"%d",CurrentMSO->Instance); idx_c = idx_cc; - if ((state_index > 0) && (state_index <= CurrentMSV->number_of_states)) { + if ((state_index > 0) && (state_index <= CurrentMSO->number_of_states)) { state_index--; length = characterstring_length(char_string); - if (length <= sizeof(CurrentMSV->State_Text[state_index])) { + if (length <= sizeof(CurrentMSO->State_Text[state_index])) { encoding = characterstring_encoding(char_string); if (encoding == CHARACTER_UTF8) { status = - characterstring_ansi_copy(CurrentMSV->State_Text[state_index], - sizeof(CurrentMSV->State_Text[state_index]), char_string); + characterstring_ansi_copy(CurrentMSO->State_Text[state_index], + sizeof(CurrentMSO->State_Text[state_index]), char_string); ucix_set_list(ctx, "bacnet_mo", idx_c, "state", - CurrentMSV->State_Text, CurrentMSV->number_of_states); - ucialarmstate_n = CurrentMSV->number_of_alarmstates; + CurrentMSO->State_Text, CurrentMSO->number_of_states); + ucialarmstate_n = CurrentMSO->number_of_alarmstates; for (j = 0; j < ucialarmstate_n; j++) { - alarm_value = CurrentMSV->Alarm_Values[j]; - length = sizeof(CurrentMSV->State_Text[state_index]); + alarm_value = CurrentMSO->Alarm_Values[j]; + length = sizeof(CurrentMSO->State_Text[state_index]); sprintf(ucialarmstate[j], "%s", - CurrentMSV->State_Text[alarm_value-1]); + CurrentMSO->State_Text[alarm_value-1]); } ucix_set_list(ctx, "bacnet_mo", idx_c, "alarmstate", ucialarmstate, ucialarmstate_n); @@ -846,7 +846,7 @@ static bool Multistate_Output_State_Text_Write( int Multistate_Output_Read_Property( BACNET_READ_PROPERTY_DATA * rpdata) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; int len = 0; int apdu_len = 0; /* return value */ BACNET_BIT_STRING bit_string; @@ -865,10 +865,10 @@ int Multistate_Output_Read_Property( if (Multistate_Output_Valid_Instance(rpdata->object_instance)) { index = Multistate_Output_Instance_To_Index(rpdata->object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; } else return BACNET_STATUS_ERROR; - if (CurrentMSV->Disable) + if (CurrentMSO->Disable) return BACNET_STATUS_ERROR; switch (rpdata->object_property) { @@ -909,7 +909,7 @@ int Multistate_Output_Read_Property( bitstring_init(&bit_string); #if defined(INTRINSIC_REPORTING) bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, - CurrentMSV->Event_State ? true : false); + CurrentMSO->Event_State ? true : false); #else bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false); #endif @@ -930,7 +930,7 @@ int Multistate_Output_Read_Property( #if defined(INTRINSIC_REPORTING) apdu_len = encode_application_enumerated(&apdu[0], - CurrentMSV->Event_State); + CurrentMSO->Event_State); #else apdu_len = encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL); @@ -938,13 +938,13 @@ int Multistate_Output_Read_Property( break; case PROP_OUT_OF_SERVICE: - state = CurrentMSV->Out_Of_Service; + state = CurrentMSO->Out_Of_Service; apdu_len = encode_application_boolean(&apdu[0], state); break; case PROP_RELIABILITY: apdu_len = encode_application_enumerated(&apdu[0], - CurrentMSV->Reliability); + CurrentMSO->Reliability); break; @@ -958,10 +958,10 @@ int Multistate_Output_Read_Property( } else if (rpdata->array_index == BACNET_ARRAY_ALL) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) { /* FIXME: check if we have room before adding it to APDU */ - if (CurrentMSV->Priority_Array[i] == MULTI_STATE_LEVEL_NULL) { + if (CurrentMSO->Priority_Array[i] == MULTI_STATE_LEVEL_NULL) { len = encode_application_null(&apdu[apdu_len]); } else { - present_value = CurrentMSV->Priority_Array[i]; + present_value = CurrentMSO->Priority_Array[i]; len = encode_application_unsigned(&apdu[apdu_len], present_value); @@ -978,12 +978,12 @@ int Multistate_Output_Read_Property( } } else { if (rpdata->array_index <= BACNET_MAX_PRIORITY) { - if (CurrentMSV->Priority_Array[rpdata->array_index - 1] + if (CurrentMSO->Priority_Array[rpdata->array_index - 1] == MULTI_STATE_LEVEL_NULL) apdu_len = encode_application_null(&apdu[0]); else { present_value = - CurrentMSV->Priority_Array[rpdata->array_index - 1]; + CurrentMSO->Priority_Array[rpdata->array_index - 1]; apdu_len = encode_application_unsigned(&apdu[0],present_value); } @@ -996,14 +996,14 @@ int Multistate_Output_Read_Property( break; case PROP_RELINQUISH_DEFAULT: - present_value = CurrentMSV->Relinquish_Default; + present_value = CurrentMSO->Relinquish_Default; apdu_len = encode_application_unsigned(&apdu[0], present_value); break; case PROP_NUMBER_OF_STATES: apdu_len = encode_application_unsigned(&apdu[apdu_len], - CurrentMSV->number_of_states); + CurrentMSO->number_of_states); break; case PROP_STATE_TEXT: @@ -1011,13 +1011,13 @@ int Multistate_Output_Read_Property( /* Array element zero is the number of elements in the array */ apdu_len = encode_application_unsigned(&apdu[0], - CurrentMSV->number_of_states); + CurrentMSO->number_of_states); } else if (rpdata->array_index == BACNET_ARRAY_ALL) { /* if no index was specified, then try to encode the entire list */ /* into one packet. */ - for (i = 0; i < CurrentMSV->number_of_states; i++) { + for (i = 0; i < CurrentMSO->number_of_states; i++) { characterstring_init_ansi(&char_string, - CurrentMSV->State_Text[i]); + CurrentMSO->State_Text[i]); /* FIXME: this might go beyond MAX_APDU length! */ len = @@ -1034,7 +1034,7 @@ int Multistate_Output_Read_Property( } } } else { - if (rpdata->array_index <= CurrentMSV->number_of_states) { + if (rpdata->array_index <= CurrentMSO->number_of_states) { characterstring_init_ansi(&char_string, Multistate_Output_State_Text(rpdata->object_instance, rpdata->array_index)); @@ -1051,35 +1051,35 @@ int Multistate_Output_Read_Property( #if defined(INTRINSIC_REPORTING) case PROP_ALARM_VALUES: - for (i = 0; i < CurrentMSV->number_of_alarmstates; i++) { + for (i = 0; i < CurrentMSO->number_of_alarmstates; i++) { len = encode_application_unsigned(&apdu[apdu_len], - CurrentMSV->Alarm_Values[i]); + CurrentMSO->Alarm_Values[i]); apdu_len += len; } break; case PROP_TIME_DELAY: apdu_len = - encode_application_unsigned(&apdu[0], CurrentMSV->Time_Delay); + encode_application_unsigned(&apdu[0], CurrentMSO->Time_Delay); break; case PROP_NOTIFICATION_CLASS: apdu_len = encode_application_unsigned(&apdu[0], - CurrentMSV->Notification_Class); + CurrentMSO->Notification_Class); break; case PROP_EVENT_ENABLE: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, - (CurrentMSV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : + (CurrentMSO->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, - (CurrentMSV->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : + (CurrentMSO->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, - (CurrentMSV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : + (CurrentMSO->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); apdu_len = encode_application_bitstring(&apdu[0], &bit_string); @@ -1088,12 +1088,12 @@ int Multistate_Output_Read_Property( case PROP_ACKED_TRANSITIONS: bitstring_init(&bit_string); bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL, - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT, - CurrentMSV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); + CurrentMSO->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL, - CurrentMSV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked); + CurrentMSO->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked); apdu_len = encode_application_bitstring(&apdu[0], &bit_string); break; @@ -1101,7 +1101,7 @@ int Multistate_Output_Read_Property( case PROP_NOTIFY_TYPE: apdu_len = encode_application_enumerated(&apdu[0], - CurrentMSV->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM); + CurrentMSO->Notify_Type ? NOTIFY_EVENT : NOTIFY_ALARM); break; case PROP_EVENT_TIME_STAMPS: @@ -1119,10 +1119,10 @@ int Multistate_Output_Read_Property( TIME_STAMP_DATETIME); len += encode_application_date(&apdu[apdu_len + len], - &CurrentMSV->Event_Time_Stamps[i].date); + &CurrentMSO->Event_Time_Stamps[i].date); len += encode_application_time(&apdu[apdu_len + len], - &CurrentMSV->Event_Time_Stamps[i].time); + &CurrentMSO->Event_Time_Stamps[i].time); len += encode_closing_tag(&apdu[apdu_len + len], TIME_STAMP_DATETIME); @@ -1142,10 +1142,10 @@ int Multistate_Output_Read_Property( encode_opening_tag(&apdu[apdu_len], TIME_STAMP_DATETIME); apdu_len += encode_application_date(&apdu[apdu_len], - &CurrentMSV->Event_Time_Stamps[rpdata->array_index].date); + &CurrentMSO->Event_Time_Stamps[rpdata->array_index].date); apdu_len += encode_application_time(&apdu[apdu_len], - &CurrentMSV->Event_Time_Stamps[rpdata->array_index].time); + &CurrentMSO->Event_Time_Stamps[rpdata->array_index].time); apdu_len += encode_closing_tag(&apdu[apdu_len], TIME_STAMP_DATETIME); } else { @@ -1180,7 +1180,7 @@ int Multistate_Output_Read_Property( bool Multistate_Output_Write_Property( BACNET_WRITE_PROPERTY_DATA * wp_data) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; bool status = false; /* return value */ unsigned index = 0; int object_type = 0; @@ -1213,8 +1213,8 @@ bool Multistate_Output_Write_Property( if (Multistate_Output_Valid_Instance(wp_data->object_instance)) { index = Multistate_Output_Instance_To_Index(wp_data->object_instance); - CurrentMSV = &MSV_Descr[index]; - sprintf(idx_cc,"%d",CurrentMSV->Instance); + CurrentMSO = &MSO_Descr[index]; + sprintf(idx_cc,"%d",CurrentMSO->Instance); idx_c = idx_cc; } else { return false; @@ -1294,7 +1294,7 @@ bool Multistate_Output_Write_Property( priority = wp_data->priority; if (priority && (priority <= BACNET_MAX_PRIORITY)) { priority--; - CurrentMSV->Priority_Array[priority] = level; + CurrentMSO->Priority_Array[priority] = level; /* Note: you could set the physical output here to the next highest priority, or to the relinquish default if no priorities are set. @@ -1325,7 +1325,7 @@ bool Multistate_Output_Write_Property( WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED, &wp_data->error_class, &wp_data->error_code); if (status) { - CurrentMSV->Reliability = value.type.Enumerated; + CurrentMSO->Reliability = value.type.Enumerated; } break; @@ -1389,11 +1389,12 @@ bool Multistate_Output_Write_Property( WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT, &wp_data->error_class, &wp_data->error_code); if (status) { - CurrentMSV->Relinquish_Default = value.type.Unsigned_Int; + CurrentMSO->Relinquish_Default = value.type.Unsigned_Int; } break; #if defined(INTRINSIC_REPORTING) +// case PROP_FEEDBACK_VALUE: case PROP_ALARM_VALUES: if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { if (wp_data->array_index == 0) { @@ -1407,18 +1408,18 @@ bool Multistate_Output_Write_Property( int array_index = 0; char ucialarmstate[254][64]; int ucialarmstate_n = 0; - for (j = 0; j < CurrentMSV->number_of_states; j++) { + for (j = 0; j < CurrentMSO->number_of_states; j++) { array_index++; if (wp_data->application_data[array_index] > 0) { alarm_value = wp_data->application_data[array_index]; - CurrentMSV->Alarm_Values[j] = alarm_value; + CurrentMSO->Alarm_Values[j] = alarm_value; sprintf(ucialarmstate[j], "%s", - CurrentMSV->State_Text[alarm_value-1]); + CurrentMSO->State_Text[alarm_value-1]); ucialarmstate_n++; } array_index++; } - CurrentMSV->number_of_alarmstates = ucialarmstate_n; + CurrentMSO->number_of_alarmstates = ucialarmstate_n; ucix_set_list(ctx, "bacnet_mo", idx_c, "alarmstate", ucialarmstate, ucialarmstate_n); } @@ -1429,8 +1430,8 @@ bool Multistate_Output_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { - CurrentMSV->Time_Delay = value.type.Unsigned_Int; - CurrentMSV->Remaining_Time_Delay = CurrentMSV->Time_Delay; + CurrentMSO->Time_Delay = value.type.Unsigned_Int; + CurrentMSO->Remaining_Time_Delay = CurrentMSO->Time_Delay; ucix_add_option_int(ctx, "bacnet_mo", index_c, "time_delay", value.type.Unsigned_Int); } break; @@ -1441,7 +1442,7 @@ bool Multistate_Output_Write_Property( &wp_data->error_class, &wp_data->error_code); if (status) { - CurrentMSV->Notification_Class = value.type.Unsigned_Int; + CurrentMSO->Notification_Class = value.type.Unsigned_Int; ucix_add_option_int(ctx, "bacnet_mo", index_c, "nc", value.type.Unsigned_Int); } break; @@ -1453,7 +1454,7 @@ bool Multistate_Output_Write_Property( if (status) { if (value.type.Bit_String.bits_used == 3) { - CurrentMSV->Event_Enable = value.type.Bit_String.value[0]; + CurrentMSO->Event_Enable = value.type.Bit_String.value[0]; ucix_add_option_int(ctx, "bacnet_mo", index_c, "event", value.type.Bit_String.value[0]); } else { wp_data->error_class = ERROR_CLASS_PROPERTY; @@ -1471,10 +1472,10 @@ bool Multistate_Output_Write_Property( if (status) { switch ((BACNET_NOTIFY_TYPE) value.type.Enumerated) { case NOTIFY_EVENT: - CurrentMSV->Notify_Type = 1; + CurrentMSO->Notify_Type = 1; break; case NOTIFY_ALARM: - CurrentMSV->Notify_Type = 0; + CurrentMSO->Notify_Type = 0; break; default: wp_data->error_class = ERROR_CLASS_PROPERTY; @@ -1515,7 +1516,7 @@ void Multistate_Output_Intrinsic_Reporting( uint32_t object_instance) { #if defined(INTRINSIC_REPORTING) - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; BACNET_EVENT_NOTIFICATION_DATA event_data; BACNET_CHARACTER_STRING msgText; unsigned index; @@ -1529,15 +1530,15 @@ void Multistate_Output_Intrinsic_Reporting( if (Multistate_Output_Valid_Instance(object_instance)) { index = Multistate_Output_Instance_To_Index(object_instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; } else return; - if (CurrentMSV->Ack_notify_data.bSendAckNotify) { + if (CurrentMSO->Ack_notify_data.bSendAckNotify) { /* clean bSendAckNotify flag */ - CurrentMSV->Ack_notify_data.bSendAckNotify = false; + CurrentMSO->Ack_notify_data.bSendAckNotify = false; /* copy toState */ - ToState = CurrentMSV->Ack_notify_data.EventState; + ToState = CurrentMSO->Ack_notify_data.EventState; #if PRINT_ENABLED fprintf(stderr, "Send Acknotification for (%s,%d).\n", @@ -1554,57 +1555,57 @@ void Multistate_Output_Intrinsic_Reporting( } else { /* actual Present_Value */ PresentVal = Multistate_Output_Present_Value(object_instance); - FromState = CurrentMSV->Event_State; - switch (CurrentMSV->Event_State) { + FromState = CurrentMSO->Event_State; + switch (CurrentMSO->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. */ - for ( i = 0; i < CurrentMSV->number_of_states; i++) { - if (CurrentMSV->Alarm_Values[i]) { - if ((PresentVal == CurrentMSV->Alarm_Values[i]) && - ((CurrentMSV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == + for ( i = 0; i < CurrentMSO->number_of_states; i++) { + if (CurrentMSO->Alarm_Values[i]) { + if ((PresentVal == CurrentMSO->Alarm_Values[i]) && + ((CurrentMSO->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) == EVENT_ENABLE_TO_OFFNORMAL)) { - if (!CurrentMSV->Remaining_Time_Delay) - CurrentMSV->Event_State = EVENT_STATE_FAULT; + if (!CurrentMSO->Remaining_Time_Delay) + CurrentMSO->Event_State = EVENT_STATE_FAULT; else - CurrentMSV->Remaining_Time_Delay--; + CurrentMSO->Remaining_Time_Delay--; break; } } } /* value of the object is still in the same event state */ - CurrentMSV->Remaining_Time_Delay = CurrentMSV->Time_Delay; + CurrentMSO->Remaining_Time_Delay = CurrentMSO->Time_Delay; break; case EVENT_STATE_FAULT: - for ( i = 0; i < CurrentMSV->number_of_states; i++) { - if (CurrentMSV->Alarm_Values[i]) { - if (PresentVal == CurrentMSV->Alarm_Values[i]) { + for ( i = 0; i < CurrentMSO->number_of_states; i++) { + if (CurrentMSO->Alarm_Values[i]) { + if (PresentVal == CurrentMSO->Alarm_Values[i]) { tonormal = false; } } } if ((tonormal) && - ((CurrentMSV->Event_Enable & EVENT_ENABLE_TO_NORMAL) == + ((CurrentMSO->Event_Enable & EVENT_ENABLE_TO_NORMAL) == EVENT_ENABLE_TO_NORMAL)) { - if (!CurrentMSV->Remaining_Time_Delay) - CurrentMSV->Event_State = EVENT_STATE_NORMAL; + if (!CurrentMSO->Remaining_Time_Delay) + CurrentMSO->Event_State = EVENT_STATE_NORMAL; else - CurrentMSV->Remaining_Time_Delay--; + CurrentMSO->Remaining_Time_Delay--; break; } /* value of the object is still in the same event state */ - CurrentMSV->Remaining_Time_Delay = CurrentMSV->Time_Delay; + CurrentMSO->Remaining_Time_Delay = CurrentMSO->Time_Delay; break; default: return; /* shouldn't happen */ } /* switch (FromState) */ - ToState = CurrentMSV->Event_State; + ToState = CurrentMSO->Event_State; if (FromState != ToState) { /* Event_State has changed. @@ -1636,7 +1637,7 @@ void Multistate_Output_Intrinsic_Reporting( #endif /* PRINT_ENABLED */ /* Notify Type */ - event_data.notifyType = CurrentMSV->Notify_Type; + event_data.notifyType = CurrentMSO->Notify_Type; /* Send EventNotification. */ SendNotify = true; @@ -1657,19 +1658,19 @@ void Multistate_Output_Intrinsic_Reporting( /* fill Event_Time_Stamps */ switch (ToState) { case EVENT_STATE_FAULT: - CurrentMSV->Event_Time_Stamps[TRANSITION_TO_FAULT] = + CurrentMSO->Event_Time_Stamps[TRANSITION_TO_FAULT] = event_data.timeStamp.value.dateTime; break; case EVENT_STATE_NORMAL: - CurrentMSV->Event_Time_Stamps[TRANSITION_TO_NORMAL] = + CurrentMSO->Event_Time_Stamps[TRANSITION_TO_NORMAL] = event_data.timeStamp.value.dateTime; break; } } /* Notification Class */ - event_data.notificationClass = CurrentMSV->Notification_Class; + event_data.notificationClass = CurrentMSO->Notification_Class; /* Event Type */ event_data.eventType = EVENT_OUT_OF_RANGE; @@ -1685,7 +1686,7 @@ void Multistate_Output_Intrinsic_Reporting( event_data.fromState = FromState; /* To State */ - event_data.toState = CurrentMSV->Event_State; + event_data.toState = CurrentMSO->Event_State; /* Event Values */ if (event_data.notifyType != NOTIFY_ACK_NOTIFICATION) { @@ -1697,14 +1698,14 @@ void Multistate_Output_Intrinsic_Reporting( outOfRange.statusFlags); bitstring_set_bit(&event_data.notificationParams. outOfRange.statusFlags, STATUS_FLAG_IN_ALARM, - CurrentMSV->Event_State ? true : false); + CurrentMSO->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, - CurrentMSV->Out_Of_Service); + CurrentMSO->Out_Of_Service); } /* add data from notification class */ @@ -1717,28 +1718,28 @@ void Multistate_Output_Intrinsic_Reporting( case EVENT_STATE_HIGH_LIMIT: case EVENT_STATE_LOW_LIMIT: case EVENT_STATE_OFFNORMAL: - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = false; - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp = event_data.timeStamp.value.dateTime; break; case EVENT_STATE_FAULT: - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = false; - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp = event_data.timeStamp.value.dateTime; break; case EVENT_STATE_NORMAL: - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = false; - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp = event_data.timeStamp.value.dateTime; break; @@ -1754,7 +1755,7 @@ int Multistate_Output_Event_Information( unsigned index, BACNET_GET_EVENT_INFORMATION_DATA * getevent_data) { - //MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + //MULTI_STATE_OUTPUT_DESCR *CurrentMSO; bool IsNotAckedTransitions; bool IsActiveEvent; int i; @@ -1762,18 +1763,18 @@ int Multistate_Output_Event_Information( /* check index */ if (index < max_multi_state_outputs_int) { - //CurrentMSV = &MSV_Descr[index]; + //CurrentMSO = &MSO_Descr[index]; /* Event_State not equal to NORMAL */ - IsActiveEvent = (MSV_Descr[index].Event_State != EVENT_STATE_NORMAL); + IsActiveEvent = (MSO_Descr[index].Event_State != EVENT_STATE_NORMAL); /* Acked_Transitions property, which has at least one of the bits (TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */ IsNotAckedTransitions = - (MSV_Descr[index]. + (MSO_Descr[index]. Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == - false) | (MSV_Descr[index]. + false) | (MSO_Descr[index]. Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == - false) | (MSV_Descr[index]. + false) | (MSO_Descr[index]. Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false); } else return -1; /* end of list */ @@ -1784,40 +1785,40 @@ int Multistate_Output_Event_Information( getevent_data->objectIdentifier.instance = Multistate_Output_Index_To_Instance(index); /* Event State */ - getevent_data->eventState = MSV_Descr[index].Event_State; + getevent_data->eventState = MSO_Descr[index].Event_State; /* Acknowledged Transitions */ bitstring_init(&getevent_data->acknowledgedTransitions); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL, - MSV_Descr[index]. + MSO_Descr[index]. Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_FAULT, - MSV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); + MSO_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked); bitstring_set_bit(&getevent_data->acknowledgedTransitions, TRANSITION_TO_NORMAL, - MSV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked); + MSO_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 = - MSV_Descr[index].Event_Time_Stamps[i]; + MSO_Descr[index].Event_Time_Stamps[i]; } /* Notify Type */ - getevent_data->notifyType = MSV_Descr[index].Notify_Type; + getevent_data->notifyType = MSO_Descr[index].Notify_Type; /* Event Enable */ bitstring_init(&getevent_data->eventEnable); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL, - (MSV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : + (MSO_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT, - (MSV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : + (MSO_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false); bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL, - (MSV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : + (MSO_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false); /* Event Priorities */ - Notification_Class_Get_Priorities(MSV_Descr[index].Notification_Class, + Notification_Class_Get_Priorities(MSO_Descr[index].Notification_Class, getevent_data->eventPriorities); return 1; /* active event */ @@ -1829,14 +1830,14 @@ int Multistate_Output_Alarm_Ack( BACNET_ALARM_ACK_DATA * alarmack_data, BACNET_ERROR_CODE * error_code) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; unsigned index; if (Multistate_Output_Valid_Instance(alarmack_data-> eventObjectIdentifier.instance)) { index = Multistate_Output_Instance_To_Index(alarmack_data-> eventObjectIdentifier.instance); - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; } else { *error_code = ERROR_CODE_UNKNOWN_OBJECT; return -1; @@ -1844,13 +1845,13 @@ int Multistate_Output_Alarm_Ack( switch (alarmack_data->eventStateAcked) { case EVENT_STATE_OFFNORMAL: - if (CurrentMSV-> + if (CurrentMSO-> 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(&CurrentMSV->Acked_Transitions + if (datetime_compare(&CurrentMSO->Acked_Transitions [TRANSITION_TO_OFFNORMAL].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; @@ -1858,7 +1859,7 @@ int Multistate_Output_Alarm_Ack( } /* Clean transitions flag. */ - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true; } else { *error_code = ERROR_CODE_INVALID_EVENT_STATE; @@ -1867,13 +1868,13 @@ int Multistate_Output_Alarm_Ack( break; case EVENT_STATE_FAULT: - if (CurrentMSV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == + if (CurrentMSO->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(&CurrentMSV->Acked_Transitions + if (datetime_compare(&CurrentMSO->Acked_Transitions [TRANSITION_TO_NORMAL].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; @@ -1881,7 +1882,7 @@ int Multistate_Output_Alarm_Ack( } /* Clean transitions flag. */ - CurrentMSV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = + CurrentMSO->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked = true; } else { *error_code = ERROR_CODE_INVALID_EVENT_STATE; @@ -1890,13 +1891,13 @@ int Multistate_Output_Alarm_Ack( break; case EVENT_STATE_NORMAL: - if (CurrentMSV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked == + if (CurrentMSO->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(&CurrentMSV->Acked_Transitions + if (datetime_compare(&CurrentMSO->Acked_Transitions [TRANSITION_TO_FAULT].Time_Stamp, &alarmack_data->eventTimeStamp.value.dateTime) > 0) { *error_code = ERROR_CODE_INVALID_TIME_STAMP; @@ -1904,7 +1905,7 @@ int Multistate_Output_Alarm_Ack( } /* Clean transitions flag. */ - CurrentMSV->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = + CurrentMSO->Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked = true; } else { *error_code = ERROR_CODE_INVALID_EVENT_STATE; @@ -1917,8 +1918,8 @@ int Multistate_Output_Alarm_Ack( } /* Need to send AckNotification. */ - CurrentMSV->Ack_notify_data.bSendAckNotify = true; - CurrentMSV->Ack_notify_data.EventState = alarmack_data->eventStateAcked; + CurrentMSO->Ack_notify_data.bSendAckNotify = true; + CurrentMSO->Ack_notify_data.EventState = alarmack_data->eventStateAcked; /* Return OK */ return 1; @@ -1928,33 +1929,33 @@ int Multistate_Output_Alarm_Summary( unsigned index, BACNET_GET_ALARM_SUMMARY_DATA * getalarm_data) { - MULTI_STATE_OUTPUT_DESCR *CurrentMSV; + MULTI_STATE_OUTPUT_DESCR *CurrentMSO; /* check index */ if (index < max_multi_state_outputs_int) { - CurrentMSV = &MSV_Descr[index]; + CurrentMSO = &MSO_Descr[index]; /* Event_State is not equal to NORMAL and Notify_Type property value is ALARM */ - if ((CurrentMSV->Event_State != EVENT_STATE_NORMAL) && - (CurrentMSV->Notify_Type == NOTIFY_ALARM)) { + if ((CurrentMSO->Event_State != EVENT_STATE_NORMAL) && + (CurrentMSO->Notify_Type == NOTIFY_ALARM)) { /* Object Identifier */ getalarm_data->objectIdentifier.type = OBJECT_MULTI_STATE_OUTPUT; getalarm_data->objectIdentifier.instance = Multistate_Output_Index_To_Instance(index); /* Alarm State */ - getalarm_data->alarmState = CurrentMSV->Event_State; + getalarm_data->alarmState = CurrentMSO->Event_State; /* Acknowledged Transitions */ bitstring_init(&getalarm_data->acknowledgedTransitions); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, TRANSITION_TO_OFFNORMAL, - CurrentMSV-> + CurrentMSO-> Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, TRANSITION_TO_FAULT, - CurrentMSV->Acked_Transitions[TRANSITION_TO_FAULT]. + CurrentMSO->Acked_Transitions[TRANSITION_TO_FAULT]. bIsAcked); bitstring_set_bit(&getalarm_data->acknowledgedTransitions, TRANSITION_TO_NORMAL, - CurrentMSV->Acked_Transitions[TRANSITION_TO_NORMAL]. + CurrentMSO->Acked_Transitions[TRANSITION_TO_NORMAL]. bIsAcked); return 1; /* active alarm */