1 #ifndef _ots_Iterator_h
2 #define _ots_Iterator_h
5 #include "otsdaq-core/ConfigurationPluginDataFormats/IterateConfiguration.h"
6 #include "otsdaq-core/XmlUtilities/HttpXmlDocument.h"
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);
34 struct IteratorWorkLoopStruct
37 :theIterator_ (iterator)
41 ,doPauseAction_ (
false)
42 ,doHaltAction_ (
false)
43 ,doResumeAction_ (
false)
44 ,commandIndex_ ((
unsigned int)-1)
50 bool running_, commandBusy_;
51 bool doPauseAction_, doHaltAction_, doResumeAction_;
53 std::string activePlan_;
54 std::vector<IterateConfiguration::Command> commands_;
55 unsigned int commandIndex_;
56 std::vector<unsigned int> stepIndexStack_;
59 std::string fsmName_, fsmRunAlias_;
60 unsigned int fsmNextRunNumber_;
62 std::vector<std::string> fsmCommandParameters_;
67 static void IteratorWorkLoop (
Iterator *iterator);
68 static void startCommand (IteratorWorkLoopStruct *iteratorStruct);
69 static bool checkCommand (IteratorWorkLoopStruct *iteratorStruct);
71 static void startCommandChooseFSM (IteratorWorkLoopStruct *iteratorStruct,
const std::string& fsmName);
73 static void startCommandConfigureActive (IteratorWorkLoopStruct *iteratorStruct);
74 static void startCommandConfigureAlias (IteratorWorkLoopStruct *iteratorStruct,
const std::string& systemAlias);
75 static void startCommandConfigureGroup (IteratorWorkLoopStruct *iteratorStruct);
76 static bool checkCommandConfigure (IteratorWorkLoopStruct *iteratorStruct);
77 static void startCommandModifyActive (IteratorWorkLoopStruct *iteratorStruct);
79 static void startCommandBeginLabel (IteratorWorkLoopStruct *iteratorStruct);
80 static void startCommandRepeatLabel (IteratorWorkLoopStruct *iteratorStruct);
82 static void startCommandRun (IteratorWorkLoopStruct *iteratorStruct);
83 static bool checkCommandRun (IteratorWorkLoopStruct *iteratorStruct);
85 static bool haltStateMachine (
Supervisor* theSupervisor,
const std::string& fsmName);
87 std::mutex accessMutex_;
88 volatile bool workloopRunning_;
89 volatile bool activePlanIsRunning_;
90 volatile bool iteratorBusy_;
91 volatile bool commandPlay_, commandPause_, commandHalt_;
92 std::string activePlanName_, lastStartedPlanName_, lastFinishedPlanName_;
93 volatile unsigned int activeCommandIndex_;
94 volatile time_t activeCommandStartTime_;
95 std::string lastFsmName_;
96 std::string errorMessage_;