Added skeleton Trend Log object. Currently allows properties to be read and written but has little of the required logic for trending implemented yet.

This commit is contained in:
petermcs
2009-11-23 08:27:09 +00:00
parent 2bb6ecfb3a
commit 916067ec59
9 changed files with 931 additions and 25 deletions
+19 -3
View File
@@ -537,6 +537,22 @@ BACNET_APPLICATION_TAG bacapp_context_tag_type(
break;
}
break;
case PROP_LOG_DEVICE_OBJECT_PROPERTY:
switch (tag_number) {
case 0: /* Object ID */
case 3: /* Device ID */
tag = BACNET_APPLICATION_TAG_OBJECT_ID;
break;
case 1: /* Property ID */
tag = BACNET_APPLICATION_TAG_ENUMERATED;
break;
case 2: /* Array index */
tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
break;
default:
break;
}
break;
default:
break;
}
@@ -735,20 +751,20 @@ int bacapp_data_len(
uint32_t value = 0;
BACNET_APPLICATION_DATA_VALUE application_value;
if (decode_is_opening_tag(&apdu[0])) {
if (IS_OPENING_TAG(apdu[0])) {
len =
decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &value);
apdu_len += len;
opening_tag_number = tag_number;
opening_tag_number_counter = 1;
while (opening_tag_number_counter) {
if (decode_is_opening_tag(&apdu[apdu_len])) {
if (IS_OPENING_TAG(apdu[apdu_len])) {
len =
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
&value);
if (tag_number == opening_tag_number)
opening_tag_number_counter++;
} else if (decode_is_closing_tag(&apdu[apdu_len])) {
} else if (IS_CLOSING_TAG(apdu[apdu_len])) {
len =
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
&value);
+10 -16
View File
@@ -399,9 +399,9 @@ int decode_tag_number_and_value(
}
len++;
}
} else if (decode_is_opening_tag(&apdu[0]) && value) {
} else if (IS_OPENING_TAG(apdu[0]) && value) {
*value = 0;
} else if (decode_is_closing_tag(&apdu[0]) && value) {
} else if (IS_CLOSING_TAG(apdu[0]) && value) {
/* closing tag */
*value = 0;
} else if (value) {
@@ -454,9 +454,9 @@ int decode_tag_number_and_value_safe(
/* packet is truncated */
len = 0;
}
} else if (decode_is_opening_tag(&apdu[0]) && value) {
} else if (IS_OPENING_TAG(apdu[0]) && value) {
*value = 0;
} else if (decode_is_closing_tag(&apdu[0]) && value) {
} else if (IS_CLOSING_TAG(apdu[0]) && value) {
/* closing tag */
*value = 0;
} else if (value) {
@@ -500,12 +500,9 @@ bool decode_is_opening_tag_number(
uint8_t tag_number)
{
uint8_t my_tag_number = 0;
bool opening_tag = false;
opening_tag = (bool) ((apdu[0] & 0x07) == 6);
decode_tag_number(apdu, &my_tag_number);
return (bool) (opening_tag && (my_tag_number == tag_number));
return (bool) (IS_OPENING_TAG(apdu[0]) && (my_tag_number == tag_number));
}
/* from clause 20.2.1.3.2 Constructed Data */
@@ -515,12 +512,9 @@ bool decode_is_closing_tag_number(
uint8_t tag_number)
{
uint8_t my_tag_number = 0;
bool closing_tag = false;
closing_tag = (bool) ((apdu[0] & 0x07) == 7);
decode_tag_number(apdu, &my_tag_number);
return (bool) (closing_tag && (my_tag_number == tag_number));
return (bool) (IS_CLOSING_TAG(apdu[0]) && (my_tag_number == tag_number));
}
/* from clause 20.2.3 Encoding of a Boolean Value */
@@ -1850,16 +1844,16 @@ void testBACDCodeTags(
ct_test(pTest, value == 0);
ct_test(pTest, len == test_len);
ct_test(pTest, tag_number == test_tag_number);
ct_test(pTest, decode_is_opening_tag(&apdu[0]) == true);
ct_test(pTest, decode_is_closing_tag(&apdu[0]) == false);
ct_test(pTest, IS_OPENING_TAG(apdu[0]) == true);
ct_test(pTest, IS_CLOSING_TAG(apdu[0]) == false);
len = encode_closing_tag(&apdu[0], tag_number);
ct_test(pTest, len == test_len);
len = decode_tag_number_and_value(&apdu[0], &test_tag_number, &value);
ct_test(pTest, len == test_len);
ct_test(pTest, value == 0);
ct_test(pTest, tag_number == test_tag_number);
ct_test(pTest, decode_is_opening_tag(&apdu[0]) == false);
ct_test(pTest, decode_is_closing_tag(&apdu[0]) == true);
ct_test(pTest, IS_OPENING_TAG(apdu[0]) == false);
ct_test(pTest, IS_CLOSING_TAG(apdu[0]) == true);
/* test the len-value-type portion */
for (value = 1;; value = value << 1) {
len = encode_tag(&apdu[0], tag_number, false, value);
+2 -2
View File
@@ -266,7 +266,7 @@ int rpm_decode_object_property(
*object_property = (BACNET_PROPERTY_ID) property;
/* Tag 1: Optional propertyArrayIndex */
if ((len < apdu_len) && IS_CONTEXT_SPECIFIC(apdu[len]) &&
(!decode_is_closing_tag(&apdu[len]))) {
(!IS_CLOSING_TAG(apdu[len]))) {
option_len =
(unsigned) decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value_type);
@@ -459,7 +459,7 @@ int rpm_ack_decode_object_property(
*object_property = (BACNET_PROPERTY_ID) property;
/* Tag 3: Optional propertyArrayIndex */
if ((len < apdu_len) && IS_CONTEXT_SPECIFIC(apdu[len]) &&
(!decode_is_closing_tag(&apdu[len]))) {
(!IS_CLOSING_TAG(apdu[len]))) {
tag_len =
(unsigned) decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value_type);