otsdaq  v2_04_01
ROCToFEConfiguration_configuration.cc
1 #include <iostream>
2 #include "otsdaq-core/Macros/TablePluginMacros.h"
3 #include "otsdaq-core/TablePlugins/ROCToFETable.h"
4 
5 using namespace ots;
6 
7 const std::string ROCToFEConfiguration::staticTableName_ = "ROCToFEConfiguration";
8 //==============================================================================
9 ROCToFEConfiguration::ROCToFEConfiguration(void)
10  : TableBase(ROCToFEConfiguration::staticTableName_)
11 {
13  // WARNING: the names and the order MUST match the ones in the enum //
15  // ROCToFEConfigurationInfo.xml
16  //<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
17  //<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18  // xsi:noNamespaceSchemaLocation="TableInfo.xsd">
19  // <CONFIGURATION Name="ROCToFEConfiguration">
20  // <VIEW Name="ROC_TO_FE_CONFIGURATION" Type="File,Database,DatabaseTest">
21  // <COLUMN Name="DetectorID" StorageName="DETECTOR_ID"
22  // DataType="VARCHAR2" /> <COLUMN Name="FEWName" StorageName="FEW_NAME"
23  // DataType="NUMBER" /> <COLUMN Name="FEWChannel" StorageName="FEW_CHANNEL"
24  // DataType="NUMBER" /> <COLUMN Name="FEWROCAddress"
25  // StorageName="FEW_ROC_ADDRESS" DataType="NUMBER" /> <COLUMN Name="FERName"
26  // StorageName="FER_NAME" DataType="NUMBER" /> <COLUMN Name="FERChannel"
27  // StorageName="FER_CHANNEL" DataType="NUMBER" /> <COLUMN
28  // Name="FERROCAddress" StorageName="FER_ROC_ADDRESS" DataType="NUMBER" />
29  // </VIEW>
30  // </CONFIGURATION>
31  //</ROOT>
32 }
33 
34 //==============================================================================
35 ROCToFEConfiguration::~ROCToFEConfiguration(void) {}
36 
37 //==============================================================================
38 void ROCToFEConfiguration::init(ConfigurationManager* configManager)
39 {
40  std::string tmpDetectorID;
41  for(unsigned int row = 0; row < TableBase::activeTableView_->getNumberOfRows(); row++)
42  {
43  TableBase::activeTableView_->getValue(tmpDetectorID, row, DetectorID);
44  nameToInfoMap_[tmpDetectorID] = ROCInfo();
45  ROCInfo& aROCInfo = nameToInfoMap_[tmpDetectorID];
46  TableBase::activeTableView_->getValue(aROCInfo.theFEWName_, row, FEWName);
47  TableBase::activeTableView_->getValue(aROCInfo.theFEWChannel_, row, FEWChannel);
48  TableBase::activeTableView_->getValue(
49  aROCInfo.theFEWROCAddress_, row, FEWROCAddress);
50  TableBase::activeTableView_->getValue(aROCInfo.theFERName_, row, FERName);
51  TableBase::activeTableView_->getValue(aROCInfo.theFERChannel_, row, FEWChannel);
52  TableBase::activeTableView_->getValue(
53  aROCInfo.theFERROCAddress_, row, FERROCAddress);
54  }
55 }
56 
57 //==============================================================================
58 std::vector<std::string> ROCToFEConfiguration::getFEWROCsList(std::string fECNumber) const
59 {
60  std::string tmpDetectorID;
61  std::string tmpFEWName;
62  std::vector<std::string> list;
63  for(unsigned int row = 0; row < TableBase::activeTableView_->getNumberOfRows(); row++)
64  {
65  TableBase::activeTableView_->getValue(tmpFEWName, row, FEWName);
66  if(tmpFEWName == fECNumber)
67  {
68  TableBase::activeTableView_->getValue(tmpDetectorID, row, DetectorID);
69  list.push_back(tmpDetectorID);
70  }
71  }
72  return list;
73 }
74 
75 //==============================================================================
76 std::vector<std::string> ROCToFEConfiguration::getFERROCsList(std::string fEDNumber) const
77 {
78  std::string tmpDetectorID;
79  std::string tmpFERName;
80  std::vector<std::string> list;
81  for(unsigned int row = 0; row < TableBase::activeTableView_->getNumberOfRows(); row++)
82  {
83  TableBase::activeTableView_->getValue(tmpFERName, row, FERName);
84  if(tmpFERName == fEDNumber)
85  {
86  TableBase::activeTableView_->getValue(tmpDetectorID, row, DetectorID);
87  list.push_back(tmpDetectorID);
88  }
89  }
90  return list;
91 }
92 
93 //==============================================================================
94 unsigned int ROCToFEConfiguration::getFEWChannel(const std::string& rOCName) const
95 {
96  return nameToInfoMap_.find(rOCName)->second.theFEWChannel_;
97 }
98 
99 //==============================================================================
100 unsigned int ROCToFEConfiguration::getFEWROCAddress(const std::string& rOCName) const
101 {
102  return nameToInfoMap_.find(rOCName)->second.theFEWROCAddress_;
103 }
104 
105 //==============================================================================
106 unsigned int ROCToFEConfiguration::getFERChannel(const std::string& rOCName) const
107 {
108  return nameToInfoMap_.find(rOCName)->second.theFERChannel_;
109 }
110 
111 DEFINE_OTS_CONFIGURATION(ROCToFEConfiguration)