diff --git a/src/cas/example/exPV.cc b/src/cas/example/exPV.cc index 0391bfa98..a3736a75d 100644 --- a/src/cas/example/exPV.cc +++ b/src/cas/example/exPV.cc @@ -7,6 +7,8 @@ const double myPI = 3.14159265358979323846; +osiTime exPV::currentTime; + // // exPV::exPV() // @@ -54,7 +56,15 @@ void exPV::scanPV() return; } - pDD = new gddAtomic (gddAppType_value, aitEnumFloat32); + // + // update current time (so we are not required to do + // this every time that we write the PV which impacts + // throughput under sunos4 because gettimeofday() is + // slow) + // + this->currentTime = osiTime::getCurrent(); + + pDD = new gddScaler (gddAppType_value, aitEnumFloat32); if (!pDD) { return; } @@ -72,6 +82,8 @@ void exPV::scanPV() limit = (float) this->info.getLopr(); newValue = max (newValue, limit); *pDD = newValue; + pDD->setStat (epicsAlarmNone); + pDD->setSevr (epicsSevNone); status = this->update (*pDD); if (status) { errMessage (status, "scan update failed\n"); @@ -111,40 +123,51 @@ caStatus exPV::update(gdd &valueIn) { gdd *pNewValue; caServer *pCAS = this->getCAS(); - osiTime cur (osiTime::getCurrent()); + // + // gettimeofday() is very slow under sunos4 + // + osiTime cur (this->currentTime); struct timespec t; gddStatus gdds; + if (!pCAS) { return S_casApp_noSupport; } - // - // this does not modify the current value - // (because it may be referenced in the event queue) - // - pNewValue = new gdd (gddAppType_value, aitEnumFloat32); - if (!pNewValue) { - return S_casApp_noMemory; - } - # if DEBUG - printf("%s = %f\n", this->info.getName().string, valueIn); + printf("%s = %f\n", + this->info.getName().string, valueIn); # endif - gdds = gddApplicationTypeTable:: - app_table.smartCopy(pNewValue, &valueIn); - if (gdds) { - pNewValue->unreference(); - return S_cas_noConvert; + if (valueIn.isScaler()) { + pNewValue = &valueIn; + pNewValue->reference(); + } + else { + // + // this does not modify the current value + // (because it may be referenced in the event queue) + // + pNewValue = new gddScaler (gddAppType_value, aitEnumFloat32); + if (!pNewValue) { + return S_casApp_noMemory; + } + + gdds = gddApplicationTypeTable:: + app_table.smartCopy(pNewValue, &valueIn); + if (gdds) { + pNewValue->unreference(); + return S_cas_noConvert; + } + + pNewValue->setStat (epicsAlarmNone); + pNewValue->setSevr (epicsSevNone); } cur.get (t.tv_sec, t.tv_nsec); pNewValue->setTimeStamp(&t); - pNewValue->setStat (epicsAlarmNone); - pNewValue->setSevr (epicsSevNone); - // // release old value and replace it // with the new one @@ -323,7 +346,7 @@ caStatus exPV::getLowLimit(gdd &value) caStatus exPV::getUnits(gdd &units) { static aitString str("@#$%"); - units.putRef(str); + units.put(str); return S_cas_success; } @@ -347,7 +370,7 @@ caStatus exPV::getValue(gdd &value) } } else { - status = S_cas_noMemory; + status = S_casApp_undefined; } return status; } diff --git a/src/cas/example/exServer.h b/src/cas/example/exServer.h index 50384f90b..8c5e150b8 100644 --- a/src/cas/example/exServer.h +++ b/src/cas/example/exServer.h @@ -91,19 +91,12 @@ public: static const pvInfo *findPV(const char *pName); - static const osiTime &getCurrentTime() - { - return exServer::currentTime; - } - static void updateCurrentTime(); - static gddAppFuncTableStatus read(exPV &pv, gdd &value) { return exServer::ft.read(pv, value); } private: static const pvInfo pvList[]; - static osiTime currentTime; static gddAppFuncTable ft; }; @@ -190,13 +183,12 @@ public: return this->info.getScanRate(); } protected: - // - // private data - // gdd *pValue; exScanTimer *pScanTimer; const pvInfo & info; aitBool interest; +private: + static osiTime currentTime; }; //