00001
00008 #ifndef _QSLOW_CONFIG_HANDLER_HH_
00009 #define _QSLOW_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 QLCSlowConfigHandler
00022 {
00023 public:
00024
00026 static QLCSlowConfigHandler& GetInstance();
00027
00029 virtual ~QLCSlowConfigHandler();
00030
00039 const QLCSlowConfig* GetConfig(const unsigned short lg,
00040 const unsigned short id) const;
00041
00043 bool GetCurrentBranch() const { return fCurrentBranch; }
00044
00046 float GetExternalBias() const { return fExternalBias; }
00047
00060 bool SetExternalBias(const float bias);
00061
00080 bool AddConfig(const unsigned short lg, QLCSlowConfig* config);
00081
00098 bool Schedule(const unsigned short lg, QLCSlowConfig* config);
00099
00107 const QLCSlowConfig* GetNextScheduled(const unsigned short lg) const;
00108
00118 void EraseNextScheduled(const unsigned short lg);
00119
00125 const QLCSlowConfig* GetLastConfig(const unsigned short lg) const;
00126
00134 bool AddNextScheduled(const unsigned short lg);
00135
00142 void SetConfDone(const unsigned short lg,const unsigned short id);
00143
00148 bool IsConfDone() const { return fCurrentConfig.empty(); }
00149
00158 bool SetCurveDone(const unsigned short lg);
00159
00164 bool IsCurvesDone() const { return fChannels.empty(); }
00165
00173 bool SetBranchDone(const unsigned short lg);
00174
00180 bool IsBranchDone() const;
00181
00188 bool SetActiveChannels(const std::list<unsigned short>& channels);
00189
00195 bool GoToPositiveBranch();
00196
00201 const std::list<unsigned short>& GetActiveChannels() const
00202 { return fChannels; }
00203
00208 void Clear();
00209
00212 void ClearMemory();
00213
00214
00232 bool Consolidate();
00233
00234 void Dump() const;
00235
00236 bool SetSleepTime(const unsigned short sleepTime);
00237
00238 unsigned short GetSleepTime() const { return fSleepTime; }
00239 private:
00241 QLCSlowConfigHandler();
00242
00243 void InitSlowClient();
00244
00245
00247 float fExternalBias;
00248
00255 std::map<unsigned short,std::vector<QLCSlowConfig*> > fConfigMap;
00256
00263 std::map<unsigned short, std::list<QLCSlowConfig*> > fScheduled;
00264
00270 std::map<unsigned short,unsigned short> fCurrentConfig;
00271
00273 std::list<unsigned short> fChannels;
00274
00276 std::list<unsigned short> fBranchDone;
00277
00287 bool fCurrentBranch;
00288
00296 std::list<int> fCrates;
00297
00304 std::map<unsigned short, QLCSlowConfig*> fNextConfig;
00305
00307 unsigned short fSleepTime;
00308
00309 QDaqClient fDaqClient;
00310 QSlowControlClient fSlowClient;
00311
00323 bool ApplyConfig(const unsigned short lg,
00324 QLCSlowConfig* conf,
00325 const QLCSlowConfig* oldConf);
00326
00327
00329 void GetCratesToKill();
00330
00332 void UpdateExternalBias();
00333
00339 bool CheckSlowStatus();
00340 };
00341
00342 #endif