1 #ifndef _ots_FEVInterface_h_
2 #define _ots_FEVInterface_h_
4 #define TRACE_NAME "FEVInterface"
5 #include "artdaq/DAQdata/Globals.hh"
7 #include "otsdaq/Configurable/Configurable.h"
8 #include "otsdaq/FECore/FESlowControlsWorkLoop.h"
9 #include "otsdaq/FiniteStateMachine/VStateMachine.h"
10 #include "otsdaq/WorkLoopManager/WorkLoop.h"
12 #include "otsdaq/CoreSupervisors/CoreSupervisorBase.h"
14 #include "otsdaq/SupervisorInfo/AllSupervisorInfo.h"
16 #include "otsdaq/CoreSupervisors/FESupervisor.h"
18 #include "otsdaq/FECore/FESlowControlsChannel.h"
19 #include "otsdaq/SOAPUtilities/SOAPMessenger.h"
26 #include "otsdaq/Macros/CoutMacros.h"
28 #define __ARGS__ [[maybe_unused]] const frontEndMacroStruct_t &feMacroStruct,[[maybe_unused]] FEVInterface::frontEndMacroConstArgs_t argsIn, [[maybe_unused]] FEVInterface::frontEndMacroArgs_t argsOut
30 #define __GET_ARG_IN__(X, Y) getFEMacroConstArgumentValue<Y>(argsIn, X)
31 #define __GET_ARG_OUT__(X, Y) getFEMacroArgumentValue<Y>(argsOut, X)
33 #define __SET_ARG_IN__(X, Y) FEVInterface::emplaceFEMacroArgumentValue(argsIn, X, Y)
34 #define __SET_ARG_OUT__(X, Y) FEVInterface::setFEMacroArgumentValue(argsOut, X, Y)
38 class FEVInterfacesManager;
57 const std::string& interfaceUID,
59 const std::string& configurationPath);
66 const std::string& getInterfaceUID (
void)
const {
return interfaceUID_; }
67 virtual std::string getInterfaceType (
void)
const
69 return theXDAQContextConfigTree_.getBackNode(theConfigurationPath_)
70 .getNode(
"FEInterfacePluginName")
71 .getValue<std::string>();
74 virtual void universalRead (
char* address,
char* returnValue) = 0;
75 virtual void universalWrite (
char* address,
char* writeValue) = 0;
76 const unsigned int& getUniversalAddressSize (
void) {
return universalAddressSize_; }
77 const unsigned int& getUniversalDataSize (
void) {
return universalDataSize_; }
79 void runSequenceOfCommands (
const std::string& treeLinkName);
81 static void sendAsyncErrorToGateway (
FEVInterface* fe,
const std::string& errMsg,
bool isSoftError);
85 virtual void configure (
void)
87 __COUT__ <<
"\t Configure" << std::endl;
88 runSequenceOfCommands(
89 "LinkToConfigureSequence");
91 virtual void start (std::string )
93 __COUT__ <<
"\t Start" << std::endl;
94 runSequenceOfCommands(
"LinkToStartSequence");
96 virtual void stop (
void)
98 __COUT__ <<
"\t Stop" << std::endl;
99 runSequenceOfCommands(
"LinkToStopSequence");
101 virtual void halt (
void) { stop(); }
102 virtual void pause (
void) { stop(); }
103 virtual void resume (
void) { start(
""); }
104 virtual bool running (
void) {
return false; }
110 virtual void configureSlowControls (
void);
111 void addSlowControlsChannels (
ConfigurationTree slowControlsGroupLink,
const std::string& subInterfaceID, std::map<std::string /* ROC UID*/, FESlowControlsChannel>* mapOfSlowControlsChannels);
113 virtual void resetSlowControlsChannelIterator (
void);
115 virtual unsigned int getSlowControlsChannelCount (
void);
117 bool slowControlsRunning (
void);
118 void startSlowControlsWorkLoop (
void) { slowControlsWorkLoop_.startWorkLoop(); }
119 void stopSlowControlsWorkLoop (
void) { slowControlsWorkLoop_.stopWorkLoop(); }
123 std::map<std::string, FESlowControlsChannel> mapOfSlowControlsChannels_;
124 std::map<std::string,
134 using frontEndMacroArg_t = std::pair<
const std::string , std::string >;
135 using frontEndMacroArgs_t = std::vector<frontEndMacroArg_t>&;
136 using frontEndMacroConstArgs_t =
const std::vector<frontEndMacroArg_t>&;
142 const std::string& feMacroName,
143 const frontEndMacroFunction_t& feMacroFunction,
144 const std::vector<std::string>& namesOfInputArgs,
145 const std::vector<std::string>& namesOfOutputArgs,
146 const uint8_t requiredUserPermissions = 1 ,
147 const std::string& allowedCallingFrontEnds =
"*" )
148 : feMacroName_ (feMacroName)
149 , macroFunction_ (feMacroFunction)
150 , namesOfInputArguments_ (namesOfInputArgs)
151 , namesOfOutputArguments_ (namesOfOutputArgs)
152 , requiredUserPermissions_ (requiredUserPermissions)
153 , allowedCallingFrontEnds_ (allowedCallingFrontEnds)
157 const std::string feMacroName_;
158 const frontEndMacroFunction_t macroFunction_;
159 const std::vector<std::string> namesOfInputArguments_, namesOfOutputArguments_;
160 const uint8_t requiredUserPermissions_;
161 const std::string allowedCallingFrontEnds_;
163 const std::map<std::string, frontEndMacroStruct_t>& getMapOfFEMacroFunctions(
void)
165 return mapOfFEMacroFunctions_;
167 void runSelfFrontEndMacro (
168 const std::string& feMacroName,
169 const std::vector<FEVInterface::frontEndMacroArg_t>& inputArgs,
170 std::vector<FEVInterface::frontEndMacroArg_t>& outputArgs);
191 std::string addressVarName_;
193 std::string dataVarName_;
200 std::string addressVarName_;
203 std::string dataVarName_;
210 std::string delayVarName_;
213 std::string macroName_;
214 std::vector<std::pair<
unsigned int ,
217 std::vector<macroStruct_t::readOp_t> readOps_;
218 std::vector<macroStruct_t::writeOp_t> writeOps_;
219 std::vector<macroStruct_t::delayOp_t> delayOps_;
220 std::set<std::string> namesOfInputArguments_, namesOfOutputArguments_;
225 std::map<std::string /*name*/, uint64_t /*value*/>& variableMap);
235 void sendToFrontEnd (
const std::string& targetInterfaceID,
const T& value)
const;
236 void runFrontEndMacro (
const std::string& targetInterfaceID,
const std::string& feMacroName,
const std::vector<FEVInterface::frontEndMacroArg_t>& inputArgs, std::vector<FEVInterface::frontEndMacroArg_t>& outputArgs)
const;
243 void receiveFromFrontEnd (
const std::string& requester, T& retValue,
unsigned int timeoutInSeconds = 1)
const;
245 void receiveFromFrontEnd (
const std::string& requester, std::string& retValue,
unsigned int timeoutInSeconds = 1)
const;
249 T receiveFromFrontEnd (
const std::string& requester =
"*",
unsigned int timeoutInSeconds = 1)
const;
251 std::string receiveFromFrontEnd (
const std::string& requester =
"*",
unsigned int timeoutInSeconds = 1)
const;
257 bool workLoopThread (toolbox::task::WorkLoop* workLoop);
259 std::string interfaceUID_;
260 std::string mfSubject_;
262 unsigned int universalAddressSize_ = 0;
263 unsigned int universalDataSize_ = 0;
268 std::map<std::string, frontEndMacroStruct_t> mapOfFEMacroFunctions_;
269 void registerFEMacroFunction (
270 const std::string& feMacroName,
271 frontEndMacroFunction_t feMacroFunction,
272 const std::vector<std::string>& namesOfInputArgs,
273 const std::vector<std::string>& namesOfOutputArgs,
274 uint8_t requiredUserPermissions = 1 ,
275 const std::string& allowedCallingFEs =
"*" );
278 static const std::string& getFEMacroConstArgument (frontEndMacroConstArgs_t args,
const std::string& argName);
279 static std::string& getFEMacroArgument (frontEndMacroArgs_t args,
const std::string& argName);
283 std::string& setFEMacroArgumentValue (frontEndMacroArgs_t args,
const std::string& argName,
const T& value)
const;
286 std::string& emplaceFEMacroArgumentValue (frontEndMacroArgs_t args,
const std::string& argName,
const T& value)
const;
292 T getFEMacroConstArgumentValue (FEVInterface::frontEndMacroConstArgs_t args,
const std::string& argName);
296 std::string getFEMacroConstArgumentValue<std::string> (FEVInterface::frontEndMacroConstArgs_t args,
const std::string& argName);
299 T getFEMacroArgumentValue (FEVInterface::frontEndMacroArgs_t args,
const std::string& argName);
303 std::string getFEMacroArgumentValue<std::string> (FEVInterface::frontEndMacroArgs_t argsIn,
const std::string& argName);
306 #include "otsdaq/FECore/FEVInterface.icc"