Commit 38cb5150 authored by claes's avatar claes

Min holdtime added for subpoll

parent 2a858fbe
/* /*
* Proview $Id: opc_server.cpp,v 1.18 2007-05-30 13:19:04 claes Exp $ * Proview $Id: opc_server.cpp,v 1.19 2007-05-30 13:22:12 claes Exp $
* Proview $Id: opc_server.cpp,v 1.19 2007-05-30 13:22:12 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
#include <net/if.h> #include <net/if.h>
#include <net/if_arp.h> #include <net/if_arp.h>
#include <pthread.h> #include <pthread.h>
#include <float.h>
#include "pwr.h" #include "pwr.h"
#include "pwr_version.h" #include "pwr_version.h"
...@@ -883,13 +885,15 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__SubscriptionPolledRefresh(struct soap* soap, ...@@ -883,13 +885,15 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__SubscriptionPolledRefresh(struct soap* soap,
bool has_waittime = false; bool has_waittime = false;
int waited_time = 0; int waited_time = 0;
pwr_tFloat32 wait_scan = 0.5; pwr_tFloat32 wait_scan = 0.5;
pwr_tDeltaTime dwait_scan; pwr_tFloat32 min_hold = 0.5;
pwr_tDeltaTime dwait_scan, dmin_hold;
if ( s0__SubscriptionPolledRefresh->HoldTime) { if ( s0__SubscriptionPolledRefresh->HoldTime) {
if ( !client->m_multi_threaded) if ( !client->m_multi_threaded)
client->m_multi_threaded = true; client->m_multi_threaded = true;
else { else {
has_holdtime = true; has_holdtime = true;
time_FloatToD( &dmin_hold, min_hold);
opc_time_OPCAsciiToA( (char *)s0__SubscriptionPolledRefresh->HoldTime->c_str(), opc_time_OPCAsciiToA( (char *)s0__SubscriptionPolledRefresh->HoldTime->c_str(),
&hold_time); &hold_time);
if ( s0__SubscriptionPolledRefresh->WaitTime) { if ( s0__SubscriptionPolledRefresh->WaitTime) {
...@@ -903,16 +907,17 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__SubscriptionPolledRefresh(struct soap* soap, ...@@ -903,16 +907,17 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__SubscriptionPolledRefresh(struct soap* soap,
if ( has_holdtime) { if ( has_holdtime) {
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pwr_tTime current_time; pwr_tTime current_time, next_time;
char str1[80], str2[80];
clock_gettime( CLOCK_REALTIME, &current_time); if ( min_hold > FLT_EPSILON) {
time_AtoAscii( &current_time, time_eFormat_DateAndTime, str1, sizeof(str1)); clock_gettime( CLOCK_REALTIME, &current_time);
time_AtoAscii( &hold_time, time_eFormat_DateAndTime, str2, sizeof(str2)); time_Aadd( &next_time, &current_time, &dmin_hold);
if ( time_Acomp( &next_time, &hold_time) == -1)
printf( "TimedWait %s %s\n", str1, str2); next_time = hold_time;
pthread_cond_timedwait( &cond, &mutex, &next_time);
pthread_cond_timedwait( &cond, &mutex, &hold_time); }
else
pthread_cond_timedwait( &cond, &mutex, &hold_time);
} }
if ( has_waittime) { if ( has_waittime) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment