diff --git a/src/cas/example/simple/exAsyncPV.cc b/src/cas/example/simple/exAsyncPV.cc index c51bbbe6e..f8fb9228c 100644 --- a/src/cas/example/simple/exAsyncPV.cc +++ b/src/cas/example/simple/exAsyncPV.cc @@ -25,7 +25,7 @@ caStatus exAsyncPV::read (const casCtx &ctx, gdd &valueIn) return S_casApp_noMemory; } - return S_casApp_asyncCompletion; + return S_casApp_asyncCompletion; } // @@ -73,7 +73,7 @@ const char *exAsyncWriteIO::name() const // exAsyncReadIO::expire() // (a virtual function that runs when the base timer expires) // -void exAsyncReadIO::expire() +void exAsyncReadIO::expire () { caStatus status; @@ -81,12 +81,12 @@ void exAsyncReadIO::expire() // map between the prototype in and the // current value // - status = exServer::read(this->pv, this->proto); + status = this->pv.exPV::readNoCtx (this->proto); // // post IO completion // - this->postIOCompletion(status, this->proto); + this->postIOCompletion (status, this->proto); } // diff --git a/src/cas/example/simple/exPV.cc b/src/cas/example/simple/exPV.cc index 94b283306..f77172b40 100644 --- a/src/cas/example/simple/exPV.cc +++ b/src/cas/example/simple/exPV.cc @@ -5,6 +5,11 @@ #include "exServer.h" #include "gddApps.h" +// +// static data for exPV +// +char exPV::hasBeenInitialized = 0; +gddAppFuncTable exPV::ft; osiTime exPV::currentTime; // @@ -223,6 +228,35 @@ void exPV::show(unsigned level) const } } +// +// exPV::initFT() +// +void exPV::initFT() +{ + if (exPV::hasBeenInitialized) { + return; + } + + exPV::ft.installReadFunc ("status", &exPV::getStatus); + exPV::ft.installReadFunc ("severity", &exPV::getSeverity); + exPV::ft.installReadFunc ("seconds", &exPV::getSeconds); + exPV::ft.installReadFunc ("nanoseconds", &exPV::getNanoseconds); + exPV::ft.installReadFunc ("precision", &exPV::getPrecision); + exPV::ft.installReadFunc ("graphicHigh", &exPV::getHighLimit); + exPV::ft.installReadFunc ("graphicLow", &exPV::getLowLimit); + exPV::ft.installReadFunc ("controlHigh", &exPV::getHighLimit); + exPV::ft.installReadFunc ("controlLow", &exPV::getLowLimit); + exPV::ft.installReadFunc ("alarmHigh", &exPV::getHighLimit); + exPV::ft.installReadFunc ("alarmLow", &exPV::getLowLimit); + exPV::ft.installReadFunc ("alarmHighWarning", &exPV::getHighLimit); + exPV::ft.installReadFunc ("alarmLowWarning", &exPV::getLowLimit); + exPV::ft.installReadFunc ("units", &exPV::getUnits); + exPV::ft.installReadFunc ("value", &exPV::getValue); + exPV::ft.installReadFunc ("enums", &exPV::getEnums); + + exPV::hasBeenInitialized = 1; +} + // // exPV::getStatus() // @@ -400,6 +434,6 @@ caStatus exPV::write (const casCtx &, gdd &valueIn) // caStatus exPV::read (const casCtx &, gdd &protoIn) { - return exServer::read(*this, protoIn); + return this->ft.read (*this, protoIn); } diff --git a/src/cas/example/simple/exServer.cc b/src/cas/example/simple/exServer.cc index 021629c52..abe7ed544 100644 --- a/src/cas/example/simple/exServer.cc +++ b/src/cas/example/simple/exServer.cc @@ -24,11 +24,6 @@ template class resTable ; #endif -// -// static data for exServer -// -gddAppFuncTable exServer::ft; - // // static list of pre-created PVs // @@ -64,22 +59,7 @@ exServer::exServer(const char * const pvPrefix, unsigned aliasCount, aitBool sca const char * const pNameFmtStr = "%.100s%.20s"; const char * const pAliasFmtStr = "%.100s%.20s%u"; - exServer::ft.installReadFunc ("status", &exPV::getStatus); - exServer::ft.installReadFunc ("severity", &exPV::getSeverity); - exServer::ft.installReadFunc ("seconds", &exPV::getSeconds); - exServer::ft.installReadFunc ("nanoseconds", &exPV::getNanoseconds); - exServer::ft.installReadFunc ("precision", &exPV::getPrecision); - exServer::ft.installReadFunc ("graphicHigh", &exPV::getHighLimit); - exServer::ft.installReadFunc ("graphicLow", &exPV::getLowLimit); - exServer::ft.installReadFunc ("controlHigh", &exPV::getHighLimit); - exServer::ft.installReadFunc ("controlLow", &exPV::getLowLimit); - exServer::ft.installReadFunc ("alarmHigh", &exPV::getHighLimit); - exServer::ft.installReadFunc ("alarmLow", &exPV::getLowLimit); - exServer::ft.installReadFunc ("alarmHighWarning", &exPV::getHighLimit); - exServer::ft.installReadFunc ("alarmLowWarning", &exPV::getLowLimit); - exServer::ft.installReadFunc ("units", &exPV::getUnits); - exServer::ft.installReadFunc ("value", &exPV::getValue); - exServer::ft.installReadFunc ("enums", &exPV::getEnums); + exPV::initFT(); // // hash table size may need adjustment here? diff --git a/src/cas/example/simple/exServer.h b/src/cas/example/simple/exServer.h index e82e38015..766d9658e 100644 --- a/src/cas/example/simple/exServer.h +++ b/src/cas/example/simple/exServer.h @@ -185,20 +185,6 @@ public: // Gets called when we add noise to the current value // virtual void scan() = 0; - - // - // Std PV Attribute fetch support - // - gddAppFuncTableStatus getStatus(gdd &value); - gddAppFuncTableStatus getSeverity(gdd &value); - gddAppFuncTableStatus getSeconds(gdd &value); - gddAppFuncTableStatus getNanoseconds(gdd &value); - gddAppFuncTableStatus getPrecision(gdd &value); - gddAppFuncTableStatus getHighLimit(gdd &value); - gddAppFuncTableStatus getLowLimit(gdd &value); - gddAppFuncTableStatus getUnits(gdd &value); - gddAppFuncTableStatus getValue(gdd &value); - gddAppFuncTableStatus getEnums(gdd &value); // // @@ -222,7 +208,12 @@ public: caStatus read (const casCtx &, gdd &protoIn); - caStatus write (const casCtx &, gdd &protoIn); + caStatus readNoCtx (gdd &protoIn) + { + return this->ft.read (*this, protoIn); + } + + caStatus write (const casCtx &, gdd &value); void destroy(); @@ -236,6 +227,8 @@ public: return this->info.getName(); } + static void initFT(); + protected: gdd *pValue; exScanTimer *pScanTimer; @@ -246,6 +239,27 @@ protected: static osiTime currentTime; virtual caStatus updateValue (gdd &value) = 0; + +private: + // + // Std PV Attribute fetch support + // + gddAppFuncTableStatus getStatus(gdd &value); + gddAppFuncTableStatus getSeverity(gdd &value); + gddAppFuncTableStatus getSeconds(gdd &value); + gddAppFuncTableStatus getNanoseconds(gdd &value); + gddAppFuncTableStatus getPrecision(gdd &value); + gddAppFuncTableStatus getHighLimit(gdd &value); + gddAppFuncTableStatus getLowLimit(gdd &value); + gddAppFuncTableStatus getUnits(gdd &value); + gddAppFuncTableStatus getValue(gdd &value); + gddAppFuncTableStatus getEnums(gdd &value); + + // + // static + // + static gddAppFuncTable ft; + static char hasBeenInitialized; }; // @@ -292,11 +306,6 @@ public: void installAliasName(pvInfo &info, const char *pAliasName); inline void removeAliasName(pvEntry &entry); - static gddAppFuncTableStatus read(exPV &pv, gdd &value) - { - return exServer::ft.read(pv, value); - } - // // removeIO // @@ -325,8 +334,6 @@ private: // static pvInfo bill; static pvInfo billy; - - static gddAppFuncTable ft; }; // @@ -345,12 +352,12 @@ public: // // read // - caStatus read(const casCtx &ctxIn, gdd &value); + caStatus read (const casCtx &ctxIn, gdd &protoIn); // // write // - caStatus write(const casCtx &ctxIn, gdd &value); + caStatus write (const casCtx &ctxIn, gdd &value); // // removeIO