/* * mpvDoubletChannel.cpp * * Created on: Sep 27, 2019 * Author: hovanes */ #include "mpvDoubletChannel.hh" mpvDoubletChannel::mpvDoubletChannel(string uri, string name, dbSubsystem* subsystemPtr, int chID ) : baseEpicsChannel( name ) , detectorName(subsystemPtr->getRootName()) { this->initBoardFileName(); } void mpvDoubletChannel::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++ ) { mpvDoubletChannel::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, 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 " << fullName << endl; cout << "Detector name is " << detectorName<< endl; detName = detectorName; 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, 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 mpvDoubletChannel::initBoardFileName() { cout << "Initializing channel of type mpvDoubletChannel " << this->fullName << endl; if ( ! dbFileIsIncluded( "AllDetectors", "db/DetMpv_8008lItLk.db" ) ) { boardFileName["AllDetectors"].push_back( "db/DetMpv_8008lItLk.db" ); macroFunctor["AllDetectors"]["db/DetMpv_8008lItLk.db"] = ¯oDefault; // For doublet interlocking } // boardFileName["BCAL"].push_back( "db/DetMpv_8008lItLk.db" ) ; // boardFileName["ST"].push_back( "db/DetMpv_8008lItLk.db" ) ; // boardFileName["PS"].push_back( "db/DetMpv_8008lItLk.db" ) ; // boardFileName["TAGM"].push_back( "db/DetMpv_8008lItLk.db" ) ; return; }