otsdaq_mu2e  v2_04_02
DTCFrontEndInterface.h
1 #ifndef _ots_DTCFrontEndInterface_h_
2 #define _ots_DTCFrontEndInterface_h_
3 
4 #include <fstream>
5 #include <iostream>
6 #include <map>
7 #include <string>
8 #include "dtcInterfaceLib/DTC.h"
9 #include "dtcInterfaceLib/DTCSoftwareCFO.h"
10 #include "mu2e_driver/mu2e_mmap_ioctl.h" // m_ioc_cmd_t, m_ioc_reg_access_t, dtc_address_t, dtc_data_t
11 #include "otsdaq-mu2e/CFOandDTCCore/CFOandDTCCoreVInterface.h"
12 #include "otsdaq-mu2e/ROCCore/ROCCoreVInterface.h"
13 
14 namespace ots
15 {
16 // class FrontEndHardwareTemplate;
17 // class FrontEndFirmwareTemplate;
18 
20 {
21  // clang-format off
22  public:
23  DTCFrontEndInterface(const std::string& interfaceUID,
24  const ConfigurationTree& theXDAQContextConfigTree,
25  const std::string& interfaceConfigurationPath);
26 
27  virtual ~DTCFrontEndInterface(void);
28 
29  // specialized ROC handling slow controls
30  //----------------
31  virtual void configureSlowControls (void) override;
32  virtual void resetSlowControlsChannelIterator (void) override;
33  virtual FESlowControlsChannel* getNextSlowControlsChannel (void) override;
34  virtual unsigned int getSlowControlsChannelCount (void) override;
35  virtual void getSlowControlsValue (FESlowControlsChannel& channel, std::string& readValue) override;
36  private:
37  bool currentChannelIsInROC_;
38  std::string currentChannelROCUID_;
39 
40  public:
41  // state machine
42  //----------------
43  void configure (void);
44  void halt (void);
45  void pause (void);
46  void resume (void);
47  void start (std::string runNumber);
48  void stop (void);
49  bool running (void);
50 
51  // emulator handlers
52  //----------------
53  void emulatorConfigure (void);
54 
55  // hardware access
56  //----------------
57 // void universalRead (char* address, char* readValue) override;
58 // void universalWrite (char* address, char* writeValue) override;
59 // dtc_data_t registerRead (const dtc_address_t address);
60 // dtc_data_t registerWrite (const dtc_address_t address, dtc_data_t dataToWrite); // return read value after having written dataToWrite
61 
62  // DTC specific items
63  //----------------
64  //void configureJitterAttenuator (void);
65  virtual void readStatus (void) override;
66  //float readTemperature (void); // return temperature of FPGA in degC
67  //void printVoltages (void);
68 
69  //void turnOnLED (void); // turn on LED on visible side of timing card
70  //void turnOffLED (void); // turn off LED on visible side of timing card
71 
72  bool ROCActive (unsigned int ROC_link);
73  int getROCLinkStatus (int ROC_link);
74  int getCFOLinkStatus (void);
75  int checkLinkStatus (void);
76 
77  DTCLib::DTC* thisDTC_;
78 
79  private:
80  void createROCs (void);
81  void registerFEMacros (void);
82 
83 // char devfile_[11];
84 // int fd_;
85 // int dtc_ = -1;
86  int dtc_location_in_chain_ = -1;
87  //bool configure_clock_ = 0;
88  unsigned roc_mask_ = 0;
89  //std::string device_name_;
90  //bool emulatorMode_;
91  int emulate_cfo_ = 0;
92  DTCLib::DTCSoftwareCFO* EmulatedCFO_;
93 
94  std::ofstream datafile_[8];
95 
96  std::map<std::string /*ROC UID*/,
97  std::unique_ptr<ROCCoreVInterface>> rocs_;
98 
99  std::map<std::string /*DTC's FEMacro name*/,
100  std::pair<std::string /*ROC UID*/,
101  std::string /*ROC's FEMacro name*/>> rocFEMacroMap_;
102 
103  std::map<std::string /* ROC UID*/,
104  FESlowControlsChannel> mapOfROCSlowControlsChannels_;
105 
106  m_ioc_reg_access_t reg_access_;
107 
108  unsigned initial_9100_ = 0;
109  unsigned initial_9114_ = 0;
110 
111  std::ofstream outputStream;
112 
113  public:
114  void ReadROC (__ARGS__);
115  void WriteROC (__ARGS__);
116  void WriteROCBlock (__ARGS__);
117  void ReadROCBlock (__ARGS__);
118  void BlockReadROC (__ARGS__);
119  void DTCHighRateBlockCheck (__ARGS__);
120  void DTCReset (__ARGS__);
121  void DTCReset (void);
122  void DTCHighRateDCSCheck (__ARGS__);
123  void RunROCFEMacro (__ARGS__);
124  void DTCSendHeartbeatAndDataRequest(__ARGS__);
125 
126  // clang-format on
127 };
128 } // namespace ots
129 #endif