00001 #include "otsdaq-core/ConfigurationPluginDataFormats/DetectorConfiguration.h"
00002 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
00003
00004 #include <iostream>
00005
00006 using namespace ots;
00007
00008
00009 DetectorConfiguration::DetectorConfiguration(void)
00010 : ConfigurationBase("DetectorConfiguration")
00011 {
00013
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 }
00028
00029
00030 DetectorConfiguration::~DetectorConfiguration(void)
00031 {}
00032
00033
00034 void DetectorConfiguration::init(ConfigurationManager *configManager)
00035 {
00036 nameToRow_ .clear();
00037 detectorIDs_ .clear();
00038 detectorTypes_ .clear();
00039 std::string tmpDetectorID;
00040 std::map<std::string,bool> detectorTypes;
00041 for(unsigned int row=0; row<ConfigurationBase::activeConfigurationView_->getNumberOfRows(); row++)
00042 {
00043 ConfigurationBase::activeConfigurationView_->getValue(tmpDetectorID, row, DetectorID);
00044 nameToRow_[tmpDetectorID] = row;
00045 detectorTypes[ConfigurationBase::getView().getDataView()[row][DetectorType]] = true;
00046 detectorIDs_.push_back(tmpDetectorID);
00047 }
00048 for(auto& it: detectorTypes)
00049 detectorTypes_.push_back(it.first);
00050 }
00051
00052
00053 const std::vector<std::string>& DetectorConfiguration::getDetectorIDs() const
00054 {
00055 return detectorIDs_;
00056 }
00057
00058
00059 const std::vector<std::string>& DetectorConfiguration::getDetectorTypes() const
00060 {
00061 return detectorTypes_;
00062 }
00063
00064
00065 const std::string& DetectorConfiguration::getDetectorType(const std::string& detectorID) const
00066 {
00067 return ConfigurationBase::getView().getDataView()[nameToRow_.find(detectorID)->second][DetectorType];
00068 }
00069
00070
00071 const std::string& DetectorConfiguration::getDetectorStatus(const std::string& detectorID) const
00072 {
00073 return ConfigurationBase::getView().getDataView()[nameToRow_.find(detectorID)->second][DetectorStatus];
00074 }
00075
00076 DEFINE_OTS_CONFIGURATION(DetectorConfiguration)