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