/* * iuBaseChannel.cc * * Created on: July 28, 2014 * Author: Hovanes Egiyan */ #include "iuBaseChannel.hh" iuBaseChannel::iuBaseChannel( string uri, string name, dbSubsystem* subsystemPtr, int chID ) : epicsChannel( uri, name, subsystemPtr, chID ) { // determine the channel name based on the MPOD convention stringstream chanNameStream; chanNameStream << hex << showbase << chanNum; chanName = chanNameStream.str(); this->initBoardFileName(); } void iuBaseChannel::loadRecords( string detPrefix, string iocPrefix ) { string macroSubstitutions = ""; cout << "Will get bus name for slot number " << this->slotNumber << endl; string busName = BaseIUDevice::DeviceID::Int2String( this->slotNumber ); cout << "slot number is " << slotNumber << " and bus name is " << busName << endl; macroSubstitutions += "DETch=" + detPrefix + fullName + ",PREF=" + iocPrefix + ",PORT=" + detPrefix + crateName + ":" + busName + ",ADDR=" + chanName; cout << "Loading EPICS DB files for channel " << fullName << " with macros " << macroSubstitutions << 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 vector detVector = boardFileName["AllDetectors"]; for ( unsigned iFile = 0; iFile < detVector.size(); iFile++ ) { 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 << "Subsystem pointer is " << hex << showbase << subsystemPtr << dec << endl; cout << " Subsystems name is " << subsystemPtr->getName() << endl; cout << "Detector name is " << subsystemPtr->getRootName() << endl; // cout << string detName = subsystemPtr->getRootName(); if ( boardFileName.count( detName ) > 0 ) { detVector = boardFileName[detName]; for ( unsigned iFile = 0; iFile < detVector.size(); iFile++ ) { 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 << " with macros " << macroSubstitutions << endl; return; } void iuBaseChannel::initBoardFileName() { // Main DB file for detector-based hierarchy if ( ! dbFileIsIncluded( "AllDetectors", "db/DetPmtBaseIU.db" ) ) { boardFileName["AllDetectors"].push_back( "db/DetPmtBaseIU.db" ); } // Interlock for FCAL overvoltage protection using voltage readback if ( ! dbFileIsIncluded( "AllDetectors", "db/DetReadbackInterlockFCAL.db" ) ) { boardFileName["AllDetectors"].push_back( "db/DetReadbackInterlockFCAL.db" ); } // Alarms calculations EPICS DB if ( ! dbFileIsIncluded( "AllDetectors", "db/DetPmtBaseIU_alarm.db" ) ) { boardFileName["AllDetectors"].push_back( "db/DetPmtBaseIU_alarm.db" ); } return; }