ROOT logo
#ifndef __DGFControlData_h__
#define __DGFControlData_h__

//_________________________________________________[C++ CLASS DEFINITION FILE]
//////////////////////////////////////////////////////////////////////////////
// Name:           DGFControlData.h
// Purpose:        Class defs for the XIA DGF-4C GUI
// Class:          DGFControlData
// Description:    A GUI to operate a XIA DGF-4C
// Author:         R. Lutter
// Revision:       $Id: DGFControlData.h,v 1.17 2008-08-28 07:16:48 Rudolf.Lutter Exp $       
// Date:           
// URL:            
// Keywords:       
//////////////////////////////////////////////////////////////////////////////

#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"

//______________________________________________________[C++ CLASS DEFINITION]
//////////////////////////////////////////////////////////////////////////////
// Name:           DGFControlData
// Purpose:        Common database to store any DGF data
// Description:    Common data base for all DGF modules
// Keywords:       
//////////////////////////////////////////////////////////////////////////////

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:
		// global status bits
		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();				// ctor

		virtual ~DGFControlData() { 	// dtor
			fHeap.Delete();
			fLofModules.Delete();
		};

//		DGFControlData(const DGFControlData & f) {};	// default copy ctor

		Int_t SetupModuleList();									// create module list and key list
		inline Int_t GetNofModules() { return(fNofModules); };		// number of dgf modules
		inline Int_t GetNofClusters() { return(fNofClusters); };	// number of clusters
		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()); };		// return first
		inline DGFModule * NextModule(DGFModule * Last) { return((DGFModule *) fLofModules.After(Last)); }; // get next module
		Bool_t CheckIfStarted();								// kTRUE if at least 1 module is active

		const Char_t * GetHost() { return(fCAMACHost.Data()); };	// get host name
		
		DGFModule * GetModule(const Char_t * ModuleName);		// get module by name
		DGFModule * GetModule(Int_t GlobIndex);					// get module by its global index
		DGFModule * GetModule(Int_t Cluster, Int_t ModNo);		// get module by [cluster,modno]
		Int_t GetChannel(Int_t ChannelIndex);					// get channel by index
		Int_t GetChannelIndex(Int_t Channel);					// convert channel number to channel index

		inline UInt_t ModuleIndex(Int_t Cluster, Int_t ModNo) { return(0x10000 << Cluster | 0x1 << ModNo); };
		TMrbNamedX * GetKey(const Char_t * ModuleName);			// get module key
		TMrbNamedX * GetKey(const Char_t * ModuleName, Int_t & Cluster, Int_t & ModuleNumber);
		UInt_t GetIndex(const Char_t * ModuleName); 			// get module index
		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); 				// check if module is in use
		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; 							// status bits

		Double_t fDeltaT;							// time granularity

		TString fCAMACHost; 						// default camac host
		Int_t fDefaultCrate;						// default crate number

		Int_t fNofClusters;							// number of clusters
		Int_t fNofModules;							// number of DGF modules
		TList fLofModules;							// list of modules

		TMrbLofNamedX fLofModuleKeys[kNofClusters];	//! ... key list
		UInt_t fPatEnabled[kNofClusters];			// pattern of modules enabled
		UInt_t fPatInUse[kNofClusters];				// pattern of modules in use
		TMrbLofNamedX fLofChannels;					//! channel numbers

		TMrbLofNamedX fLofClusters; 				// clusters: name, serial, color

		TObjArray fLofModulesToBeUpdated;			// modules to be updated

		Int_t fSelectedModule;						// index of module currently selected
		Int_t fSelectedChannel;						// index of channel currently selected

		Bool_t fSimulStartStop;						// kTRUE if to start/stop simultaneously
		Bool_t fSyncClocks;							// kTRUE if clocks have to be synchronized
		Bool_t fIndivSwitchBusTerm;					// kTRUE if switchbus should be terminated individually
		Bool_t fUserPSA;							// kTRUE if user PSA code should be used

		TString fLoadPath;						// where to load DSP/FPGA code from
		TString fDSPCodeFile;						// ... DSP code
		TString fDSPParamsFile;						// ... param table
		TString fUPSAParamsFile;					// ... extension for user psa
		TString fSystemFPGAConfigFile;				// ... FPGA config (system)
		TString fFippiFPGAConfigFile[TMrbDGFData::kNofRevs];		// ...             (fippi, rev D,E)
		TString fCptmCodeFile;						// where to load CPTM code from

		TString fDataPath;							// where to read user's setup files from
		TString fRunDataFile;						// ... run data

		TString fDgfSettingsPath; 					// param settings (dgf)
		TString fCptmSettingsPath; 					// ... (cptm)

		HistPresent * fHistPresent;					//! the famous histogram presenter
		
		TString fNormalFont; 						// gui fonts
		TString fBoldFont;
		TString fSlantedFont;
		
		ULong_t fColorBlack;						// gui colors
		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;						// environment
		TMrbResource * fDgfrc;

	ClassDef(DGFControlData, 1) 		// [DGFControl] Common data base
};

