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:
@@ -145,6 +145,8 @@ The git repositories are hosted at the following sites:
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
* Added CHANNEL_VALUE_ALL define and fixed the API integration for the
|
||||||
|
additional datatypes now supported in the Channel object. (#1135)
|
||||||
* Fixed the error class returned for AlarmAcknowledgment (#1131)
|
* Fixed the error class returned for AlarmAcknowledgment (#1131)
|
||||||
* Fixed object creation failure when create is called before init. (#1122)
|
* Fixed object creation failure when create is called before init. (#1122)
|
||||||
* Fixed octetstring_copy_value() and added unit tests. (#1121)
|
* Fixed octetstring_copy_value() and added unit tests. (#1121)
|
||||||
|
|||||||
@@ -388,12 +388,12 @@ bool bacnet_channel_value_same(
|
|||||||
#endif
|
#endif
|
||||||
#if defined(CHANNEL_CHARACTER_STRING)
|
#if defined(CHANNEL_CHARACTER_STRING)
|
||||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||||
return characterstring_value_same(
|
return characterstring_same(
|
||||||
&value1->type.Character_String, &value2->type.Character_String);
|
&value1->type.Character_String, &value2->type.Character_String);
|
||||||
#endif
|
#endif
|
||||||
#if defined(CHANNEL_BIT_STRING)
|
#if defined(CHANNEL_BIT_STRING)
|
||||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||||
return bitstring_value_same(
|
return bitstring_same(
|
||||||
&value1->type.Bit_String, &value2->type.Bit_String);
|
&value1->type.Bit_String, &value2->type.Bit_String);
|
||||||
#endif
|
#endif
|
||||||
#if defined(CHANNEL_ENUMERATED)
|
#if defined(CHANNEL_ENUMERATED)
|
||||||
@@ -402,16 +402,18 @@ bool bacnet_channel_value_same(
|
|||||||
#endif
|
#endif
|
||||||
#if defined(CHANNEL_DATE)
|
#if defined(CHANNEL_DATE)
|
||||||
case BACNET_APPLICATION_TAG_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
|
#endif
|
||||||
#if defined(CHANNEL_TIME)
|
#if defined(CHANNEL_TIME)
|
||||||
case BACNET_APPLICATION_TAG_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
|
#endif
|
||||||
#if defined(CHANNEL_OBJECT_ID)
|
#if defined(CHANNEL_OBJECT_ID)
|
||||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||||
return object_id_value_same(
|
return bacnet_object_id_same(
|
||||||
&value1->type.Object_Id, &value2->type.Object_Id);
|
value1->type.Object_Id.type, value1->type.Object_Id.instance,
|
||||||
|
value2->type.Object_Id.type, value2->type.Object_Id.instance);
|
||||||
#endif
|
#endif
|
||||||
#if defined(CHANNEL_LIGHTING_COMMAND)
|
#if defined(CHANNEL_LIGHTING_COMMAND)
|
||||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||||
@@ -498,11 +500,13 @@ bool bacnet_channel_value_copy(
|
|||||||
#endif
|
#endif
|
||||||
#if defined(CHANNEL_DATE)
|
#if defined(CHANNEL_DATE)
|
||||||
case BACNET_APPLICATION_TAG_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
|
#endif
|
||||||
#if defined(CHANNEL_TIME)
|
#if defined(CHANNEL_TIME)
|
||||||
case BACNET_APPLICATION_TAG_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
|
#endif
|
||||||
#if defined(CHANNEL_OBJECT_ID)
|
#if defined(CHANNEL_OBJECT_ID)
|
||||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
/* BACnet Stack defines - first */
|
/* BACnet Stack defines - first */
|
||||||
#include "bacnet/bacdef.h"
|
#include "bacnet/bacdef.h"
|
||||||
|
#include "bacnet/bacstr.h"
|
||||||
|
#include "bacnet/datetime.h"
|
||||||
#include "bacnet/lighting.h"
|
#include "bacnet/lighting.h"
|
||||||
|
|
||||||
/* BACNET_CHANNEL_VALUE decodes WriteProperty service requests
|
/* BACNET_CHANNEL_VALUE decodes WriteProperty service requests
|
||||||
@@ -26,8 +28,16 @@
|
|||||||
defined(CHANNEL_ENUMERATED) || defined(CHANNEL_DATE) || \
|
defined(CHANNEL_ENUMERATED) || defined(CHANNEL_DATE) || \
|
||||||
defined(CHANNEL_TIME) || defined(CHANNEL_OBJECT_ID) || \
|
defined(CHANNEL_TIME) || defined(CHANNEL_OBJECT_ID) || \
|
||||||
defined(CHANNEL_LIGHTING_COMMAND) || defined(CHANNEL_XY_COLOR) || \
|
defined(CHANNEL_LIGHTING_COMMAND) || defined(CHANNEL_XY_COLOR) || \
|
||||||
defined(CHANNEL_COLOR_COMMAND))
|
defined(CHANNEL_COLOR_COMMAND) || defined(CHANNEL_VALUE_ALL))
|
||||||
#define CHANNEL_NUMERIC
|
#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
|
#endif
|
||||||
|
|
||||||
#if defined(CHANNEL_NUMERIC)
|
#if defined(CHANNEL_NUMERIC)
|
||||||
|
|||||||
@@ -304,6 +304,25 @@ int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2)
|
|||||||
return diff;
|
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 the time1 is the same as time2, return is 0.
|
||||||
* If time1 is after time2, returns positive.
|
* 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;
|
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 the datetime1 is the same datetime2, return is 0.
|
||||||
* If datetime1 is after datetime2, returns positive.
|
* If datetime1 is after datetime2, returns positive.
|
||||||
@@ -357,6 +395,26 @@ int datetime_compare(
|
|||||||
return diff;
|
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(
|
int datetime_wildcard_compare_date(
|
||||||
const BACNET_DATE *date1, const BACNET_DATE *date2)
|
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
|
BACNET_STACK_EXPORT
|
||||||
int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2);
|
int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2);
|
||||||
BACNET_STACK_EXPORT
|
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);
|
int datetime_compare_time(const BACNET_TIME *time1, const BACNET_TIME *time2);
|
||||||
BACNET_STACK_EXPORT
|
BACNET_STACK_EXPORT
|
||||||
|
bool datetime_time_same(const BACNET_TIME *time1, const BACNET_TIME *time2);
|
||||||
|
BACNET_STACK_EXPORT
|
||||||
int datetime_compare(
|
int datetime_compare(
|
||||||
const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2);
|
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:
|
/* full comparison functions:
|
||||||
* taking into account FF fields in date and time structures,
|
* taking into account FF fields in date and time structures,
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ set(ZTST_DIR "${TST_DIR}/ztest/src")
|
|||||||
add_compile_definitions(
|
add_compile_definitions(
|
||||||
BIG_ENDIAN=0
|
BIG_ENDIAN=0
|
||||||
CONFIG_ZTEST=1
|
CONFIG_ZTEST=1
|
||||||
BACAPP_ALL
|
CHANNEL_VALUE_ALL=1
|
||||||
|
BACAPP_ALL=1
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|||||||
Reference in New Issue
Block a user