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