added software disbale board, not impletement in GUI

This commit is contained in:
carina@hades 2023-11-06 17:59:16 -05:00
parent f9758a670a
commit d62d037492
3 changed files with 28 additions and 3 deletions

View File

@ -210,6 +210,8 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
}
ErrorMsg("end of OpenDigitizer");
softwareDisable = false;
if( isConnected ) isDummy = false;
if( isConnected && program) {
@ -237,6 +239,7 @@ int Digitizer::CloseDigitizer(){
void Digitizer::SetRegChannelMask(uint32_t mask){
if( softwareDisable ) return;
if( !isConnected ) return;
regChannelMask = mask;
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, regChannelMask);
@ -246,6 +249,8 @@ void Digitizer::SetRegChannelMask(uint32_t mask){
}
bool Digitizer::GetInputChannelOnOff(unsigned ch) {
if( softwareDisable ) return false;
regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
if( isInputChEqRegCh ) return (regChannelMask & ( 1 << ch) );
@ -255,12 +260,14 @@ bool Digitizer::GetInputChannelOnOff(unsigned ch) {
}
void Digitizer::SetRegChannelOnOff(unsigned short ch, bool onOff){
if( softwareDisable ) return;
if( !isConnected ) return;
regChannelMask = ((regChannelMask & ~( 1 << ch) ) | ( onOff << ch)) ;
SetRegChannelMask(regChannelMask);
}
int Digitizer::ProgramBoard_PHA(){
if( softwareDisable ) return 0;
printf("===== Digitizer::%s\n", __func__);
@ -339,6 +346,7 @@ int Digitizer::ProgramBoard_PHA(){
}
int Digitizer::ProgramBoard_PSD(){
if( softwareDisable ) return 0;
printf("===== Digitizer::%s\n", __func__);
@ -393,6 +401,7 @@ int Digitizer::ProgramBoard_PSD(){
}
int Digitizer::ProgramBoard_QDC(){
if( softwareDisable ) return 0;
printf("===== Digitizer::%s\n", __func__);
Reset();
@ -450,6 +459,7 @@ int Digitizer::ProgramBoard_QDC(){
//========================================================= ACQ control
void Digitizer::StartACQ(){
if( softwareDisable ) return;
if ( AcqRun ) return;
unsigned int bufferSize = 0;
@ -561,6 +571,7 @@ unsigned int Digitizer::CalByteForBuffer(){
}
int Digitizer::ReadData(){
if( softwareDisable ) return CAEN_DGTZ_DigitizerNotReady;
if( !isConnected ) return CAEN_DGTZ_DigitizerNotFound;
if( !AcqRun) return CAEN_DGTZ_WrongAcqMode;
if( data->buffer == NULL ) {
@ -601,7 +612,7 @@ void Digitizer::PrintACQStatue(){
//===========================================================
//===========================================================
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
if( softwareDisable ) return;
printf("%30s[0x%04X](digi-%d,ch-%02d) [0x%04X]: 0x%08X \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),GetSerialNumber(), ch, registerAddress.ActualAddress(ch), value);
if( !isConnected ) {
@ -641,6 +652,7 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool
}
uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){
if( softwareDisable ) return 0;
if( !isConnected ) return 0;
if( registerAddress.GetRWType() == RW::WriteONLY ) return 0;
@ -727,6 +739,7 @@ Reg Digitizer::FindRegister(uint32_t address){
}
void Digitizer::ReadAllSettingsFromBoard(bool force){
if( softwareDisable ) return;
if( !isConnected ) return;
if( AcqRun ) return;
if( isSettingFilledinMemeory && !force) return;
@ -781,6 +794,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
}
void Digitizer::ProgramSettingsToBoard(){
if( softwareDisable ) return;
if( !isConnected || isDummy ) return;
printf("========== %s \n", __func__);
@ -1097,11 +1111,13 @@ void Digitizer::ErrorMsg(std::string header){
//============================== DPP-Alpgorthm Control
void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
if( softwareDisable ) return;
WriteRegister( DPP::DPPAlgorithmControl, bit, ch);
if( ret != 0 ) ErrorMsg(__func__);
}
unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){
if( softwareDisable ) return 0;
int tempCh = ch;
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
uint32_t bit = ReadRegister(address, tempCh);
@ -1110,6 +1126,7 @@ unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned i
}
void Digitizer::SetBits(Reg address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
if( softwareDisable ) return;
///printf("address : 0x%X, value : 0x%X, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
uint32_t bit ;
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);

View File

@ -38,6 +38,7 @@ class Digitizer{
CAEN_DGTZ_BoardInfo_t BoardInfo;
//^----- adjustable parameters
bool softwareDisable; /// not using the whole board
uint32_t regChannelMask ; /// the channel mask from NumInputCh
uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0
CAEN_DGTZ_ConnectionType LinkType; /// USB or Optic
@ -77,6 +78,9 @@ class Digitizer{
bool IsDummy() {return isDummy;}
bool IsConnected() {return isConnected;}
void DisableBoard() {softwareDisable = true;}
bool IsBoardDisabled() const {return softwareDisable;}
void PrintBoard() ;
int ProgramBoard_PHA() ; /// program a default PHA board with dual trace
int ProgramBoard_PSD() ;

View File

@ -977,6 +977,8 @@ void MainWindow::UpdateScalar(){
//printf("----------------------\n");
uint64_t totalFileSize = 0;
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
if( digi[iDigi]->IsBoardDisabled() ) continue;
digiMTX[iDigi].lock();
uint32_t acqStatus = digi[iDigi]->ReadRegister(DPP::AcquisitionStatus_R);
@ -1039,6 +1041,7 @@ void MainWindow::StartACQ(){
//assume master board is the 0-th board
for( int i = (int) nDigi-1; i >= 0 ; i--){
if( digi[i]->IsBoardDisabled() ) continue;
if( chkSaveData->isChecked() ) {
if( digi[i]->GetData()->OpenSaveFile((rawDataPath + "/" + prefix + "_" + QString::number(runID).rightJustified(3, '0')).toStdString()) == false ) {
LogMsg("Cannot open save file : " + QString::fromStdString(digi[i]->GetData()->GetOutFileName() ) + ". Probably read-only?");
@ -1054,7 +1057,7 @@ void MainWindow::StartACQ(){
readDataThread[i]->start();
}
if( chkSaveData->isChecked() ) SaveLastRunFile();
if( chkSaveData->isChecked() ) SaveLastRunFile();
// printf("------------ wait for 2 sec \n");
// usleep(1000*1000);
@ -1117,6 +1120,7 @@ void MainWindow::StopACQ(){
}
for( unsigned int i = 0; i < nDigi; i++){
if( digi[i]->IsBoardDisabled() ) continue;
readDataThread[i]->Stop();
readDataThread[i]->quit();
readDataThread[i]->wait();