installed beacon anomaly generator

This commit is contained in:
Jeff Hill
2002-09-19 19:32:29 +00:00
parent 7cc7d596b3
commit 41fd1ff1f8
7 changed files with 47 additions and 160 deletions
+2
View File
@@ -58,6 +58,8 @@ LIBSRCS += casBufferFactory.cc
LIBSRCS += pvExistReturn.cc
LIBSRCS += pvAttachReturn.cc
LIBSRCS += caNetAddr.cc
LIBSRCS += beaconTimer.cc
LIBSRCS += beaconAnomalyGovernor.cc
LIBSRCS += caServerOS.cc
LIBSRCS += casIntfOS.cc
+7
View File
@@ -205,6 +205,13 @@ epicsShareFunc unsigned caServer::subscriptionEventsPosted () const // X aCC 361
}
}
epicsShareFunc void caServer::generateBeaconAnomaly ()
{
if ( pCAS ) {
this->pCAS->generateBeaconAnomaly ();
}
}
//
// casRes::~casRes()
//
+21 -97
View File
@@ -23,66 +23,29 @@
#define caServerGlobal
#include "server.h"
#include "casCtxIL.h" // casCtx in line func
#include "beaconTimer.h"
#include "beaconAnomalyGovernor.h"
static const char *id = "@(#) " EPICS_VERSION_STRING ", CA Portable Server Library" "$Date$";
//
// the maximum beacon period if EPICS_CA_BEACON_PERIOD isnt available
//
static const double CAServerMaxBeaconPeriod = 15.0; // seconds
//
// the initial beacon period
//
static const double CAServerMinBeaconPeriod = 1.0e-3; // seconds
//
// caServerI::caServerI()
//
caServerI::caServerI (caServer &tool) :
//
// Set up periodic beacon interval
// (exponential back off to a plateau
// from this intial period)
//
beaconPeriod (CAServerMinBeaconPeriod),
adapter (tool),
beaconTmr ( * new beaconTimer ( *this ) ),
beaconAnomalyGov ( * new beaconAnomalyGovernor ( *this ) ),
debugLevel (0u),
nEventsProcessed (0u),
nEventsPosted (0u),
beaconCounter (0u)
nEventsPosted (0u)
{
caStatus status;
double maxPeriod;
assert ( & adapter != NULL );
assert (&adapter != NULL);
//
// create predefined event types
//
this->valueEvent = registerEvent ("value");
this->logEvent = registerEvent ("log");
this->alarmEvent = registerEvent ("alarm");
if ( envGetConfigParamPtr ( & EPICS_CAS_BEACON_PERIOD ) ) {
status = envGetDoubleConfigParam ( & EPICS_CAS_BEACON_PERIOD, & maxPeriod );
}
else {
status = envGetDoubleConfigParam ( & EPICS_CA_BEACON_PERIOD, & maxPeriod );
}
if ( status || maxPeriod <= 0.0 ) {
this->maxBeaconInterval = CAServerMaxBeaconPeriod;
errlogPrintf (
"EPICS \"%s\" float fetch failed\n", EPICS_CAS_BEACON_PERIOD.name );
errlogPrintf (
"Setting \"%s\" = %f\n", EPICS_CAS_BEACON_PERIOD.name,
this->maxBeaconInterval);
}
else {
this->maxBeaconInterval = maxPeriod;
}
this->locateInterfaces ();
if (this->intfList.count()==0u) {
@@ -101,9 +64,10 @@ caServerI::~caServerI()
{
epicsGuard < epicsMutex > locker ( this->mutex );
//
delete & this->beaconAnomalyGov;
delete & this->beaconTmr;
// delete all clients
//
tsDLIter <casStrmClient> iter = this->clientList.firstIter ();
while ( iter.valid () ) {
tsDLIter <casStrmClient> tmp = iter;
@@ -116,7 +80,7 @@ caServerI::~caServerI()
}
casIntfOS *pIF;
while ( (pIF = this->intfList.get()) ) {
while ( ( pIF = this->intfList.get() ) ) {
delete pIF;
}
}
@@ -151,27 +115,6 @@ void caServerI::connectCB ( casIntfOS & intf )
}
}
//
// caServerI::advanceBeaconPeriod()
//
// compute delay to the next beacon
//
void caServerI::advanceBeaconPeriod()
{
//
// return if we are already at the plateau
//
if (this->beaconPeriod >= this->maxBeaconInterval) {
return;
}
this->beaconPeriod += this->beaconPeriod;
if (this->beaconPeriod >= this->maxBeaconInterval) {
this->beaconPeriod = this->maxBeaconInterval;
}
}
//
// casVerifyFunc()
//
@@ -217,42 +160,23 @@ caStatus caServerI::attachInterface (const caNetAddr &addr, bool autoBeaconAddr,
return S_cas_success;
}
//
// caServerI::sendBeacon()
// (implemented here because this has knowledge of the protocol)
// send a beacon over each configured address
//
void caServerI::sendBeacon()
void caServerI::sendBeacon ( ca_uint32_t beaconNo )
{
//
// send a broadcast beacon over each configured
// interface unless EPICS_CA_AUTO_ADDR_LIST specifies
// otherwise. Also send a beacon to all configured
// addresses.
//
{
epicsGuard < epicsMutex > locker ( this->mutex );
tsDLIter <casIntfOS> iter = this->intfList.firstIter ();
while ( iter.valid () ) {
iter->sendBeacon ( this->beaconCounter );
iter++;
}
}
this->beaconCounter++;
//
// double the period between beacons (but dont exceed max)
//
this->advanceBeaconPeriod();
epicsGuard < epicsMutex > locker ( this->mutex );
tsDLIter <casIntfOS> iter = this->intfList.firstIter ();
while ( iter.valid () ) {
iter->sendBeacon ( beaconNo );
iter++;
}
}
//
// caServerI::getBeaconPeriod()
//
double caServerI::getBeaconPeriod() const
{
return this->beaconPeriod;
void caServerI::generateBeaconAnomaly ()
{
this->beaconAnomalyGov.start ();
}
//
+4 -4
View File
@@ -267,12 +267,12 @@ public:
epicsShareFunc unsigned subscriptionEventsPosted () const;
epicsShareFunc unsigned subscriptionEventsProcessed () const;
epicsShareFunc void generateBeaconAnomaly () const;
epicsShareFunc class epicsTimer & createTimer ();
//caStatus enableClients ();
//caStatus disableClients ();
epicsShareFunc void generateBeaconAnomaly ();
// caStatus enableClients ();
// caStatus disableClients ();
private:
caServerI *pCAS;
+12 -13
View File
@@ -843,6 +843,8 @@ private:
#include "casOSD.h" // OS dependent
class casClientMon;
class beaconTimer;
class beaconAnomalyGovernor;
//
// caServerI
@@ -918,19 +920,18 @@ public:
void lock () const;
void unlock () const;
private:
void advanceBeaconPeriod();
void generateBeaconAnomaly ();
private:
mutable epicsMutex mutex;
tsDLList<casStrmClient> clientList;
tsDLList<casIntfOS> intfList;
double maxBeaconInterval;
double beaconPeriod;
caServer &adapter;
caServer & adapter;
beaconTimer & beaconTmr;
beaconAnomalyGovernor & beaconAnomalyGov;
unsigned debugLevel;
unsigned nEventsProcessed;
unsigned nEventsPosted;
ca_uint32_t beaconCounter;
//
// predefined event types
@@ -939,18 +940,16 @@ private:
casEventMask logEvent; // DBE_LOG registerEvent("log")
casEventMask alarmEvent; // DBE_ALARM registerEvent("alarm")
double getBeaconPeriod () const;
//
// send beacon and advance beacon timer
//
void sendBeacon ();
caStatus attachInterface (const caNetAddr &addr, bool autoBeaconAddr,
bool addConfigAddr);
void sendBeacon ( ca_uint32_t beaconNo );
caServerI ( const caServerI & );
caServerI & operator = ( const caServerI & );
friend class beaconAnomalyGovernor;
friend class beaconTimer;
};
#define CAServerConnectPendQueueSize 10
-38
View File
@@ -22,38 +22,11 @@
#include "server.h"
#include "fdManager.h"
//
// casBeaconTimer
//
class casBeaconTimer : public epicsTimerNotify {
public:
casBeaconTimer ( double delay, caServerOS &osIn );
virtual ~casBeaconTimer ();
private:
epicsTimer &timer;
caServerOS &os;
expireStatus expire ( const epicsTime & currentTime );
casBeaconTimer ( const casBeaconTimer & );
casBeaconTimer & operator = ( const casBeaconTimer & );
};
casBeaconTimer::casBeaconTimer ( double delay, caServerOS &osIn ) :
timer ( fileDescriptorManager.createTimer() ), os ( osIn )
{
this->timer.start ( *this, delay );
}
casBeaconTimer::~casBeaconTimer ()
{
this->timer.destroy ();
}
//
// caServerOS::caServerOS()
//
caServerOS::caServerOS ()
{
this->pBTmr = new casBeaconTimer(0.0, *this);
}
//
@@ -61,17 +34,6 @@ caServerOS::caServerOS ()
//
caServerOS::~caServerOS()
{
if ( this->pBTmr ) {
delete this->pBTmr;
}
}
//
// casBeaconTimer::expire()
//
epicsTimerNotify::expireStatus casBeaconTimer::expire( const epicsTime & /* currentTime */ )
{
os.sendBeacon ();
return expireStatus ( restart, os.getBeaconPeriod() );
}
+1 -8
View File
@@ -32,23 +32,16 @@ class caServerI;
class caServerOS;
class casServerReg;
class casBeaconTimer;
//
// caServerOS
//
class caServerOS {
friend class casServerReg;
friend class casBeaconTimer;
public:
caServerOS ();
virtual ~caServerOS ();
private:
casBeaconTimer *pBTmr;
virtual double getBeaconPeriod() const = 0;
virtual void sendBeacon() = 0;
friend class casServerReg;
};
class casDGReadReg;