Bugfix/channel-object-type-all-enabled (#1135)
* Added datetime same API for unit testing. * Added CHANNEL_VALUE_ALL define and fixed the API integration for the additional datatypes now supported.
This commit is contained in:
@@ -388,12 +388,12 @@ bool bacnet_channel_value_same(
|
||||
#endif
|
||||
#if defined(CHANNEL_CHARACTER_STRING)
|
||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||
return characterstring_value_same(
|
||||
return characterstring_same(
|
||||
&value1->type.Character_String, &value2->type.Character_String);
|
||||
#endif
|
||||
#if defined(CHANNEL_BIT_STRING)
|
||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||
return bitstring_value_same(
|
||||
return bitstring_same(
|
||||
&value1->type.Bit_String, &value2->type.Bit_String);
|
||||
#endif
|
||||
#if defined(CHANNEL_ENUMERATED)
|
||||
@@ -402,16 +402,18 @@ bool bacnet_channel_value_same(
|
||||
#endif
|
||||
#if defined(CHANNEL_DATE)
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
return date_value_same(&value1->type.Date, &value2->type.Date);
|
||||
return datetime_date_same(&value1->type.Date, &value2->type.Date);
|
||||
break;
|
||||
#endif
|
||||
#if defined(CHANNEL_TIME)
|
||||
case BACNET_APPLICATION_TAG_TIME:
|
||||
return time_value_same(&value1->type.Time, &value2->type.Time);
|
||||
return datetime_time_same(&value1->type.Time, &value2->type.Time);
|
||||
#endif
|
||||
#if defined(CHANNEL_OBJECT_ID)
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
return object_id_value_same(
|
||||
&value1->type.Object_Id, &value2->type.Object_Id);
|
||||
return bacnet_object_id_same(
|
||||
value1->type.Object_Id.type, value1->type.Object_Id.instance,
|
||||
value2->type.Object_Id.type, value2->type.Object_Id.instance);
|
||||
#endif
|
||||
#if defined(CHANNEL_LIGHTING_COMMAND)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
@@ -498,11 +500,13 @@ bool bacnet_channel_value_copy(
|
||||
#endif
|
||||
#if defined(CHANNEL_DATE)
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
return datetime_copy_date(&dest->type.Date, &src->type.Date);
|
||||
datetime_copy_date(&dest->type.Date, &src->type.Date);
|
||||
return true;
|
||||
#endif
|
||||
#if defined(CHANNEL_TIME)
|
||||
case BACNET_APPLICATION_TAG_TIME:
|
||||
return datetime_copy_time(&dest->type.Time, &src->type.Time);
|
||||
datetime_copy_time(&dest->type.Time, &src->type.Time);
|
||||
return true;
|
||||
#endif
|
||||
#if defined(CHANNEL_OBJECT_ID)
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <stddef.h>
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
#include "bacnet/bacstr.h"
|
||||
#include "bacnet/datetime.h"
|
||||
#include "bacnet/lighting.h"
|
||||
|
||||
/* BACNET_CHANNEL_VALUE decodes WriteProperty service requests
|
||||
@@ -26,8 +28,16 @@
|
||||
defined(CHANNEL_ENUMERATED) || defined(CHANNEL_DATE) || \
|
||||
defined(CHANNEL_TIME) || defined(CHANNEL_OBJECT_ID) || \
|
||||
defined(CHANNEL_LIGHTING_COMMAND) || defined(CHANNEL_XY_COLOR) || \
|
||||
defined(CHANNEL_COLOR_COMMAND))
|
||||
defined(CHANNEL_COLOR_COMMAND) || defined(CHANNEL_VALUE_ALL))
|
||||
#define CHANNEL_NUMERIC
|
||||
#elif defined(CHANNEL_VALUE_ALL)
|
||||
#define CHANNEL_NUMERIC
|
||||
#define CHANNEL_OCTET_STRING
|
||||
#define CHANNEL_CHARACTER_STRING
|
||||
#define CHANNEL_BIT_STRING
|
||||
#define CHANNEL_DATE
|
||||
#define CHANNEL_TIME
|
||||
#define CHANNEL_OBJECT_ID
|
||||
#endif
|
||||
|
||||
#if defined(CHANNEL_NUMERIC)
|
||||
|
||||
@@ -304,6 +304,25 @@ int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2)
|
||||
return diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if date1 is the same as date2
|
||||
* @param date1 - Pointer to a BACNET_DATE structure
|
||||
* @param date2 - Pointer to a BACNET_DATE structure
|
||||
* @return true if same, false if different
|
||||
*/
|
||||
bool datetime_date_same(const BACNET_DATE *date1, const BACNET_DATE *date2)
|
||||
{
|
||||
bool status = false;
|
||||
int diff = 0;
|
||||
|
||||
diff = datetime_compare_date(date1, date2);
|
||||
if (diff == 0) {
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the time1 is the same as time2, return is 0.
|
||||
* If time1 is after time2, returns positive.
|
||||
@@ -334,6 +353,25 @@ int datetime_compare_time(const BACNET_TIME *time1, const BACNET_TIME *time2)
|
||||
return diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if time1 is the same as time2
|
||||
* @param time1 - Pointer to a BACNET_TIME structure
|
||||
* @param time2 - Pointer to a BACNET_TIME structure
|
||||
* @return true if same, false if different
|
||||
*/
|
||||
bool datetime_time_same(const BACNET_TIME *time1, const BACNET_TIME *time2)
|
||||
{
|
||||
bool status = false;
|
||||
int diff = 0;
|
||||
|
||||
diff = datetime_compare_time(time1, time2);
|
||||
if (diff == 0) {
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the datetime1 is the same datetime2, return is 0.
|
||||
* If datetime1 is after datetime2, returns positive.
|
||||
@@ -357,6 +395,26 @@ int datetime_compare(
|
||||
return diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if the datetime1 is the same as datetime2
|
||||
* @param datetime1 - Pointer to a BACNET_DATE_TIME structure
|
||||
* @param datetime2 - Pointer to a BACNET_DATE_TIME structure
|
||||
* @return true if same, false if different
|
||||
*/
|
||||
bool datetime_same(
|
||||
const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2)
|
||||
{
|
||||
bool status = false;
|
||||
int diff = 0;
|
||||
|
||||
diff = datetime_compare(datetime1, datetime2);
|
||||
if (diff == 0) {
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int datetime_wildcard_compare_date(
|
||||
const BACNET_DATE *date1, const BACNET_DATE *date2)
|
||||
{
|
||||
|
||||
@@ -159,10 +159,17 @@ uint16_t datetime_minutes_since_midnight(const BACNET_TIME *btime);
|
||||
BACNET_STACK_EXPORT
|
||||
int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2);
|
||||
BACNET_STACK_EXPORT
|
||||
bool datetime_date_same(const BACNET_DATE *date1, const BACNET_DATE *date2);
|
||||
BACNET_STACK_EXPORT
|
||||
int datetime_compare_time(const BACNET_TIME *time1, const BACNET_TIME *time2);
|
||||
BACNET_STACK_EXPORT
|
||||
bool datetime_time_same(const BACNET_TIME *time1, const BACNET_TIME *time2);
|
||||
BACNET_STACK_EXPORT
|
||||
int datetime_compare(
|
||||
const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2);
|
||||
BACNET_STACK_EXPORT
|
||||
bool datetime_same(
|
||||
const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2);
|
||||
|
||||
/* full comparison functions:
|
||||
* taking into account FF fields in date and time structures,
|
||||
|
||||
Reference in New Issue
Block a user