$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_Iterator_h 00002 #define _ots_Iterator_h 00003 00004 #include <mutex> //for std::mutex 00005 #include <string> 00006 #include "otsdaq-core/TablePluginDataFormats/IterateTable.h" 00007 #include "otsdaq-core/XmlUtilities/HttpXmlDocument.h" 00008 00009 #include "otsdaq-core/ConfigurationInterface/ConfigurationManagerRW.h" 00010 00011 namespace ots 00012 { 00013 class GatewaySupervisor; 00014 class ConfigurationManagerRW; 00015 00016 class Iterator 00017 { 00018 friend class GatewaySupervisor; 00019 00020 public: 00021 Iterator(GatewaySupervisor* supervisor); 00022 ~Iterator(void); 00023 00024 void playIterationPlan(HttpXmlDocument& xmldoc, const std::string& planName); 00025 void pauseIterationPlan(HttpXmlDocument& xmldoc); 00026 void haltIterationPlan(HttpXmlDocument& xmldoc); 00027 void getIterationPlanStatus(HttpXmlDocument& xmldoc); 00028 00029 bool handleCommandRequest(HttpXmlDocument& xmldoc, 00030 const std::string& command, 00031 const std::string& parameter); 00032 00033 private: 00034 // begin declaration of iterator workloop members 00035 struct IteratorWorkLoopStruct 00036 { 00037 IteratorWorkLoopStruct(Iterator* iterator, ConfigurationManagerRW* cfgMgr) 00038 : theIterator_(iterator) 00039 , cfgMgr_(cfgMgr) 00040 , originalTrackChanges_(false) 00041 , running_(false) 00042 , commandBusy_(false) 00043 , doPauseAction_(false) 00044 , doHaltAction_(false) 00045 , doResumeAction_(false) 00046 , commandIndex_((unsigned int)-1) 00047 { 00048 } 00049 00050 Iterator* theIterator_; 00051 ConfigurationManagerRW* cfgMgr_; 00052 bool originalTrackChanges_; 00053 std::string originalConfigGroup_; 00054 TableGroupKey originalConfigKey_; 00055 00056 bool running_, commandBusy_; 00057 bool doPauseAction_, doHaltAction_, doResumeAction_; 00058 00059 std::string activePlan_; 00060 std::vector<IterateTable::Command> commands_; 00061 std::vector<unsigned int> commandIterations_; 00062 unsigned int commandIndex_; 00063 std::vector<unsigned int> stepIndexStack_; 00064 00065 // associated with FSM 00066 std::string fsmName_, fsmRunAlias_; 00067 unsigned int fsmNextRunNumber_; 00068 bool runIsDone_; 00069 00070 std::vector<std::string> fsmCommandParameters_; 00071 std::vector<bool> targetsDone_; 00072 00073 }; // end declaration of iterator workloop members 00074 00075 static void IteratorWorkLoop(Iterator* iterator); 00076 static void startCommand(IteratorWorkLoopStruct* iteratorStruct); 00077 static bool checkCommand(IteratorWorkLoopStruct* iteratorStruct); 00078 00079 static void startCommandChooseFSM(IteratorWorkLoopStruct* iteratorStruct, 00080 const std::string& fsmName); 00081 00082 static void startCommandConfigureActive(IteratorWorkLoopStruct* iteratorStruct); 00083 static void startCommandConfigureAlias(IteratorWorkLoopStruct* iteratorStruct, 00084 const std::string& systemAlias); 00085 static void startCommandConfigureGroup(IteratorWorkLoopStruct* iteratorStruct); 00086 static bool checkCommandConfigure(IteratorWorkLoopStruct* iteratorStruct); 00087 00088 static void startCommandModifyActive(IteratorWorkLoopStruct* iteratorStruct); 00089 00090 static void startCommandMacro(IteratorWorkLoopStruct* iteratorStruct, bool isFEMacro); 00091 static bool checkCommandMacro(IteratorWorkLoopStruct* iteratorStruct, bool isFEMacro); 00092 00093 static void startCommandBeginLabel(IteratorWorkLoopStruct* iteratorStruct); 00094 static void startCommandRepeatLabel(IteratorWorkLoopStruct* iteratorStruct); 00095 00096 static void startCommandRun(IteratorWorkLoopStruct* iteratorStruct); 00097 static bool checkCommandRun(IteratorWorkLoopStruct* iteratorStruct); 00098 00099 static bool haltIterator( 00100 Iterator* iterator, 00101 IteratorWorkLoopStruct* iteratorStruct = 00102 0); //(GatewaySupervisor* theSupervisor, const std::string& fsmName); 00103 00104 std::mutex accessMutex_; 00105 volatile bool workloopRunning_; 00106 volatile bool activePlanIsRunning_; 00107 volatile bool iteratorBusy_; 00108 volatile bool commandPlay_, commandPause_, 00109 commandHalt_; // commands are set by 00110 // supervisor thread, and 00111 // cleared by iterator thread 00112 std::string activePlanName_, lastStartedPlanName_, lastFinishedPlanName_; 00113 volatile unsigned int activeCommandIndex_, activeCommandIteration_; 00114 std::vector<unsigned int> depthIterationStack_; 00115 volatile time_t activeCommandStartTime_; 00116 std::string lastFsmName_; 00117 std::string errorMessage_; 00118 00119 GatewaySupervisor* theSupervisor_; 00120 00121 template<class T> // defined in included .icc source 00122 static void helpCommandModifyActive(IteratorWorkLoopStruct* iteratorStruct, 00123 const T& setValue, 00124 bool doTrackGroupChanges); 00125 }; 00126 00127 #include "otsdaq-core/GatewaySupervisor/Iterator.icc" //for template definitions 00128 00129 } // namespace ots 00130 00131 #endif