//______________________________________________________[C++ CLASS DEFINITION]
//////////////////////////////////////////////////////////////////////////////
// Name:           DGFControlInfo
// Purpose:        Pass results from transient wdw to caller
// Description:    
// Keywords:       
//////////////////////////////////////////////////////////////////////////////

class DGFControlInfo {

	public:
		UInt_t fActionBits; 			// selected actions
		UInt_t fChannels;				// selected channels
		UInt_t fModules[kNofClusters];	// selected modules
		Bool_t fExecute;				// execute
		Bool_t fAccessDSP;				// read from / write to DSP
		TString fPath;					// file path
};

#endif
 DGFControlData.h:1
 DGFControlData.h:2
 DGFControlData.h:3
 DGFControlData.h:4
 DGFControlData.h:5
 DGFControlData.h:6
 DGFControlData.h:7
 DGFControlData.h:8
 DGFControlData.h:9
 DGFControlData.h:10
 DGFControlData.h:11
 DGFControlData.h:12
 DGFControlData.h:13
 DGFControlData.h:14
 DGFControlData.h:15
 DGFControlData.h:16
 DGFControlData.h:17
 DGFControlData.h:18
 DGFControlData.h:19
 DGFControlData.h:20
 DGFControlData.h:21
 DGFControlData.h:22
 DGFControlData.h:23
 DGFControlData.h:24
 DGFControlData.h:25
 DGFControlData.h:26
 DGFControlData.h:27
 DGFControlData.h:28
 DGFControlData.h:29
 DGFControlData.h:30
 DGFControlData.h:31
 DGFControlData.h:32
 DGFControlData.h:33
 DGFControlData.h:34
 DGFControlData.h:35
 DGFControlData.h:36
 DGFControlData.h:37
 DGFControlData.h:38
 DGFControlData.h:39
 DGFControlData.h:40
 DGFControlData.h:41
 DGFControlData.h:42
 DGFControlData.h:43
 DGFControlData.h:44
 DGFControlData.h:45
 DGFControlData.h:46
 DGFControlData.h:47
 DGFControlData.h:48
 DGFControlData.h:49
 DGFControlData.h:50
 DGFControlData.h:51
 DGFControlData.h:52
 DGFControlData.h:53
 DGFControlData.h:54
 DGFControlData.h:55
 DGFControlData.h:56
 DGFControlData.h:57
 DGFControlData.h:58
 DGFControlData.h:59
 DGFControlData.h:60
 DGFControlData.h:61
 DGFControlData.h:62
 DGFControlData.h:63
 DGFControlData.h:64
 DGFControlData.h:65
 DGFControlData.h:66
 DGFControlData.h:67
 DGFControlData.h:68
 DGFControlData.h:69
 DGFControlData.h:70
 DGFControlData.h:71
 DGFControlData.h:72
 DGFControlData.h:73
 DGFControlData.h:74
 DGFControlData.h:75
 DGFControlData.h:76
 DGFControlData.h:77
 DGFControlData.h:78
 DGFControlData.h:79
 DGFControlData.h:80
 DGFControlData.h:81
 DGFControlData.h:82
 DGFControlData.h:83
 DGFControlData.h:84
 DGFControlData.h:85
 DGFControlData.h:86
 DGFControlData.h:87
 DGFControlData.h:88
 DGFControlData.h:89
 DGFControlData.h:90
 DGFControlData.h:91
 DGFControlData.h:92
 DGFControlData.h:93
 DGFControlData.h:94
 DGFControlData.h:95
 DGFControlData.h:96
 DGFControlData.h:97
 DGFControlData.h:98
 DGFControlData.h:99
 DGFControlData.h:100
 DGFControlData.h:101
 DGFControlData.h:102
 DGFControlData.h:103
 DGFControlData.h:104
 DGFControlData.h:105
 DGFControlData.h:106
 DGFControlData.h:107
 DGFControlData.h:108
 DGFControlData.h:109
 DGFControlData.h:110
 DGFControlData.h:111
 DGFControlData.h:112
 DGFControlData.h:113
 DGFControlData.h:114
 DGFControlData.h:115
 DGFControlData.h:116
 DGFControlData.h:117
 DGFControlData.h:118
 DGFControlData.h:119
 DGFControlData.h:120
 DGFControlData.h:121
 DGFControlData.h:122
 DGFControlData.h:123
 DGFControlData.h:124
 DGFControlData.h:125
 DGFControlData.h:126
 DGFControlData.h:127
 DGFControlData.h:128
 DGFControlData.h:129
 DGFControlData.h:130
 DGFControlData.h:131
 DGFControlData.h:132
 DGFControlData.h:133
 DGFControlData.h:134
 DGFControlData.h:135
 DGFControlData.h:136
 DGFControlData.h:137
 DGFControlData.h:138
 DGFControlData.h:139
 DGFControlData.h:140
 DGFControlData.h:141
 DGFControlData.h:142
 DGFControlData.h:143
 DGFControlData.h:144
 DGFControlData.h:145
 DGFControlData.h:146
 DGFControlData.h:147
 DGFControlData.h:148
 DGFControlData.h:149
 DGFControlData.h:150
 DGFControlData.h:151
 DGFControlData.h:152
 DGFControlData.h:153
 DGFControlData.h:154
 DGFControlData.h:155
 DGFControlData.h:156
 DGFControlData.h:157
 DGFControlData.h:158
 DGFControlData.h:159
 DGFControlData.h:160
 DGFControlData.h:161
 DGFControlData.h:162
 DGFControlData.h:163
 DGFControlData.h:164
 DGFControlData.h:165
 DGFControlData.h:166
 DGFControlData.h:167
 DGFControlData.h:168
 DGFControlData.h:169
 DGFControlData.h:170
 DGFControlData.h:171
 DGFControlData.h:172
 DGFControlData.h:173
 DGFControlData.h:174
 DGFControlData.h:175
 DGFControlData.h:176
 DGFControlData.h:177
 DGFControlData.h:178
 DGFControlData.h:179
 DGFControlData.h:180
 DGFControlData.h:181
 DGFControlData.h:182
 DGFControlData.h:183
 DGFControlData.h:184
 DGFControlData.h:185
 DGFControlData.h:186
 DGFControlData.h:187
 DGFControlData.h:188
 DGFControlData.h:189
 DGFControlData.h:190
 DGFControlData.h:191
 DGFControlData.h:192
 DGFControlData.h:193
 DGFControlData.h:194
 DGFControlData.h:195
 DGFControlData.h:196
 DGFControlData.h:197
 DGFControlData.h:198
 DGFControlData.h:199
 DGFControlData.h:200
 DGFControlData.h:201
 DGFControlData.h:202
 DGFControlData.h:203
 DGFControlData.h:204
 DGFControlData.h:205
 DGFControlData.h:206
 DGFControlData.h:207
 DGFControlData.h:208
 DGFControlData.h:209
 DGFControlData.h:210
 DGFControlData.h:211
 DGFControlData.h:212
 DGFControlData.h:213
 DGFControlData.h:214
 DGFControlData.h:215
 DGFControlData.h:216
 DGFControlData.h:217
 DGFControlData.h:218
 DGFControlData.h:219
 DGFControlData.h:220
 DGFControlData.h:221
 DGFControlData.h:222
 DGFControlData.h:223
 DGFControlData.h:224
 DGFControlData.h:225
 DGFControlData.h:226
 DGFControlData.h:227
 DGFControlData.h:228
 DGFControlData.h:229
 DGFControlData.h:230
 DGFControlData.h:231
 DGFControlData.h:232
 DGFControlData.h:233
 DGFControlData.h:234
 DGFControlData.h:235
 DGFControlData.h:236
 DGFControlData.h:237
 DGFControlData.h:238
 DGFControlData.h:239
 DGFControlData.h:240
 DGFControlData.h:241
 DGFControlData.h:242
 DGFControlData.h:243
 DGFControlData.h:244
 DGFControlData.h:245
 DGFControlData.h:246
 DGFControlData.h:247
 DGFControlData.h:248
 DGFControlData.h:249