fix many bugs and extended RegisterAddress to include max value and step

This commit is contained in:
splitPoleDAQ 2023-04-19 13:41:43 -04:00
parent cd0f41841f
commit fecb77a105
10 changed files with 471 additions and 225 deletions

67
.vscode/settings.json vendored
View File

@ -84,6 +84,71 @@
"files.associations": {
"mainWindow.C": "cpp",
"Scope.C": "cpp",
"new": "cpp"
"new": "cpp",
"allocator": "cpp",
"array": "cpp",
"istream": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"limits": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"mutex": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"span": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
}
}

View File

@ -19,13 +19,13 @@
class Data{
public:
char *buffer; /// readout buffer
int DPPType;
std::string DPPTypeStr;
unsigned short boardSN;
float ch2ns;
unsigned int nByte; /// number of byte from read buffer
char *buffer; /// readout buffer
uint32_t AllocatedSize;
double TriggerRate[MaxNChannels]; /// Hz
@ -81,18 +81,19 @@ class Data{
unsigned int nw;
bool SaveWaveToMemory;
unsigned int outFileIndex;
std::string outFilePrefix;
std::string outFileName;
FILE * outFile;
unsigned int outFileSize; // should be max at 2 GB
uint64_t FinishedOutFilesSize; // sum of files size.
///for temperary
std::vector<unsigned short> tempWaveform1;
std::vector<unsigned short> tempWaveform2;
std::vector<bool> tempDigiWaveform1;
std::vector<bool> tempDigiWaveform2;
FILE * outFile;
uint64_t FinishedOutFilesSize; // sum of files size.
unsigned int outFileIndex;
std::string outFilePrefix;
std::string outFileName;
unsigned int outFileSize; // should be max at 2 GB
unsigned int ReadBuffer(unsigned int nWord, int verbose = 0);

View File

@ -462,7 +462,7 @@ void Digitizer::PrintACQStatue(){
//===========================================================
//===========================================================
//===========================================================
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
void Digitizer::WriteRegister (Register::Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
printf("%30s[0x%04X](ch-%02d) [0x%04X]: 0x%08X \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),ch, registerAddress.ActualAddress(ch), value);
@ -472,10 +472,10 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool
return;
}
if( registerAddress.GetType() == RW::ReadONLY ) return;
if( registerAddress.GetType() == Register::RW::ReadONLY ) return;
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress.ActualAddress(ch), value);
if( ret == 0 && isSave2MemAndFile && registerAddress.GetType() == RW::ReadWrite) {
if( ret == 0 && isSave2MemAndFile && registerAddress.GetType() == Register::RW::ReadWrite) {
SetSettingToMemory(registerAddress, value, ch);
SaveSettingToFile(registerAddress, value, ch);
}
@ -483,21 +483,20 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool
ErrorMsg("WriteRegister:" + std::to_string(registerAddress));
}
uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){
uint32_t Digitizer::ReadRegister(Register::Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){
if( !isConnected ) return 0;
if( registerAddress.GetType() == RW::WriteONLY ) return 0;
if( registerAddress.GetType() == Register::RW::WriteONLY ) return 0;
uint32_t data[1];
ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), data);
ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), &returnData);
if( ret == 0 && isSave2MemAndFile) {
SetSettingToMemory(registerAddress, data[0], ch);
SaveSettingToFile(registerAddress, data[0], ch);
SetSettingToMemory(registerAddress, returnData, ch);
SaveSettingToFile(registerAddress, returnData, ch);
}
ErrorMsg("ReadRegister:" + std::to_string(registerAddress));
if( str != "" ) printf("%s : 0x%04X(0x%04X) is 0x%08X \n", str.c_str(),
registerAddress.ActualAddress(ch), registerAddress.GetAddress(), data[0]);
return data[0];
registerAddress.ActualAddress(ch), registerAddress.GetAddress(), returnData);
return returnData;
}
uint32_t Digitizer::PrintRegister(uint32_t address, std::string msg){
@ -518,9 +517,9 @@ uint32_t Digitizer::PrintRegister(uint32_t address, std::string msg){
}
//========================================== setting file IO
Reg Digitizer::FindRegister(uint32_t address){
Register::Reg Digitizer::FindRegister(uint32_t address){
Reg tempReg;
Register::Reg tempReg;
///========= Find Match Register
for( int p = 0; p < (int) RegisterDPPList[p]; p++){
if( address == RegisterDPPList[p].GetAddress() ) {
@ -558,8 +557,8 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
printf("===== %s \n", __func__);
/// board setting
for( int p = 0; p < (int) RegisterDPPList[p]; p++){
if( RegisterDPPList[p].GetType() == RW::WriteONLY) continue;
for( int p = 0; p < (int) RegisterDPPList.size(); p++){
if( RegisterDPPList[p].GetType() == Register::RW::WriteONLY) continue;
ReadRegister(RegisterDPPList[p]);
}
@ -568,14 +567,14 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
/// Channels Setting
for( int ch = 0; ch < NChannel; ch ++){
if( DPPType == V1730_DPP_PHA_CODE ){
for( int p = 0; p < (int) RegisterPHAList[p]; p++){
if( RegisterPHAList[p].GetType() == RW::WriteONLY) continue;
for( int p = 0; p < (int) RegisterPHAList.size(); p++){
if( RegisterPHAList[p].GetType() == Register::RW::WriteONLY) continue;
ReadRegister(RegisterPHAList[p], ch);
}
}
if( DPPType == V1730_DPP_PSD_CODE ){
for( int p = 0; p < (int) RegisterPSDList[p]; p++){
if( RegisterPSDList[p].GetType() == RW::WriteONLY) continue;
for( int p = 0; p < (int) RegisterPSDList.size(); p++){
if( RegisterPSDList[p].GetType() == Register::RW::WriteONLY) continue;
ReadRegister(RegisterPSDList[p], ch);
}
}
@ -587,11 +586,11 @@ void Digitizer::ProgramSettingsToBoard(){
if( !isConnected ) return;
if( isDummy ) return;
Reg haha;
Register::Reg haha;
/// board setting
for( int p = 0; p < (int) RegisterDPPList[p]; p++){
if( RegisterDPPList[p].GetType() == RW::ReadONLY) continue;
if( RegisterDPPList[p].GetType() == Register::RW::ReadONLY) continue;
haha = RegisterDPPList[p];
WriteRegister(haha, GetSettingFromMemory(haha), -1, false);
usleep(100 * 1000);
@ -600,7 +599,7 @@ void Digitizer::ProgramSettingsToBoard(){
for( int ch = 0; ch < NChannel; ch ++){
if( DPPType == V1730_DPP_PHA_CODE ){
for( int p = 0; p < (int) RegisterPHAList[p]; p++){
if( RegisterPHAList[p].GetType() == RW::ReadONLY) continue;
if( RegisterPHAList[p].GetType() == Register::RW::ReadONLY) continue;
haha = RegisterPHAList[p];
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
usleep(100 * 1000);
@ -608,7 +607,7 @@ void Digitizer::ProgramSettingsToBoard(){
}
if( DPPType == V1730_DPP_PSD_CODE ){
for( int p = 0; p < (int) RegisterPSDList[p]; p++){
if( RegisterPSDList[p].GetType() == RW::ReadONLY) continue;
if( RegisterPSDList[p].GetType() == Register::RW::ReadONLY) continue;
haha = RegisterPHAList[p];
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
usleep(100 * 1000);
@ -617,13 +616,13 @@ void Digitizer::ProgramSettingsToBoard(){
}
}
void Digitizer::SetSettingToMemory(Reg registerAddress, unsigned int value, unsigned short ch ){
void Digitizer::SetSettingToMemory(Register::Reg registerAddress, unsigned int value, unsigned short ch ){
unsigned short index = registerAddress.Index(ch);
if( index > SETTINGSIZE ) return;
setting[index] = value;
}
unsigned int Digitizer::GetSettingFromMemory(Reg registerAddress, unsigned short ch ){
unsigned int Digitizer::GetSettingFromMemory(Register::Reg registerAddress, unsigned short ch ){
unsigned short index = registerAddress.Index(ch);
if( index > SETTINGSIZE ) return 0xFFFF;
return setting[index] ;
@ -697,7 +696,7 @@ int Digitizer::LoadSettingBinaryToMemory(std::string fileName){
}
}
unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short ch){
unsigned int Digitizer::ReadSettingFromFile(Register::Reg registerAddress, unsigned short ch){
if ( !settingFileExist ) return -1;
unsigned short index = registerAddress.Index(ch);
@ -717,7 +716,7 @@ unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short
}
void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){
void Digitizer::SaveSettingToFile(Register::Reg registerAddress, unsigned int value, unsigned short ch){
if ( !settingFileExist ) return ;
unsigned short index = registerAddress.Index(ch);
@ -757,7 +756,7 @@ void Digitizer::SaveAllSettingsAsText(std::string fileName){
return;
}
Reg haha;
Register::Reg haha;
for( unsigned int i = 0; i < SETTINGSIZE ; i++){
haha.SetName("");
@ -779,9 +778,9 @@ void Digitizer::SaveAllSettingsAsText(std::string fileName){
}
if( haha.GetName() != "" ) {
std::string typeStr ;
if( haha.GetType() == RW::ReadWrite ) typeStr = "R/W";
if( haha.GetType() == RW::ReadONLY ) typeStr = "R ";
if( haha.GetType() == RW::WriteONLY ) typeStr = " W";
if( haha.GetType() == Register::RW::ReadWrite ) typeStr = "R/W";
if( haha.GetType() == Register::RW::ReadONLY ) typeStr = "R ";
if( haha.GetType() == Register::RW::WriteONLY ) typeStr = " W";
fprintf( txtFile, "0x%04X %30s 0x%08X %s %u\n", actualAddress,
haha.GetNameChar(),
setting[i],

View File

@ -56,6 +56,8 @@ class Digitizer{
//^-------- other protected functions
void ErrorMsg(std::string header = "");
uint32_t returnData;
public:
Digitizer(); /// no digitizer open
Digitizer(int boardID, int portID = 0, bool program = false, bool verbose = false);
@ -90,10 +92,10 @@ class Digitizer{
/// write value to digitizer, memory, and settingFile (if exist)
/// ONLY WriteRegister can have ch = -1, for writting all channels
/// for board setting, ignore ch
void WriteRegister (Reg registerAddress, uint32_t value, int ch = -1, bool isSave2MemAndFile = true);
void WriteRegister (Register::Reg registerAddress, uint32_t value, int ch = -1, bool isSave2MemAndFile = true);
/// read value from digitizer and memory, and save to memory, and settingFile(if exist),
/// for board setting, ignore ch
uint32_t ReadRegister (Reg registerAddress, unsigned short ch = 0, bool isSave2MemAndFile = true, std::string str = "" );
uint32_t ReadRegister (Register::Reg registerAddress, unsigned short ch = 0, bool isSave2MemAndFile = true, std::string str = "" );
uint32_t PrintRegister(uint32_t address, std::string msg);
//^================ Get Board info
@ -112,14 +114,14 @@ class Digitizer{
CAEN_DGTZ_ConnectionType GetLinkType() const {return LinkType;}
//^================ Setting
Reg FindRegister(uint32_t address);
Register::Reg FindRegister(uint32_t address);
/// board <--> memory functions
void ReadAllSettingsFromBoard (bool force = false);
void ProgramSettingsToBoard ();
/// simply read settings from memory
void SetSettingToMemory (Reg registerAddress, unsigned int value, unsigned short ch = 0);
unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0);
void SetSettingToMemory (Register::Reg registerAddress, unsigned int value, unsigned short ch = 0);
unsigned int GetSettingFromMemory (Register::Reg registerAddress, unsigned short ch = 0);
void PrintSettingFromMemory ();
unsigned int * GetSettings() {return setting;};
@ -133,8 +135,8 @@ class Digitizer{
/// load setting file to memory
/// if problem, return -1; load without problem, return 0;
int LoadSettingBinaryToMemory (std::string fileName);
void SaveSettingToFile (Reg registerAddress, unsigned int value, unsigned short ch = 0); /// also save to memory
unsigned int ReadSettingFromFile (Reg registerAddress, unsigned short ch = 0); /// read from setting binary
void SaveSettingToFile (Register::Reg registerAddress, unsigned int value, unsigned short ch = 0); /// also save to memory
unsigned int ReadSettingFromFile (Register::Reg registerAddress, unsigned short ch = 0); /// read from setting binary
};

View File

@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
bnOpenScope = new QPushButton("Open Scope", this);
layout->addWidget(bnOpenScope, 1, 0);
//connect(bnDigiSettings, &QPushButton::clicked, this, &MainWindow::OpenDigiSettings);
connect(bnOpenScope, &QPushButton::clicked, this, &MainWindow::OpenScope);
bnDigiSettings = new QPushButton("Digitizers Settings", this);
layout->addWidget(bnDigiSettings, 1, 1);
@ -186,6 +186,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
//connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar);
}
//=========== disable widget
WaitForDigitizersOpen(true);
}
MainWindow::~MainWindow(){
@ -194,6 +198,7 @@ MainWindow::~MainWindow(){
SaveProgramSettings();
if( scope ) delete scope;
}
@ -335,19 +340,19 @@ void MainWindow::OpenDigitizers(){
logMsgHTMLMode = false;
nDigi = 0;
std::vector<std::pair<int, int>> portList; //boardID, portID
Digitizer dig;
for(int port = 0; port < MaxNPorts; port++){
for( int board = 0; board < MaxNBoards; board ++){ /// max number of iasy chain
Digitizer dig;
dig.OpenDigitizer(board, port);
if( dig.IsConnected() ){
nDigi++;
portList.push_back(std::pair(board, port));
LogMsg(QString("... Found at port: %1, board: %2. SN: %3 %4").arg(port).arg(board).arg(dig.GetSerialNumber(), 3, 10, QChar(' ')).arg(dig.GetDPPString().c_str()));
dig.CloseDigitizer();
QCoreApplication::processEvents(); //to prevent Qt said application not responding.
}//else{
//LogMsg(QString("... Nothing at port: %1, board: %2.").arg(port).arg(board));
//}
dig.CloseDigitizer();
QCoreApplication::processEvents(); //to prevent Qt said application not responding.
}
}
LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s)....").arg(nDigi));
@ -363,6 +368,8 @@ void MainWindow::OpenDigitizers(){
LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi));
WaitForDigitizersOpen(false);
SetupScalar();
}
@ -391,6 +398,21 @@ void MainWindow::CloseDigitizers(){
LogMsg("Done. Closed " + QString::number(nDigi) + " Digitizer(s).");
nDigi = 0;
WaitForDigitizersOpen(true);
}
void MainWindow::WaitForDigitizersOpen(bool onOff){
bnOpenDigitizers->setEnabled(onOff);
bnCloseDigitizers->setEnabled(!onOff);
bnOpenScope->setEnabled(!onOff);
bnDigiSettings->setEnabled(!onOff);
bnOpenScaler->setEnabled(!onOff);
bnStartACQ->setEnabled(!onOff);
bnStopACQ->setEnabled(!onOff);
chkSaveData->setEnabled(!onOff);
}

View File

@ -22,6 +22,10 @@ public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void closeEvent(QCloseEvent * event){
if( scope ) scope->close();
event->accept();
}
private slots:
@ -33,6 +37,7 @@ private slots:
void OpenDigitizers();
void CloseDigitizers();
void WaitForDigitizersOpen(bool onOff);
void SetupScalar();
void CleanUpScalar();

View File

@ -2,6 +2,7 @@
#define REGISTERADDRESS_H
#include <vector>
#include <string>
///=======
/// All 0x1XXX registers are either indiviual or Group
@ -17,32 +18,41 @@
/// Reg haha("haha", 0x1234);
/// uint32_t papa = haha; /// papa = 0x1234
enum RW { ReadWrite = 0, ReadONLY = 1, WriteONLY = 2};
namespace Register {
enum RW { ReadWrite, ReadONLY, WriteONLY};
class Reg{
public:
Reg(){
this->name = "";
this->address = 0;
this->type = 0;
this->group = 0;
name = "";
address = 0;
type = RW::ReadWrite;
group = 0;
maxValue = 0;
partialStep = 0;
}
Reg(std::string name, uint32_t address, char type = 0, bool group = 0){
Reg(std::string name, uint32_t address, RW type = RW::ReadWrite, bool group = false, unsigned int max = 0, int pStep = 0){
this->name = name;
this->address = address;
this->type = type;
this->group = group;
this->maxValue = max;
this->partialStep = pStep;
};
~Reg(){};
operator uint32_t () const {return this->address;} /// this allows Reg kaka("kaka", 0x1234) uint32_t haha = kaka;
std::string GetName() const {return this->name;}
const char * GetNameChar() const {return this->name.c_str();}
uint32_t GetAddress() const {return this->address; }
char GetType() const {return this->type;}
bool GetGroup() const {return this->group;}
std::string GetName() const {return name;}
const char * GetNameChar() const {return name.c_str();}
uint32_t GetAddress() const {return address; }
RW GetType() const {return type;}
bool GetGroup() const {return group;}
unsigned int GetMax() const {return maxValue;}
int GetPartialStep() const {return partialStep;} /// step = partialStep * ch2ns, -1 : step = 1
void Print() const ;
uint32_t ActualAddress(int ch = -1){
@ -58,17 +68,22 @@ class Reg{
void SetName(std::string str) {this->name = str;}
private:
uint32_t address; /// This is the table of register, the actual address should call ActualAddress();
std::string name;
char type; /// read/write = 0; read = 1; write = 2
uint32_t address; /// This is the table of register, the actual address should call ActualAddress();
RW type; /// read/write = 0; read = 1; write = 2
bool group;
unsigned int maxValue ;
int partialStep;
};
inline void Reg::Print() const{
printf(" Name: %s\n", name.c_str());
printf("Address: 0x%04X\n", address);
printf(" Type: %s\n", type == RW::ReadWrite ? "Read/Write" : (type == RW::ReadONLY ? "Read-Only" : "Write-Only") );
printf(" Group: %s\n", group ? "True" : "False");
printf(" Name: %s\n", name.c_str());
printf(" Re.Address: 0x%04X\n", address);
printf(" Type: %s\n", type == RW::ReadWrite ? "Read/Write" : (type == RW::ReadONLY ? "Read-Only" : "Write-Only") );
printf(" Group: %s\n", group ? "True" : "False");
printf(" Max Value : 0x%X = %d \n", maxValue, maxValue);
}
inline unsigned short Reg::Index (unsigned short ch){
@ -109,168 +124,169 @@ inline uint32_t Reg::CalAddress(unsigned int index){
return actualAddress;
}
namespace Register {
const Reg EventReadOutBuffer("EventReadOutBuffer", 0x0000, 1); /// R
const Reg EventReadOutBuffer("EventReadOutBuffer", 0x0000, RW::ReadONLY); /// R
///========== Channel or Group
const Reg ChannelDummy32 ("ChannelDummy32" , 0x1024); /// R/W
const Reg InputDynamicRange ("InputDynamicRange" , 0x1028); /// R/W
const Reg ChannelPulseWidth ("ChannelPulseWidth" , 0x1070); /// R/W
const Reg ChannelTriggerThreshold ("ChannelTriggerThreshold" , 0x1080); /// R/W
const Reg CoupleSelfTriggerLogic_G ("CoupleSelfTriggerLogic_G" , 0x1084, 0 , 1); /// R/W
const Reg ChannelStatus_R ("ChannelStatus_R" , 0x1088, 1); /// R
const Reg AMCFirmwareRevision_R ("AMCFirmwareRevision_R" , 0x108C, 1); /// R
const Reg CoupleSelfTriggerLogic_G ("CoupleSelfTriggerLogic_G" , 0x1084, RW::ReadWrite , 1); /// R/W
const Reg ChannelStatus_R ("ChannelStatus_R" , 0x1088, RW::ReadONLY); /// R
const Reg AMCFirmwareRevision_R ("AMCFirmwareRevision_R" , 0x108C, RW::ReadONLY); /// R
const Reg ChannelDCOffset ("ChannelDCOffset" , 0x1098); /// R/W
const Reg ChannelADCTemperature_R ("ChannelADCTemperature_R" , 0x10A8, 1); /// R
const Reg ChannelSelfTriggerRateMeter_R ("ChannelSelfTriggerRateMeter_R", 0x10EC, 1); /// R
const Reg ChannelADCTemperature_R ("ChannelADCTemperature_R" , 0x10A8, RW::ReadONLY); /// R
const Reg ChannelSelfTriggerRateMeter_R ("ChannelSelfTriggerRateMeter_R", 0x10EC, RW::ReadONLY); /// R
///========== Board
const Reg BoardConfiguration ("BoardConfiguration" , 0x8000, 0); /// R/W
const Reg BufferOrganization ("BufferOrganization" , 0x800C, 0); /// R/W
const Reg CustomSize ("CustomSize" , 0x8020, 0); /// R/W
const Reg ADCCalibration_W ("ADCCalibration_W" , 0x809C, 2); /// W
const Reg AcquisitionControl ("AcquisitionControl" , 0x8100, 0); /// R/W
const Reg AcquisitionStatus_R ("AcquisitionStatus_R" , 0x8104, 1); /// R
const Reg SoftwareTrigger_W ("SoftwareTrigger_W" , 0x8108, 2); /// W
const Reg GlobalTriggerMask ("GlobalTriggerMask" , 0x810C, 0); /// R/W
const Reg FrontPanelTRGOUTEnableMask ("FrontPanelTRGOUTEnableMask" , 0x8110, 0); /// R/W
const Reg PostTrigger ("PostTrigger" , 0x8114, 0); /// R/W
const Reg LVDSIOData ("LVDSIOData" , 0x8118, 0); /// R/W
const Reg FrontPanelIOControl ("FrontPanelIOControl" , 0x811C, 0); /// R/W
const Reg ChannelEnableMask ("ChannelEnableMask" , 0x8120, 0); /// R/W
const Reg ROCFPGAFirmwareRevision_R ("ROCFPGAFirmwareRevision_R" , 0x8124, 1); /// R
const Reg EventStored_R ("EventStored_R" , 0x812C, 1); /// R
const Reg VoltageLevelModeConfig ("VoltageLevelModeConfig" , 0x8138, 0); /// R/W
const Reg SoftwareClockSync_W ("SoftwareClockSync_W" , 0x813C, 2); /// W
const Reg BoardInfo_R ("BoardInfo_R" , 0x8140, 1); /// R
const Reg AnalogMonitorMode ("AnalogMonitorMode" , 0x8144, 0); /// R/W
const Reg EventSize_R ("EventSize_R" , 0x814C, 1); /// R
const Reg FanSpeedControl ("FanSpeedControl" , 0x8168, 0); /// R/W
const Reg MemoryBufferAlmostFullLevel ("MemoryBufferAlmostFullLevel" , 0x816C, 0); /// R/W
const Reg RunStartStopDelay ("RunStartStopDelay" , 0x8170, 0); /// R/W
const Reg BoardFailureStatus_R ("BoardFailureStatus_R" , 0x8178, 1); /// R
const Reg FrontPanelLVDSIONewFeatures ("FrontPanelLVDSIONewFeatures" , 0x81A0, 0); /// R/W
const Reg BufferOccupancyGain ("BufferOccupancyGain" , 0x81B4, 0); /// R/W
const Reg ChannelsShutdown_W ("ChannelsShutdown_W" , 0x81C0, 2); /// W
const Reg ExtendedVetoDelay ("ExtendedVetoDelay" , 0x81C4, 0); /// R/W
const Reg ReadoutControl ("ReadoutControl" , 0xEF00, 0); /// R/W
const Reg ReadoutStatus_R ("ReadoutStatus_R" , 0xEF04, 1); /// R
const Reg BoardID ("BoardID" , 0xEF08, 0); /// R/W
const Reg MCSTBaseAddressAndControl ("MCSTBaseAddressAndControl" , 0xEF0C, 0); /// R/W
const Reg RelocationAddress ("RelocationAddress" , 0xEF10, 0); /// R/W
const Reg InterruptStatusID ("InterruptStatusID" , 0xEF14, 0); /// R/W
const Reg InterruptEventNumber ("InterruptEventNumber" , 0xEF18, 0); /// R/W
const Reg MaxAggregatePerBlockTransfer ("MaxAggregatePerBlockTransfer" , 0xEF1C, 0); /// R/W
const Reg Scratch ("Scratch" , 0xEF20, 0); /// R/W
const Reg SoftwareReset_W ("SoftwareReset_W" , 0xEF24, 2); /// W
const Reg SoftwareClear_W ("SoftwareClear_W" , 0xEF28, 2); /// W
const Reg BoardConfiguration ("BoardConfiguration" , 0x8000, RW::ReadWrite); /// R/W
const Reg BufferOrganization ("BufferOrganization" , 0x800C, RW::ReadWrite); /// R/W
const Reg CustomSize ("CustomSize" , 0x8020, RW::ReadWrite); /// R/W
const Reg ADCCalibration_W ("ADCCalibration_W" , 0x809C, RW::WriteONLY); /// W
const Reg AcquisitionControl ("AcquisitionControl" , 0x8100, RW::ReadWrite); /// R/W
const Reg AcquisitionStatus_R ("AcquisitionStatus_R" , 0x8104, RW::ReadONLY); /// R
const Reg SoftwareTrigger_W ("SoftwareTrigger_W" , 0x8108, RW::WriteONLY); /// W
const Reg GlobalTriggerMask ("GlobalTriggerMask" , 0x810C, RW::ReadWrite); /// R/W
const Reg FrontPanelTRGOUTEnableMask ("FrontPanelTRGOUTEnableMask" , 0x8110, RW::ReadWrite); /// R/W
const Reg PostTrigger ("PostTrigger" , 0x8114, RW::ReadWrite); /// R/W
const Reg LVDSIOData ("LVDSIOData" , 0x8118, RW::ReadWrite); /// R/W
const Reg FrontPanelIOControl ("FrontPanelIOControl" , 0x811C, RW::ReadWrite); /// R/W
const Reg ChannelEnableMask ("ChannelEnableMask" , 0x8120, RW::ReadWrite); /// R/W
const Reg ROCFPGAFirmwareRevision_R ("ROCFPGAFirmwareRevision_R" , 0x8124, RW::ReadONLY); /// R
const Reg EventStored_R ("EventStored_R" , 0x812C, RW::ReadONLY); /// R
const Reg VoltageLevelModeConfig ("VoltageLevelModeConfig" , 0x8138, RW::ReadWrite); /// R/W
const Reg SoftwareClockSync_W ("SoftwareClockSync_W" , 0x813C, RW::WriteONLY); /// W
const Reg BoardInfo_R ("BoardInfo_R" , 0x8140, RW::ReadONLY); /// R
const Reg AnalogMonitorMode ("AnalogMonitorMode" , 0x8144, RW::ReadWrite); /// R/W
const Reg EventSize_R ("EventSize_R" , 0x814C, RW::ReadONLY); /// R
const Reg FanSpeedControl ("FanSpeedControl" , 0x8168, RW::ReadWrite); /// R/W
const Reg MemoryBufferAlmostFullLevel ("MemoryBufferAlmostFullLevel" , 0x816C, RW::ReadWrite); /// R/W
const Reg RunStartStopDelay ("RunStartStopDelay" , 0x8170, RW::ReadWrite); /// R/W
const Reg BoardFailureStatus_R ("BoardFailureStatus_R" , 0x8178, RW::ReadONLY); /// R
const Reg FrontPanelLVDSIONewFeatures ("FrontPanelLVDSIONewFeatures" , 0x81A0, RW::ReadWrite); /// R/W
const Reg BufferOccupancyGain ("BufferOccupancyGain" , 0x81B4, RW::ReadWrite); /// R/W
const Reg ChannelsShutdown_W ("ChannelsShutdown_W" , 0x81C0, RW::WriteONLY); /// W
const Reg ExtendedVetoDelay ("ExtendedVetoDelay" , 0x81C4, RW::ReadWrite); /// R/W
const Reg ReadoutControl ("ReadoutControl" , 0xEF00, RW::ReadWrite); /// R/W
const Reg ReadoutStatus_R ("ReadoutStatus_R" , 0xEF04, RW::ReadONLY); /// R
const Reg BoardID ("BoardID" , 0xEF08, RW::ReadWrite); /// R/W
const Reg MCSTBaseAddressAndControl ("MCSTBaseAddressAndControl" , 0xEF0C, RW::ReadWrite); /// R/W
const Reg RelocationAddress ("RelocationAddress" , 0xEF10, RW::ReadWrite); /// R/W
const Reg InterruptStatusID ("InterruptStatusID" , 0xEF14, RW::ReadWrite); /// R/W
const Reg InterruptEventNumber ("InterruptEventNumber" , 0xEF18, RW::ReadWrite); /// R/W
const Reg MaxAggregatePerBlockTransfer ("MaxAggregatePerBlockTransfer" , 0xEF1C, RW::ReadWrite); /// R/W
const Reg Scratch ("Scratch" , 0xEF20, RW::ReadWrite); /// R/W
const Reg SoftwareReset_W ("SoftwareReset_W" , 0xEF24, RW::WriteONLY); /// W
const Reg SoftwareClear_W ("SoftwareClear_W" , 0xEF28, RW::WriteONLY); /// W
///====== Common for PHA and PSD
namespace DPP {
const Reg RecordLength_G ("RecordLength_G" , 0x1020, 0, 1); /// R/W
const Reg InputDynamicRange ("InputDynamicRange" , 0x1028, 0); /// R/W
const Reg NumberEventsPerAggregate_G ("NumberEventsPerAggregate_G" , 0x1034, 0, 1); /// R/W
const Reg PreTrigger ("PreTrigger" , 0x1038, 0); /// R/W
const Reg TriggerThreshold ("TriggerThreshold" , 0x106C, 0); /// R/W
const Reg TriggerHoldOffWidth ("TriggerHoldOffWidth" , 0x1074, 0); /// R/W
const Reg DPPAlgorithmControl ("DPPAlgorithmControl" , 0x1080, 0); /// R/W
const Reg ChannelStatus_R ("ChannelStatus_R" , 0x1088, 1); /// R
const Reg AMCFirmwareRevision_R ("AMCFirmwareRevision_R" , 0x108C, 1); /// R
const Reg ChannelDCOffset ("ChannelDCOffset" , 0x1098, 0); /// R/W
const Reg ChannelADCTemperature_R ("ChannelADCTemperature_R" , 0x10A8, 1); /// R
const Reg IndividualSoftwareTrigger_W ("IndividualSoftwareTrigger_W" , 0x10C0, 2); /// W
const Reg VetoWidth ("VetoWidth" , 0x10D4, 0); /// R/W
const Reg RecordLength_G ("RecordLength_G" , 0x1020, RW::ReadWrite, 1, 0x3FFF, 8); /// R/W
const Reg InputDynamicRange ("InputDynamicRange" , 0x1028, RW::ReadWrite, 0, 1, -1); /// R/W
const Reg NumberEventsPerAggregate_G ("NumberEventsPerAggregate_G" , 0x1034, RW::ReadWrite, 1, 0x3FF, -1); /// R/W
const Reg PreTrigger ("PreTrigger" , 0x1038, RW::ReadWrite, 0, 0xFF, 4); /// R/W
const Reg TriggerThreshold ("TriggerThreshold" , 0x106C, RW::ReadWrite, 0, 0x3FFF, -1); /// R/W
const Reg TriggerHoldOffWidth ("TriggerHoldOffWidth" , 0x1074, RW::ReadWrite, 0, 0x3FF, 4); /// R/W
const Reg DPPAlgorithmControl ("DPPAlgorithmControl" , 0x1080, RW::ReadWrite); /// R/W
const Reg ChannelStatus_R ("ChannelStatus_R" , 0x1088, RW::ReadONLY); /// R
const Reg AMCFirmwareRevision_R ("AMCFirmwareRevision_R" , 0x108C, RW::ReadONLY); /// R
const Reg ChannelDCOffset ("ChannelDCOffset" , 0x1098, RW::ReadWrite, 0, 0xFFFF, -1); /// R/W
const Reg ChannelADCTemperature_R ("ChannelADCTemperature_R" , 0x10A8, RW::ReadONLY); /// R
const Reg IndividualSoftwareTrigger_W ("IndividualSoftwareTrigger_W" , 0x10C0, RW::WriteONLY); /// W
const Reg VetoWidth ("VetoWidth" , 0x10D4, RW::ReadWrite); /// R/W
/// I know there are many duplication, it is the design.
const Reg BoardConfiguration ("BoardConfiguration" , 0x8000, 0 ); /// R/W
const Reg AggregateOrganization ("AggregateOrganization" , 0x800C, 0 ); /// R/W
const Reg ADCCalibration_W ("ADCCalibration_W" , 0x809C, 2 ); /// W
const Reg ChannelShutdown_W ("ChannelShutdown_W" , 0x80BC, 2 ); /// W
const Reg AcquisitionControl ("AcquisitionControl" , 0x8100, 0 ); /// R/W
const Reg AcquisitionStatus_R ("AcquisitionStatus_R" , 0x8104, 1 ); /// R
const Reg SoftwareTrigger_W ("SoftwareTrigger_W" , 0x8108, 2 ); /// W
const Reg GlobalTriggerMask ("GlobalTriggerMask" , 0x810C, 0 ); /// R/W
const Reg FrontPanelTRGOUTEnableMask ("FrontPanelTRGOUTEnableMask" , 0x8110, 0 ); /// R/W
const Reg LVDSIOData ("LVDSIOData" , 0x8118, 0 ); /// R/W
const Reg FrontPanelIOControl ("FrontPanelIOControl" , 0x811C, 0 ); /// R/W
const Reg ChannelEnableMask ("ChannelEnableMask" , 0x8120, 0 ); /// R/W
const Reg ROCFPGAFirmwareRevision_R ("ROCFPGAFirmwareRevision_R" , 0x8124, 1 ); /// R
const Reg EventStored_R ("EventStored_R" , 0x812C, 1 ); /// R
const Reg VoltageLevelModeConfig ("VoltageLevelModeConfig" , 0x8138, 0 ); /// R/W
const Reg SoftwareClockSync_W ("SoftwareClockSync_W" , 0x813C, 2 ); /// W
const Reg BoardInfo_R ("BoardInfo_R" , 0x8140, 1 ); /// R
const Reg AnalogMonitorMode ("AnalogMonitorMode" , 0x8144, 0 ); /// R/W
const Reg EventSize_R ("EventSize_R" , 0x814C, 1 ); /// R
const Reg TimeBombDowncounter_R ("TimeBombDowncounter_R" , 0x8158, 1 ); /// R
const Reg FanSpeedControl ("FanSpeedControl" , 0x8168, 0 ); /// R/W
const Reg RunStartStopDelay ("RunStartStopDelay" , 0x8170, 0 ); /// R/W
const Reg BoardFailureStatus_R ("BoardFailureStatus_R" , 0x8178, 1 ); /// R
const Reg DisableExternalTrigger ("DisableExternalTrigger" , 0x817C, 0 ); /// R/W
const Reg TriggerValidationMask_G ("TriggerValidationMask_G" , 0x8180, 0 , 1); /// R/W,
const Reg FrontPanelLVDSIONewFeatures ("FrontPanelLVDSIONewFeatures" , 0x81A0, 0 ); /// R/W
const Reg BufferOccupancyGain ("BufferOccupancyGain" , 0x81B4, 0 ); /// R/W
const Reg ExtendedVetoDelay ("ExtendedVetoDelay" , 0x81C4, 0 ); /// R/W
const Reg ReadoutControl ("ReadoutControl" , 0xEF00, 0 ); /// R/W
const Reg ReadoutStatus_R ("ReadoutStatus_R" , 0xEF04, 1 ); /// R
const Reg BoardID ("BoardID" , 0xEF08, 0 ); /// R/W
const Reg MCSTBaseAddressAndControl ("MCSTBaseAddressAndControl" , 0xEF0C, 0 ); /// R/W
const Reg RelocationAddress ("RelocationAddress" , 0xEF10, 0 ); /// R/W
const Reg InterruptStatusID ("InterruptStatusID" , 0xEF14, 0 ); /// R/W
const Reg InterruptEventNumber ("InterruptEventNumber" , 0xEF18, 0 ); /// R/W
const Reg MaxAggregatePerBlockTransfer("MaxAggregatePerBlockTransfer", 0xEF1C, 0 ); /// R/W
const Reg Scratch ("Scratch" , 0xEF20, 0 ); /// R/W
const Reg SoftwareReset_W ("SoftwareReset_W" , 0xEF24, 2 ); /// W
const Reg SoftwareClear_W ("SoftwareClear_W" , 0xEF28, 2 ); /// W
const Reg ConfigurationReload_W ("ConfigurationReload_W" , 0xEF34, 2 ); /// W
const Reg ROMChecksum_R ("ROMChecksum_R" , 0xF000, 1 ); /// R
const Reg ROMChecksumByte2_R ("ROMChecksumByte2_R" , 0xF004, 1 ); /// R
const Reg ROMChecksumByte1_R ("ROMChecksumByte1_R" , 0xF008, 1 ); /// R
const Reg ROMChecksumByte0_R ("ROMChecksumByte0_R" , 0xF00C, 1 ); /// R
const Reg ROMConstantByte2_R ("ROMConstantByte2_R" , 0xF010, 1 ); /// R
const Reg ROMConstantByte1_R ("ROMConstantByte1_R" , 0xF014, 1 ); /// R
const Reg ROMConstantByte0_R ("ROMConstantByte0_R" , 0xF018, 1 ); /// R
const Reg ROM_C_Code_R ("ROM_C_Code_R" , 0xF01C, 1 ); /// R
const Reg ROM_R_Code_R ("ROM_R_Code_R" , 0xF020, 1 ); /// R
const Reg ROM_IEEE_OUI_Byte2_R ("ROM_IEEE_OUI_Byte2_R" , 0xF024, 1 ); /// R
const Reg ROM_IEEE_OUI_Byte1_R ("ROM_IEEE_OUI_Byte1_R" , 0xF028, 1 ); /// R
const Reg ROM_IEEE_OUI_Byte0_R ("ROM_IEEE_OUI_Byte0_R" , 0xF02C, 1 ); /// R
const Reg ROM_BoardVersion_R ("ROM_BoardVersion_R" , 0xF030, 1 ); /// R
const Reg ROM_BoardFromFactor_R ("ROM_BoardFromFactor_R" , 0xF034, 1 ); /// R
const Reg ROM_BoardIDByte1_R ("ROM_BoardIDByte1_R" , 0xF038, 1 ); /// R
const Reg ROM_BoardIDByte0_R ("ROM_BoardIDByte0_R" , 0xF03C, 1 ); /// R
const Reg ROM_PCB_rev_Byte3_R ("ROM_PCB_rev_Byte3_R" , 0xF040, 1 ); /// R
const Reg ROM_PCB_rev_Byte2_R ("ROM_PCB_rev_Byte2_R" , 0xF044, 1 ); /// R
const Reg ROM_PCB_rev_Byte1_R ("ROM_PCB_rev_Byte1_R" , 0xF048, 1 ); /// R
const Reg ROM_PCB_rev_Byte0_R ("ROM_PCB_rev_Byte0_R" , 0xF04C, 1 ); /// R
const Reg ROM_FlashType_R ("ROM_FlashType_R" , 0xF050, 1 ); /// R
const Reg ROM_BoardSerialNumByte1_R ("ROM_BoardSerialNumByte1_R" , 0xF080, 1 ); /// R
const Reg ROM_BoardSerialNumByte0_R ("ROM_BoardSerialNumByte0_R" , 0xF084, 1 ); /// R
const Reg ROM_VCXO_Type_R ("ROM_VCXO_Type_R" , 0xF088, 1 ); /// R
const Reg BoardConfiguration ("BoardConfiguration" , 0x8000, RW::ReadWrite ); /// R/W
const Reg AggregateOrganization ("AggregateOrganization" , 0x800C, RW::ReadWrite ); /// R/W
const Reg ADCCalibration_W ("ADCCalibration_W" , 0x809C, RW::WriteONLY ); /// W
const Reg ChannelShutdown_W ("ChannelShutdown_W" , 0x80BC, RW::WriteONLY ); /// W
const Reg AcquisitionControl ("AcquisitionControl" , 0x8100, RW::ReadWrite ); /// R/W
const Reg AcquisitionStatus_R ("AcquisitionStatus_R" , 0x8104, RW::ReadONLY ); /// R
const Reg SoftwareTrigger_W ("SoftwareTrigger_W" , 0x8108, RW::WriteONLY ); /// W
const Reg GlobalTriggerMask ("GlobalTriggerMask" , 0x810C, RW::ReadWrite ); /// R/W
const Reg FrontPanelTRGOUTEnableMask ("FrontPanelTRGOUTEnableMask" , 0x8110, RW::ReadWrite ); /// R/W
const Reg LVDSIOData ("LVDSIOData" , 0x8118, RW::ReadWrite ); /// R/W
const Reg FrontPanelIOControl ("FrontPanelIOControl" , 0x811C, RW::ReadWrite ); /// R/W
const Reg ChannelEnableMask ("ChannelEnableMask" , 0x8120, RW::ReadWrite ); /// R/W
const Reg ROCFPGAFirmwareRevision_R ("ROCFPGAFirmwareRevision_R" , 0x8124, RW::ReadONLY ); /// R
const Reg EventStored_R ("EventStored_R" , 0x812C, RW::ReadONLY ); /// R
const Reg VoltageLevelModeConfig ("VoltageLevelModeConfig" , 0x8138, RW::ReadWrite ); /// R/W
const Reg SoftwareClockSync_W ("SoftwareClockSync_W" , 0x813C, RW::WriteONLY ); /// W
const Reg BoardInfo_R ("BoardInfo_R" , 0x8140, RW::ReadONLY ); /// R
const Reg AnalogMonitorMode ("AnalogMonitorMode" , 0x8144, RW::ReadWrite ); /// R/W
const Reg EventSize_R ("EventSize_R" , 0x814C, RW::ReadONLY ); /// R
const Reg TimeBombDowncounter_R ("TimeBombDowncounter_R" , 0x8158, RW::ReadONLY ); /// R
const Reg FanSpeedControl ("FanSpeedControl" , 0x8168, RW::ReadWrite ); /// R/W
const Reg RunStartStopDelay ("RunStartStopDelay" , 0x8170, RW::ReadWrite ); /// R/W
const Reg BoardFailureStatus_R ("BoardFailureStatus_R" , 0x8178, RW::ReadONLY ); /// R
const Reg DisableExternalTrigger ("DisableExternalTrigger" , 0x817C, RW::ReadWrite ); /// R/W
const Reg FrontPanelLVDSIONewFeatures ("FrontPanelLVDSIONewFeatures" , 0x81A0, RW::ReadWrite ); /// R/W
const Reg BufferOccupancyGain ("BufferOccupancyGain" , 0x81B4, RW::ReadWrite ); /// R/W
const Reg ExtendedVetoDelay ("ExtendedVetoDelay" , 0x81C4, RW::ReadWrite ); /// R/W
const Reg ReadoutControl ("ReadoutControl" , 0xEF00, RW::ReadWrite ); /// R/W
const Reg ReadoutStatus_R ("ReadoutStatus_R" , 0xEF04, RW::ReadONLY ); /// R
const Reg BoardID ("BoardID" , 0xEF08, RW::ReadWrite ); /// R/W
const Reg MCSTBaseAddressAndControl ("MCSTBaseAddressAndControl" , 0xEF0C, RW::ReadWrite ); /// R/W
const Reg RelocationAddress ("RelocationAddress" , 0xEF10, RW::ReadWrite ); /// R/W
const Reg InterruptStatusID ("InterruptStatusID" , 0xEF14, RW::ReadWrite ); /// R/W
const Reg InterruptEventNumber ("InterruptEventNumber" , 0xEF18, RW::ReadWrite ); /// R/W
const Reg MaxAggregatePerBlockTransfer("MaxAggregatePerBlockTransfer", 0xEF1C, RW::ReadWrite, 0, 0x3FF, -1); /// R/W
const Reg Scratch ("Scratch" , 0xEF20, RW::ReadWrite ); /// R/W
const Reg SoftwareReset_W ("SoftwareReset_W" , 0xEF24, RW::WriteONLY ); /// W
const Reg SoftwareClear_W ("SoftwareClear_W" , 0xEF28, RW::WriteONLY ); /// W
const Reg ConfigurationReload_W ("ConfigurationReload_W" , 0xEF34, RW::WriteONLY ); /// W
const Reg ROMChecksum_R ("ROMChecksum_R" , 0xF000, RW::ReadONLY ); /// R
const Reg ROMChecksumByte2_R ("ROMChecksumByte2_R" , 0xF004, RW::ReadONLY ); /// R
const Reg ROMChecksumByte1_R ("ROMChecksumByte1_R" , 0xF008, RW::ReadONLY ); /// R
const Reg ROMChecksumByte0_R ("ROMChecksumByte0_R" , 0xF00C, RW::ReadONLY ); /// R
const Reg ROMConstantByte2_R ("ROMConstantByte2_R" , 0xF010, RW::ReadONLY ); /// R
const Reg ROMConstantByte1_R ("ROMConstantByte1_R" , 0xF014, RW::ReadONLY ); /// R
const Reg ROMConstantByte0_R ("ROMConstantByte0_R" , 0xF018, RW::ReadONLY ); /// R
const Reg ROM_C_Code_R ("ROM_C_Code_R" , 0xF01C, RW::ReadONLY ); /// R
const Reg ROM_R_Code_R ("ROM_R_Code_R" , 0xF020, RW::ReadONLY ); /// R
const Reg ROM_IEEE_OUI_Byte2_R ("ROM_IEEE_OUI_Byte2_R" , 0xF024, RW::ReadONLY ); /// R
const Reg ROM_IEEE_OUI_Byte1_R ("ROM_IEEE_OUI_Byte1_R" , 0xF028, RW::ReadONLY ); /// R
const Reg ROM_IEEE_OUI_Byte0_R ("ROM_IEEE_OUI_Byte0_R" , 0xF02C, RW::ReadONLY ); /// R
const Reg ROM_BoardVersion_R ("ROM_BoardVersion_R" , 0xF030, RW::ReadONLY ); /// R
const Reg ROM_BoardFromFactor_R ("ROM_BoardFromFactor_R" , 0xF034, RW::ReadONLY ); /// R
const Reg ROM_BoardIDByte1_R ("ROM_BoardIDByte1_R" , 0xF038, RW::ReadONLY ); /// R
const Reg ROM_BoardIDByte0_R ("ROM_BoardIDByte0_R" , 0xF03C, RW::ReadONLY ); /// R
const Reg ROM_PCB_rev_Byte3_R ("ROM_PCB_rev_Byte3_R" , 0xF040, RW::ReadONLY ); /// R
const Reg ROM_PCB_rev_Byte2_R ("ROM_PCB_rev_Byte2_R" , 0xF044, RW::ReadONLY ); /// R
const Reg ROM_PCB_rev_Byte1_R ("ROM_PCB_rev_Byte1_R" , 0xF048, RW::ReadONLY ); /// R
const Reg ROM_PCB_rev_Byte0_R ("ROM_PCB_rev_Byte0_R" , 0xF04C, RW::ReadONLY ); /// R
const Reg ROM_FlashType_R ("ROM_FlashType_R" , 0xF050, RW::ReadONLY ); /// R
const Reg ROM_BoardSerialNumByte1_R ("ROM_BoardSerialNumByte1_R" , 0xF080, RW::ReadONLY ); /// R
const Reg ROM_BoardSerialNumByte0_R ("ROM_BoardSerialNumByte0_R" , 0xF084, RW::ReadONLY ); /// R
const Reg ROM_VCXO_Type_R ("ROM_VCXO_Type_R" , 0xF088, RW::ReadONLY ); /// R
const Reg TriggerValidationMask_G ("TriggerValidationMask_G" , 0x8180, RW::ReadWrite , 1); /// R/W,
namespace PHA {
const Reg DataFlush_W ("DataFlush_W" , 0x103C, 2); /// W not sure
const Reg ChannelStopAcquisition ("ChannelStopAcquisition" , 0x1040); /// R/W not sure
const Reg RCCR2SmoothingFactor ("RCCR2SmoothingFactor" , 0x1054); /// R/W Trigger Filter smoothing, triggerSmoothingFactor
const Reg InputRiseTime ("InputRiseTime" , 0x1058); /// R/W OK
const Reg TrapezoidRiseTime ("TrapezoidRiseTime" , 0x105C); /// R/W OK
const Reg TrapezoidFlatTop ("TrapezoidFlatTop" , 0x1060); /// R/W OK
const Reg PeakingTime ("PeakingTime" , 0x1064); /// R/W OK
const Reg DecayTime ("DecayTime" , 0x1068); /// R/W OK
const Reg TriggerThreshold ("TriggerThreshold" , 0x106C); /// R/W OK
const Reg RiseTimeValidationWindow ("RiseTimeValidationWindow" , 0x1070); /// R/W OK
const Reg TriggerHoldOffWidth ("TriggerHoldOffWidth" , 0x1074); /// R/W OK
const Reg PeakHoldOff ("PeakHoldOff" , 0x1078); /// R/W OK
const Reg ShapedTriggerWidth ("ShapedTriggerWidth" , 0x1084); /// R/W not sure
const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x10A0, 0, 1); /// R/W OK
const Reg DataFlush_W ("DataFlush_W" , 0x103C, RW::WriteONLY); /// W not sure
const Reg ChannelStopAcquisition ("ChannelStopAcquisition" , 0x1040, RW::ReadWrite); /// R/W not sure
const Reg RCCR2SmoothingFactor ("RCCR2SmoothingFactor" , 0x1054, RW::ReadWrite); /// R/W Trigger Filter smoothing, triggerSmoothingFactor
const Reg InputRiseTime ("InputRiseTime" , 0x1058, RW::ReadWrite, 0, 0xFF, 4); /// R/W OK
const Reg TrapezoidRiseTime ("TrapezoidRiseTime" , 0x105C, RW::ReadWrite, 0, 0xFFF, 4); /// R/W OK
const Reg TrapezoidFlatTop ("TrapezoidFlatTop" , 0x1060, RW::ReadWrite, 0, 0xFFF, 4); /// R/W OK
const Reg PeakingTime ("PeakingTime" , 0x1064, RW::ReadWrite, 0, 0xFFF, 4); /// R/W OK
const Reg DecayTime ("DecayTime" , 0x1068, RW::ReadWrite, 0, 0xFFFF, 4); /// R/W OK
const Reg TriggerThreshold ("TriggerThreshold" , 0x106C, RW::ReadWrite, 0, 0x3FFF, -1); /// R/W OK
const Reg RiseTimeValidationWindow ("RiseTimeValidationWindow" , 0x1070, RW::ReadWrite, 0, 0x3FF, 1); /// R/W OK
const Reg TriggerHoldOffWidth ("TriggerHoldOffWidth" , 0x1074, RW::ReadWrite, 0, 0x3FF, 4); /// R/W OK
const Reg PeakHoldOff ("PeakHoldOff" , 0x1078, RW::ReadWrite, 0, 0x3FF, 4); /// R/W OK
const Reg ShapedTriggerWidth ("ShapedTriggerWidth" , 0x1084, RW::ReadWrite, 0, 0x3FF, 4); /// R/W not sure
const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x10A0, RW::ReadWrite, 1); /// R/W OK
const Reg FineGain ("FineGain" , 0x10C4); /// R/W OK
}
namespace PSD {
const Reg CFDSetting ("CFDSetting" , 0x103C); /// R/W
const Reg ForcedDataFlush_W ("ForcedDataFlush_W" , 0x1040, 2); /// W
const Reg ForcedDataFlush_W ("ForcedDataFlush_W" , 0x1040, RW::WriteONLY); /// W
const Reg ChargeZeroSuppressionThreshold ("ChargeZeroSuppressionThreshold" , 0x1044); /// R/W
const Reg ShortGateWidth ("ShortGateWidth" , 0x1054); /// R/W
const Reg LongGateWidth ("LongGateWidth" , 0x1058); /// R/W
@ -282,13 +298,13 @@ namespace Register {
const Reg TriggerHoldOffWidth ("TriggerHoldOffWidth" , 0x1074); /// R/W
const Reg ThresholdForPSDCut ("ThresholdForPSDCut" , 0x1078); /// R/W
const Reg PurGapThreshold ("PurGapThreshold" , 0x107C); /// R/W
const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x1084, 0, 1); /// R/W
const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x1084, RW::ReadWrite, 1); /// R/W
const Reg EarlyBaselineFreeze ("EarlyBaselineFreeze" , 0x10D8); /// R/W
}
}
};
}; // end of namepace Register
const std::vector<Reg> RegisterPHAList = {
const std::vector<Register::Reg> RegisterPHAList = {
Register::DPP::PHA::DataFlush_W ,
Register::DPP::PHA::ChannelStopAcquisition ,
Register::DPP::PHA::RCCR2SmoothingFactor ,
@ -322,7 +338,7 @@ const std::vector<Reg> RegisterPHAList = {
Register::DPP::TriggerValidationMask_G
};
const std::vector<Reg> RegisterPSDList = {
const std::vector<Register::Reg> RegisterPSDList = {
Register::DPP::PSD::CFDSetting ,
Register::DPP::PSD::ForcedDataFlush_W ,
Register::DPP::PSD::ChargeZeroSuppressionThreshold ,
@ -357,7 +373,7 @@ const std::vector<Reg> RegisterPSDList = {
};
/// Only Board Setting
const std::vector<Reg> RegisterDPPList = {
const std::vector<Register::Reg> RegisterDPPList = {
Register::DPP::BoardConfiguration ,
Register::DPP::AggregateOrganization ,

119
Scope.cpp
View File

@ -59,21 +59,65 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
QGridLayout * layout = new QGridLayout(layoutWidget);
layoutWidget->setLayout(layout);
//--------------------
//================ Board & Ch selection
rowID ++;
cbScopeDigi = new RComboBox(this);
cbScopeCh = new RComboBox(this);
layout->addWidget(cbScopeDigi, rowID, 0);
layout->addWidget(cbScopeCh, rowID, 1);
for(unsigned int i = 0; i < nDigi; i++){
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
}
//-------------------- Plot view
ID = 0;
cbScopeDigi->setCurrentIndex(0);
for( int i = 0; i < digi[0]->GetNChannels(); i++) cbScopeCh->addItem("Ch-" + QString::number(i));
ch2ns = digi[ID]->GetCh2ns();
connect(cbScopeCh, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
ID = index;
ch2ns = digi[ID]->GetCh2ns();
//---setup cbScopeCh
cbScopeCh->clear();
for( int i = 0; i < digi[ID]->GetNChannels(); i++) cbScopeCh->addItem("Ch-" + QString::number(i));
});
//================ Trace settings
rowID ++;
{
QGroupBox * settingGroup = new QGroupBox("Trace Settings",this);
layout->addWidget(settingGroup, rowID, 0, 1, 6);
QGridLayout * bLayout = new QGridLayout(settingGroup);
bLayout->setSpacing(0);
SetUpSpinBox(sbReordLength, "Record Length", bLayout, 0, 0, Register::DPP::RecordLength_G);
}
//================ Plot view
rowID ++;
TraceView * plotView = new TraceView(plot);
plotView->setRenderHints(QPainter::Antialiasing);
layout->addWidget(plotView, rowID, 0, 1, 6);
//------------ close button
//================ Key binding
rowID ++;
QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this);
layout->addWidget(lbhints, rowID, 0, 1, 4);
QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeSec()) + " sec.", this);
lbinfo->setAlignment(Qt::AlignRight);
layout->addWidget(lbinfo, rowID, 5);
rowID ++;
//TODO =========== Trace step
QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceDataLength * 8) + " ns due to processing speed.", this);
layout->addWidget(lbinfo2, rowID, 0, 1, 5);
//================ close button
rowID ++;
bnScopeStart = new QPushButton("Start", this);
layout->addWidget(bnScopeStart, rowID, 0);
@ -97,8 +141,20 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
layout->addWidget(bnClose, rowID, 5);
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
layout->setColumnStretch(0, 1);
layout->setColumnStretch(1, 1);
layout->setColumnStretch(2, 1);
layout->setColumnStretch(3, 1);
layout->setColumnStretch(4, 1);
layout->setColumnStretch(5, 1);
enableSignalSlot = true;
}
Scope::~Scope(){
updateTraceThread->Stop();
@ -109,6 +165,8 @@ Scope::~Scope(){
delete plot;
}
//*=======================================================
//*=======================================================
void Scope::StartScope(){
@ -118,3 +176,58 @@ void Scope::StopScope(){
}
//*=======================================================
//*=======================================================
void Scope::SetUpComboBox(RComboBox * &cb, QString str, QGridLayout * layout, int row, int col, const Register::Reg para){
QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col);
cb = new RComboBox(this);
layout->addWidget(cb, row, col + 1);
}
void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, QGridLayout * layout, int row, int col, const Register::Reg para){
QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col);
sb = new RSpinBox(this);
if( para.GetPartialStep() != 0 ){
sb->setMinimum(0);
sb->setMaximum(para.GetMax() * para.GetPartialStep() * ch2ns);
if( para.GetPartialStep() > 0 ) sb->setSingleStep(para.GetPartialStep() * ch2ns);
if( para.GetPartialStep() == -1 ) sb->setSingleStep(1);
}
layout->addWidget(sb, row, col + 1);
connect(sb, &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return;
sb->setStyleSheet("color:blue");
});
connect(sb, &RSpinBox::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
//int iDigi = cbScopeDigi->currentIndex();
if( sb->decimals() == 0 && sb->singleStep() != 1) {
double step = sb->singleStep();
double value = sb->value();
sb->setValue( (std::round(value/step)*step));
}
//int ch = cbScopeCh->currentIndex();
//if( chkSetAllChannel->isChecked() ) ch = -1;
// QString msg;
// msg = QString::fromStdString(digPara.GetPara()) + "|DIG:"+ QString::number(digi[iDigi]->GetSerialNumber()) + ",CH:" + (ch == -1 ? "All" : QString::number(ch));
// msg += " = " + QString::number(sb->value());
// if( digi[iDigi]->WriteValue(digPara, std::to_string(sb->value()), ch)){
// SendLogMsg(msg + "|OK.");
// sb->setStyleSheet("");
// UpdateSettingsFromMemeory();
// UpdateOtherPanels();
// }else{
// SendLogMsg(msg + "|Fail.");
// sb->setStyleSheet("color:red;");
// }
});
}

11
Scope.h
View File

@ -36,12 +36,17 @@ private slots:
void StartScope();
void StopScope();
void SetUpComboBox(RComboBox * &cb, QString str, QGridLayout * layout, int row, int col, const Register::Reg para);
void SetUpSpinBox(RSpinBox * &sb, QString str, QGridLayout * layout, int row, int col, const Register::Reg para);
signals:
private:
Digitizer ** digi;
unsigned short nDigi;
unsigned short ID; // the id of digi, index of cbScopeDigi
int ch2ns;
ReadDataThread ** readDataThread;
UpdateTraceThread * updateTraceThread;
@ -54,12 +59,16 @@ private:
RComboBox * cbScopeDigi;
RComboBox * cbScopeCh;
QPushButton * bnScopeStart;
QPushButton * bnScopeStop;
QLineEdit * leTriggerRate;
RSpinBox * sbReordLength;
//RSpinBox * sbPreTrigger;
//RComboBox * cbDynamicRange;
};

View File

@ -24,12 +24,9 @@ int keyboardhit();
int getch(void);
//^======================================
int main(int argc, char* argv[]){
/**///##################### Demo with 2 digitizers
const int nBoard = 2;
const int nBoard = 1;
Digitizer **dig = new Digitizer *[nBoard];
for( int i = 0 ; i < nBoard; i++){
@ -37,8 +34,25 @@ int main(int argc, char* argv[]){
int port = i/3;
dig[i] = new Digitizer(board, port, false, true);
}
const float ch2ns = dig[0]->GetCh2ns();
Data * data = dig[0]->GetData();
data->Allocate80MBMemory();
dig[0]->StartACQ();
sleep(3);
dig[0]->ReadData();
data->SaveBuffer("test");
/******
/*
TApplication * app = new TApplication("app", &argc, argv);
TCanvas * canvas = new TCanvas("c", "haha", 1200, 400);
canvas->Divide(3, 1);
@ -53,7 +67,7 @@ int main(int argc, char* argv[]){
canvas->cd(3); g1->Draw("AP");
Data * data = dig[0]->GetData();
data->AllocateMemory();
data->Allocate80MBMemory();
remove("test.bin");
@ -65,13 +79,15 @@ int main(int argc, char* argv[]){
uint32_t CurrentTime = 0;
uint32_t ElapsedTime = 0;
int waveFormLength = dig[0]->ReadRegister(Register::DPP::RecordLength_G);
while(true){
if(keyboardhit()) {
break;
}
usleep(50000);
usleep(1000);
dig[0]->ReadData();
if( data->nByte > 0 ){
@ -119,9 +135,7 @@ int main(int argc, char* argv[]){
}
app->Run();
***********/
*/
printf("Closing digitizers..............\n");
for( int i = 0; i < nBoard; i++){