Fixed BACnetAccessRule application integration into Access Rights object. Improved unit testing and code coverage. (#790)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#endif
|
||||
#include "bacnet/access_rule.h"
|
||||
#include "bacnet/bacenum.h"
|
||||
#include "bacnet/bacdcode.h"
|
||||
#include "bacnet/bacint.h"
|
||||
@@ -502,6 +503,13 @@ int bacapp_encode_application_data(
|
||||
apdu_len =
|
||||
bacnet_shed_level_encode(apdu, &value->type.Shed_Level);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ACCESS_RULE)
|
||||
case BACNET_APPLICATION_TAG_ACCESS_RULE:
|
||||
/* BACnetAccessRule */
|
||||
apdu_len =
|
||||
bacapp_encode_access_rule(apdu, &value->type.Access_Rule);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@@ -919,6 +927,7 @@ int bacapp_encode_context_data_value(
|
||||
case BACNET_APPLICATION_TAG_ACTION_COMMAND:
|
||||
case BACNET_APPLICATION_TAG_SCALE:
|
||||
case BACNET_APPLICATION_TAG_SHED_LEVEL:
|
||||
case BACNET_APPLICATION_TAG_ACCESS_RULE:
|
||||
/* complex data is enclosed in open/close tags */
|
||||
len = encode_opening_tag(apdu, context_tag_number);
|
||||
apdu_len += len;
|
||||
@@ -1291,6 +1300,10 @@ int bacapp_known_property_tag(
|
||||
case PROP_BBMD_FOREIGN_DEVICE_TABLE:
|
||||
/* BACnetFDTEntry */
|
||||
return BACNET_APPLICATION_TAG_FDT_ENTRY;
|
||||
case PROP_POSITIVE_ACCESS_RULES:
|
||||
case PROP_NEGATIVE_ACCESS_RULES:
|
||||
/* BACnetAccessRule */
|
||||
return BACNET_APPLICATION_TAG_ACCESS_RULE;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
@@ -1587,6 +1600,13 @@ int bacapp_decode_application_tag_value(
|
||||
apdu_len = bacnet_shed_level_decode(
|
||||
apdu, apdu_size, &value->type.Shed_Level);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ACCESS_RULE)
|
||||
case BACNET_APPLICATION_TAG_ACCESS_RULE:
|
||||
/* BACnetAccessRule */
|
||||
apdu_len = bacnet_access_rule_decode(
|
||||
apdu, apdu_size, &value->type.Access_Rule);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@@ -2500,6 +2520,51 @@ static int bacapp_snprintf_object_property_reference(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BACAPP_ACCESS_RULE)
|
||||
/**
|
||||
* @brief Print a value to a string for EPICS
|
||||
* @param str - destination string, or NULL for length only
|
||||
* @param str_len - length of the destination string, or 0 for length only
|
||||
* @param value - value to be printed
|
||||
* @return number of characters written to the string
|
||||
*/
|
||||
static int bacapp_snprintf_access_rule(
|
||||
char *str, size_t str_len, const BACNET_ACCESS_RULE *value)
|
||||
{
|
||||
int slen;
|
||||
int ret_val = 0;
|
||||
|
||||
slen = bacapp_snprintf(str, str_len, "{");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
/* specified (0), always (1) */
|
||||
if (value->time_range_specifier == TIME_RANGE_SPECIFIER_SPECIFIED) {
|
||||
slen = bacapp_snprintf(str, str_len, "specified, ");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf_device_object_property_reference(
|
||||
str, str_len, &value->time_range);
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
} else {
|
||||
slen = bacapp_snprintf(str, str_len, "always, ");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
}
|
||||
/* specified (0), all (1) */
|
||||
if (value->location_specifier == LOCATION_SPECIFIER_SPECIFIED) {
|
||||
slen = bacapp_snprintf(str, str_len, "specified, ");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
slen = bacapp_snprintf_device_object_reference(
|
||||
str, str_len, &value->location);
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
} else {
|
||||
slen = bacapp_snprintf(str, str_len, "all");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
}
|
||||
slen = bacapp_snprintf(str, str_len, "}");
|
||||
ret_val += bacapp_snprintf_shift(slen, &str, &str_len);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BACAPP_WEEKLY_SCHEDULE)
|
||||
/**
|
||||
* @brief Print a weekly schedule value to a string for EPICS
|
||||
@@ -3279,6 +3344,12 @@ int bacapp_snprintf_value(
|
||||
ret_val = bacapp_snprintf_shed_level(
|
||||
str, str_len, &value->type.Shed_Level);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ACCESS_RULE)
|
||||
case BACNET_APPLICATION_TAG_ACCESS_RULE:
|
||||
ret_val = bacapp_snprintf_access_rule(
|
||||
str, str_len, &value->type.Access_Rule);
|
||||
break;
|
||||
#endif
|
||||
case BACNET_APPLICATION_TAG_EMPTYLIST:
|
||||
ret_val = bacapp_snprintf(str, str_len, "{}");
|
||||
@@ -3892,6 +3963,12 @@ bool bacapp_parse_application_data(
|
||||
status =
|
||||
bacnet_shed_level_from_ascii(&value->type.Shed_Level, argv);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ACCESS_RULE)
|
||||
case BACNET_APPLICATION_TAG_ACCESS_RULE:
|
||||
/* BACnetAccessRule - not implemented */
|
||||
bacnet_access_rule_from_ascii(&value->type.Access_Rule, argv);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@@ -4444,6 +4521,12 @@ bool bacapp_same_value(
|
||||
status = bacnet_shed_level_same(
|
||||
&value->type.Shed_Level, &test_value->type.Shed_Level);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ACCESS_RULE)
|
||||
case BACNET_APPLICATION_TAG_ACCESS_RULE:
|
||||
status = bacnet_access_rule_same(
|
||||
&value->type.Access_Rule, &test_value->type.Access_Rule);
|
||||
break;
|
||||
#endif
|
||||
case BACNET_APPLICATION_TAG_EMPTYLIST:
|
||||
status = true;
|
||||
|
||||
Reference in New Issue
Block a user