osiTimer => epicsTimer
This commit is contained in:
@@ -20,7 +20,7 @@ caStatus exAsyncPV::read (const casCtx &ctx, gdd &valueIn)
|
||||
|
||||
this->simultAsychIOCount++;
|
||||
|
||||
pIO = new exAsyncReadIO(ctx, *this, valueIn);
|
||||
pIO = new exAsyncReadIO ( ctx, *this, valueIn );
|
||||
if (!pIO) {
|
||||
return S_casApp_noMemory;
|
||||
}
|
||||
@@ -32,18 +32,18 @@ caStatus exAsyncPV::read (const casCtx &ctx, gdd &valueIn)
|
||||
// exAsyncPV::write()
|
||||
// (virtual replacement for the default)
|
||||
//
|
||||
caStatus exAsyncPV::write (const casCtx &ctx, const gdd &valueIn)
|
||||
caStatus exAsyncPV::write ( const casCtx &ctx, const gdd &valueIn )
|
||||
{
|
||||
exAsyncWriteIO *pIO;
|
||||
exAsyncWriteIO *pIO;
|
||||
|
||||
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
|
||||
if ( this->simultAsychIOCount >= maxSimultAsyncIO ) {
|
||||
return S_casApp_postponeAsyncIO;
|
||||
}
|
||||
|
||||
this->simultAsychIOCount++;
|
||||
|
||||
pIO = new exAsyncWriteIO(ctx, *this, valueIn);
|
||||
if (!pIO) {
|
||||
pIO = new exAsyncWriteIO ( ctx, *this, valueIn );
|
||||
if ( ! pIO ) {
|
||||
return S_casApp_noMemory;
|
||||
}
|
||||
|
||||
@@ -51,29 +51,63 @@ caStatus exAsyncPV::write (const casCtx &ctx, const gdd &valueIn)
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncWriteIO::expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
// exAsyncWriteIO::exAsyncWriteIO()
|
||||
//
|
||||
void exAsyncWriteIO::expire()
|
||||
exAsyncWriteIO::exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn,
|
||||
const gdd &valueIn ) :
|
||||
casAsyncWriteIO ( ctxIn ), pv ( pvIn ),
|
||||
timer ( pvIn.getCAS()->timerQueue().createTimer ( *this ) ), pValue(valueIn)
|
||||
{
|
||||
caStatus status;
|
||||
status = this->pv.update(this->pValue);
|
||||
this->postIOCompletion (status);
|
||||
this->timer.start ( 0.1 );
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncWriteIO::name()
|
||||
// exAsyncWriteIO::~exAsyncWriteIO()
|
||||
//
|
||||
const char *exAsyncWriteIO::name() const
|
||||
exAsyncWriteIO::~exAsyncWriteIO()
|
||||
{
|
||||
return "exAsyncWriteIO";
|
||||
this->pv.removeIO();
|
||||
delete & this->timer;
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncWriteIO::expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
//
|
||||
epicsTimerNotify::expireStatus exAsyncWriteIO::expire ()
|
||||
{
|
||||
caStatus status;
|
||||
status = this->pv.update ( this->pValue );
|
||||
this->postIOCompletion ( status );
|
||||
return noRestart;
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncReadIO::exAsyncReadIO()
|
||||
//
|
||||
exAsyncReadIO::exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn,
|
||||
gdd &protoIn ) :
|
||||
casAsyncReadIO ( ctxIn ), pv ( pvIn ),
|
||||
timer ( pvIn.getCAS()->timerQueue().createTimer(*this) ), pProto ( protoIn )
|
||||
{
|
||||
this->timer.start ( 0.1 );
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncReadIO::~exAsyncReadIO()
|
||||
//
|
||||
exAsyncReadIO::~exAsyncReadIO()
|
||||
{
|
||||
this->pv.removeIO ();
|
||||
delete & this->timer;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// exAsyncReadIO::expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
//
|
||||
void exAsyncReadIO::expire ()
|
||||
epicsTimerNotify::expireStatus exAsyncReadIO::expire ()
|
||||
{
|
||||
caStatus status;
|
||||
|
||||
@@ -81,19 +115,13 @@ void exAsyncReadIO::expire ()
|
||||
// map between the prototype in and the
|
||||
// current value
|
||||
//
|
||||
status = this->pv.exPV::readNoCtx (this->pProto);
|
||||
status = this->pv.exPV::readNoCtx ( this->pProto );
|
||||
|
||||
//
|
||||
// post IO completion
|
||||
//
|
||||
this->postIOCompletion (status, *this->pProto );
|
||||
}
|
||||
this->postIOCompletion ( status, *this->pProto );
|
||||
|
||||
//
|
||||
// exAsyncReadIO::name()
|
||||
//
|
||||
const char *exAsyncReadIO::name() const
|
||||
{
|
||||
return "exAsyncReadIO";
|
||||
return noRestart;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,12 @@ class exFixedStringDestructor: public gddDestructor {
|
||||
//
|
||||
// exPV::exPV()
|
||||
//
|
||||
exPV::exPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) :
|
||||
info (setup),
|
||||
interest (false),
|
||||
preCreate (preCreateFlag),
|
||||
scanOn (scanOnIn)
|
||||
exPV::exPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
|
||||
timer ( this->getCAS()->timerQueue().createTimer(*this) ),
|
||||
info ( setup ),
|
||||
interest ( false ),
|
||||
preCreate ( preCreateFlag ),
|
||||
scanOn ( scanOnIn )
|
||||
{
|
||||
//
|
||||
// no dataless PV allowed
|
||||
@@ -38,12 +39,8 @@ exPV::exPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) :
|
||||
// someone is watching the PV)
|
||||
//
|
||||
if ( this->scanOn && this->info.getScanPeriod () > 0.0 ) {
|
||||
this->pScanTimer =
|
||||
new exScanTimer (this->getScanPeriod(), *this);
|
||||
this->timer.start ( this->getScanPeriod() );
|
||||
}
|
||||
else {
|
||||
this->pScanTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -51,10 +48,7 @@ exPV::exPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) :
|
||||
//
|
||||
exPV::~exPV()
|
||||
{
|
||||
if (this->pScanTimer) {
|
||||
delete this->pScanTimer;
|
||||
this->pScanTimer = NULL;
|
||||
}
|
||||
delete & this->timer;
|
||||
this->info.unlinkPV();
|
||||
}
|
||||
|
||||
@@ -66,7 +60,7 @@ exPV::~exPV()
|
||||
//
|
||||
void exPV::destroy()
|
||||
{
|
||||
if (!this->preCreate) {
|
||||
if ( ! this->preCreate ) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
@@ -100,44 +94,18 @@ caStatus exPV::update(smartConstGDDPointer pValueIn)
|
||||
return S_casApp_success;
|
||||
}
|
||||
|
||||
//
|
||||
// exScanTimer::~exScanTimer ()
|
||||
//
|
||||
exScanTimer::~exScanTimer ()
|
||||
{
|
||||
pv.pScanTimer = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// exScanTimer::expire ()
|
||||
//
|
||||
void exScanTimer::expire ()
|
||||
epicsTimerNotify::expireStatus exPV::expire ()
|
||||
{
|
||||
pv.scan();
|
||||
}
|
||||
|
||||
//
|
||||
// exScanTimer::again()
|
||||
//
|
||||
bool exScanTimer::again() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// exScanTimer::delay()
|
||||
//
|
||||
double exScanTimer::delay() const
|
||||
{
|
||||
return pv.getScanPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
// exScanTimer::name()
|
||||
//
|
||||
const char *exScanTimer::name() const
|
||||
{
|
||||
return "exScanTimer";
|
||||
this->scan();
|
||||
if ( this->scanOn ) {
|
||||
return expireStatus ( restart, this->getScanPeriod() );
|
||||
}
|
||||
else {
|
||||
return noRestart;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -153,34 +121,16 @@ aitEnum exPV::bestExternalType() const
|
||||
//
|
||||
caStatus exPV::interestRegister()
|
||||
{
|
||||
caServer *pCAS = this->getCAS();
|
||||
caServer *pCAS = this->getCAS();
|
||||
|
||||
if (!pCAS) {
|
||||
if ( ! pCAS ) {
|
||||
return S_casApp_success;
|
||||
}
|
||||
|
||||
this->interest = true;
|
||||
|
||||
if (!this->scanOn) {
|
||||
return S_casApp_success;
|
||||
}
|
||||
|
||||
//
|
||||
// If a slow scan is pending then reschedule it
|
||||
// with the specified scan period.
|
||||
//
|
||||
if (this->pScanTimer) {
|
||||
this->pScanTimer->reschedule(this->getScanPeriod());
|
||||
}
|
||||
else if ( this->getScanPeriod () > 0.0 ) {
|
||||
this->pScanTimer = new exScanTimer
|
||||
(this->getScanPeriod(), *this);
|
||||
if (!this->pScanTimer) {
|
||||
errPrintf (S_cas_noMemory, __FILE__, __LINE__,
|
||||
"Scan init for %s failed\n",
|
||||
this->info.getName());
|
||||
return S_cas_noMemory;
|
||||
}
|
||||
if ( this->scanOn && this->getScanPeriod() < this->timer.getExpireDelay() ) {
|
||||
this->timer.start ( this->getScanPeriod() );
|
||||
}
|
||||
|
||||
return S_casApp_success;
|
||||
@@ -192,15 +142,12 @@ caStatus exPV::interestRegister()
|
||||
void exPV::interestDelete()
|
||||
{
|
||||
this->interest = false;
|
||||
if (this->pScanTimer && this->scanOn) {
|
||||
this->pScanTimer->reschedule(this->getScanPeriod());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// exPV::show()
|
||||
//
|
||||
void exPV::show(unsigned level) const
|
||||
void exPV::show ( unsigned level ) const
|
||||
{
|
||||
if (level>1u) {
|
||||
if ( this->pValue.valid () ) {
|
||||
@@ -209,8 +156,7 @@ void exPV::show(unsigned level) const
|
||||
printf ( "exPV: value=%f\n", static_cast < double > ( * this->pValue ) );
|
||||
}
|
||||
printf ( "exPV: interest=%d\n", this->interest );
|
||||
printf ( "exPV: pScanTimer=%p\n",
|
||||
static_cast < const void * > ( this->pScanTimer ) );
|
||||
this->timer.show ( level - 1u );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +165,7 @@ void exPV::show(unsigned level) const
|
||||
//
|
||||
void exPV::initFT()
|
||||
{
|
||||
if (exPV::hasBeenInitialized) {
|
||||
if ( exPV::hasBeenInitialized ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ pvInfo exServer::billy (-1.0, "billy", 10.0f, -10.0f, excasIoAsync, 1u);
|
||||
//
|
||||
// exServer::exServer()
|
||||
//
|
||||
exServer::exServer(const char * const pvPrefix, unsigned aliasCount, bool scanOnIn) :
|
||||
exServer::exServer ( const char * const pvPrefix,
|
||||
unsigned aliasCount, bool scanOnIn ) :
|
||||
caServer (pvListNElem+2u),
|
||||
stringResTbl (pvListNElem*(aliasCount+1u)+2u),
|
||||
simultAsychIOCount (0u),
|
||||
@@ -176,7 +177,7 @@ pvExistReturn exServer::pvExistTest
|
||||
this->simultAsychIOCount++;
|
||||
|
||||
exAsyncExistIO *pIO;
|
||||
pIO = new exAsyncExistIO(pvi, ctxIn, *this);
|
||||
pIO = new exAsyncExistIO ( pvi, ctxIn, *this );
|
||||
if (pIO) {
|
||||
return pverAsyncCompletion;
|
||||
}
|
||||
@@ -242,7 +243,7 @@ pvAttachReturn exServer::pvAttach
|
||||
//
|
||||
// pvInfo::createPV()
|
||||
//
|
||||
exPV *pvInfo::createPV (exServer &, bool preCreateFlag, bool scanOn)
|
||||
exPV *pvInfo::createPV ( exServer &cas, bool preCreateFlag, bool scanOn )
|
||||
{
|
||||
if (this->pPV) {
|
||||
return this->pPV;
|
||||
@@ -258,10 +259,10 @@ exPV *pvInfo::createPV (exServer &, bool preCreateFlag, bool scanOn)
|
||||
if (this->elementCount==1u) {
|
||||
switch (this->ioType){
|
||||
case excasIoSync:
|
||||
pNewPV = new exScalarPV (*this, preCreateFlag, scanOn);
|
||||
pNewPV = new exScalarPV ( *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
case excasIoAsync:
|
||||
pNewPV = new exAsyncPV (*this, preCreateFlag, scanOn);
|
||||
pNewPV = new exAsyncPV ( *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
default:
|
||||
pNewPV = NULL;
|
||||
@@ -269,8 +270,8 @@ exPV *pvInfo::createPV (exServer &, bool preCreateFlag, bool scanOn)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->ioType==excasIoSync) {
|
||||
pNewPV = new exVectorPV (*this, preCreateFlag, scanOn);
|
||||
if ( this->ioType == excasIoSync ) {
|
||||
pNewPV = new exVectorPV ( *this, preCreateFlag, scanOn );
|
||||
}
|
||||
else {
|
||||
pNewPV = NULL;
|
||||
@@ -312,56 +313,75 @@ void exServer::show (unsigned level) const
|
||||
}
|
||||
|
||||
//
|
||||
// this is a noop that postpones the timer expiration
|
||||
// destroy so the exAsyncIO class will hang around until the
|
||||
// casAsyncIO::destroy() is called
|
||||
// exAsyncExistIO::exAsyncExistIO()
|
||||
//
|
||||
void exOSITimer::destroy()
|
||||
exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
|
||||
exServer &casIn ) :
|
||||
casAsyncPVExistIO ( ctxIn ), pvi ( pviIn ),
|
||||
timer ( casIn.timerQueue().createTimer ( *this ) ), cas ( casIn )
|
||||
{
|
||||
this->timer.start ( 0.00001 );
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncExistIO::~exAsyncExistIO()
|
||||
//
|
||||
exAsyncExistIO::~exAsyncExistIO()
|
||||
{
|
||||
this->cas.removeIO();
|
||||
delete & this->timer;
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncExistIO::expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
//
|
||||
void exAsyncExistIO::expire()
|
||||
epicsTimerNotify::expireStatus exAsyncExistIO::expire ()
|
||||
{
|
||||
//
|
||||
// post IO completion
|
||||
//
|
||||
this->postIOCompletion (pvExistReturn(pverExistsHere));
|
||||
//
|
||||
// post IO completion
|
||||
//
|
||||
this->postIOCompletion ( pvExistReturn(pverExistsHere) );
|
||||
return noRestart;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// exAsyncCreateIO::exAsyncCreateIO()
|
||||
//
|
||||
exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
|
||||
const casCtx &ctxIn, bool scanOnIn ) :
|
||||
casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ),
|
||||
timer ( casIn.timerQueue().createTimer ( *this ) ),
|
||||
cas ( casIn ), scanOn ( scanOnIn )
|
||||
{
|
||||
this->timer.start ( 0.00001 );
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncExistIO::name()
|
||||
// exAsyncCreateIO::~exAsyncCreateIO()
|
||||
//
|
||||
const char *exAsyncExistIO::name() const
|
||||
exAsyncCreateIO::~exAsyncCreateIO()
|
||||
{
|
||||
return "exAsyncExistIO";
|
||||
this->cas.removeIO ();
|
||||
delete & this->timer;
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncCreateIO::expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
//
|
||||
void exAsyncCreateIO::expire()
|
||||
epicsTimerNotify::expireStatus exAsyncCreateIO::expire ()
|
||||
{
|
||||
exPV *pPV;
|
||||
|
||||
pPV = this->pvi.createPV(this->cas, false, this->scanOn);
|
||||
if (pPV) {
|
||||
this->postIOCompletion (pvAttachReturn(*pPV));
|
||||
pPV = this->pvi.createPV ( this->cas, false, this->scanOn );
|
||||
if ( pPV ) {
|
||||
this->postIOCompletion ( pvAttachReturn ( *pPV ) );
|
||||
}
|
||||
else {
|
||||
this->postIOCompletion (pvAttachReturn(S_casApp_noMemory));
|
||||
this->postIOCompletion ( pvAttachReturn ( S_casApp_noMemory ) );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncCreateIO::name()
|
||||
//
|
||||
const char *exAsyncCreateIO::name() const
|
||||
{
|
||||
return "exAsyncCreateIO";
|
||||
return noRestart;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
//
|
||||
// EPICS
|
||||
//
|
||||
#include "epicsTimer.h"
|
||||
#include "casdef.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "gddAppFuncTable.h"
|
||||
#include "osiTimer.h"
|
||||
#include "resourceLib.h"
|
||||
#include "tsMinMax.h"
|
||||
|
||||
@@ -130,35 +130,16 @@ private:
|
||||
exServer &cas;
|
||||
};
|
||||
|
||||
//
|
||||
// exScanTimer
|
||||
//
|
||||
class exScanTimer : public osiTimer {
|
||||
public:
|
||||
exScanTimer (double delayIn, exPV &pvIn) :
|
||||
osiTimer(delayIn), pv(pvIn) {}
|
||||
~exScanTimer();
|
||||
void expire ();
|
||||
bool again() const;
|
||||
double delay() const;
|
||||
const char *name() const;
|
||||
private:
|
||||
exPV &pv;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// exPV
|
||||
//
|
||||
class exPV : public casPV, public tsSLNode<exPV> {
|
||||
// allow the exScanTimer destructor to set dangling pScanTimer pointer to NULL
|
||||
friend exScanTimer::~exScanTimer();
|
||||
class exPV : public casPV, public epicsTimerNotify, public tsSLNode<exPV> {
|
||||
public:
|
||||
exPV (pvInfo &setup, bool preCreateFlag, bool scanOn);
|
||||
exPV ( pvInfo &setup, bool preCreateFlag, bool scanOn );
|
||||
virtual ~exPV();
|
||||
|
||||
void show(unsigned level) const;
|
||||
void show ( unsigned level ) const;
|
||||
|
||||
//
|
||||
// Called by the server libary each time that it wishes to
|
||||
@@ -204,8 +185,8 @@ public:
|
||||
{
|
||||
double curPeriod;
|
||||
|
||||
curPeriod = this->info.getScanPeriod();
|
||||
if (!this->interest) {
|
||||
curPeriod = this->info.getScanPeriod ();
|
||||
if ( ! this->interest ) {
|
||||
curPeriod *= 10.0L;
|
||||
}
|
||||
return curPeriod;
|
||||
@@ -242,7 +223,7 @@ public:
|
||||
|
||||
protected:
|
||||
smartConstGDDPointer pValue;
|
||||
exScanTimer *pScanTimer;
|
||||
epicsTimer &timer;
|
||||
pvInfo & info;
|
||||
bool interest;
|
||||
bool preCreate;
|
||||
@@ -252,6 +233,12 @@ protected:
|
||||
virtual caStatus updateValue (smartConstGDDPointer pValue) = 0;
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// scan timer expire
|
||||
//
|
||||
expireStatus expire ();
|
||||
|
||||
//
|
||||
// Std PV Attribute fetch support
|
||||
//
|
||||
@@ -274,8 +261,8 @@ private:
|
||||
//
|
||||
class exScalarPV : public exPV {
|
||||
public:
|
||||
exScalarPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) :
|
||||
exPV (setup, preCreateFlag, scanOnIn) {}
|
||||
exScalarPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
|
||||
exPV ( setup, preCreateFlag, scanOnIn) {}
|
||||
void scan();
|
||||
private:
|
||||
caStatus updateValue (smartConstGDDPointer pValue);
|
||||
@@ -286,8 +273,8 @@ private:
|
||||
//
|
||||
class exVectorPV : public exPV {
|
||||
public:
|
||||
exVectorPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) :
|
||||
exPV (setup, preCreateFlag, scanOnIn) {}
|
||||
exVectorPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
|
||||
exPV ( setup, preCreateFlag, scanOnIn) {}
|
||||
void scan();
|
||||
|
||||
unsigned maxDimension() const;
|
||||
@@ -302,7 +289,8 @@ private:
|
||||
//
|
||||
class exServer : public caServer {
|
||||
public:
|
||||
exServer(const char * const pvPrefix, unsigned aliasCount, bool scanOn);
|
||||
exServer ( const char * const pvPrefix,
|
||||
unsigned aliasCount, bool scanOn );
|
||||
~exServer();
|
||||
|
||||
void show (unsigned level) const;
|
||||
@@ -352,9 +340,9 @@ public:
|
||||
//
|
||||
// exAsyncPV()
|
||||
//
|
||||
exAsyncPV (pvInfo &setup, bool preCreateFlag, bool scanOnIn) :
|
||||
exScalarPV (setup, preCreateFlag, scanOnIn),
|
||||
simultAsychIOCount(0u) {}
|
||||
exAsyncPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
|
||||
exScalarPV ( setup, preCreateFlag, scanOnIn ),
|
||||
simultAsychIOCount ( 0u ) {}
|
||||
|
||||
//
|
||||
// read
|
||||
@@ -398,120 +386,48 @@ public:
|
||||
private:
|
||||
};
|
||||
|
||||
//
|
||||
// exOSITimer
|
||||
//
|
||||
// a special version of osiTimer which is only to be used
|
||||
// within an exAsyncIO. The destroy() method is replaced
|
||||
// so that the timer destroy() will not destroy the
|
||||
// exAsyncIO until the casAsyncIO has completed
|
||||
//
|
||||
class exOSITimer : public osiTimer {
|
||||
public:
|
||||
exOSITimer (double delay) : osiTimer(delay) {}
|
||||
|
||||
//
|
||||
// this is a noop that postpones the timer expiration
|
||||
// destroy so this object will hang around until the
|
||||
// casAsyncIO::destroy() is called
|
||||
//
|
||||
void destroy();
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// exAsyncWriteIO
|
||||
//
|
||||
class exAsyncWriteIO : public casAsyncWriteIO, public exOSITimer {
|
||||
class exAsyncWriteIO : public casAsyncWriteIO, public epicsTimerNotify {
|
||||
public:
|
||||
//
|
||||
// exAsyncWriteIO()
|
||||
//
|
||||
exAsyncWriteIO (const casCtx &ctxIn, exAsyncPV &pvIn, const gdd &valueIn) :
|
||||
casAsyncWriteIO(ctxIn), exOSITimer(0.1), pv(pvIn), pValue(valueIn)
|
||||
{
|
||||
}
|
||||
|
||||
~exAsyncWriteIO()
|
||||
{
|
||||
this->pv.removeIO();
|
||||
}
|
||||
|
||||
//
|
||||
// expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
// see exAsyncPV.cc
|
||||
//
|
||||
void expire();
|
||||
|
||||
const char *name() const;
|
||||
|
||||
exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn, const gdd &valueIn );
|
||||
~exAsyncWriteIO ();
|
||||
private:
|
||||
exAsyncPV &pv;
|
||||
smartConstGDDPointer pValue;
|
||||
exAsyncPV &pv;
|
||||
epicsTimer &timer;
|
||||
smartConstGDDPointer pValue;
|
||||
expireStatus expire ();
|
||||
};
|
||||
|
||||
//
|
||||
// exAsyncReadIO
|
||||
//
|
||||
class exAsyncReadIO : public casAsyncReadIO, public exOSITimer {
|
||||
class exAsyncReadIO : public casAsyncReadIO, public epicsTimerNotify {
|
||||
public:
|
||||
//
|
||||
// exAsyncReadIO()
|
||||
//
|
||||
exAsyncReadIO(const casCtx &ctxIn, exAsyncPV &pvIn, gdd &protoIn) :
|
||||
casAsyncReadIO(ctxIn), exOSITimer(0.1), pv(pvIn), pProto(protoIn)
|
||||
{
|
||||
}
|
||||
|
||||
~exAsyncReadIO()
|
||||
{
|
||||
this->pv.removeIO();
|
||||
}
|
||||
|
||||
//
|
||||
// expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
// see exAsyncPV.cc
|
||||
//
|
||||
void expire();
|
||||
|
||||
const char *name() const;
|
||||
|
||||
exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn, gdd &protoIn );
|
||||
~exAsyncReadIO ();
|
||||
private:
|
||||
exAsyncPV &pv;
|
||||
smartGDDPointer pProto;
|
||||
exAsyncPV &pv;
|
||||
epicsTimer &timer;
|
||||
smartGDDPointer pProto;
|
||||
expireStatus expire ();
|
||||
};
|
||||
|
||||
//
|
||||
// exAsyncExistIO
|
||||
// (PV exist async IO)
|
||||
//
|
||||
class exAsyncExistIO : public casAsyncPVExistIO, public exOSITimer {
|
||||
class exAsyncExistIO : public casAsyncPVExistIO, public epicsTimerNotify {
|
||||
public:
|
||||
//
|
||||
// exAsyncExistIO()
|
||||
//
|
||||
exAsyncExistIO(const pvInfo &pviIn, const casCtx &ctxIn,
|
||||
exServer &casIn) :
|
||||
casAsyncPVExistIO(ctxIn), exOSITimer(0.00001), pvi(pviIn), cas(casIn) {}
|
||||
|
||||
~exAsyncExistIO()
|
||||
{
|
||||
this->cas.removeIO();
|
||||
}
|
||||
|
||||
//
|
||||
// expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
// see exServer.cc
|
||||
//
|
||||
void expire();
|
||||
|
||||
const char *name() const;
|
||||
exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
|
||||
exServer &casIn );
|
||||
~exAsyncExistIO ();
|
||||
private:
|
||||
const pvInfo &pvi;
|
||||
exServer &cas;
|
||||
const pvInfo &pvi;
|
||||
epicsTimer &timer;
|
||||
exServer &cas;
|
||||
expireStatus expire ();
|
||||
};
|
||||
|
||||
|
||||
@@ -519,43 +435,27 @@ private:
|
||||
// exAsyncCreateIO
|
||||
// (PV create async IO)
|
||||
//
|
||||
class exAsyncCreateIO : public casAsyncPVAttachIO, public exOSITimer {
|
||||
class exAsyncCreateIO : public casAsyncPVAttachIO, public epicsTimerNotify {
|
||||
public:
|
||||
//
|
||||
// exAsyncCreateIO()
|
||||
//
|
||||
exAsyncCreateIO(pvInfo &pviIn, exServer &casIn,
|
||||
const casCtx &ctxIn, bool scanOnIn) :
|
||||
casAsyncPVAttachIO(ctxIn), exOSITimer(0.00001),
|
||||
pvi(pviIn), cas(casIn), scanOn(scanOnIn) {}
|
||||
|
||||
~exAsyncCreateIO()
|
||||
{
|
||||
this->cas.removeIO();
|
||||
}
|
||||
|
||||
//
|
||||
// expire()
|
||||
// (a virtual function that runs when the base timer expires)
|
||||
// see exServer.cc
|
||||
//
|
||||
void expire();
|
||||
|
||||
const char *name() const;
|
||||
exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
|
||||
const casCtx &ctxIn, bool scanOnIn );
|
||||
~exAsyncCreateIO ();
|
||||
private:
|
||||
pvInfo &pvi;
|
||||
epicsTimer &timer;
|
||||
exServer &cas;
|
||||
bool scanOn;
|
||||
expireStatus expire ();
|
||||
};
|
||||
|
||||
//
|
||||
// exServer::removeAliasName()
|
||||
//
|
||||
inline void exServer::removeAliasName(pvEntry &entry)
|
||||
inline void exServer::removeAliasName ( pvEntry &entry )
|
||||
{
|
||||
pvEntry *pE;
|
||||
pE = this->stringResTbl.remove(entry);
|
||||
assert(pE = &entry);
|
||||
pE = this->stringResTbl.remove ( entry );
|
||||
assert ( pE == &entry );
|
||||
}
|
||||
|
||||
//
|
||||
@@ -563,7 +463,7 @@ inline void exServer::removeAliasName(pvEntry &entry)
|
||||
//
|
||||
inline pvEntry::~pvEntry()
|
||||
{
|
||||
this->cas.removeAliasName(*this);
|
||||
this->cas.removeAliasName ( *this );
|
||||
}
|
||||
|
||||
//
|
||||
@@ -571,28 +471,20 @@ inline pvEntry::~pvEntry()
|
||||
//
|
||||
inline void pvEntry::destroy ()
|
||||
{
|
||||
//
|
||||
// always created with new (in this example)
|
||||
//
|
||||
delete this;
|
||||
}
|
||||
|
||||
inline pvInfo::~pvInfo ()
|
||||
{
|
||||
//
|
||||
// dont leak pre created PVs when we exit
|
||||
//
|
||||
if (this->pPV!=NULL) {
|
||||
//
|
||||
// always created with new (in this example)
|
||||
//
|
||||
if ( this->pPV != NULL ) {
|
||||
delete this->pPV;
|
||||
}
|
||||
}
|
||||
|
||||
inline void pvInfo::deletePV ()
|
||||
{
|
||||
if (this->pPV!=NULL) {
|
||||
if ( this->pPV != NULL ) {
|
||||
delete this->pPV;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,14 @@ extern int main (int argc, const char **argv)
|
||||
scanOn = false;
|
||||
}
|
||||
|
||||
pCAS = new exServer (pvPrefix, aliasCount, scanOn);
|
||||
if (!pCAS) {
|
||||
pCAS = new exServer ( pvPrefix, aliasCount, scanOn );
|
||||
if ( ! pCAS ) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
pCAS->setDebugLevel(debugLevel);
|
||||
|
||||
if (forever) {
|
||||
if ( forever ) {
|
||||
//
|
||||
// loop here forever
|
||||
//
|
||||
@@ -72,8 +72,8 @@ extern int main (int argc, const char **argv)
|
||||
// loop here untill the specified execution time
|
||||
// expires
|
||||
//
|
||||
while (delay < executionTime) {
|
||||
fileDescriptorManager.process(delay);
|
||||
while ( delay < executionTime ) {
|
||||
fileDescriptorManager.process ( delay );
|
||||
delay = epicsTime::getCurrent() - begin;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user