$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* 00002 * RegisterBase.cpp 00003 * 00004 * Created on: Jul 29, 2015 00005 * Author: parilla 00006 */ 00007 00008 #include "otsdaq-core/ConfigurationDataFormats/RegisterBase.h" 00009 #include "otsdaq-core/ConfigurationDataFormats/RegisterConfigurationInfoReader.h" 00010 #include "otsdaq-core/ConfigurationDataFormats/RegisterSequencerInfoReader.h" 00011 00012 #include <algorithm> 00013 00014 using namespace ots; 00015 00016 RegisterBase::RegisterBase(std::string configurationName, std::string componentType) 00017 : ConfigurationBase(configurationName), componentTypeName_(componentType) 00018 { 00019 RegisterConfigurationInfoReader configurationInfoReader; 00020 configurationInfoReader.read(this); 00021 00022 RegisterSequencerInfoReader sequencerInfoReader; 00023 sequencerInfoReader.read(this); 00024 00025 init(); 00026 } 00027 00028 RegisterBase::~RegisterBase() 00029 { 00030 // TODO Auto-generated destructor stub 00031 } 00032 //============================================================================== 00033 void RegisterBase::init(void) 00034 { 00035 theComponentList_.clear(); 00036 00037 // Loop through each component via the sequencer and add them to theComponentList_ 00038 for(auto it : *mockupRegisterView_.getRegistersSequencerInfoPointer()) 00039 { 00040 // if(theComponentList_.find(it->getComponentName()) != theComponentList_.end()) 00041 // the insert function will have no effect if it already finds the key (component 00042 // name) in theComponentList_; otherwise, let's add it 00043 theComponentList_.insert( 00044 std::make_pair(it.getComponentName(), Component(it.getComponentName()))); 00045 // theComponentList_ now atleast contains the component, now lets set the state 00046 // that we are looking at 00047 auto regs = 00048 theComponentList_.find(it.getComponentName())->second.getRegistersPointer(); 00049 std::find_if(regs->begin(), 00050 regs->end(), 00051 [it](auto r) { return r.getName() == it.getRegisterName(); }) 00052 ->setState(it.getState(), it.getValueSequencePair()); 00053 } 00054 // Iterate through our newly-filled theComponentList_ 00055 for(auto aComponent : theComponentList_) 00056 { 00057 // Iterate through each register of the component 00058 for(auto registerFromConfiguration : *aComponent.second.getRegistersPointer()) 00059 { 00060 // Iterate through MockupView of the xxxRegisterConfiguration.xml 00061 for(auto aRegister : *mockupRegisterView_.getRegistersInfoPointer()) 00062 { 00063 // If the Register names match 00064 if(aRegister.getRegisterName() == registerFromConfiguration.getName() 00065 //&& aRegister.getComponentName() == 00066 // registerFromConfiguration.getComponentName() 00067 ) 00068 { 00069 registerFromConfiguration.fillRegisterInfo(aRegister.getBaseAddress(), 00070 aRegister.getSize(), 00071 aRegister.getAccess()); 00072 } 00073 } 00074 } 00075 } 00076 00077 // Print for Debugging 00078 for(auto aComponent : theComponentList_) 00079 { 00080 aComponent.second.printInfo(); 00081 } 00082 00083 // create new instance of "Component" and add to "theComponentList_; set Name 00084 // according to XML tempComponent = new Component(FROM_XML); 00085 // mockupRegisterView_.getRegistersInfoPointer(); 00086 // theComponent_ = new Component(componentNameType_); 00087 00088 // Add component based on sequencer XML 00089 00090 /* 00091 for(std::vector<ViewRegisterInfo>::iterator it = 00092 mockupRegisterView_.getRegistersInfoPointer().begin(); it != 00093 mockupRegisterView_.getRegistersInfoPointer().end(); ++it){ 00094 00095 if(it->getTypeName == componentNameType_) 00096 { 00097 //Check the Component's "type_name" 00098 //Accordingly create instances of "Register" based on Configuration XML 00099 and add to Component theComponent_.addRegister(it->getregisterName(), 00100 it->getBaseAddress, it->getSize(), it->getAccess); 00101 00102 } 00103 }*/ 00104 00105 // Fill the Registers based on the Sequencer XML File 00106 00107 /* 00108 std::string tmpDetectorID; 00109 std::string tmpDACName; 00110 unsigned int tmpDACValue; 00111 for(unsigned int row=0; row<activeRegisterView_->getNumberOfRows(); row++) 00112 { 00113 activeRegisterView_->getValue(tmpDetectorID,row,rocNameColumn_); 00114 nameToROCDACsMap_[tmpDetectorID] = ROCDACs(); 00115 ROCDACs& aROCDACs = nameToROCDACsMap_[tmpDetectorID]; 00116 for(unsigned int col=firstDAC_; col<=lastDAC_; col++)*/ 00117 /* 00118 theComponentList_.pushback() 00119 { 00120 activeRegisterView_->getValue(tmpDACValue,row,col); 00121 tmpDACName = activeRegisterView_->getColumnInfo(col).getName(); 00122 aROCDACs.setDAC(tmpDACName,dacNameToDACAddress_[tmpDACName],tmpDACValue); 00123 //std::cout << __COUT_HDR_FL__ << "DAC. Name: " << tmpDACName << " addr: " << 00124 dacNameToDACAddress_[tmpDACName] << " val: " << tmpDACValue << std::endl; 00125 } 00126 }*/ 00127 } 00128 //============================================================================== 00129 const RegisterView& RegisterBase::getRegisterView() const { return *activeRegisterView_; } 00130 00131 //============================================================================== 00132 RegisterView* RegisterBase::getRegisterViewPointer() { return activeRegisterView_; } 00133 00134 //============================================================================== 00135 RegisterView* RegisterBase::getMockupRegisterViewPointer() 00136 { 00137 return &mockupRegisterView_; 00138 } 00139 //============================================================================== 00140 std::string RegisterBase::getTypeName() { return componentTypeName_; }