#ifndef __DGFControlData_h__
#define __DGFControlData_h__
#include "TNamed.h"
#include "TEnv.h"
#include "TString.h"
#include "TList.h"
#include "TGLayout.h"
#include "TGMrbLayout.h"
#include "HistPresent.h"
#include "TMrbResource.h"
#include "TMrbNamedX.h"
#include "TMrbDGF.h"
#include "DGFModule.h"
class DGFControlData : public TObject {
friend class DGFRunControlPanel;
friend class DGFSetupPanel;
friend class DGFSetFilesPanel;
friend class DGFInstrumentPanel;
friend class DGFParamsPanel;
friend class DGFTauDisplayPanel;
friend class DGFTraceDisplayPanel;
friend class DGFUntrigTracePanel;
friend class DGFOffsetsPanel;
friend class DGFMcaDisplayPanel;
friend class DGFTauFitPanel;
friend class DGFEditModICSRPanel;
friend class DGFEditChanCSRAPanel;
friend class DGFEditUserPsaCSRPanel;
friend class DGFEditRunTaskPanel;
friend class DGFEditCoincPatternPanel;
friend class DGFCopyModuleSettingsPanel;
friend class DGFRestoreModuleSettingsPanel;
friend class DGFSaveModuleSettingsPanel;
friend class DGFMiscPanel;
friend class DGFModule;
friend class DGFCptmPanel;
public:
enum EDGFStatusBit { kDGFVerboseMode = BIT(0),
kDGFDebugMode = BIT(1),
kDGFModNumGlobal = BIT(2),
kDGFOfflineMode = BIT(3),
kDGFSimulStartStop = BIT(4),
kDGFSyncClocks = BIT(5),
kDGFIndivSwitchBusTerm = BIT(6),
kDGFUserPSA = BIT(7),
kDGFEsoneSingleStepMode = BIT(8)
};
enum EDGFAccessBit { kDGFAccessDirectory = BIT(0),
kDGFAccessRegular = BIT(1),
kDGFAccessRead = BIT(2),
kDGFAccessWrite = BIT(3)
};
public:
DGFControlData();
virtual ~DGFControlData() {
fHeap.Delete();
fLofModules.Delete();
};
Int_t SetupModuleList();
inline Int_t GetNofModules() { return(fNofModules); };
inline Int_t GetNofClusters() { return(fNofClusters); };
TMrbLofNamedX * CopyKeyList(TMrbLofNamedX * KeyList, Int_t Cluster = 0, Int_t NofClusters = -1, Bool_t ArrayMode = kTRUE);
TMrbLofNamedX * CopyKeyList(TMrbLofNamedX * KeyList, Int_t Cluster, UInt_t Pattern, Bool_t ClearFlag = kFALSE);
inline DGFModule * FirstModule() { return((DGFModule *) fLofModules.First()); };
inline DGFModule * NextModule(DGFModule * Last) { return((DGFModule *) fLofModules.After(Last)); };
Bool_t CheckIfStarted();
const Char_t * GetHost() { return(fCAMACHost.Data()); };
DGFModule * GetModule(const Char_t * ModuleName);
DGFModule * GetModule(Int_t GlobIndex);
DGFModule * GetModule(Int_t Cluster, Int_t ModNo);
Int_t GetChannel(Int_t ChannelIndex);
Int_t GetChannelIndex(Int_t Channel);
inline UInt_t ModuleIndex(Int_t Cluster, Int_t ModNo) { return(0x10000 << Cluster | 0x1 << ModNo); };
TMrbNamedX * GetKey(const Char_t * ModuleName);
TMrbNamedX * GetKey(const Char_t * ModuleName, Int_t & Cluster, Int_t & ModuleNumber);
UInt_t GetIndex(const Char_t * ModuleName);
UInt_t GetIndex(const Char_t * ModuleName, Int_t & Cluster, Int_t & ModuleNumber);
inline UInt_t GetPatEnabled(Int_t Cluster) { return(fPatEnabled[Cluster]); };
inline UInt_t GetPatInUse(Int_t Cluster) { return(fPatInUse[Cluster]); };
inline void SetPatInUse(Int_t Cluster, UInt_t Pattern) { fPatInUse[Cluster] = Pattern & 0xFFFF; };
inline DGFModule * GetSelectedModule() { return(this->GetModule(fSelectedModule)); };
inline Int_t GetSelectedModuleIndex() { return(fSelectedModule); };
inline void SetSelectedModuleIndex(Int_t ModuleIndex) { fSelectedModule = ModuleIndex; };
void SetSelectedModule(const Char_t * ModuleName);
inline void SetSelectedModule(DGFModule * Module) { this->SetSelectedModule(Module->GetName()); };
inline Int_t GetSelectedChannel() { return(this->GetChannel(fSelectedChannel)); };
inline Int_t GetSelectedChannelIndex() { return(fSelectedChannel); };
inline void SetSelectedChannel(Int_t Channel) { fSelectedChannel = this->GetChannelIndex(Channel); };
inline void SetSelectedChannelIndex(Int_t ChannelIndex) { fSelectedChannel = ChannelIndex; };
Int_t ChannelIndex2Number(Int_t ChannelIndex);
Bool_t ModuleInUse(DGFModule * Module);
Bool_t ModuleInUse(const Char_t * ModuleName);
inline HistPresent * GetHistPresent() { return(fHistPresent); };
inline Bool_t IsOffline() { return((fStatus & kDGFOfflineMode) != 0); };
inline Bool_t IsVerbose() { return((fStatus & DGFControlData::kDGFVerboseMode) != 0); };
inline Bool_t IsDebug() { return((fStatus & DGFControlData::kDGFDebugMode) != 0); };
inline Bool_t IsSingleStep() { return((fStatus & DGFControlData::kDGFEsoneSingleStepMode) != 0); };
inline const Char_t * NormalFont() { return(fNormalFont.Data()); };
inline const Char_t * BoldFont() { return(fBoldFont.Data()); };
inline const Char_t * SlantedFont() { return(fSlantedFont.Data()); };
inline void SetLH(TGMrbLayout * Layout1, TGMrbLayout * Layout2, TGLayoutHints * Hints) {
Layout1->SetLH(Hints);
Layout2->SetLH(Hints);
};
Bool_t CheckAccess(const Char_t * FileOrPath, Int_t AccessMode, TString & ErrMsg, Bool_t WarningOnly = kFALSE);
void UpdateParamsAndFPGAs();
void AddToUpdateList(DGFModule * Module);
inline TMrbResource * Rootrc() { return(fRootrc ? fRootrc : NULL); };
inline TMrbResource * Dgfrc() { return(fDgfrc ? fDgfrc : NULL); };
protected:
TList fHeap;
UInt_t fStatus;
Double_t fDeltaT;
TString fCAMACHost;
Int_t fDefaultCrate;
Int_t fNofClusters;
Int_t fNofModules;
TList fLofModules;
TMrbLofNamedX fLofModuleKeys[kNofClusters];
UInt_t fPatEnabled[kNofClusters];
UInt_t fPatInUse[kNofClusters];
TMrbLofNamedX fLofChannels;
TMrbLofNamedX fLofClusters;
TObjArray fLofModulesToBeUpdated;
Int_t fSelectedModule;
Int_t fSelectedChannel;
Bool_t fSimulStartStop;
Bool_t fSyncClocks;
Bool_t fIndivSwitchBusTerm;
Bool_t fUserPSA;
TString fLoadPath;
TString fDSPCodeFile;
TString fDSPParamsFile;
TString fUPSAParamsFile;
TString fSystemFPGAConfigFile;
TString fFippiFPGAConfigFile[TMrbDGFData::kNofRevs];
TString fCptmCodeFile;
TString fDataPath;
TString fRunDataFile;
TString fDgfSettingsPath;
TString fCptmSettingsPath;
HistPresent * fHistPresent;
TString fNormalFont;
TString fBoldFont;
TString fSlantedFont;
ULong_t fColorBlack;
ULong_t fColorWhite;
ULong_t fColorGray;
ULong_t fColorBlue;
ULong_t fColorDarkBlue;
ULong_t fColorGold;
ULong_t fColorGreen;
ULong_t fColorYellow;
ULong_t fColorRed;
TMrbResource * fRootrc;
TMrbResource * fDgfrc;
ClassDef(DGFControlData, 1)
};
class DGFControlInfo {
public:
UInt_t fActionBits;
UInt_t fChannels;
UInt_t fModules[kNofClusters];
Bool_t fExecute;
Bool_t fAccessDSP;
TString fPath;
};
#endif