2023-01-25 14:59:48 -05:00
|
|
|
#ifndef DIGITIZER_CLASS_H
|
|
|
|
#define DIGITIZER_CLASS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <CAEN_FELib.h>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string>
|
2023-02-28 17:08:34 -05:00
|
|
|
#include <map>
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-09-26 10:41:24 -04:00
|
|
|
#include "Hit.h"
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-02-22 12:41:48 -05:00
|
|
|
#define MaxOutFileSize 2*1024*1024*1024 //2GB
|
|
|
|
//#define MaxOutFileSize 20*1024*1024 //20MB
|
2023-01-25 14:59:48 -05:00
|
|
|
#define MaxNumberOfChannel 64
|
2023-10-25 14:57:07 -04:00
|
|
|
#define MaxNumberOfGroup 16
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-02-08 17:35:04 -05:00
|
|
|
#include "DigiParameters.h"
|
|
|
|
|
|
|
|
//^=================== Digitizer Class
|
2023-01-25 14:59:48 -05:00
|
|
|
class Digitizer2Gen {
|
|
|
|
private:
|
|
|
|
uint64_t handle;
|
|
|
|
uint64_t ep_handle; ///end point handle
|
|
|
|
uint64_t ep_folder_handle; ///end point folder handle
|
|
|
|
|
|
|
|
uint64_t stat_handle;
|
|
|
|
//uint64_t stat_folder_handle;
|
|
|
|
|
2023-01-27 18:52:03 -05:00
|
|
|
bool isDummy;
|
2023-01-25 14:59:48 -05:00
|
|
|
bool isConnected;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
char retValue[256];
|
|
|
|
|
|
|
|
unsigned short serialNumber;
|
2023-10-25 15:06:33 -04:00
|
|
|
unsigned int CupVer;
|
2023-09-22 15:58:28 -04:00
|
|
|
std::string FPGAType; // look the DigitiParameter.h::PHA::DIG::FirwareType, DPP_PHA, DPP_ZLE, DPP_PSD, DPP_DAW, DPP_OPEN, and Scope
|
|
|
|
unsigned int FPGAVer; // for checking copy setting
|
2023-01-25 14:59:48 -05:00
|
|
|
unsigned short nChannels;
|
2023-10-26 16:37:29 -04:00
|
|
|
unsigned short tick2ns;
|
2023-03-16 16:05:55 -04:00
|
|
|
std::string ModelName;
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
void Initialization();
|
|
|
|
|
|
|
|
uint64_t realTime[MaxNumberOfChannel];
|
|
|
|
uint64_t deadTime[MaxNumberOfChannel];
|
|
|
|
uint64_t liveTime[MaxNumberOfChannel];
|
|
|
|
uint32_t triggerCount[MaxNumberOfChannel];
|
|
|
|
uint32_t savedEventCount[MaxNumberOfChannel];
|
|
|
|
|
|
|
|
unsigned short outFileIndex;
|
|
|
|
unsigned short dataStartIndetifier;
|
|
|
|
std::string outFileNameBase;
|
|
|
|
char outFileName[100];
|
|
|
|
FILE * outFile;
|
|
|
|
unsigned int outFileSize;
|
2023-02-22 12:41:48 -05:00
|
|
|
uint64_t FinishedOutFilesSize;
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
bool acqON;
|
2023-02-23 12:24:39 -05:00
|
|
|
|
|
|
|
//all read and read/write settings
|
2023-02-23 16:08:47 -05:00
|
|
|
std::string settingFileName;
|
2023-02-23 12:24:39 -05:00
|
|
|
std::vector<Reg> boardSettings;
|
|
|
|
std::vector<Reg> chSettings[MaxNumberOfChannel];
|
2023-09-18 17:05:13 -04:00
|
|
|
std::vector<Reg> LVDSSettings[4];
|
2023-02-23 12:24:39 -05:00
|
|
|
Reg VGASetting[4];
|
2023-10-25 14:57:07 -04:00
|
|
|
Reg InputDelay[16];
|
2023-02-23 12:24:39 -05:00
|
|
|
|
2023-02-28 17:08:34 -05:00
|
|
|
std::map<std::string, int> boardMap;
|
2023-09-18 17:05:13 -04:00
|
|
|
std::map<std::string, int> LVDSMap;
|
2023-02-28 17:08:34 -05:00
|
|
|
std::map<std::string, int> chMap;
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
public:
|
|
|
|
Digitizer2Gen();
|
|
|
|
~Digitizer2Gen();
|
2023-01-25 17:16:14 -05:00
|
|
|
|
2023-09-22 15:58:28 -04:00
|
|
|
unsigned short GetSerialNumber() const {return serialNumber;}
|
|
|
|
std::string GetFPGAType() const {return FPGAType;}
|
|
|
|
std::string GetModelName() const {return ModelName;}
|
|
|
|
unsigned int GetFPGAVersion() const {return FPGAVer;}
|
2023-10-25 15:06:33 -04:00
|
|
|
unsigned int GetCupVer() const {return CupVer;}
|
2023-01-27 18:52:03 -05:00
|
|
|
|
2023-02-13 15:22:24 -05:00
|
|
|
void SetDummy(unsigned short sn);
|
2023-09-22 15:58:28 -04:00
|
|
|
bool IsDummy() const {return isDummy;}
|
|
|
|
bool IsConnected() const {return isConnected;}
|
2023-01-27 18:52:03 -05:00
|
|
|
|
2023-09-22 15:58:28 -04:00
|
|
|
int OpenDigitizer(const char * url);
|
|
|
|
int CloseDigitizer();
|
2023-02-07 18:58:00 -05:00
|
|
|
|
|
|
|
int GetRet() const {return ret;};
|
2023-02-28 17:08:34 -05:00
|
|
|
|
2023-09-22 15:58:28 -04:00
|
|
|
uint64_t GetHandle(const char * parameter);
|
|
|
|
uint64_t GetParentHandle(uint64_t handle);
|
|
|
|
std::string GetPath(uint64_t handle);
|
2023-02-28 17:08:34 -05:00
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
std::string ReadValue(const char * parameter, bool verbose = false);
|
2023-03-01 12:26:37 -05:00
|
|
|
std::string ReadValue(const Reg para, int ch_index = -1, bool verbose = false); // read digitizer and save to memory
|
2023-04-12 13:52:42 -04:00
|
|
|
bool WriteValue(const char * parameter, std::string value, bool verbose = true);
|
2023-03-01 12:26:37 -05:00
|
|
|
bool WriteValue(const Reg para, std::string value, int ch_index = -1); // write digituzer and save to memory
|
2023-01-25 14:59:48 -05:00
|
|
|
void SendCommand(const char * parameter);
|
2023-02-08 17:35:04 -05:00
|
|
|
void SendCommand(std::string shortPara);
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-09-22 15:58:28 -04:00
|
|
|
int FindIndex(const Reg para); // get index from DIGIPARA
|
2023-11-06 13:13:42 -05:00
|
|
|
std::string GetSettingValueFromMemory(const Reg para, unsigned int ch_index = 0); // read from memory
|
2023-09-22 15:58:28 -04:00
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
std::string ErrorMsg(const char * funcName);
|
|
|
|
|
|
|
|
void StartACQ();
|
|
|
|
void StopACQ();
|
|
|
|
bool IsAcqOn() const {return acqON;}
|
|
|
|
|
2023-09-22 15:58:28 -04:00
|
|
|
void SetDataFormat(unsigned short dataFormat); // dataFormat = namespace DataFormat
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
int ReadData();
|
2023-02-13 17:07:26 -05:00
|
|
|
int ReadStat(); // digitizer update it every 500 msec
|
2023-01-25 14:59:48 -05:00
|
|
|
void PrintStat();
|
2023-02-13 17:07:26 -05:00
|
|
|
uint32_t GetTriggerCount(int ch) const {return triggerCount[ch];}
|
|
|
|
uint64_t GetRealTime(int ch) const {return realTime[ch];}
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
void Reset();
|
2023-09-22 17:57:43 -04:00
|
|
|
void ProgramBoard();
|
|
|
|
void ProgramChannels(bool testPulse = false);
|
|
|
|
|
|
|
|
void PrintBoardSettings();
|
|
|
|
void PrintChannelSettings(unsigned short ch);
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
unsigned short GetNChannels() const {return nChannels;}
|
2023-10-26 16:37:29 -04:00
|
|
|
unsigned short GetTick2ns() const {return tick2ns;}
|
2023-01-25 14:59:48 -05:00
|
|
|
uint64_t GetHandle() const {return handle;}
|
|
|
|
|
2023-09-26 10:41:24 -04:00
|
|
|
Hit *hit; // should be hit[MaxNumber], when full or stopACQ, save into file
|
2023-04-04 11:46:02 -04:00
|
|
|
void OpenOutFile(std::string fileName, const char * mode = "wb"); //overwrite binary
|
2023-01-25 14:59:48 -05:00
|
|
|
void CloseOutFile();
|
|
|
|
void SaveDataToFile();
|
2023-02-22 12:41:48 -05:00
|
|
|
unsigned int GetFileSize() const {return outFileSize;}
|
|
|
|
uint64_t GetTotalFilesSize() const {return FinishedOutFilesSize + outFileSize;}
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-02-23 16:08:47 -05:00
|
|
|
std::string GetSettingFileName() const {return settingFileName;}
|
|
|
|
void SetSettingFileName(std::string fileName) {settingFileName = fileName;}
|
2023-02-23 12:24:39 -05:00
|
|
|
void ReadAllSettings(); // read settings from digitier and save to memory
|
2023-03-27 18:21:51 -04:00
|
|
|
int SaveSettingsToFile(const char * saveFileName = NULL, bool setReadOnly = false); //Save settings from memory to text file
|
2023-03-02 15:00:59 -05:00
|
|
|
int ReadAndSaveSettingsToFile(const char * saveFileName = NULL); // ReadAllSettings + text file
|
2023-02-23 16:08:47 -05:00
|
|
|
bool LoadSettingsFromFile(const char * loadFileName = NULL); // Load settings, write to digitizer and save to memory
|
2023-02-28 17:08:34 -05:00
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|