otsdaq  v1_01_03
 All Classes Namespaces Functions
DetectorToFEConfiguration_configuration.cc
1 #include "otsdaq-core/ConfigurationPluginDataFormats/DetectorToFEConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 
4 #include <iostream>
5 
6 using namespace ots;
7 
8 //==============================================================================
9 DetectorToFEConfiguration::DetectorToFEConfiguration(void)
10 : ConfigurationBase("DetectorToFEConfiguration")
11 {
13  //WARNING: the names and the order MUST match the ones in the enum //
15  //DetectorToFEConfigurationInfo.xml
16  //<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
17  //<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ConfigurationInfo.xsd">
18  // <CONFIGURATION Name="DetectorToFEConfiguration">
19  // <VIEW Name="DETECTOR_TO_FE_CONFIGURATION" Type="File,Database,DatabaseTest">
20  // <COLUMN Name="DetectorID" StorageName="DETECTOR_ID" DataType="VARCHAR2"/>
21  // <COLUMN Name="FEWriterID" StorageName="FE_WRITER_ID" DataType="VARCHAR2"/>
22  // <COLUMN Name="FEWriterChannel" StorageName="FE_WRITER_CHANNEL" DataType="NUMBER" />
23  // <COLUMN Name="FEWriterDetectorAddress" StorageName="FE_WRITER_DETECTOR_ADDRESS" DataType="NUMBER" />
24  // <COLUMN Name="FEReaderID" StorageName="FE_READER_ID" DataType="VARCHAR2"/>
25  // <COLUMN Name="FEReaderChannel" StorageName="FE_READER_CHANNEL" DataType="NUMBER" />
26  // <COLUMN Name="FEReaderDetectorAddress" StorageName="FE_READER_DETECTOR_ADDRESS" DataType="NUMBER" />
27  // </VIEW>
28  // </CONFIGURATION>
29  //</ROOT>
30 }
31 
32 //==============================================================================
33 DetectorToFEConfiguration::~DetectorToFEConfiguration(void)
34 {}
35 
36 //==============================================================================
37 void DetectorToFEConfiguration::init(ConfigurationManager *configManager)
38 {
39  std::string tmpDetectorName;
40  for(unsigned int row=0; row<ConfigurationBase::activeConfigurationView_->getNumberOfRows(); row++)
41  {
42  ConfigurationBase::activeConfigurationView_->getValue(tmpDetectorName , row, DetectorID);
43  nameToInfoMap_[tmpDetectorName] = DetectorInfo();
44  DetectorInfo& aDetectorInfo = nameToInfoMap_[tmpDetectorName];
45  ConfigurationBase::activeConfigurationView_->getValue(aDetectorInfo.theFEWriterID_ , row, FEWriterID);
46  ConfigurationBase::activeConfigurationView_->getValue(aDetectorInfo.theFEWriterChannel_ , row, FEWriterChannel);
47  ConfigurationBase::activeConfigurationView_->getValue(aDetectorInfo.theFEWriterDetectorAddress_, row, FEWriterDetectorAddress);
48  ConfigurationBase::activeConfigurationView_->getValue(aDetectorInfo.theFEReaderID_ , row, FEReaderID);
49  ConfigurationBase::activeConfigurationView_->getValue(aDetectorInfo.theFEReaderChannel_ , row, FEReaderChannel);
50  ConfigurationBase::activeConfigurationView_->getValue(aDetectorInfo.theFEReaderDetectorAddress_, row, FEReaderDetectorAddress);
51  }
52 }
53 
54 //==============================================================================
55 std::vector<std::string> DetectorToFEConfiguration::getFEWriterDetectorList(std::string interfaceID) const
56 {
57  std::string tmpDetectorID;
58  std::string tmpFEWriterID;
59  std::vector<std::string> list;
60  for(unsigned int row=0; row<ConfigurationBase::activeConfigurationView_->getNumberOfRows(); row++)
61  {
62  ConfigurationBase::activeConfigurationView_->getValue(tmpFEWriterID, row, FEWriterID);
63  if(tmpFEWriterID == interfaceID)
64  {
65  ConfigurationBase::activeConfigurationView_->getValue(tmpDetectorID, row, DetectorID);
66  list.push_back(tmpDetectorID);
67  }
68  }
69  return list;
70 }
71 
72 //==============================================================================
73 std::vector<std::string> DetectorToFEConfiguration::getFEReaderDetectorList(std::string interfaceID) const
74 {
75  std::string tmpDetectorID;
76  std::string tmpFEReaderID;
77  std::vector<std::string> list;
78  for(unsigned int row=0; row<ConfigurationBase::activeConfigurationView_->getNumberOfRows(); row++)
79  {
80  ConfigurationBase::activeConfigurationView_->getValue(tmpFEReaderID,row,FEReaderID);
81  if(tmpFEReaderID == interfaceID)
82  {
83  ConfigurationBase::activeConfigurationView_->getValue(tmpDetectorID, row, DetectorID);
84  list.push_back(tmpDetectorID);
85  }
86  }
87  return list;
88 }
89 
90 //==============================================================================
91 unsigned int DetectorToFEConfiguration::getFEWriterChannel(const std::string& detectorID) const
92 {
93  return nameToInfoMap_.find(detectorID)->second.theFEWriterChannel_;
94 }
95 
96 //==============================================================================
97 unsigned int DetectorToFEConfiguration::getFEWriterDetectorAddress(const std::string& detectorID) const
98 {
99  return nameToInfoMap_.find(detectorID)->second.theFEWriterDetectorAddress_;
100 }
101 
102 //==============================================================================
103 unsigned int DetectorToFEConfiguration::getFEReaderChannel(const std::string& detectorID) const
104 {
105  return nameToInfoMap_.find(detectorID)->second.theFEReaderChannel_;
106 }
107 
108 DEFINE_OTS_CONFIGURATION(DetectorToFEConfiguration)