QEleConfigHandler.hh
Go to the documentation of this file.00001
00002 #ifndef _Q_ELE_CONFIG_HANDLER_HH_
00003 #define _Q_ELE_CONFIG_HANDLER_HH_
00004
00005 #include <map>
00006 #include <vector>
00007 #include <set>
00008
00009 #include "QOnlineMessenger.hh"
00010
00011 namespace boost { class mutex; }
00012 namespace boost { class thread; }
00013
00014 #include "QError.hh"
00015
00016 class QEleChannelConfig;
00017
00053 class QEleConfigHandler: public QOnlineMessenger
00054 {
00055 public:
00057 static QEleConfigHandler& GetInstance();
00058
00060 virtual ~QEleConfigHandler();
00061
00071 bool Add(const QEleChannelConfig& config);
00072
00079 bool Replace(const QEleChannelConfig& config);
00080
00082 void RemoveConfig(int lg);
00083
00085 void RemoveAllConfigs();
00086
00094 void SetSleepAfterChangeSec(unsigned int sleepSec)
00095 { fSleepAfterChangeSec = sleepSec; }
00096
00098 void SetExternalBiasV(float extBiasVolt) { fExtBiasV = extBiasVolt; }
00099
00120 bool Apply();
00121
00130 const QEleChannelConfig* GetConfig(unsigned int lg, unsigned int id);
00131
00140 bool Reset(int settingsBasket, const std::set<int>& activeChannels);
00141
00150 void SetWrongPolarityChannels(const std::set<int>& channels)
00151 { fWrongPolarityChannels = channels; }
00152
00154 const QError& GetError() const { return fError; }
00155
00161 bool ResetError();
00162
00164 bool ConfigOngoing();
00165
00167 bool IsActiveChannel(int lg) const
00168 { return (fPastConfigs.find(lg) != fPastConfigs.end()); }
00169
00170 private:
00172 QEleConfigHandler();
00173
00175 static QEleConfigHandler *gMe;
00176
00182 std::map<int, QEleChannelConfig*> fInputConfigs;
00183
00189 std::map<int, QEleChannelConfig*> fTmpConfigs;
00190
00195 std::map<int, std::vector<QEleChannelConfig*> > fPastConfigs;
00196
00201 std::set<unsigned int> fCratesToKill;
00202
00204 std::set<int> fWrongPolarityChannels;
00205
00207 int fSettingsBasket;
00208
00213 unsigned int fSleepAfterChangeSec;
00214
00216 float fExtBiasV;
00217
00219 boost::mutex *fMutex;
00221 boost::thread *fThread;
00222
00227 QError fError;
00228
00237 bool SyncThread();
00238
00240 void CheckThread();
00241
00250 bool InterruptExecution();
00251
00257 bool GetCratesToKill(const std::set<int>& activeChannels);
00258
00260 void ClearMaps();
00261 };
00262
00263
00305 void ApplyElectronicsConfiguration(std::map<int, QEleChannelConfig> configs,
00306 int settingsBasket,
00307 const std::set<unsigned int>& cratesToKill,
00308 std::set<int> wrongPolarityChannels,
00309 unsigned int sleepAfterChangeSec,
00310 boost::mutex& theMutex,
00311 QError& retStatus);
00312
00313 #endif