otsdaq_components  v2_05_02_indev
FENIMPlusInterfaceTable_table.cc
1 #include <iostream>
2 #include "otsdaq-components/UserTableDataFormats/FENIMPlusInterfaceTable.h"
3 #include "otsdaq/Macros/TablePluginMacros.h"
4 #include "otsdaq/TablePlugins/DataManagerTable.h"
5 
6 using namespace ots;
7 
8 //==============================================================================
9 FENIMPlusInterfaceTable::FENIMPlusInterfaceTable(void)
10  : FEInterfaceTableBase("FENIMPlusInterfaceTable")
11 {
13  // WARNING: the names and the order MUST match the ones in the enum //
15  // FENIMPlusInterfaceTableInfo.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  // <TABLE InterfaceID="FEWRPurdueFSSRInterfaceTable">
20  // <VIEW InterfaceID="FEWR_PURDUE_FSSR_INTERFACE_TABLE"
21  // Type="File,Database,DatabaseTest">
22  // <COLUMN NAME="InterfaceID" StorageName="INTERFACE_ID"
23  // DataType="VARCHAR2" /> <COLUMN InterfaceID="Status"
24  // StorageName="STATUS" DataType="VARCHAR2"/> <COLUMN
25  // InterfaceID="FirmwareVersion" StorageName="FIRMWARE_VERSION"
26  // DataType="NUMBER" /> <COLUMN InterfaceID="IPAddress"
27  // StorageName="IP_ADDRESS" DataType="VARCHAR2"/> <COLUMN
28  // InterfaceID="Port" StorageName="PORT" DataType="NUMBER" />
29  // <COLUMN InterfaceID="InterfaceIPAddress" StorageName="INTERFACE_IP_ADDRESS"
30  // DataType="VARCHAR2"/> <COLUMN InterfaceID="InterfacePort"
31  // StorageName="INTERFACE_PORT" DataType="NUMBER" /> <COLUMN
32  // InterfaceID="StreamingIPAddress" StorageName="STREAMING_IP_ADDRESS"
33  // DataType="VARCHAR2"/> <COLUMN InterfaceID="StreamingPort"
34  // StorageName="STREAMING_PORT" DataType="NUMBER" /> <COLUMN
35  // InterfaceID="ClockSelect" StorageName="CLOCK_SELECT"
36  // DataType="VARCHAR2"/> <COLUMN InterfaceID="ClockSpeedMHz"
37  // StorageName="CLOCK_SPEED_MHZ" DataType="NUMBER" /> <COLUMN
38  // InterfaceID="ChannelStatus0" StorageName="CHANNEL0_STATUS"
39  // DataType="VARCHAR2"/> <COLUMN InterfaceID="ChannelStatus1"
40  // StorageName="CHANNEL1_STATUS" DataType="VARCHAR2"/> <COLUMN
41  // InterfaceID="ChannelStatus2" StorageName="CHANNEL2_STATUS"
42  // DataType="VARCHAR2"/> <COLUMN InterfaceID="ChannelStatus3"
43  // StorageName="CHANNEL3_STATUS" DataType="VARCHAR2"/> <COLUMN
44  // InterfaceID="ChannelStatus4" StorageName="CHANNEL4_STATUS"
45  // DataType="VARCHAR2"/> <COLUMN InterfaceID="ChannelStatus5"
46  // StorageName="CHANNEL5_STATUS" DataType="VARCHAR2"/>
47  // </VIEW>
48  // </TABLE>
49  //</ROOT>
50 }
51 
52 //==============================================================================
53 FENIMPlusInterfaceTable::~FENIMPlusInterfaceTable(void) {}
54 
55 //==============================================================================
56 void FENIMPlusInterfaceTable::init(ConfigurationManager* configManager)
57 {
58  /*
59  std::string enumValue1;
60  unsigned int enumValue2;
61  for(unsigned int row=0; row<TableBase::tableData_.getNumberOfRows();
62  row++)
63  {
64  TableBase::tableData_.getValue(enumValue1,row,Enum1);
65  TableBase::tableData_.getValue(enumValue2,row,Enum2);
66  }
67  */
68 }
69 
70 //==============================================================================
71 bool FENIMPlusInterfaceTable::getStatus(std::string interfaceID) const
72 {
73  bool tmpStatus;
74  TableBase::activeTableView_->getValue(
75  tmpStatus,
76  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
77  Status);
78  return tmpStatus;
79 }
80 
81 //==============================================================================
82 unsigned int FENIMPlusInterfaceTable::getFirmwareVersion(std::string interfaceID) const
83 {
84  unsigned int tmpFirmwareVersion;
85  TableBase::activeTableView_->getValue(
86  tmpFirmwareVersion,
87  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
88  FirmwareVersion);
89  return tmpFirmwareVersion;
90 }
91 
92 //==============================================================================
93 std::string FENIMPlusInterfaceTable::getIPAddress(std::string interfaceID) const
94 {
95  std::string tmpIPAddress;
96  TableBase::activeTableView_->getValue(
97  tmpIPAddress,
98  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
99  IPAddress);
100  return tmpIPAddress;
101 }
102 
103 //==============================================================================
104 unsigned int FENIMPlusInterfaceTable::getPort(std::string interfaceID) const
105 {
106  unsigned int tmpPort;
107  TableBase::activeTableView_->getValue(
108  tmpPort, TableBase::activeTableView_->findRow(InterfaceID, interfaceID), Port);
109  return tmpPort;
110 }
111 
112 //==============================================================================
113 std::string FENIMPlusInterfaceTable::getInterfaceIPAddress(std::string interfaceID) const
114 {
115  std::string tmpInterfaceIPAddress;
116  TableBase::activeTableView_->getValue(
117  tmpInterfaceIPAddress,
118  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
119  InterfaceIPAddress);
120  return tmpInterfaceIPAddress;
121 }
122 
123 //==============================================================================
124 unsigned int FENIMPlusInterfaceTable::getInterfacePort(std::string interfaceID) const
125 {
126  unsigned int tmpInterfacePort;
127  TableBase::activeTableView_->getValue(
128  tmpInterfacePort,
129  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
130  InterfacePort);
131  return tmpInterfacePort;
132 }
133 
134 //==============================================================================
135 std::string FENIMPlusInterfaceTable::getStreamingIPAddress(std::string interfaceID) const
136 {
137  std::string tmpStreamingIPAddress;
138  TableBase::activeTableView_->getValue(
139  tmpStreamingIPAddress,
140  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
141  StreamingIPAddress);
142  return tmpStreamingIPAddress;
143 }
144 
145 //==============================================================================
146 unsigned int FENIMPlusInterfaceTable::getStreamingPort(std::string interfaceID) const
147 {
148  unsigned int tmpStreamingPort;
149  TableBase::activeTableView_->getValue(
150  tmpStreamingPort,
151  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
152  StreamingPort);
153  return tmpStreamingPort;
154 }
155 
156 //==============================================================================
157 std::string FENIMPlusInterfaceTable::getClockSelect(std::string interfaceID) const
158 {
159  std::string tmpClockSelect;
160  TableBase::activeTableView_->getValue(
161  tmpClockSelect,
162  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
163  ClockSelect);
164  return tmpClockSelect;
165 }
166 
167 //==============================================================================
168 double FENIMPlusInterfaceTable::getClockSpeedMHz(std::string interfaceID) const
169 {
170  double tmpClockSpeedMHz;
171  TableBase::activeTableView_->getValue(
172  tmpClockSpeedMHz,
173  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
174  ClockSpeedMHz);
175  return tmpClockSpeedMHz;
176 }
177 
178 //==============================================================================
179 bool FENIMPlusInterfaceTable::getChannelStatus(std::string interfaceID,
180  unsigned int channel) const
181 {
182  bool tmpStatus;
183  switch(channel)
184  {
185  case 0:
186  TableBase::activeTableView_->getValue(
187  tmpStatus,
188  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
189  ChannelStatus0);
190  break;
191  case 1:
192  TableBase::activeTableView_->getValue(
193  tmpStatus,
194  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
195  ChannelStatus1);
196  break;
197  case 2:
198  TableBase::activeTableView_->getValue(
199  tmpStatus,
200  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
201  ChannelStatus2);
202  break;
203  case 3:
204  TableBase::activeTableView_->getValue(
205  tmpStatus,
206  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
207  ChannelStatus3);
208  break;
209  case 4:
210  TableBase::activeTableView_->getValue(
211  tmpStatus,
212  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
213  ChannelStatus4);
214  break;
215  case 5:
216  TableBase::activeTableView_->getValue(
217  tmpStatus,
218  TableBase::activeTableView_->findRow(InterfaceID, interfaceID),
219  ChannelStatus5);
220  break;
221  default: // There are only 6 channels on OtsUDPHardware board
222  __SS____ << "Table Error:\t"
223  << "OtsUDPHardware FER Channel " << std::dec << channel
224  << " does not exist" << std::endl;
225  __COUT_ERR__ << "\n" << ss.str();
226  __SS_THROW__;
227  }
228  return tmpStatus;
229 }
230 
231 DEFINE_OTS_TABLE(FENIMPlusInterfaceTable)