added software disbale board, not impletement in GUI
This commit is contained in:
parent
f9758a670a
commit
d62d037492
|
@ -209,6 +209,8 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ErrorMsg("end of OpenDigitizer");
|
ErrorMsg("end of OpenDigitizer");
|
||||||
|
|
||||||
|
softwareDisable = false;
|
||||||
|
|
||||||
if( isConnected ) isDummy = false;
|
if( isConnected ) isDummy = false;
|
||||||
|
|
||||||
|
@ -237,6 +239,7 @@ int Digitizer::CloseDigitizer(){
|
||||||
|
|
||||||
|
|
||||||
void Digitizer::SetRegChannelMask(uint32_t mask){
|
void Digitizer::SetRegChannelMask(uint32_t mask){
|
||||||
|
if( softwareDisable ) return;
|
||||||
if( !isConnected ) return;
|
if( !isConnected ) return;
|
||||||
regChannelMask = mask;
|
regChannelMask = mask;
|
||||||
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, regChannelMask);
|
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, regChannelMask);
|
||||||
|
@ -246,6 +249,8 @@ void Digitizer::SetRegChannelMask(uint32_t mask){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Digitizer::GetInputChannelOnOff(unsigned ch) {
|
bool Digitizer::GetInputChannelOnOff(unsigned ch) {
|
||||||
|
if( softwareDisable ) return false;
|
||||||
|
|
||||||
regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
|
regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
|
||||||
|
|
||||||
if( isInputChEqRegCh ) return (regChannelMask & ( 1 << ch) );
|
if( isInputChEqRegCh ) return (regChannelMask & ( 1 << ch) );
|
||||||
|
@ -255,13 +260,15 @@ bool Digitizer::GetInputChannelOnOff(unsigned ch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SetRegChannelOnOff(unsigned short ch, bool onOff){
|
void Digitizer::SetRegChannelOnOff(unsigned short ch, bool onOff){
|
||||||
|
if( softwareDisable ) return;
|
||||||
if( !isConnected ) return;
|
if( !isConnected ) return;
|
||||||
regChannelMask = ((regChannelMask & ~( 1 << ch) ) | ( onOff << ch)) ;
|
regChannelMask = ((regChannelMask & ~( 1 << ch) ) | ( onOff << ch)) ;
|
||||||
SetRegChannelMask(regChannelMask);
|
SetRegChannelMask(regChannelMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Digitizer::ProgramBoard_PHA(){
|
int Digitizer::ProgramBoard_PHA(){
|
||||||
|
if( softwareDisable ) return 0;
|
||||||
|
|
||||||
printf("===== Digitizer::%s\n", __func__);
|
printf("===== Digitizer::%s\n", __func__);
|
||||||
|
|
||||||
//ret = CAEN_DGTZ_Reset(handle);
|
//ret = CAEN_DGTZ_Reset(handle);
|
||||||
|
@ -339,6 +346,7 @@ int Digitizer::ProgramBoard_PHA(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int Digitizer::ProgramBoard_PSD(){
|
int Digitizer::ProgramBoard_PSD(){
|
||||||
|
if( softwareDisable ) return 0;
|
||||||
|
|
||||||
printf("===== Digitizer::%s\n", __func__);
|
printf("===== Digitizer::%s\n", __func__);
|
||||||
|
|
||||||
|
@ -393,6 +401,7 @@ int Digitizer::ProgramBoard_PSD(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int Digitizer::ProgramBoard_QDC(){
|
int Digitizer::ProgramBoard_QDC(){
|
||||||
|
if( softwareDisable ) return 0;
|
||||||
|
|
||||||
printf("===== Digitizer::%s\n", __func__);
|
printf("===== Digitizer::%s\n", __func__);
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -450,6 +459,7 @@ int Digitizer::ProgramBoard_QDC(){
|
||||||
|
|
||||||
//========================================================= ACQ control
|
//========================================================= ACQ control
|
||||||
void Digitizer::StartACQ(){
|
void Digitizer::StartACQ(){
|
||||||
|
if( softwareDisable ) return;
|
||||||
if ( AcqRun ) return;
|
if ( AcqRun ) return;
|
||||||
|
|
||||||
unsigned int bufferSize = 0;
|
unsigned int bufferSize = 0;
|
||||||
|
@ -561,6 +571,7 @@ unsigned int Digitizer::CalByteForBuffer(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int Digitizer::ReadData(){
|
int Digitizer::ReadData(){
|
||||||
|
if( softwareDisable ) return CAEN_DGTZ_DigitizerNotReady;
|
||||||
if( !isConnected ) return CAEN_DGTZ_DigitizerNotFound;
|
if( !isConnected ) return CAEN_DGTZ_DigitizerNotFound;
|
||||||
if( !AcqRun) return CAEN_DGTZ_WrongAcqMode;
|
if( !AcqRun) return CAEN_DGTZ_WrongAcqMode;
|
||||||
if( data->buffer == NULL ) {
|
if( data->buffer == NULL ) {
|
||||||
|
@ -601,7 +612,7 @@ void Digitizer::PrintACQStatue(){
|
||||||
//===========================================================
|
//===========================================================
|
||||||
//===========================================================
|
//===========================================================
|
||||||
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
|
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);
|
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 ) {
|
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 ){
|
uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){
|
||||||
|
if( softwareDisable ) return 0;
|
||||||
if( !isConnected ) return 0;
|
if( !isConnected ) return 0;
|
||||||
if( registerAddress.GetRWType() == RW::WriteONLY ) return 0;
|
if( registerAddress.GetRWType() == RW::WriteONLY ) return 0;
|
||||||
|
|
||||||
|
@ -727,6 +739,7 @@ Reg Digitizer::FindRegister(uint32_t address){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ReadAllSettingsFromBoard(bool force){
|
void Digitizer::ReadAllSettingsFromBoard(bool force){
|
||||||
|
if( softwareDisable ) return;
|
||||||
if( !isConnected ) return;
|
if( !isConnected ) return;
|
||||||
if( AcqRun ) return;
|
if( AcqRun ) return;
|
||||||
if( isSettingFilledinMemeory && !force) return;
|
if( isSettingFilledinMemeory && !force) return;
|
||||||
|
@ -781,6 +794,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ProgramSettingsToBoard(){
|
void Digitizer::ProgramSettingsToBoard(){
|
||||||
|
if( softwareDisable ) return;
|
||||||
if( !isConnected || isDummy ) return;
|
if( !isConnected || isDummy ) return;
|
||||||
|
|
||||||
printf("========== %s \n", __func__);
|
printf("========== %s \n", __func__);
|
||||||
|
@ -1097,11 +1111,13 @@ void Digitizer::ErrorMsg(std::string header){
|
||||||
|
|
||||||
//============================== DPP-Alpgorthm Control
|
//============================== DPP-Alpgorthm Control
|
||||||
void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
|
void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
|
||||||
|
if( softwareDisable ) return;
|
||||||
WriteRegister( DPP::DPPAlgorithmControl, bit, ch);
|
WriteRegister( DPP::DPPAlgorithmControl, bit, ch);
|
||||||
if( ret != 0 ) ErrorMsg(__func__);
|
if( ret != 0 ) ErrorMsg(__func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){
|
unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){
|
||||||
|
if( softwareDisable ) return 0;
|
||||||
int tempCh = ch;
|
int tempCh = ch;
|
||||||
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
|
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
|
||||||
uint32_t bit = ReadRegister(address, tempCh);
|
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){
|
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);
|
///printf("address : 0x%X, value : 0x%X, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
|
||||||
uint32_t bit ;
|
uint32_t bit ;
|
||||||
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
|
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Digitizer{
|
||||||
CAEN_DGTZ_BoardInfo_t BoardInfo;
|
CAEN_DGTZ_BoardInfo_t BoardInfo;
|
||||||
|
|
||||||
//^----- adjustable parameters
|
//^----- adjustable parameters
|
||||||
|
bool softwareDisable; /// not using the whole board
|
||||||
uint32_t regChannelMask ; /// the channel mask from NumInputCh
|
uint32_t regChannelMask ; /// the channel mask from NumInputCh
|
||||||
uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0
|
uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0
|
||||||
CAEN_DGTZ_ConnectionType LinkType; /// USB or Optic
|
CAEN_DGTZ_ConnectionType LinkType; /// USB or Optic
|
||||||
|
@ -77,6 +78,9 @@ class Digitizer{
|
||||||
bool IsDummy() {return isDummy;}
|
bool IsDummy() {return isDummy;}
|
||||||
bool IsConnected() {return isConnected;}
|
bool IsConnected() {return isConnected;}
|
||||||
|
|
||||||
|
void DisableBoard() {softwareDisable = true;}
|
||||||
|
bool IsBoardDisabled() const {return softwareDisable;}
|
||||||
|
|
||||||
void PrintBoard() ;
|
void PrintBoard() ;
|
||||||
int ProgramBoard_PHA() ; /// program a default PHA board with dual trace
|
int ProgramBoard_PHA() ; /// program a default PHA board with dual trace
|
||||||
int ProgramBoard_PSD() ;
|
int ProgramBoard_PSD() ;
|
||||||
|
|
|
@ -977,6 +977,8 @@ void MainWindow::UpdateScalar(){
|
||||||
//printf("----------------------\n");
|
//printf("----------------------\n");
|
||||||
uint64_t totalFileSize = 0;
|
uint64_t totalFileSize = 0;
|
||||||
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
|
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
|
||||||
|
if( digi[iDigi]->IsBoardDisabled() ) continue;
|
||||||
|
|
||||||
digiMTX[iDigi].lock();
|
digiMTX[iDigi].lock();
|
||||||
|
|
||||||
uint32_t acqStatus = digi[iDigi]->ReadRegister(DPP::AcquisitionStatus_R);
|
uint32_t acqStatus = digi[iDigi]->ReadRegister(DPP::AcquisitionStatus_R);
|
||||||
|
@ -1039,6 +1041,7 @@ void MainWindow::StartACQ(){
|
||||||
|
|
||||||
//assume master board is the 0-th board
|
//assume master board is the 0-th board
|
||||||
for( int i = (int) nDigi-1; i >= 0 ; i--){
|
for( int i = (int) nDigi-1; i >= 0 ; i--){
|
||||||
|
if( digi[i]->IsBoardDisabled() ) continue;
|
||||||
if( chkSaveData->isChecked() ) {
|
if( chkSaveData->isChecked() ) {
|
||||||
if( digi[i]->GetData()->OpenSaveFile((rawDataPath + "/" + prefix + "_" + QString::number(runID).rightJustified(3, '0')).toStdString()) == false ) {
|
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?");
|
LogMsg("Cannot open save file : " + QString::fromStdString(digi[i]->GetData()->GetOutFileName() ) + ". Probably read-only?");
|
||||||
|
@ -1054,7 +1057,7 @@ void MainWindow::StartACQ(){
|
||||||
|
|
||||||
readDataThread[i]->start();
|
readDataThread[i]->start();
|
||||||
}
|
}
|
||||||
if( chkSaveData->isChecked() ) SaveLastRunFile();
|
if( chkSaveData->isChecked() ) SaveLastRunFile();
|
||||||
|
|
||||||
// printf("------------ wait for 2 sec \n");
|
// printf("------------ wait for 2 sec \n");
|
||||||
// usleep(1000*1000);
|
// usleep(1000*1000);
|
||||||
|
@ -1117,6 +1120,7 @@ void MainWindow::StopACQ(){
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned int i = 0; i < nDigi; i++){
|
for( unsigned int i = 0; i < nDigi; i++){
|
||||||
|
if( digi[i]->IsBoardDisabled() ) continue;
|
||||||
readDataThread[i]->Stop();
|
readDataThread[i]->Stop();
|
||||||
readDataThread[i]->quit();
|
readDataThread[i]->quit();
|
||||||
readDataThread[i]->wait();
|
readDataThread[i]->wait();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user