removed tabs
This commit is contained in:
+223
-223
@@ -13,27 +13,27 @@
|
||||
// template member functions
|
||||
//
|
||||
#if defined(EXPL_TEMPL)
|
||||
//
|
||||
// From Stroustrups's "The C++ Programming Language"
|
||||
// Appendix A: r.14.9
|
||||
//
|
||||
// This explicitly instantiates the template class's
|
||||
// member functions into "templInst.o"
|
||||
//
|
||||
template class gddAppFuncTable <exPV>;
|
||||
template class resTable <pvEntry,stringId>;
|
||||
//
|
||||
// From Stroustrups's "The C++ Programming Language"
|
||||
// Appendix A: r.14.9
|
||||
//
|
||||
// This explicitly instantiates the template class's
|
||||
// member functions into "templInst.o"
|
||||
//
|
||||
template class gddAppFuncTable <exPV>;
|
||||
template class resTable <pvEntry,stringId>;
|
||||
#endif
|
||||
|
||||
//
|
||||
// static list of pre-created PVs
|
||||
//
|
||||
pvInfo exServer::pvList[] = {
|
||||
pvInfo (1.0e-1, "jane", 10.0f, 0.0f, excasIoSync, 1u),
|
||||
pvInfo (2.0, "fred", 10.0f, -10.0f, excasIoSync, 1u),
|
||||
pvInfo (1.0e-1, "janet", 10.0f, 0.0f, excasIoAsync, 1u),
|
||||
pvInfo (2.0, "freddy", 10.0f, -10.0f, excasIoAsync, 1u),
|
||||
pvInfo (2.0, "alan", 10.0f, -10.0f, excasIoSync, 100u),
|
||||
pvInfo (20.0, "albert", 10.0f, -10.0f, excasIoSync, 1000u)
|
||||
pvInfo (1.0e-1, "jane", 10.0f, 0.0f, excasIoSync, 1u),
|
||||
pvInfo (2.0, "fred", 10.0f, -10.0f, excasIoSync, 1u),
|
||||
pvInfo (1.0e-1, "janet", 10.0f, 0.0f, excasIoAsync, 1u),
|
||||
pvInfo (2.0, "freddy", 10.0f, -10.0f, excasIoAsync, 1u),
|
||||
pvInfo (2.0, "alan", 10.0f, -10.0f, excasIoSync, 100u),
|
||||
pvInfo (20.0, "albert", 10.0f, -10.0f, excasIoSync, 1000u)
|
||||
};
|
||||
|
||||
const unsigned exServer::pvListNElem = NELEMENTS (exServer::pvList);
|
||||
@@ -49,56 +49,56 @@ pvInfo exServer::billy (-1.0, "billy", 10.0f, -10.0f, excasIoAsync, 1u);
|
||||
//
|
||||
exServer::exServer ( const char * const pvPrefix,
|
||||
unsigned aliasCount, bool scanOnIn ) :
|
||||
caServer (pvListNElem+2u),
|
||||
caServer (pvListNElem+2u),
|
||||
stringResTbl (pvListNElem*(aliasCount+1u)+2u),
|
||||
simultAsychIOCount (0u),
|
||||
scanOn (scanOnIn)
|
||||
simultAsychIOCount (0u),
|
||||
scanOn (scanOnIn)
|
||||
{
|
||||
unsigned i;
|
||||
exPV *pPV;
|
||||
pvInfo *pPVI;
|
||||
pvInfo *pPVAfter = &exServer::pvList[pvListNElem];
|
||||
char pvAlias[256];
|
||||
const char * const pNameFmtStr = "%.100s%.20s";
|
||||
const char * const pAliasFmtStr = "%.100s%.20s%u";
|
||||
unsigned i;
|
||||
exPV *pPV;
|
||||
pvInfo *pPVI;
|
||||
pvInfo *pPVAfter = &exServer::pvList[pvListNElem];
|
||||
char pvAlias[256];
|
||||
const char * const pNameFmtStr = "%.100s%.20s";
|
||||
const char * const pAliasFmtStr = "%.100s%.20s%u";
|
||||
|
||||
exPV::initFT();
|
||||
exPV::initFT();
|
||||
|
||||
//
|
||||
// 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);
|
||||
if (!pPV) {
|
||||
fprintf(stderr, "Unable to create new PV \"%s\"\n",
|
||||
pPVI->getName());
|
||||
}
|
||||
//
|
||||
// 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);
|
||||
if (!pPV) {
|
||||
fprintf(stderr, "Unable to create new PV \"%s\"\n",
|
||||
pPVI->getName());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Install canonical (root) name
|
||||
//
|
||||
sprintf(pvAlias, pNameFmtStr, pvPrefix, pPVI->getName());
|
||||
this->installAliasName(*pPVI, pvAlias);
|
||||
//
|
||||
// Install canonical (root) name
|
||||
//
|
||||
sprintf(pvAlias, pNameFmtStr, pvPrefix, pPVI->getName());
|
||||
this->installAliasName(*pPVI, pvAlias);
|
||||
|
||||
//
|
||||
// Install numbered alias names
|
||||
//
|
||||
for (i=0u; i<aliasCount; i++) {
|
||||
sprintf(pvAlias, pAliasFmtStr, pvPrefix,
|
||||
pPVI->getName(), i);
|
||||
this->installAliasName(*pPVI, pvAlias);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Install numbered alias names
|
||||
//
|
||||
for (i=0u; i<aliasCount; i++) {
|
||||
sprintf(pvAlias, pAliasFmtStr, pvPrefix,
|
||||
pPVI->getName(), i);
|
||||
this->installAliasName(*pPVI, pvAlias);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Install create on-the-fly PVs
|
||||
// into the PV name hash table
|
||||
//
|
||||
sprintf(pvAlias, pNameFmtStr, pvPrefix, bill.getName());
|
||||
this->installAliasName(bill, pvAlias);
|
||||
sprintf(pvAlias, pNameFmtStr, pvPrefix, billy.getName());
|
||||
this->installAliasName(billy, pvAlias);
|
||||
//
|
||||
// Install create on-the-fly PVs
|
||||
// into the PV name hash table
|
||||
//
|
||||
sprintf(pvAlias, pNameFmtStr, pvPrefix, bill.getName());
|
||||
this->installAliasName(bill, pvAlias);
|
||||
sprintf(pvAlias, pNameFmtStr, pvPrefix, billy.getName());
|
||||
this->installAliasName(billy, pvAlias);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -106,16 +106,16 @@ exServer::exServer ( const char * const pvPrefix,
|
||||
//
|
||||
exServer::~exServer()
|
||||
{
|
||||
pvInfo *pPVI;
|
||||
pvInfo *pPVAfter =
|
||||
&exServer::pvList[NELEMENTS(exServer::pvList)];
|
||||
pvInfo *pPVI;
|
||||
pvInfo *pPVAfter =
|
||||
&exServer::pvList[NELEMENTS(exServer::pvList)];
|
||||
|
||||
//
|
||||
// delete all pre-created PVs (eliminate bounds-checker warnings)
|
||||
//
|
||||
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
|
||||
pPVI->deletePV ();
|
||||
}
|
||||
//
|
||||
// delete all pre-created PVs (eliminate bounds-checker warnings)
|
||||
//
|
||||
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
|
||||
pPVI->deletePV ();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -123,121 +123,121 @@ exServer::~exServer()
|
||||
//
|
||||
void exServer::installAliasName(pvInfo &info, const char *pAliasName)
|
||||
{
|
||||
pvEntry *pEntry;
|
||||
pvEntry *pEntry;
|
||||
|
||||
pEntry = new pvEntry(info, *this, pAliasName);
|
||||
if (pEntry) {
|
||||
int resLibStatus;
|
||||
resLibStatus = this->stringResTbl.add(*pEntry);
|
||||
if (resLibStatus==0) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
delete pEntry;
|
||||
}
|
||||
}
|
||||
fprintf(stderr,
|
||||
pEntry = new pvEntry(info, *this, pAliasName);
|
||||
if (pEntry) {
|
||||
int resLibStatus;
|
||||
resLibStatus = this->stringResTbl.add(*pEntry);
|
||||
if (resLibStatus==0) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
delete pEntry;
|
||||
}
|
||||
}
|
||||
fprintf(stderr,
|
||||
"Unable to enter PV=\"%s\" Alias=\"%s\" in PV name alias hash table\n",
|
||||
info.getName(), pAliasName);
|
||||
info.getName(), pAliasName);
|
||||
}
|
||||
|
||||
//
|
||||
// exServer::pvExistTest()
|
||||
//
|
||||
pvExistReturn exServer::pvExistTest
|
||||
(const casCtx& ctxIn, const char *pPVName)
|
||||
(const casCtx& ctxIn, const char *pPVName)
|
||||
{
|
||||
//
|
||||
// lifetime of id is shorter than lifetime of pName
|
||||
//
|
||||
stringId id(pPVName, stringId::refString);
|
||||
pvEntry *pPVE;
|
||||
//
|
||||
// lifetime of id is shorter than lifetime of pName
|
||||
//
|
||||
stringId id(pPVName, stringId::refString);
|
||||
pvEntry *pPVE;
|
||||
|
||||
//
|
||||
// Look in hash table for PV name (or PV alias name)
|
||||
//
|
||||
pPVE = this->stringResTbl.lookup(id);
|
||||
if (!pPVE) {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
//
|
||||
// Look in hash table for PV name (or PV alias name)
|
||||
//
|
||||
pPVE = this->stringResTbl.lookup(id);
|
||||
if (!pPVE) {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
|
||||
pvInfo &pvi = pPVE->getInfo();
|
||||
pvInfo &pvi = pPVE->getInfo();
|
||||
|
||||
//
|
||||
// Initiate async IO if this is an async PV
|
||||
//
|
||||
if (pvi.getIOType() == excasIoSync) {
|
||||
return pverExistsHere;
|
||||
}
|
||||
else {
|
||||
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
//
|
||||
// Initiate async IO if this is an async PV
|
||||
//
|
||||
if (pvi.getIOType() == excasIoSync) {
|
||||
return pverExistsHere;
|
||||
}
|
||||
else {
|
||||
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
|
||||
this->simultAsychIOCount++;
|
||||
this->simultAsychIOCount++;
|
||||
|
||||
exAsyncExistIO *pIO;
|
||||
pIO = new exAsyncExistIO ( pvi, ctxIn, *this );
|
||||
if (pIO) {
|
||||
return pverAsyncCompletion;
|
||||
}
|
||||
else {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
}
|
||||
exAsyncExistIO *pIO;
|
||||
pIO = new exAsyncExistIO ( pvi, ctxIn, *this );
|
||||
if (pIO) {
|
||||
return pverAsyncCompletion;
|
||||
}
|
||||
else {
|
||||
return pverDoesNotExistHere;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// exServer::pvAttach()
|
||||
//
|
||||
pvAttachReturn exServer::pvAttach
|
||||
(const casCtx &ctx, const char *pName)
|
||||
(const casCtx &ctx, const char *pName)
|
||||
{
|
||||
//
|
||||
// lifetime of id is shorter than lifetime of pName
|
||||
//
|
||||
stringId id(pName, stringId::refString);
|
||||
exPV *pPV;
|
||||
pvEntry *pPVE;
|
||||
//
|
||||
// lifetime of id is shorter than lifetime of pName
|
||||
//
|
||||
stringId id(pName, stringId::refString);
|
||||
exPV *pPV;
|
||||
pvEntry *pPVE;
|
||||
|
||||
pPVE = this->stringResTbl.lookup(id);
|
||||
if (!pPVE) {
|
||||
return S_casApp_pvNotFound;
|
||||
}
|
||||
pPVE = this->stringResTbl.lookup(id);
|
||||
if (!pPVE) {
|
||||
return S_casApp_pvNotFound;
|
||||
}
|
||||
|
||||
pvInfo &pvi = pPVE->getInfo();
|
||||
pvInfo &pvi = pPVE->getInfo();
|
||||
|
||||
//
|
||||
// If this is a synchronous PV create the PV now
|
||||
//
|
||||
if (pvi.getIOType() == excasIoSync) {
|
||||
pPV = pvi.createPV(*this, false, this->scanOn);
|
||||
if (pPV) {
|
||||
return *pPV;
|
||||
}
|
||||
else {
|
||||
return S_casApp_noMemory;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Initiate async IO if this is an async PV
|
||||
//
|
||||
else {
|
||||
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
|
||||
return S_casApp_postponeAsyncIO;
|
||||
}
|
||||
//
|
||||
// If this is a synchronous PV create the PV now
|
||||
//
|
||||
if (pvi.getIOType() == excasIoSync) {
|
||||
pPV = pvi.createPV(*this, false, this->scanOn);
|
||||
if (pPV) {
|
||||
return *pPV;
|
||||
}
|
||||
else {
|
||||
return S_casApp_noMemory;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Initiate async IO if this is an async PV
|
||||
//
|
||||
else {
|
||||
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
|
||||
return S_casApp_postponeAsyncIO;
|
||||
}
|
||||
|
||||
this->simultAsychIOCount++;
|
||||
this->simultAsychIOCount++;
|
||||
|
||||
exAsyncCreateIO *pIO =
|
||||
new exAsyncCreateIO(pvi, *this, ctx, this->scanOn);
|
||||
if (pIO) {
|
||||
return S_casApp_asyncCompletion;
|
||||
}
|
||||
else {
|
||||
return S_casApp_noMemory;
|
||||
}
|
||||
}
|
||||
exAsyncCreateIO *pIO =
|
||||
new exAsyncCreateIO(pvi, *this, ctx, this->scanOn);
|
||||
if (pIO) {
|
||||
return S_casApp_asyncCompletion;
|
||||
}
|
||||
else {
|
||||
return S_casApp_noMemory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -245,54 +245,54 @@ pvAttachReturn exServer::pvAttach
|
||||
//
|
||||
exPV *pvInfo::createPV ( exServer &cas, bool preCreateFlag, bool scanOn )
|
||||
{
|
||||
if (this->pPV) {
|
||||
return this->pPV;
|
||||
}
|
||||
if (this->pPV) {
|
||||
return this->pPV;
|
||||
}
|
||||
|
||||
exPV *pNewPV;
|
||||
exPV *pNewPV;
|
||||
|
||||
//
|
||||
// create an instance of the appropriate class
|
||||
// depending on the io type and the number
|
||||
// of elements
|
||||
//
|
||||
if (this->elementCount==1u) {
|
||||
switch (this->ioType){
|
||||
case excasIoSync:
|
||||
pNewPV = new exScalarPV ( *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
case excasIoAsync:
|
||||
pNewPV = new exAsyncPV ( *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
default:
|
||||
pNewPV = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( this->ioType == excasIoSync ) {
|
||||
pNewPV = new exVectorPV ( *this, preCreateFlag, scanOn );
|
||||
}
|
||||
else {
|
||||
pNewPV = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// load initial value (this is not done in
|
||||
// the constructor because the base class's
|
||||
// pure virtual function would be called)
|
||||
//
|
||||
// We always perform this step even if
|
||||
// scanning is disable so that there will
|
||||
// always be an initial value
|
||||
//
|
||||
if (pNewPV) {
|
||||
this->pPV = pNewPV;
|
||||
pNewPV->scan();
|
||||
}
|
||||
//
|
||||
// create an instance of the appropriate class
|
||||
// depending on the io type and the number
|
||||
// of elements
|
||||
//
|
||||
if (this->elementCount==1u) {
|
||||
switch (this->ioType){
|
||||
case excasIoSync:
|
||||
pNewPV = new exScalarPV ( *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
case excasIoAsync:
|
||||
pNewPV = new exAsyncPV ( *this, preCreateFlag, scanOn );
|
||||
break;
|
||||
default:
|
||||
pNewPV = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( this->ioType == excasIoSync ) {
|
||||
pNewPV = new exVectorPV ( *this, preCreateFlag, scanOn );
|
||||
}
|
||||
else {
|
||||
pNewPV = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// load initial value (this is not done in
|
||||
// the constructor because the base class's
|
||||
// pure virtual function would be called)
|
||||
//
|
||||
// We always perform this step even if
|
||||
// scanning is disable so that there will
|
||||
// always be an initial value
|
||||
//
|
||||
if (pNewPV) {
|
||||
this->pPV = pNewPV;
|
||||
pNewPV->scan();
|
||||
}
|
||||
|
||||
return pNewPV;
|
||||
return pNewPV;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -300,24 +300,24 @@ exPV *pvInfo::createPV ( exServer &cas, bool preCreateFlag, bool scanOn )
|
||||
//
|
||||
void exServer::show (unsigned level) const
|
||||
{
|
||||
//
|
||||
// server tool specific show code goes here
|
||||
//
|
||||
this->stringResTbl.show(level);
|
||||
//
|
||||
// server tool specific show code goes here
|
||||
//
|
||||
this->stringResTbl.show(level);
|
||||
|
||||
//
|
||||
// print information about ca server libarary
|
||||
// internals
|
||||
//
|
||||
this->caServer::show(level);
|
||||
//
|
||||
// print information about ca server libarary
|
||||
// internals
|
||||
//
|
||||
this->caServer::show(level);
|
||||
}
|
||||
|
||||
//
|
||||
// exAsyncExistIO::exAsyncExistIO()
|
||||
//
|
||||
exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
|
||||
exServer &casIn ) :
|
||||
casAsyncPVExistIO ( ctxIn ), pvi ( pviIn ),
|
||||
exServer &casIn ) :
|
||||
casAsyncPVExistIO ( ctxIn ), pvi ( pviIn ),
|
||||
timer ( casIn.timerQueue().createTimer ( *this ) ), cas ( casIn )
|
||||
{
|
||||
this->timer.start ( 0.00001 );
|
||||
@@ -328,7 +328,7 @@ exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
|
||||
//
|
||||
exAsyncExistIO::~exAsyncExistIO()
|
||||
{
|
||||
this->cas.removeIO();
|
||||
this->cas.removeIO();
|
||||
delete & this->timer;
|
||||
}
|
||||
|
||||
@@ -350,8 +350,8 @@ epicsTimerNotify::expireStatus exAsyncExistIO::expire ()
|
||||
// exAsyncCreateIO::exAsyncCreateIO()
|
||||
//
|
||||
exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
|
||||
const casCtx &ctxIn, bool scanOnIn ) :
|
||||
casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ),
|
||||
const casCtx &ctxIn, bool scanOnIn ) :
|
||||
casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ),
|
||||
timer ( casIn.timerQueue().createTimer ( *this ) ),
|
||||
cas ( casIn ), scanOn ( scanOnIn )
|
||||
{
|
||||
@@ -363,7 +363,7 @@ exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
|
||||
//
|
||||
exAsyncCreateIO::~exAsyncCreateIO()
|
||||
{
|
||||
this->cas.removeIO ();
|
||||
this->cas.removeIO ();
|
||||
delete & this->timer;
|
||||
}
|
||||
|
||||
@@ -373,15 +373,15 @@ exAsyncCreateIO::~exAsyncCreateIO()
|
||||
//
|
||||
epicsTimerNotify::expireStatus exAsyncCreateIO::expire ()
|
||||
{
|
||||
exPV *pPV;
|
||||
exPV *pPV;
|
||||
|
||||
pPV = this->pvi.createPV ( this->cas, false, this->scanOn );
|
||||
if ( pPV ) {
|
||||
this->postIOCompletion ( pvAttachReturn ( *pPV ) );
|
||||
}
|
||||
else {
|
||||
this->postIOCompletion ( pvAttachReturn ( S_casApp_noMemory ) );
|
||||
}
|
||||
pPV = this->pvi.createPV ( this->cas, false, this->scanOn );
|
||||
if ( pPV ) {
|
||||
this->postIOCompletion ( pvAttachReturn ( *pPV ) );
|
||||
}
|
||||
else {
|
||||
this->postIOCompletion ( pvAttachReturn ( S_casApp_noMemory ) );
|
||||
}
|
||||
return noRestart;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user