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