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);
30 const std::string& command,
31 const std::string& parameter);
35 struct IteratorWorkLoopStruct
38 : theIterator_(iterator)
40 , originalTrackChanges_(
false)
43 , doPauseAction_(
false)
44 , doHaltAction_(
false)
45 , doResumeAction_(
false)
46 , commandIndex_((
unsigned int)-1)
52 bool originalTrackChanges_;
53 std::string originalConfigGroup_;
56 bool running_, commandBusy_;
57 bool doPauseAction_, doHaltAction_, doResumeAction_;
59 std::string activePlan_;
60 std::vector<IterateTable::Command> commands_;
61 std::vector<unsigned int> commandIterations_;
62 unsigned int commandIndex_;
63 std::vector<unsigned int> stepIndexStack_;
64 time_t originalDurationInSeconds_;
67 std::string fsmName_, fsmRunAlias_;
68 unsigned int fsmNextRunNumber_;
71 std::vector<std::string> fsmCommandParameters_;
72 std::vector<bool> targetsDone_;
76 static void IteratorWorkLoop(
Iterator* iterator);
77 static void startCommand(IteratorWorkLoopStruct* iteratorStruct);
78 static bool checkCommand(IteratorWorkLoopStruct* iteratorStruct);
80 static void startCommandChooseFSM(IteratorWorkLoopStruct* iteratorStruct,
81 const std::string& fsmName);
83 static void startCommandConfigureActive(IteratorWorkLoopStruct* iteratorStruct);
84 static void startCommandConfigureAlias(IteratorWorkLoopStruct* iteratorStruct,
85 const std::string& systemAlias);
86 static void startCommandConfigureGroup(IteratorWorkLoopStruct* iteratorStruct);
87 static bool checkCommandConfigure(IteratorWorkLoopStruct* iteratorStruct);
89 static void startCommandModifyActive(IteratorWorkLoopStruct* iteratorStruct);
91 static void startCommandMacro(IteratorWorkLoopStruct* iteratorStruct,
bool isFEMacro);
92 static bool checkCommandMacro(IteratorWorkLoopStruct* iteratorStruct,
bool isFEMacro);
94 static void startCommandBeginLabel(IteratorWorkLoopStruct* iteratorStruct);
95 static void startCommandRepeatLabel(IteratorWorkLoopStruct* iteratorStruct);
97 static void startCommandRun(IteratorWorkLoopStruct* iteratorStruct);
98 static bool checkCommandRun(IteratorWorkLoopStruct* iteratorStruct);
100 static bool haltIterator(
102 IteratorWorkLoopStruct* iteratorStruct =
105 std::mutex accessMutex_;
106 volatile bool workloopRunning_;
107 volatile bool activePlanIsRunning_;
108 volatile bool iteratorBusy_;
109 volatile bool commandPlay_, commandPause_,
113 std::string activePlanName_, lastStartedPlanName_, lastFinishedPlanName_;
114 volatile unsigned int activeCommandIndex_, activeCommandIteration_;
115 std::vector<unsigned int> depthIterationStack_;
116 volatile time_t activeCommandStartTime_;
117 std::string lastFsmName_;
118 std::string errorMessage_;
123 static void helpCommandModifyActive(IteratorWorkLoopStruct* iteratorStruct,
125 bool doTrackGroupChanges);
128 #include "otsdaq/GatewaySupervisor/Iterator.icc"