Added a Binary Input object to the demo objects and updated the demo applications and device object to support the new object.

This commit is contained in:
skarg
2006-03-22 03:51:36 +00:00
parent 69289f8f88
commit e6a37a34a8
42 changed files with 191 additions and 135 deletions
+22 -40
View File
@@ -41,8 +41,7 @@
/* encode service */
int timesync_encode_apdu_service(uint8_t * apdu,
BACNET_UNCONFIRMED_SERVICE service,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
int len = 0; /* length of each encoding */
int apdu_len = 0; /* total length of the apdu, return value */
@@ -61,30 +60,22 @@ int timesync_encode_apdu_service(uint8_t * apdu,
}
int timesync_utc_encode_apdu(uint8_t * apdu,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
my_date,
my_time);
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, my_date, my_time);
}
int timesync_encode_apdu(uint8_t * apdu,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
my_date,
my_time);
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, my_date, my_time);
}
/* decode the service request only */
int timesync_decode_service_request(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
int len = 0;
uint8_t tag_number = 0;
@@ -114,9 +105,7 @@ int timesync_decode_service_request(uint8_t * apdu,
int timesync_decode_apdu_service(uint8_t * apdu,
BACNET_UNCONFIRMED_SERVICE service,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
int len = 0;
@@ -130,34 +119,26 @@ int timesync_decode_apdu_service(uint8_t * apdu,
/* optional limits - must be used as a pair */
if (apdu_len > 2) {
len = timesync_decode_service_request(&apdu[2], apdu_len - 2,
my_date, my_time);
my_date, my_time);
}
return len;
}
int timesync_utc_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_decode_apdu_service(apdu,
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
apdu_len,
my_date,
my_time);
apdu_len, my_date, my_time);
}
int timesync_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_decode_apdu_service(apdu,
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
apdu_len,
my_date,
my_time);
apdu_len, my_date, my_time);
}
#ifdef TEST
@@ -166,8 +147,7 @@ int timesync_decode_apdu(uint8_t * apdu,
#include "ctest.h"
void testTimeSyncData(Test * pTest,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
uint8_t apdu[480] = { 0 };
int len = 0;
@@ -186,7 +166,9 @@ void testTimeSyncData(Test * pTest,
len = timesync_utc_encode_apdu(&apdu[0], my_date, my_time);
ct_test(pTest, len != 0);
apdu_len = len;
len = timesync_utc_decode_apdu(&apdu[0], apdu_len, &test_date, &test_time);
len =
timesync_utc_decode_apdu(&apdu[0], apdu_len, &test_date,
&test_time);
ct_test(pTest, len != -1);
ct_test(pTest, bacapp_same_time(my_time, &test_time));
ct_test(pTest, bacapp_same_date(my_date, &test_date));
@@ -197,10 +179,10 @@ void testTimeSync(Test * pTest)
BACNET_DATE bdate;
BACNET_TIME btime;
bdate.year = 2006; /* AD */
bdate.month = 4; /* 1=Jan */
bdate.day = 11; /* 1..31 */
bdate.wday = 1; /* 1=Monday */
bdate.year = 2006; /* AD */
bdate.month = 4; /* 1=Jan */
bdate.day = 11; /* 1..31 */
bdate.wday = 1; /* 1=Monday */
btime.hour = 7;
btime.min = 0;