Corrected the COV lifetime to be seconds, not milliseconds.

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