diff --git a/demo/object/ai.c b/demo/object/ai.c index e956bca..b5f67ab 100644 --- a/demo/object/ai.c +++ b/demo/object/ai.c @@ -46,7 +46,7 @@ /* number of demo objects */ #ifndef MAX_ANALOG_INPUTS -#define MAX_ANALOG_INPUTS 65535 +#define MAX_ANALOG_INPUTS 1024 #endif unsigned max_analog_inputs_int = 0; @@ -78,6 +78,8 @@ static const int Analog_Input_Properties_Optional[] = { PROP_DESCRIPTION, PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT, + PROP_MAX_PRES_VALUE, + PROP_MIN_PRES_VALUE, #if defined(INTRINSIC_REPORTING) PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS, @@ -153,6 +155,12 @@ void Analog_Input_Init( int uciunit = 0; int uciunit_default = 0; const char *ucivalue_default; + char max_value[64]; + const char *ucimax_value_default; + const char *ucimax_value; + char min_value[64]; + const char *ucimin_value_default; + const char *ucimin_value; int ucinc_default; int ucinc; int ucievent_default; @@ -220,6 +228,10 @@ void Analog_Input_Init( "dead_limit"); ucicov_increment_default = ucix_get_option(ctx, sec, "default", "cov_increment"); + ucimax_value_default = ucix_get_option(ctx, sec, "default", + "max_value"); + ucimin_value_default = ucix_get_option(ctx, sec, "default", + "min_value"); i = 0; for( cur = itr_m.list; cur; cur = cur->next ) { strncpy(idx_cc, cur->idx, sizeof(idx_cc)); @@ -300,6 +312,32 @@ void Analog_Input_Init( AI_Descr[i].COV_Increment = strtof(cov_increment, (char **) NULL); + ucimax_value = ucix_get_option(ctx, "bacnet_ai", idx_c, + "max_value"); + if (ucimax_value != 0) { + sprintf(max_value, "%s", ucimax_value); + } else { + if (ucimax_value_default != 0) { + sprintf(max_value, "%s", ucimax_value_default); + } else { + sprintf(max_value, "%s", "0"); + } + } + AI_Descr[i].Max_Pres_Value = strtof(max_value, (char **) NULL); + + ucimin_value = ucix_get_option(ctx, "bacnet_ai", idx_c, + "min_value"); + if (ucimin_value != 0) { + sprintf(min_value, "%s", ucimin_value); + } else { + if (ucimin_value_default != 0) { + sprintf(min_value, "%s", ucimin_value_default); + } else { + sprintf(min_value, "%s", "0"); + } + } + AI_Descr[i].Min_Pres_Value = strtof(min_value, (char **) NULL); + #if defined(INTRINSIC_REPORTING) ucinc = ucix_get_option_int(ctx, "bacnet_ai", idx_c, "nc", ucinc_default); @@ -997,6 +1035,16 @@ int Analog_Input_Read_Property( apdu_len = encode_application_real(&apdu[0], present_value); break; + case PROP_MAX_PRES_VALUE: + apdu_len = + encode_application_real(&apdu[0], CurrentAI->Max_Pres_Value); + break; + + case PROP_MIN_PRES_VALUE: + apdu_len = + encode_application_real(&apdu[0], CurrentAI->Min_Pres_Value); + break; + #if defined(INTRINSIC_REPORTING) case PROP_TIME_DELAY: apdu_len = @@ -1337,6 +1385,30 @@ bool Analog_Input_Write_Property( } break; + case PROP_MAX_PRES_VALUE: + status = + WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL, + &wp_data->error_class, &wp_data->error_code); + + if (status) { + CurrentAI->Max_Pres_Value = value.type.Real; + ucix_add_option_int(ctx, "bacnet_ai", idx_c, "max_value", + value.type.Real); + } + break; + + case PROP_MIN_PRES_VALUE: + status = + WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL, + &wp_data->error_class, &wp_data->error_code); + + if (status) { + CurrentAI->Min_Pres_Value = value.type.Real; + ucix_add_option_int(ctx, "bacnet_ai", idx_c, "min_value", + value.type.Real); + } + break; + #if defined(INTRINSIC_REPORTING) case PROP_TIME_DELAY: status = diff --git a/demo/object/ai.h b/demo/object/ai.h index 5bf8852..c741a75 100644 --- a/demo/object/ai.h +++ b/demo/object/ai.h @@ -62,6 +62,8 @@ extern "C" { /* and load a Real for returning the value when asked. */ float Priority_Array[BACNET_MAX_PRIORITY]; float Relinquish_Default; + float Max_Pres_Value; + float Min_Pres_Value; #if defined(INTRINSIC_REPORTING) uint32_t Time_Delay; uint32_t Notification_Class; diff --git a/demo/object/ao.c b/demo/object/ao.c index 87f935e..063d5bc 100644 --- a/demo/object/ao.c +++ b/demo/object/ao.c @@ -46,7 +46,7 @@ /* number of demo objects */ #ifndef MAX_ANALOG_OUTPUTS -#define MAX_ANALOG_OUTPUTS 65535 +#define MAX_ANALOG_OUTPUTS 1024 #endif unsigned max_analog_outputs_int = 0; @@ -78,6 +78,8 @@ static const int Analog_Output_Properties_Optional[] = { PROP_DESCRIPTION, PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT, + PROP_MAX_PRES_VALUE, + PROP_MIN_PRES_VALUE, #if defined(INTRINSIC_REPORTING) PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS, @@ -153,6 +155,12 @@ void Analog_Output_Init( int uciunit = 0; int uciunit_default = 0; const char *ucivalue_default; + char max_value[64]; + const char *ucimax_value_default; + const char *ucimax_value; + char min_value[64]; + const char *ucimin_value_default; + const char *ucimin_value; int ucinc_default; int ucinc; int ucievent_default; @@ -220,6 +228,10 @@ void Analog_Output_Init( "dead_limit"); ucicov_increment_default = ucix_get_option(ctx, sec, "default", "cov_increment"); + ucimax_value_default = ucix_get_option(ctx, sec, "default", + "max_value"); + ucimin_value_default = ucix_get_option(ctx, sec, "default", + "min_value"); i = 0; for( cur = itr_m.list; cur; cur = cur->next ) { strncpy(idx_cc, cur->idx, sizeof(idx_cc)); @@ -300,6 +312,32 @@ void Analog_Output_Init( AO_Descr[i].COV_Increment = strtof(cov_increment, (char **) NULL); + ucimax_value = ucix_get_option(ctx, "bacnet_ao", idx_c, + "max_value"); + if (ucimax_value != 0) { + sprintf(max_value, "%s", ucimax_value); + } else { + if (ucimax_value_default != 0) { + sprintf(max_value, "%s", ucimax_value_default); + } else { + sprintf(max_value, "%s", "0"); + } + } + AO_Descr[i].Max_Pres_Value = strtof(max_value, (char **) NULL); + + ucimin_value = ucix_get_option(ctx, "bacnet_ao", idx_c, + "min_value"); + if (ucimin_value != 0) { + sprintf(min_value, "%s", ucimin_value); + } else { + if (ucimin_value_default != 0) { + sprintf(min_value, "%s", ucimin_value_default); + } else { + sprintf(min_value, "%s", "0"); + } + } + AO_Descr[i].Min_Pres_Value = strtof(min_value, (char **) NULL); + #if defined(INTRINSIC_REPORTING) ucinc = ucix_get_option_int(ctx, "bacnet_ao", idx_c, "nc", ucinc_default); @@ -1024,6 +1062,16 @@ int Analog_Output_Read_Property( apdu_len = encode_application_real(&apdu[0], present_value); break; + case PROP_MAX_PRES_VALUE: + apdu_len = + encode_application_real(&apdu[0], CurrentAO->Max_Pres_Value); + break; + + case PROP_MIN_PRES_VALUE: + apdu_len = + encode_application_real(&apdu[0], CurrentAO->Min_Pres_Value); + break; + #if defined(INTRINSIC_REPORTING) case PROP_TIME_DELAY: apdu_len = @@ -1364,6 +1412,30 @@ bool Analog_Output_Write_Property( } break; + case PROP_MAX_PRES_VALUE: + status = + WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL, + &wp_data->error_class, &wp_data->error_code); + + if (status) { + CurrentAO->Max_Pres_Value = value.type.Real; + ucix_add_option_int(ctx, "bacnet_ao", idx_c, "max_value", + value.type.Real); + } + break; + + case PROP_MIN_PRES_VALUE: + status = + WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL, + &wp_data->error_class, &wp_data->error_code); + + if (status) { + CurrentAO->Min_Pres_Value = value.type.Real; + ucix_add_option_int(ctx, "bacnet_ao", idx_c, "min_value", + value.type.Real); + } + break; + #if defined(INTRINSIC_REPORTING) case PROP_TIME_DELAY: status = diff --git a/demo/object/ao.h b/demo/object/ao.h index eb71e4c..77b8539 100644 --- a/demo/object/ao.h +++ b/demo/object/ao.h @@ -62,6 +62,8 @@ extern "C" { /* and load a Real for returning the value when asked. */ float Priority_Array[BACNET_MAX_PRIORITY]; float Relinquish_Default; + float Max_Pres_Value; + float Min_Pres_Value; #if defined(INTRINSIC_REPORTING) uint32_t Time_Delay; uint32_t Notification_Class; diff --git a/demo/object/av.c b/demo/object/av.c index abc338a..a0b0148 100644 --- a/demo/object/av.c +++ b/demo/object/av.c @@ -46,7 +46,7 @@ /* number of demo objects */ #ifndef MAX_ANALOG_VALUES -#define MAX_ANALOG_VALUES 65535 +#define MAX_ANALOG_VALUES 1024 #endif unsigned max_analog_values_int = 0;