adjustable asyn delay, adjustable max simult io, added variables
This commit is contained in:
@@ -39,16 +39,20 @@ const unsigned exServer::pvListNElem = NELEMENTS (exServer::pvList);
|
||||
// static on-the-fly PVs
|
||||
//
|
||||
pvInfo exServer::billy (-1.0, "billybob", 10.0f, -10.0f, aitEnumFloat64, excasIoAsync, 1u);
|
||||
pvInfo exServer::bloaty (-1.0, "bloaty", 10.0f, -10.0f, aitEnumFloat64, excasIoSync, 100000u);
|
||||
pvInfo exServer::bloater (.010, "bloater", 10.0f, -10.0f, aitEnumFloat64, excasIoSync, 10000u);
|
||||
pvInfo exServer::bloaty (.010, "bloaty", 10.0f, -10.0f, aitEnumFloat64, excasIoSync, 100000u);
|
||||
|
||||
|
||||
//
|
||||
// exServer::exServer()
|
||||
//
|
||||
exServer::exServer ( const char * const pvPrefix,
|
||||
unsigned aliasCount, bool scanOnIn,
|
||||
bool asyncScan ) :
|
||||
pTimerQueue ( 0 ), simultAsychIOCount ( 0u ),
|
||||
scanOn ( scanOnIn )
|
||||
bool asyncScan, double asyncDelayIn,
|
||||
unsigned maxSimultAsyncIOIn ) :
|
||||
pTimerQueue ( 0 ), simultAsychIOCount ( 0u ),
|
||||
_maxSimultAsyncIO ( maxSimultAsyncIOIn ),
|
||||
asyncDelay ( asyncDelayIn ), scanOn ( scanOnIn )
|
||||
{
|
||||
unsigned i;
|
||||
exPV *pPV;
|
||||
@@ -74,7 +78,7 @@ exServer::exServer ( const char * const pvPrefix,
|
||||
// pre-create all of the simple PVs that this server will export
|
||||
//
|
||||
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
|
||||
pPV = pPVI->createPV (*this, true, scanOnIn);
|
||||
pPV = pPVI->createPV (*this, true, scanOnIn, this->asyncDelay );
|
||||
if (!pPV) {
|
||||
fprintf(stderr, "Unable to create new PV \"%s\"\n",
|
||||
pPVI->getName());
|
||||
@@ -103,6 +107,8 @@ exServer::exServer ( const char * const pvPrefix,
|
||||
//
|
||||
sprintf ( pvAlias, pNameFmtStr, pvPrefix, billy.getName() );
|
||||
this->installAliasName ( billy, pvAlias );
|
||||
sprintf ( pvAlias, pNameFmtStr, pvPrefix, bloater.getName() );
|
||||
this->installAliasName ( bloater, pvAlias );
|
||||
sprintf ( pvAlias, pNameFmtStr, pvPrefix, bloaty.getName() );
|
||||
this->installAliasName ( bloaty, pvAlias );
|
||||
}
|
||||
@@ -187,7 +193,7 @@ pvExistReturn exServer::pvExistTest // X aCC 361
|
||||
return pverExistsHere;
|
||||
}
|
||||
else {
|
||||
if ( this->simultAsychIOCount >= maxSimultAsyncIO ) {
|
||||
if ( this->simultAsychIOCount >= this->_maxSimultAsyncIO ) {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
|
||||
@@ -228,7 +234,7 @@ pvAttachReturn exServer::pvAttach // X aCC 361
|
||||
// If this is a synchronous PV create the PV now
|
||||
//
|
||||
if (pvi.getIOType() == excasIoSync) {
|
||||
pPV = pvi.createPV(*this, false, this->scanOn);
|
||||
pPV = pvi.createPV(*this, false, this->scanOn, this->asyncDelay );
|
||||
if (pPV) {
|
||||
return *pPV;
|
||||
}
|
||||
@@ -240,14 +246,15 @@ pvAttachReturn exServer::pvAttach // X aCC 361
|
||||
// Initiate async IO if this is an async PV
|
||||
//
|
||||
else {
|
||||
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
|
||||
if (this->simultAsychIOCount>=this->_maxSimultAsyncIO) {
|
||||
return S_casApp_postponeAsyncIO;
|
||||
}
|
||||
|
||||
this->simultAsychIOCount++;
|
||||
|
||||
exAsyncCreateIO *pIO =
|
||||
new exAsyncCreateIO(pvi, *this, ctx, this->scanOn);
|
||||
new exAsyncCreateIO ( pvi, *this, ctx,
|
||||
this->scanOn, this->asyncDelay );
|
||||
if (pIO) {
|
||||
return S_casApp_asyncCompletion;
|
||||
}
|
||||
@@ -281,8 +288,8 @@ class epicsTimer & exServer::createTimer ()
|
||||
//
|
||||
// pvInfo::createPV()
|
||||
//
|
||||
exPV *pvInfo::createPV ( exServer & cas,
|
||||
bool preCreateFlag, bool scanOn )
|
||||
exPV *pvInfo::createPV ( exServer & cas, bool preCreateFlag,
|
||||
bool scanOn, double asyncDelay )
|
||||
{
|
||||
if (this->pPV) {
|
||||
return this->pPV;
|
||||
@@ -301,7 +308,8 @@ exPV *pvInfo::createPV ( exServer & cas,
|
||||
pNewPV = new exScalarPV ( cas, *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
case excasIoAsync:
|
||||
pNewPV = new exAsyncPV ( cas, *this, preCreateFlag, scanOn );
|
||||
pNewPV = new exAsyncPV ( cas, *this,
|
||||
preCreateFlag, scanOn, asyncDelay );
|
||||
break;
|
||||
default:
|
||||
pNewPV = NULL;
|
||||
@@ -388,11 +396,12 @@ epicsTimerNotify::expireStatus exAsyncExistIO::expire ( const epicsTime & /*curr
|
||||
//
|
||||
// exAsyncCreateIO::exAsyncCreateIO()
|
||||
//
|
||||
exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
|
||||
const casCtx &ctxIn, bool scanOnIn ) :
|
||||
exAsyncCreateIO ::
|
||||
exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
|
||||
const casCtx &ctxIn, bool scanOnIn, double asyncDelayIn ) :
|
||||
casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ),
|
||||
timer ( casIn.createTimer () ),
|
||||
cas ( casIn ), scanOn ( scanOnIn )
|
||||
cas ( casIn ), scanOn ( scanOnIn ), asyncDelay ( asyncDelayIn )
|
||||
{
|
||||
this->timer.start ( *this, 0.00001 );
|
||||
}
|
||||
@@ -412,9 +421,8 @@ exAsyncCreateIO::~exAsyncCreateIO()
|
||||
//
|
||||
epicsTimerNotify::expireStatus exAsyncCreateIO::expire ( const epicsTime & /*currentTime*/ )
|
||||
{
|
||||
exPV *pPV;
|
||||
|
||||
pPV = this->pvi.createPV ( this->cas, false, this->scanOn );
|
||||
exPV * pPV = this->pvi.createPV ( this->cas, false,
|
||||
this->scanOn, this->asyncDelay );
|
||||
if ( pPV ) {
|
||||
this->postIOCompletion ( pvAttachReturn ( *pPV ) );
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@
|
||||
# define NELEMENTS(A) (sizeof(A)/sizeof(A[0]))
|
||||
#endif
|
||||
|
||||
#define maxSimultAsyncIO 1000u
|
||||
|
||||
//
|
||||
// info about all pv in this server
|
||||
//
|
||||
@@ -62,28 +60,27 @@ class exPV;
|
||||
class exServer;
|
||||
|
||||
//
|
||||
// pvInfo
|
||||
//
|
||||
// pvInfo
|
||||
//
|
||||
class pvInfo {
|
||||
public:
|
||||
pvInfo ( double scanPeriodIn, const char *pNameIn,
|
||||
aitFloat32 hoprIn, aitFloat32 loprIn,
|
||||
aitEnum typeIn, excasIoType ioTypeIn,
|
||||
unsigned countIn );
|
||||
pvInfo ( const pvInfo & copyIn );
|
||||
public:
|
||||
|
||||
pvInfo ( double scanPeriodIn, const char * pNameIn,
|
||||
aitFloat32 hoprIn, aitFloat32 loprIn, aitEnum typeIn,
|
||||
excasIoType ioTypeIn, unsigned countIn );
|
||||
pvInfo ( const pvInfo & copyIn );
|
||||
~pvInfo ();
|
||||
double getScanPeriod () const;
|
||||
const char *getName () const;
|
||||
double getHopr () const;
|
||||
double getLopr () const;
|
||||
aitEnum getType () const;
|
||||
excasIoType getIOType () const;
|
||||
unsigned getElementCount () const;
|
||||
void unlinkPV ();
|
||||
exPV *createPV ( exServer & exCAS,
|
||||
bool preCreateFlag, bool scanOn );
|
||||
double getScanPeriod () const;
|
||||
const char * getName ()
|
||||
const; double getHopr () const;
|
||||
double getLopr () const;
|
||||
aitEnum getType () const;
|
||||
excasIoType getIOType () const;
|
||||
unsigned getElementCount () const;
|
||||
void unlinkPV ();
|
||||
exPV *createPV ( exServer & exCAS, bool preCreateFlag,
|
||||
bool scanOn, double asyncDelay );
|
||||
void deletePV ();
|
||||
|
||||
private:
|
||||
const double scanPeriod;
|
||||
const char * pName;
|
||||
@@ -277,7 +274,8 @@ class exServer : private caServer {
|
||||
public:
|
||||
exServer ( const char * const pvPrefix,
|
||||
unsigned aliasCount, bool scanOn,
|
||||
bool asyncScan );
|
||||
bool asyncScan, double asyncDelay,
|
||||
unsigned maxSimultAsyncIO );
|
||||
~exServer ();
|
||||
void show ( unsigned level ) const;
|
||||
void removeIO ();
|
||||
@@ -287,11 +285,15 @@ public:
|
||||
void setDebugLevel ( unsigned level );
|
||||
|
||||
void destroyAllPV ();
|
||||
|
||||
unsigned maxSimultAsyncIO () const;
|
||||
|
||||
private:
|
||||
resTable < pvEntry, stringId > stringResTbl;
|
||||
epicsTimerQueueActive * pTimerQueue;
|
||||
unsigned simultAsychIOCount;
|
||||
const unsigned _maxSimultAsyncIO;
|
||||
double asyncDelay;
|
||||
bool scanOn;
|
||||
|
||||
void installAliasName ( pvInfo & info, const char * pAliasName );
|
||||
@@ -310,12 +312,13 @@ private:
|
||||
//
|
||||
static pvInfo pvList[];
|
||||
static const unsigned pvListNElem;
|
||||
|
||||
|
||||
//
|
||||
// on-the-fly PVs
|
||||
//
|
||||
static pvInfo bill;
|
||||
static pvInfo billy;
|
||||
static pvInfo bloater;
|
||||
static pvInfo bloaty;
|
||||
static pvInfo boot;
|
||||
static pvInfo booty;
|
||||
@@ -327,11 +330,12 @@ private:
|
||||
class exAsyncPV : public exScalarPV {
|
||||
public:
|
||||
exAsyncPV ( exServer & cas, pvInfo &setup,
|
||||
bool preCreateFlag, bool scanOnIn );
|
||||
bool preCreateFlag, bool scanOnIn, double asyncDelay );
|
||||
caStatus read ( const casCtx & ctxIn, gdd & protoIn );
|
||||
caStatus write ( const casCtx & ctxIn, const gdd & value );
|
||||
void removeIO();
|
||||
private:
|
||||
double asyncDelay;
|
||||
unsigned simultAsychIOCount;
|
||||
exAsyncPV & operator = ( const exAsyncPV & );
|
||||
exAsyncPV ( const exAsyncPV & );
|
||||
@@ -357,7 +361,8 @@ private:
|
||||
//
|
||||
class exAsyncWriteIO : public casAsyncWriteIO, public epicsTimerNotify {
|
||||
public:
|
||||
exAsyncWriteIO ( exServer &, const casCtx & ctxIn, exAsyncPV &, const gdd & );
|
||||
exAsyncWriteIO ( exServer &, const casCtx & ctxIn,
|
||||
exAsyncPV &, const gdd &, double asyncDelay );
|
||||
~exAsyncWriteIO ();
|
||||
private:
|
||||
exAsyncPV & pv;
|
||||
@@ -373,7 +378,8 @@ private:
|
||||
//
|
||||
class exAsyncReadIO : public casAsyncReadIO, public epicsTimerNotify {
|
||||
public:
|
||||
exAsyncReadIO ( exServer &, const casCtx &, exAsyncPV &, gdd & );
|
||||
exAsyncReadIO ( exServer &, const casCtx &,
|
||||
exAsyncPV &, gdd &, double asyncDelay );
|
||||
virtual ~exAsyncReadIO ();
|
||||
private:
|
||||
exAsyncPV & pv;
|
||||
@@ -410,12 +416,13 @@ private:
|
||||
class exAsyncCreateIO : public casAsyncPVAttachIO, public epicsTimerNotify {
|
||||
public:
|
||||
exAsyncCreateIO ( pvInfo & pviIn, exServer & casIn,
|
||||
const casCtx & ctxIn, bool scanOnIn );
|
||||
const casCtx & ctxIn, bool scanOnIn, double asyncDelay );
|
||||
virtual ~exAsyncCreateIO ();
|
||||
private:
|
||||
pvInfo & pvi;
|
||||
epicsTimer & timer;
|
||||
exServer & cas;
|
||||
double asyncDelay;
|
||||
bool scanOn;
|
||||
expireStatus expire ( const epicsTime & currentTime );
|
||||
exAsyncCreateIO & operator = ( const exAsyncCreateIO & );
|
||||
@@ -566,10 +573,17 @@ inline void exServer::removeIO()
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned exServer :: maxSimultAsyncIO () const
|
||||
{
|
||||
return this->_maxSimultAsyncIO;
|
||||
}
|
||||
|
||||
inline exAsyncPV::exAsyncPV ( exServer & cas, pvInfo & setup,
|
||||
bool preCreateFlag, bool scanOnIn ) :
|
||||
bool preCreateFlag, bool scanOnIn,
|
||||
double asyncDelayIn ) :
|
||||
asyncDelay ( asyncDelayIn ),
|
||||
exScalarPV ( cas, setup, preCreateFlag, scanOnIn ),
|
||||
simultAsychIOCount ( 0u )
|
||||
simultAsychIOCount ( 0u )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,14 @@ extern int main ( int argc, const char **argv )
|
||||
exServer *pCAS;
|
||||
unsigned debugLevel = 0u;
|
||||
double executionTime = 0.0;
|
||||
double asyncDelay = 0.1;
|
||||
char pvPrefix[128] = "";
|
||||
unsigned aliasCount = 1u;
|
||||
unsigned scanOn = true;
|
||||
unsigned syncScan = true;
|
||||
char arraySize[64] = "";
|
||||
bool forever = true;
|
||||
unsigned maxSimultAsyncIO = 1000u;
|
||||
int i;
|
||||
|
||||
i = 1;
|
||||
@@ -77,6 +79,18 @@ extern int main ( int argc, const char **argv )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( strcmp ( argv[i],"-ad" ) == 0 ) {
|
||||
if ( i+1 < argc && sscanf ( argv[i+1], "%lf", & asyncDelay ) == 1 ) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( strcmp ( argv[i],"-an" ) == 0 ) {
|
||||
if ( i+1 < argc && sscanf ( argv[i+1], "%u", & maxSimultAsyncIO ) == 1 ) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
printf ( "\"%s\"?\n", argv[i] );
|
||||
if ( i + 1 < argc ) {
|
||||
printf ( "\"%s\"?\n", argv[i+1] );
|
||||
@@ -85,7 +99,8 @@ extern int main ( int argc, const char **argv )
|
||||
"usage: %s [-d <debug level> -t <execution time> -p <PV name prefix> "
|
||||
"-c <numbered alias count> -s <1=scan on (default), 0=scan off> "
|
||||
"-ss <1=synchronous scan (default), 0=asynchronous scan> "
|
||||
"-a <max array size>\n",
|
||||
"-a <max array size> -ad <async delay>"
|
||||
"-an <max simultaneous async>\n",
|
||||
argv[0]);
|
||||
|
||||
return (1);
|
||||
@@ -97,7 +112,8 @@ extern int main ( int argc, const char **argv )
|
||||
|
||||
try {
|
||||
pCAS = new exServer ( pvPrefix, aliasCount,
|
||||
scanOn != 0, syncScan == 0 );
|
||||
scanOn != 0, syncScan == 0, asyncDelay,
|
||||
maxSimultAsyncIO );
|
||||
}
|
||||
catch ( ... ) {
|
||||
errlogPrintf ( "Server initialization error\n" );
|
||||
|
||||
Reference in New Issue
Block a user