#include "moAsynPar.hh" #include "asynMasterOscillatorDrv.hh" template class moAsynPar; template class moAsynPar; volatile static int dummyIntUnsigned = moAsynPar::initGlobalMutex(); volatile static int dummyIntDouble = moAsynPar::initGlobalMutex(); //======================================================================== // Specializations for template class moAsynPar member functions //======================================================================== // Method to create the parameter for the driver passed by the argument. // This method is expected to be called from the AsynDriver constructor template <> void moAsynPar::Connect2Driver(asynMasterOscillatorDrv* driver) { MtxLock objLock(this->mcMutex); driver->createParam( this->mvapParName.c_str(), asynParamUInt32Digital, &this->mvapParNum ) ; } // Write unsigned asyn parameter template<> asynStatus moAsynPar::Write( asynMasterOscillatorDrv* driver, unsigned channel, void* valPtr, epicsUInt32 mask ) { MtxLock objLock( this->mcMutex ); asynStatus aStat = asynError; unsigned value = *reinterpret_cast( valPtr ); // cout << "Setting UInt32 parameter " << this->mvapParName << "(" << this->mvapParNum << // ") for channel " << channel << " to " << value << endl; try { WriteParameters* parStruct = new WriteParameters( driver, this, static_cast( channel ), value ); // cout << "Launching thread for " << this->mvapParNum << // " for channel " << channel << " to set it to " << value << endl; pthread_t thID; int stat = pthread_create( &thID, NULL, (void* (*)(void*)) moAsynPar::asynWriteFunc, reinterpret_cast( parStruct ) ); if( stat != 0 ) { cout << "********************Could not start thread" << " for channel " << channel << " to set it to " << value << endl; aStat = asynError; } // this->mapWriteFunc(channel, value); } catch ( runtime_error& errMsg ) { cerr << errMsg.what() << endl; return aStat; } aStat = driver->setUIntDigitalParam( channel, this->mvapParNum, value, mask, mask ); return aStat; } // Read unsigned asyn parameter template <> asynStatus moAsynPar::Read(asynMasterOscillatorDrv* driver, unsigned channel, void* valPtr, epicsUInt32* mask) { MtxLock objLock(this->mcMutex); asynStatus aStat = asynError; // cout << "Calling read function for parameter " << this->mvapParName << " for channel " << channel << endl; try { this->mapValue = this->mapReadFunc(channel); } catch ( runtime_error& errMsg ) { cerr << errMsg.what() << endl; return aStat; } aStat = driver->setUIntDigitalParam(channel, this->mvapParNum, this->mapValue, *mask, *mask); *(static_cast(valPtr)) = this->mapValue; return aStat; } // Method to create the parameter for the driver passed by the argument. // This method is expected to be called from the AsynDriver constructor template <> void moAsynPar::Connect2Driver(asynMasterOscillatorDrv* driver) { MtxLock objLock(this->mcMutex); driver->createParam( this->mvapParName.c_str(), asynParamFloat64, &this->mvapParNum ) ; } // Write double asyn parameter template <> asynStatus moAsynPar::Write(asynMasterOscillatorDrv* driver, unsigned channel, void* valPtr, epicsUInt32 mask) { MtxLock objLock(this->mcMutex); asynStatus aStat = asynError; epicsFloat64 value = *static_cast(valPtr); // cout << "Setting Double parameter " << this->mvapParName << "(" << this->mvapParNum << // ") for channel " << channel << " to " << value << endl; try { this->mapWriteFunc(channel, value); } catch (runtime_error& errMsg ) { cerr << errMsg.what() << endl; return aStat; } aStat = driver->setDoubleParam(channel, this->mvapParNum, value); return aStat; } // Read double asyn parameter template <> asynStatus moAsynPar::Read(asynMasterOscillatorDrv* driver, unsigned channel, void* valPtr, epicsUInt32* mask) { MtxLock objLock(this->mcMutex); asynStatus aStat = asynError; try { this->mapValue = this->mapReadFunc(channel); } catch ( runtime_error& errMsg ) { cerr << errMsg.what() << endl; return aStat; } // cout << "Read value " << this->mapValue << " for channel " << channel << endl; aStat = driver->setDoubleParam(channel, this->mvapParNum, this->mapValue); *(static_cast(valPtr)) = this->mapValue; // cout << "Sending back value " << *(static_cast(valPtr)) << endl; return aStat; }