Corrected the COV lifetime to be seconds, not milliseconds.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_file>
|
||||
<Workspace title="Workspace">
|
||||
<Project filename="epics\bacepics.cbp" active="1" />
|
||||
<Project filename="epics\bacepics.cbp" />
|
||||
<Project filename="..\lib\bacnet.cbp" />
|
||||
<Project filename="server\bacserv.cbp" />
|
||||
<Project filename="server\bacserv.cbp" active="1" />
|
||||
</Workspace>
|
||||
</CodeBlocks_workspace_file>
|
||||
|
||||
@@ -224,10 +224,10 @@ COV_FAILED:
|
||||
/* note: worst case tasking: MS/TP with the ability to send only
|
||||
one notification per task cycle */
|
||||
void handler_cov_task(
|
||||
uint32_t elapsed_milliseconds)
|
||||
uint32_t elapsed_seconds)
|
||||
{
|
||||
int index;
|
||||
int lifetime_milliseconds;
|
||||
int lifetime_seconds;
|
||||
BACNET_OBJECT_ID object_id;
|
||||
bool status = false;
|
||||
|
||||
@@ -236,9 +236,9 @@ void handler_cov_task(
|
||||
for (index = 0; index < MAX_COV_SUBCRIPTIONS; index++) {
|
||||
if (COV_Subscriptions[index].valid) {
|
||||
/* handle timeouts */
|
||||
lifetime_milliseconds = COV_Subscriptions[index].lifetime;
|
||||
if (lifetime_milliseconds >= elapsed_milliseconds) {
|
||||
COV_Subscriptions[index].lifetime -= elapsed_milliseconds;
|
||||
lifetime_seconds = COV_Subscriptions[index].lifetime;
|
||||
if (lifetime_seconds >= elapsed_seconds) {
|
||||
COV_Subscriptions[index].lifetime -= elapsed_seconds;
|
||||
} else {
|
||||
COV_Subscriptions[index].lifetime = 0;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ int main(
|
||||
unsigned timeout = 100; /* milliseconds */
|
||||
time_t last_seconds = 0;
|
||||
time_t current_seconds = 0;
|
||||
uint32_t elapsed_seconds = 0;
|
||||
uint32_t elapsed_milliseconds = 0;
|
||||
char *pEnv = NULL;
|
||||
|
||||
@@ -178,11 +179,12 @@ int main(
|
||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||
}
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
dcc_timer_seconds(current_seconds - last_seconds);
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
dcc_timer_seconds(elapsed_seconds);
|
||||
Load_Control_State_Machine_Handler();
|
||||
elapsed_milliseconds = (current_seconds - last_seconds) * 1000;
|
||||
handler_cov_task(elapsed_milliseconds);
|
||||
elapsed_milliseconds = elapsed_seconds * 1000;
|
||||
handler_cov_task(elapsed_seconds);
|
||||
tsm_timer_milliseconds(elapsed_milliseconds);
|
||||
}
|
||||
/* output */
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef struct BACnet_COV_Data {
|
||||
uint32_t subscriberProcessIdentifier;
|
||||
uint32_t initiatingDeviceIdentifier;
|
||||
BACNET_OBJECT_ID monitoredObjectIdentifier;
|
||||
uint32_t timeRemaining;
|
||||
uint32_t timeRemaining; /* seconds */
|
||||
/* simple linked list of values */
|
||||
BACNET_PROPERTY_VALUE listOfValues;
|
||||
} BACNET_COV_DATA;
|
||||
@@ -67,7 +67,7 @@ typedef struct BACnet_Subscribe_COV_Data {
|
||||
BACNET_OBJECT_ID monitoredObjectIdentifier;
|
||||
bool cancellationRequest; /* true if this is a cancellation request */
|
||||
bool issueConfirmedNotifications; /* optional */
|
||||
uint32_t lifetime; /* optional */
|
||||
uint32_t lifetime; /* seconds, optional */
|
||||
BACNET_PROPERTY_REFERENCE monitoredProperty;
|
||||
bool covIncrementPresent; /* true if present */
|
||||
float covIncrement; /* optional */
|
||||
|
||||
@@ -149,7 +149,7 @@ extern "C" {
|
||||
BACNET_ADDRESS * src,
|
||||
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
||||
void handler_cov_task(
|
||||
uint32_t elapsed_milliseconds);
|
||||
uint32_t elapsed_seconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user