otsdaq  v2_05_02_indev
FEVInterfacesManager.h
1 #ifndef _ots_FEVInterfacesManager_h_
2 #define _ots_FEVInterfacesManager_h_
3 
4 #include <map>
5 #include <memory>
6 #include <mutex>
7 #include <queue>
8 #include <string>
9 #include "otsdaq/Configurable/Configurable.h"
10 #include "otsdaq/FECore/FEVInterface.h"
11 #include "otsdaq/FiniteStateMachine/VStateMachine.h"
12 
13 namespace ots
14 {
15 // FEVInterfacesManager
16 // This class is a virtual class that handles a collection of front-end interface
17 // plugins.
19 {
20  public:
21  FEVInterfacesManager(const ConfigurationTree& theXDAQContextConfigTree, const std::string& supervisorConfigurationPath);
22  virtual ~FEVInterfacesManager(void);
23 
24  // Methods
25  void init(void);
26  void destroy(void);
27  void createInterfaces(void);
28 
29  // State Machine Methods
30  virtual void configure(void) override;
31  virtual void halt(void) override;
32  virtual void pause(void) override;
33  virtual void resume(void) override;
34  virtual void start(std::string runNumber) override;
35  virtual void stop(void) override;
36  virtual std::string getStatusProgressDetail(void) override; // overriding VStateMachine::getStatusProgressDetail
37 
38  void universalRead(const std::string& interfaceID, char* address,
39  char* returnValue); // used by MacroMaker
40  void universalWrite(const std::string& interfaceID, char* address,
41  char* writeValue); // used by MacroMaker
42  std::string getFEListString(const std::string& supervisorLid); // used by MacroMaker
43  std::string getFEMacrosString(const std::string& supervisorName,
44  const std::string& supervisorLid); // used by MacroMaker
45  void runFEMacro(const std::string& interfaceID,
47  const std::string& inputArgs,
48  std::string& outputArgs); // used by MacroMaker and FE calling indirectly
49  void runFEMacro(const std::string& interfaceID,
50  const std::string& feMacroName,
51  const std::string& inputArgs,
52  std::string& outputArgs); // used by MacroMaker
53  void runMacro(const std::string& interfaceID,
54  const std::string& macroObjectString,
55  const std::string& inputArgs,
56  std::string& outputArgs); // used by MacroMaker
57  void runFEMacroByFE(const std::string& callingInterfaceID,
58  const std::string& interfaceID,
59  const std::string& feMacroName,
60  const std::string& inputArgs,
61  std::string& outputArgs); // used by FE calling (i.e. FESupervisor)
62  void startFEMacroMultiDimensional(const std::string& requester,
63  const std::string& interfaceID,
64  const std::string& feMacroName,
65  const bool enableSavingOutput,
66  const std::string& outputFilePath,
67  const std::string& outputFileRadix,
68  const std::string& inputArgs); // used by iterator calling (i.e. FESupervisor)
69  void startMacroMultiDimensional(const std::string& requester,
70  const std::string& interfaceID,
71  const std::string& macroName,
72  const std::string& macroString,
73  const bool enableSavingOutput,
74  const std::string& outputFilePath,
75  const std::string& outputFileRadix,
76  const std::string& inputArgs); // used by iterator calling (i.e. FESupervisor)
77  bool checkMacroMultiDimensional(const std::string& interfaceID,
78  const std::string& macroName); // used by iterator calling (i.e. FESupervisor)
79 
80  unsigned int getInterfaceUniversalAddressSize(const std::string& interfaceID); // used by MacroMaker
81  unsigned int getInterfaceUniversalDataSize(const std::string& interfaceID); // used by MacroMaker
82  bool allFEWorkloopsAreDone(void); // used by Iterator, e.g.
83  const FEVInterface& getFEInterface(const std::string& interfaceID) const;
84 
85  const std::map<std::string /*name*/, std::unique_ptr<FEVInterface> >& getFEInterfaces(void) const { return theFEInterfaces_; }
86  FEVInterface* getFEInterfaceP(const std::string& interfaceID);
87 
88  // FE communication helpers
89  std::mutex frontEndCommunicationReceiveMutex_;
90  std::map<std::string /*targetInterfaceID*/, // map of target to buffers organized by
91  // source
92  std::map<std::string /*requester*/, std::queue<std::string /*value*/> > >
93  frontEndCommunicationReceiveBuffer_;
94 
95  // multi-dimensional FE Macro helpers
96  std::mutex macroMultiDimensionalDoneMutex_;
97  std::map<std::string /*targetInterfaceID*/, // set of active multi-dimensional Macro
98  // launches
99  std::string /*status := Active, Done, Error: <message> */>
100  macroMultiDimensionalStatusMap_;
101 
102  private:
103  std::map<std::string /*name*/, std::unique_ptr<FEVInterface> > theFEInterfaces_;
104  std::vector<std::string /*name*/> theFENamesByPriority_;
105 
106  // for managing transition iterations
107  std::map<std::string /*name*/, bool /*isDone*/> stateMachinesIterationDone_;
108  unsigned int stateMachinesIterationWorkCount_;
109  unsigned int subIterationWorkStateMachineIndex_;
110  void preStateMachineExecution(unsigned int i, const std::string& transitionName);
111  bool postStateMachineExecution(unsigned int i);
112  void preStateMachineExecutionLoop(void);
113  void postStateMachineExecutionLoop(void);
114 };
115 
116 } // namespace ots
117 
118 #endif
void startMacroMultiDimensional(const std::string &requester, const std::string &interfaceID, const std::string &macroName, const std::string &macroString, const bool enableSavingOutput, const std::string &outputFilePath, const std::string &outputFileRadix, const std::string &inputArgs)