/* * mpodChannel.cc * * Created on: July 28, 2014 * Author: Hovanes Egiyan */ #include "mpodChannel.hh" mpodChannel::mpodChannel(string uri, string name, dbSubsystem* subsystemPtr, int chID ) : epicsChannel( uri, name, subsystemPtr, chID ) { chanName = getMPODChannelName( slotNumber, chanNum ); this->initBoardFileName(); } // static function to determine the channel name based on the MPOD convention std::string mpodChannel::getMPODChannelName( int slot, int chan ) { stringstream chanNameStream; chanNameStream << slot * 100 + chan; return chanNameStream.str(); } void mpodChannel::loadRecords( string detPrefix, string iocPrefix ) { cout << "Loading EPICS DB files for channel " << fullName << endl; // Now load DB files for the particular detectors that this channel belongs to // Load the files that needs to be loaded for all detectors for this board type string detName( "AllDetectors" ); vector detVector = boardFileName[detName]; for ( unsigned iFile = 0; iFile < detVector.size(); iFile++ ) { BaseMacro4DB* macroF = ¯oDefault; if ( macroFunctor[detName][detVector[iFile]] != 0 ) { cout << "Redefining functor for " << detName << "," << detVector[iFile] << endl; macroF = macroFunctor[detName][detVector[iFile]]; } string macroSubstitutions = (*macroF)( detPrefix, iocPrefix, const_cast(this) ); cout << "Loading " << detVector[iFile] << " with macros " << macroSubstitutions << endl; dbLoadRecords( detVector[iFile].c_str(), macroSubstitutions.c_str() ); } cout << "Loading extras" << endl; // Load DB files that are only needed for particular detectors cout << " Subsystems name is " << subsystemPtr->getName() << endl; cout << "Detector name is " << subsystemPtr->getRootName() << endl; detName = subsystemPtr->getRootName(); if ( boardFileName.count( detName ) > 0 ) { detVector = boardFileName[detName]; for ( unsigned iFile = 0; iFile < detVector.size(); iFile++ ) { // Default is the macro substitution for channel name cout << "Using default functor" << endl; BaseMacro4DB* macroF = ¯oDefault; if ( macroFunctor[detName][detVector[iFile]] != 0 ) { // if we defined another macro substitution function use that one cout << "Redefining functor for " << detName << "," << detVector[iFile] << endl; macroF = macroFunctor[detName][detVector[iFile]]; } string macroSubstitutions = (*macroF)( detPrefix, iocPrefix, const_cast(this) ); cout << "Loading " << detVector[iFile] << " with macros " << macroSubstitutions << endl; dbLoadRecords( detVector[iFile].c_str(), macroSubstitutions.c_str() ); } } cout << "Finished loading EPICS DB files for channel " << fullName << endl; return; } void mpodChannel::initBoardFileName() { // the interlock is generic for both bias and lv channels if ( ! dbFileIsIncluded( "AllDetectors", "db/DetMPODItLk.db" ) ) { boardFileName["AllDetectors"].push_back( "db/DetMPODItLk.db" ); macroFunctor["AllDetectors"]["db/DetMPODItLk.db"] = ¯oDefault; } }