otsdaq_demo  v2_05_02_indev
DemoInterfaceTestMain.cc
1 #include <fstream>
2 #include <iostream>
3 
4 #include "otsdaq-components/FEInterfaces/FEOtsUDPTemplateInterface.h"
5 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
6 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
7 #include "otsdaq/TableCore/TableGroupKey.h"
8 /*
9 
10 #include "otsdaq-components/FEInterfaces/FEWOtsUDPFSSRInterface.h"
11 #include "otsdaq-components/FEInterfaces/FEWOtsUDPHCALInterface.h"
12 #include "otsdaq/ConfigurationDataFormats/FEWOtsUDPHardwareTable.h"
13 */
14 using namespace ots;
15 
16 int main(int argc, char** argv)
17 {
18  if (argc < 1) {
19  std::cout << "Usage: " << std::string(argv[0]) << " <run number>" << std::endl;
20  return 1;
21  }
22  // Variables
23  //const int supervisorInstance_ = 1;
24  const unsigned int configurationKeyValue_ = 1;
25 
26  ConfigurationManager* theConfigurationManager_ = new ConfigurationManager();
27 
28  std::string XDAQContextTableName_ = "XDAQContextTable";
29  std::string supervisorContextUID_ = "mainContext";
30  std::string supervisorApplicationUID_ = "FESupervisor";
31  std::string interfaceUID_ = "ExampleInterface0";
32  std::string supervisorConfigurationPath_ =
33  "/" + supervisorContextUID_ + "/LinkToApplicationConfiguration/" +
34  supervisorApplicationUID_ + "/LinkToSupervisorConfiguration";
35  const ConfigurationTree theXDAQContextConfigTree_ =
36  theConfigurationManager_->getNode(XDAQContextTableName_);
37 
38  std::string configurationGroupName = "defaultConfig";
39  std::pair<std::string, TableGroupKey> theGroup(configurationGroupName,
40  TableGroupKey(configurationKeyValue_));
41 
42  theConfigurationManager_->loadTableGroup(theGroup.first, theGroup.second, true);
43 
44  FEOtsUDPTemplateInterface* theInterface_ = new FEOtsUDPTemplateInterface(
45  interfaceUID_,
46  theXDAQContextConfigTree_,
47  supervisorConfigurationPath_ + "/LinkToFEInterfaceTable/" + interfaceUID_ +
48  "/LinkToFETypeConfiguration");
49  std::cout << "Done with new" << std::endl;
50  // Test interface class methods here //
51  theInterface_->configure();
52  theInterface_->start(std::string(argv[1]));
53  unsigned int second = 1000; // x1ms
54  unsigned int time = 60 * 60 * second;
55  unsigned int counter = 0;
56  while(counter++ < time)
57  {
58  theInterface_->running(); // There is a 1ms sleep inside the running
59  // std::cout << counter << std::endl;
60  }
61  theInterface_->stop();
62 
63  return 0;
64 }