00001 00008 #ifndef _QWPSLOW_CONFIG_HANDLER_HH_ 00009 #define _QWPSLOW_CONFIG_HANDLER_HH_ 00010 00011 #include "QCuore.hh" 00012 #include "QDaqClient.hh" 00013 #include "QSlowControlClient.hh" 00014 00015 #include <map> 00016 #include <list> 00017 #include <vector> 00018 00019 class QLCSlowConfig; 00020 00021 class QWPSlowConfigHandler 00022 { 00023 public: 00024 00026 static QWPSlowConfigHandler& GetInstance(); 00027 00029 virtual ~QWPSlowConfigHandler(); 00030 00031 void KillDaqCrates(bool kill) { fKillDaq = kill; } 00032 00033 QError GetPresentConfig(const unsigned short lg,QLCSlowConfig& config); 00042 const QLCSlowConfig* GetConfig(const unsigned short lg, 00043 const unsigned short id) const; 00044 00063 virtual bool AddConfig(const unsigned short lg, QLCSlowConfig* config); 00064 00081 bool Schedule(const unsigned short lg, QLCSlowConfig* config); 00082 00090 const QLCSlowConfig* GetNextScheduled(const unsigned short lg) const; 00091 00101 void EraseNextScheduled(const unsigned short lg); 00102 00108 const QLCSlowConfig* GetLastConfig(const unsigned short lg) const; 00109 00117 bool AddNextScheduled(const unsigned short lg); 00118 00125 virtual void SetConfDone(const unsigned short lg,const unsigned short id); 00126 00131 bool IsConfDone() const { return fCurrentConfig.empty(); } 00132 00139 virtual bool SetActiveChannels(const std::list<unsigned short>& channels); 00140 00145 const std::list<unsigned short>& GetActiveChannels() const 00146 { return fChannels; } 00147 00152 void Clear(); 00153 00171 bool Consolidate(bool triggerFlag); 00172 00173 void Dump() const; 00174 00175 bool SetSleepTime(const unsigned short sleepTime); 00176 00177 unsigned short GetSleepTime() const { return fSleepTime; } 00178 00179 void Update() { UpdateDaq(false); } 00180 00181 00182 protected: 00184 QWPSlowConfigHandler(); 00192 std::map<unsigned short,std::vector<QLCSlowConfig*> > fConfigMap; 00193 00195 std::list<unsigned short> fChannels; 00196 private: 00197 bool fKillDaq; 00198 void UpdateDaq(bool reset); 00199 bool fTriggerFlag; 00200 00201 void InitSlowClient(); 00202 00209 std::map<unsigned short, std::list<QLCSlowConfig*> > fScheduled; 00210 std::map<unsigned short, QLCSlowConfig> fPresentConfigs; 00211 00217 std::map<unsigned short,unsigned short> fCurrentConfig; 00218 00219 00227 std::list<int> fCrates; 00228 00235 std::map<unsigned short, QLCSlowConfig*> fNextConfig; 00236 00238 unsigned short fSleepTime; 00239 00240 QDaqClient fDaqClient; 00241 QSlowControlClient fSlowClient; 00242 00254 bool ApplyConfig(const unsigned short lg, 00255 QLCSlowConfig* conf, 00256 const QLCSlowConfig* oldConf); 00257 00258 00260 void GetCratesToKill(); 00261 00267 bool CheckSlowStatus(); 00268 }; 00269 00270 #endif