1 #ifndef _ots_Iterator_h
2 #define _ots_Iterator_h
6 #include "otsdaq/TablePlugins/IterateTable.h"
7 #include "otsdaq/XmlUtilities/HttpXmlDocument.h"
9 #include "otsdaq/ConfigurationInterface/ConfigurationManagerRW.h"
13 class GatewaySupervisor;
14 class ConfigurationManagerRW;
24 void playIterationPlan(
HttpXmlDocument& xmldoc,
const std::string& planName);
29 bool handleCommandRequest(
HttpXmlDocument& xmldoc,
const std::string& command,
const std::string& parameter);
33 struct IteratorWorkLoopStruct
36 : theIterator_(iterator)
38 , originalTrackChanges_(
false)
41 , doPauseAction_(
false)
42 , doHaltAction_(
false)
43 , doResumeAction_(
false)
44 , commandIndex_((
unsigned int)-1)
50 bool originalTrackChanges_;
51 std::string originalConfigGroup_;
54 bool running_, commandBusy_;
55 bool doPauseAction_, doHaltAction_, doResumeAction_;
57 std::string activePlan_;
58 std::vector<IterateTable::Command> commands_;
59 std::vector<unsigned int> commandIterations_;
60 unsigned int commandIndex_;
61 std::vector<unsigned int> stepIndexStack_;
62 time_t originalDurationInSeconds_;
65 std::string fsmName_, fsmRunAlias_;
66 unsigned int fsmNextRunNumber_;
69 std::vector<std::string> fsmCommandParameters_;
70 std::vector<bool> targetsDone_;
74 static void IteratorWorkLoop(
Iterator* iterator);
75 static void startCommand(IteratorWorkLoopStruct* iteratorStruct);
76 static bool checkCommand(IteratorWorkLoopStruct* iteratorStruct);
78 static void startCommandChooseFSM(IteratorWorkLoopStruct* iteratorStruct,
const std::string& fsmName);
80 static void startCommandConfigureActive(IteratorWorkLoopStruct* iteratorStruct);
81 static void startCommandConfigureAlias(IteratorWorkLoopStruct* iteratorStruct,
const std::string& systemAlias);
82 static void startCommandConfigureGroup(IteratorWorkLoopStruct* iteratorStruct);
83 static bool checkCommandConfigure(IteratorWorkLoopStruct* iteratorStruct);
85 static void startCommandModifyActive(IteratorWorkLoopStruct* iteratorStruct);
87 static void startCommandMacro(IteratorWorkLoopStruct* iteratorStruct,
bool isFEMacro);
88 static bool checkCommandMacro(IteratorWorkLoopStruct* iteratorStruct,
bool isFEMacro);
90 static void startCommandBeginLabel(IteratorWorkLoopStruct* iteratorStruct);
91 static void startCommandRepeatLabel(IteratorWorkLoopStruct* iteratorStruct);
93 static void startCommandRun(IteratorWorkLoopStruct* iteratorStruct);
94 static bool checkCommandRun(IteratorWorkLoopStruct* iteratorStruct);
96 static bool haltIterator(
Iterator* iterator,
97 IteratorWorkLoopStruct* iteratorStruct = 0);
99 std::mutex accessMutex_;
100 volatile bool workloopRunning_;
101 volatile bool activePlanIsRunning_;
102 volatile bool iteratorBusy_;
103 volatile bool commandPlay_, commandPause_,
107 std::string activePlanName_, lastStartedPlanName_, lastFinishedPlanName_;
108 volatile unsigned int activeCommandIndex_, activeCommandIteration_;
109 std::vector<unsigned int> depthIterationStack_;
110 volatile time_t activeCommandStartTime_;
111 std::string lastFsmName_;
112 std::string errorMessage_;
117 static void helpCommandModifyActive(IteratorWorkLoopStruct* iteratorStruct,
const T& setValue,
bool doTrackGroupChanges);
120 #include "otsdaq/GatewaySupervisor/Iterator.icc"