Schedule sets the correct value but only in the schedule object. References are not set yet. (#1236)
Add device_moc.c to tests cmake. Thanks Steve
This commit is contained in:
@@ -406,7 +406,7 @@ static object_functions_t My_Object_Table[] = {
|
|||||||
NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
|
NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
|
||||||
NULL /* Intrinsic Reporting */, NULL /* Add_List_Element */,
|
NULL /* Intrinsic Reporting */, NULL /* Add_List_Element */,
|
||||||
NULL /* Remove_List_Element */, NULL /* Create */, NULL /* Delete */,
|
NULL /* Remove_List_Element */, NULL /* Create */, NULL /* Delete */,
|
||||||
NULL /* Timer */, Schedule_Writable_Property_List },
|
Schedule_Timer /* Timer */, Schedule_Writable_Property_List },
|
||||||
{ OBJECT_STRUCTURED_VIEW, Structured_View_Init, Structured_View_Count,
|
{ OBJECT_STRUCTURED_VIEW, Structured_View_Init, Structured_View_Count,
|
||||||
Structured_View_Index_To_Instance, Structured_View_Valid_Instance,
|
Structured_View_Index_To_Instance, Structured_View_Valid_Instance,
|
||||||
Structured_View_Object_Name, Structured_View_Read_Property,
|
Structured_View_Object_Name, Structured_View_Read_Property,
|
||||||
|
|||||||
@@ -16,9 +16,11 @@
|
|||||||
#include "bacnet/timestamp.h"
|
#include "bacnet/timestamp.h"
|
||||||
#include "bacnet/basic/services.h"
|
#include "bacnet/basic/services.h"
|
||||||
#include "bacnet/basic/sys/debug.h"
|
#include "bacnet/basic/sys/debug.h"
|
||||||
#include "bacnet/basic/object/device.h"
|
#include "bacnet/basic/object/device.h" /* me */
|
||||||
#include "bacnet/basic/object/schedule.h"
|
#include "bacnet/basic/object/schedule.h"
|
||||||
|
|
||||||
|
#define UNUSED(v) (void)(v)
|
||||||
|
|
||||||
#ifndef MAX_SCHEDULES
|
#ifndef MAX_SCHEDULES
|
||||||
#define MAX_SCHEDULES 4
|
#define MAX_SCHEDULES 4
|
||||||
#endif
|
#endif
|
||||||
@@ -1027,30 +1029,58 @@ bool Schedule_In_Effective_Period(
|
|||||||
void Schedule_Recalculate_PV(
|
void Schedule_Recalculate_PV(
|
||||||
SCHEDULE_DESCR *desc, BACNET_WEEKDAY wday, const BACNET_TIME *time)
|
SCHEDULE_DESCR *desc, BACNET_WEEKDAY wday, const BACNET_TIME *time)
|
||||||
{
|
{
|
||||||
int i;
|
int i, current, diff;
|
||||||
|
BACNET_TIME *tmptime;
|
||||||
desc->Present_Value.tag = BACNET_APPLICATION_TAG_NULL;
|
desc->Present_Value.tag = BACNET_APPLICATION_TAG_NULL;
|
||||||
|
|
||||||
/* for future development, here should be the loop for Exception Schedule */
|
/* for future development, here should be the loop for Exception Schedule */
|
||||||
|
|
||||||
/* Note to developers: please ping Edward at info@connect-ex.com
|
/* Note to developers: please ping Edward at info@connect-ex.com
|
||||||
for a more complete schedule object implementation. */
|
for a more complete schedule object implementation. */
|
||||||
for (i = 0; i < desc->Weekly_Schedule[wday - 1].TV_Count &&
|
current = -1;
|
||||||
desc->Present_Value.tag == BACNET_APPLICATION_TAG_NULL;
|
tmptime = NULL;
|
||||||
i++) {
|
for (i = 0; i < desc->Weekly_Schedule[wday - 1].TV_Count; i++) {
|
||||||
int diff = datetime_wildcard_compare_time(
|
diff = datetime_wildcard_compare_time(
|
||||||
time, &desc->Weekly_Schedule[wday - 1].Time_Values[i].Time);
|
time, &desc->Weekly_Schedule[wday - 1].Time_Values[i].Time);
|
||||||
if (diff >= 0 &&
|
if (diff >= 0) {
|
||||||
desc->Weekly_Schedule[wday - 1].Time_Values[i].Value.tag !=
|
if (tmptime == NULL) {
|
||||||
BACNET_APPLICATION_TAG_NULL) {
|
tmptime = &desc->Weekly_Schedule[wday - 1].Time_Values[i].Time;
|
||||||
bacnet_primitive_to_application_data_value(
|
current = i;
|
||||||
&desc->Present_Value,
|
} else {
|
||||||
&desc->Weekly_Schedule[wday - 1].Time_Values[i].Value);
|
diff = datetime_wildcard_compare_time(
|
||||||
|
&desc->Weekly_Schedule[wday - 1].Time_Values[i].Time,
|
||||||
|
tmptime);
|
||||||
|
if (diff >= 0) {
|
||||||
|
tmptime =
|
||||||
|
&desc->Weekly_Schedule[wday - 1].Time_Values[i].Time;
|
||||||
|
current = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (current >= 0) {
|
||||||
if (desc->Present_Value.tag == BACNET_APPLICATION_TAG_NULL) {
|
bacnet_primitive_to_application_data_value(
|
||||||
|
&desc->Present_Value,
|
||||||
|
&desc->Weekly_Schedule[wday - 1].Time_Values[current].Value);
|
||||||
|
} else {
|
||||||
memcpy(
|
memcpy(
|
||||||
&desc->Present_Value, &desc->Schedule_Default,
|
&desc->Present_Value, &desc->Schedule_Default,
|
||||||
sizeof(desc->Present_Value));
|
sizeof(desc->Present_Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Updates the Present Value of the Schedule object
|
||||||
|
* @param object_instance - object-instance number of the object
|
||||||
|
* @param milliseconds - Unused parameter
|
||||||
|
*/
|
||||||
|
void Schedule_Timer(uint32_t object_instance, uint16_t milliseconds)
|
||||||
|
{
|
||||||
|
BACNET_DATE_TIME bdatetime;
|
||||||
|
UNUSED(milliseconds);
|
||||||
|
|
||||||
|
Device_getCurrentDateTime(&bdatetime);
|
||||||
|
|
||||||
|
Schedule_Recalculate_PV(
|
||||||
|
Schedule_Object(object_instance), bdatetime.date.wday, &bdatetime.time);
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,6 +147,9 @@ BACNET_STACK_EXPORT
|
|||||||
void Schedule_Recalculate_PV(
|
void Schedule_Recalculate_PV(
|
||||||
SCHEDULE_DESCR *desc, BACNET_WEEKDAY wday, const BACNET_TIME *time);
|
SCHEDULE_DESCR *desc, BACNET_WEEKDAY wday, const BACNET_TIME *time);
|
||||||
|
|
||||||
|
BACNET_STACK_EXPORT
|
||||||
|
void Schedule_Timer(uint32_t object_instance, uint16_t milliseconds);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ add_executable(${PROJECT_NAME}
|
|||||||
# Test and test library files
|
# Test and test library files
|
||||||
./src/main.c
|
./src/main.c
|
||||||
${TST_DIR}/bacnet/basic/object/test/property_test.c
|
${TST_DIR}/bacnet/basic/object/test/property_test.c
|
||||||
|
${TST_DIR}/bacnet/basic/object/test/device_mock.c
|
||||||
${ZTST_DIR}/ztest_mock.c
|
${ZTST_DIR}/ztest_mock.c
|
||||||
${ZTST_DIR}/ztest.c
|
${ZTST_DIR}/ztest.c
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user