/* File: asynDrvBoard.cpp * Author: Hovanes Egiyan, Jefferson Lab * Date: 09-Feb-2015 * * Purpose: * This module provides the driver support for the asyn device support layer * for the VME board scaler information to interface with software developed * by Paul Mattione. * * */ #include "asynDrvBoard.hh" #include "boardVAsynPar.hh" #include "boardAsynPar.hh" #include "jlabSSPDIRCBoard.hh" using namespace std; // Driver name template string asynDrvBoard::adbDriverName = "asynDrvBoard"; // Maximum length for values that are of scalar, string or waveform type template unsigned asynDrvBoard::adbMaxValueBufferLength = (2<<16); //// Parameter vector is initialized as empty //template //vector*> asynDrvBoard::adbParVec; // parameter number for JLAB discriminator boards template <> unsigned asynDrvBoard::adbParamNumber = 4; // parameter number for JLAB FADC250 boards template <> unsigned asynDrvBoard::adbParamNumber = 1; // parameter number for JLAB SSPDIRC boards //template <> unsigned asynDrvBoard::adbParamNumber = 1 + jlabSSPDIRCBoard::GetTempNames().size(); template <> unsigned asynDrvBoard::adbParamNumber = 1 + 9; // This function simply calls the member function of the driver whose pointer // is passed as the argument. This function is to be called from a separate // thread and is specified in the argument when launching that thread template void asynDrvBoard::threadFunction( void *drvPvt ) { asynDrvBoard* pPvt = (asynDrvBoard *)drvPvt; pPvt->readSharedMemory(); } // Method to create the asyn parameter vector for discriminator boards template <> void asynDrvBoard::createParVector() { string functionName = "asynDrvBoard::createParVector"; cout << "In function " << functionName << endl; jlabDiscBoard* boardObjPtr = dynamic_cast(this->adbBoard); // Scalers { boost::function readFun = boost::bind( &jlabDiscBoard::GetScaler, boardObjPtr, _1, "Readout1", true); boost::function writeFun ; adbParVec.push_back( new boardAsynParDouble ("SCALER_R1", adbParVec.size(), readFun, writeFun ) ); } { boost::function readFun = boost::bind( &jlabDiscBoard::GetScaler, boardObjPtr, _1, "Readout2", true); boost::function writeFun ; adbParVec.push_back( new boardAsynParDouble ("SCALER_R2", adbParVec.size(), readFun, writeFun ) ); } { boost::function readFun = boost::bind( &jlabDiscBoard::GetScaler, boardObjPtr, _1, "Trigger1", true); boost::function writeFun ; adbParVec.push_back( new boardAsynParDouble ("SCALER_T1", adbParVec.size(), readFun, writeFun ) ); } { boost::function readFun = boost::bind( &jlabDiscBoard::GetScaler, boardObjPtr, _1, "Trigger2", true); boost::function writeFun ; adbParVec.push_back( new boardAsynParDouble ("SCALER_T2", adbParVec.size(), readFun, writeFun ) ); } // boost::function readFun = boost::bind( &jlabDiscBoard::GetUnsigned, boardObjPtr, _1, "test"); // boost::function writeFun = boost::bind( &jlabDiscBoard::SetUnsigned, boardObjPtr, _1, "test", _2 ); // boost::function writeFun ; // boost::function tempFun = boost::bind( &jlabDiscBoard::GetUnsigned, boardObjPtr, 1, "test"); // // cout << "Assigned Read function is " << readFun << " with object pointer " << hex << showbase << boardObjPtr << endl; // cout << "Value of the read func is " << readFun( 0 ) << endl; // cout << "Value of the read func is " << tempFun() << endl; // adbParVec.push_back( new boardAsynParUInt32 ("THRESHOLD", adbParVec.size(), readFun, writeFun, 0xFFFF) ); return; } // Method to create the asyn parameter vector for FADC250 boards template <> void asynDrvBoard::createParVector() { string functionName = "asynDrvBoard::createParVector"; cout << "In function " << functionName << endl; jlabFADC250Board* boardObjPtr = dynamic_cast(this->adbBoard); // Scaler { boost::function readFun = boost::bind( &jlabFADC250Board::GetScaler, boardObjPtr, _1, "Readout1", true); boost::function writeFun ; adbParVec.push_back( new boardAsynParDouble ("SCALER_R1", adbParVec.size(), readFun, writeFun ) ); } return; } // Method to create the asyn parameter vector for SSP DIRC boards template <> void asynDrvBoard::createParVector() { string functionName = "asynDrvBoard::createParVector"; cout << "In function " << functionName << endl; jlabSSPDIRCBoard* boardObjPtr = dynamic_cast(this->adbBoard); // Scaler { boost::function readFun = boost::bind( &jlabSSPDIRCBoard::GetScaler, boardObjPtr, _1, "Readout1", true); boost::function writeFun ; adbParVec.push_back( new boardAsynParDouble ("SCALER_R1", adbParVec.size(), readFun, writeFun ) ); } // Temperatures vector& tempNames = jlabSSPDIRCBoard::GetTempNames(); for( unsigned tempType = 0; tempType < tempNames.size(); tempType++ ) { string tempName = tempNames[tempType]; boost::function readFun = boost::bind( &jlabSSPDIRCBoard::GetTemperature, boardObjPtr, _1, tempType ); boost::function statFun = boost::bind( &jlabSSPDIRCBoard::GetAlarmStatus, boardObjPtr, _1 ); boost::function sevrFun = boost::bind( &jlabSSPDIRCBoard::GetAlarmSeverity, boardObjPtr, _1 ); boost::function writeFun ; boardAsynParDouble* newPar = new boardAsynParDouble ( tempName, adbParVec.size(), readFun, writeFun ); newPar->SetAlarmStatusFunc( statFun ); newPar->SetAlarmSeverityFunc( sevrFun ); adbParVec.push_back( newPar ) ; } return; } /***********************/ /* Definitions for IOC */ /***********************/ extern "C" { // Define IOC function arguments static const iocshArg asynDrvBoardConfigArg0 = { "Chassis Port Name", iocshArgString }; static const iocshArg asynDrvBoardConfigArg1 = { "Asyn port name" , iocshArgString }; static const iocshArg asynDrvBoardConfigArg2 = { "Slot number" , iocshArgInt }; static const iocshArg * const asynDrvBoardConfigArgs[] = { &asynDrvBoardConfigArg0, &asynDrvBoardConfigArg1, &asynDrvBoardConfigArg2 }; // Define IOC functions for Discriminator board char* asynDrvDiscBoardConfig(const char* chassisPort, const char *portName, int slot) { // Now create the asyn driver cout << "Creating the driver for discriminator board at port " << portName << " for slot " << slot << " on chassis " << chassisPort << endl; asynDrvBoard* pBoard = new asynDrvBoard( chassisPort, portName, slot ); cout << "asynPortDriver has been created at address " << hex << pBoard << dec << endl; if( pBoard != 0 && !pBoard->driverExists() ) { pBoard = 0; } return reinterpret_cast(pBoard); } static const iocshFuncDef asynDrvDiscBoardConfigFuncDef = { "asynDrvDiscBoardConfig", 3, asynDrvBoardConfigArgs }; static void asynDrvDiscBoardConfigCallFunc(const iocshArgBuf *args) { asynDrvDiscBoardConfig(args[0].sval, args[1].sval, args[2].ival); } void asynDrvDiscBoardRegister(void) { iocshRegister(&asynDrvDiscBoardConfigFuncDef, asynDrvDiscBoardConfigCallFunc); } epicsExportRegistrar( asynDrvDiscBoardRegister ); // Define IOC functions for FADC board char* asynDrvFADCBoardConfig(const char* chassisPort, const char *portName, int slot) { // Now create the asyn driver cout << "Creating the driver for FADC250 board at port " << portName << " for slot " << slot << " on chassis " << chassisPort << endl; asynDrvBoard* pBoard = new asynDrvBoard( chassisPort, portName, slot ); cout << "asynPortDriver has been created at address " << hex << pBoard << dec << endl; if( pBoard != 0 && !pBoard->driverExists() ) { pBoard = 0; } return reinterpret_cast(pBoard); } static const iocshFuncDef asynDrvFADCBoardConfigFuncDef = { "asynDrvFADCBoardConfig", 3, asynDrvBoardConfigArgs }; static void asynDrvFADCBoardConfigCallFunc(const iocshArgBuf *args) { asynDrvFADCBoardConfig(args[0].sval, args[1].sval, args[2].ival); } void asynDrvFADCBoardRegister(void) { iocshRegister(&asynDrvFADCBoardConfigFuncDef, asynDrvFADCBoardConfigCallFunc); } epicsExportRegistrar( asynDrvFADCBoardRegister ); // Define IOC functions for SSPDIRC board char* asynDrvSSPDIRCBoardConfig(const char* chassisPort, const char *portName, int slot) { // Now create the asyn driver cout << "Creating the driver for SSPDIRC board at port " << portName << " for slot " << slot << " on chassis " << chassisPort << endl; asynDrvBoard* pBoard = new asynDrvBoard( chassisPort, portName, slot ); cout << "asynPortDriver has been created at address " << hex << pBoard << dec << endl; if( pBoard != 0 && !pBoard->driverExists() ) { pBoard = 0; } return reinterpret_cast(pBoard); } static const iocshFuncDef asynDrvSSPDIRCBoardConfigFuncDef = { "asynDrvSSPDIRCBoardConfig", 3, asynDrvBoardConfigArgs }; static void asynDrvSSPDIRCBoardConfigCallFunc(const iocshArgBuf *args) { asynDrvFADCBoardConfig(args[0].sval, args[1].sval, args[2].ival); } void asynDrvSSPDIRCBoardRegister(void) { iocshRegister(&asynDrvSSPDIRCBoardConfigFuncDef, asynDrvSSPDIRCBoardConfigCallFunc); } epicsExportRegistrar( asynDrvSSPDIRCBoardRegister ); } // extern "C"