find Digi-XXX.bin for initial when opening digitizer
This commit is contained in:
parent
9783cc0edf
commit
c345fdbea5
|
@ -284,8 +284,9 @@ int Digitizer::ProgramBoard(){
|
||||||
|
|
||||||
int Digitizer::ProgramPHABoard(){
|
int Digitizer::ProgramPHABoard(){
|
||||||
|
|
||||||
|
printf("========Digitizer::%s\n", __func__);
|
||||||
|
|
||||||
ret = CAEN_DGTZ_Reset(handle);
|
ret = CAEN_DGTZ_Reset(handle);
|
||||||
printf("======== program board PHA\n");
|
|
||||||
|
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, DPP::RecordLength_G + 0x7000, 62);
|
ret = CAEN_DGTZ_WriteRegister(handle, DPP::RecordLength_G + 0x7000, 62);
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardConfiguration, 0x0F8915); /// has Extra2, dual trace, input and trap-baseline
|
ret = CAEN_DGTZ_WriteRegister(handle, DPP::BoardConfiguration, 0x0F8915); /// has Extra2, dual trace, input and trap-baseline
|
||||||
|
@ -303,8 +304,6 @@ int Digitizer::ProgramPHABoard(){
|
||||||
ret = CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
|
ret = CAEN_DGTZ_SetRunSynchronizationMode(handle, CAEN_DGTZ_RUN_SYNC_Disabled);
|
||||||
if( ret != 0 ) { printf("==== set board error.\n"); return 0;}
|
if( ret != 0 ) { printf("==== set board error.\n"); return 0;}
|
||||||
|
|
||||||
printf("======== program Channels PHA\n");
|
|
||||||
|
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
|
|
||||||
address = DPP::PHA::DecayTime; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 5000 );
|
address = DPP::PHA::DecayTime; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 5000 );
|
||||||
|
@ -330,8 +329,6 @@ int Digitizer::ProgramPHABoard(){
|
||||||
|
|
||||||
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
|
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
|
||||||
|
|
||||||
printf("End of program board and channels\n");
|
|
||||||
|
|
||||||
isSettingFilledinMemeory = false; /// unlock the ReadAllSettingsFromBoard();
|
isSettingFilledinMemeory = false; /// unlock the ReadAllSettingsFromBoard();
|
||||||
ReadAllSettingsFromBoard();
|
ReadAllSettingsFromBoard();
|
||||||
|
|
||||||
|
@ -555,7 +552,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
|
||||||
if( AcqRun ) return;
|
if( AcqRun ) return;
|
||||||
if( isSettingFilledinMemeory && !force) return;
|
if( isSettingFilledinMemeory && !force) return;
|
||||||
|
|
||||||
printf("===== %s \n", __func__);
|
printf("===== Digitizer::%s \n", __func__);
|
||||||
|
|
||||||
/// board setting
|
/// board setting
|
||||||
for( int p = 0; p < (int) RegisterDPPList.size(); p++){
|
for( int p = 0; p < (int) RegisterDPPList.size(); p++){
|
||||||
|
@ -581,37 +578,44 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isSettingFilledinMemeory = true;
|
isSettingFilledinMemeory = true;
|
||||||
|
|
||||||
|
printf("---------------------- end of %s \n", __func__);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ProgramSettingsToBoard(){
|
void Digitizer::ProgramSettingsToBoard(){
|
||||||
if( !isConnected ) return;
|
if( !isConnected || isDummy ) return;
|
||||||
if( isDummy ) return;
|
|
||||||
|
printf("========== %s \n", __func__);
|
||||||
|
|
||||||
Reg haha;
|
Reg haha;
|
||||||
|
|
||||||
/// board setting
|
/// board setting
|
||||||
for( int p = 0; p < (int) RegisterDPPList[p]; p++){
|
for( int p = 0; p < (int) RegisterDPPList.size(); p++){
|
||||||
if( RegisterDPPList[p].GetType() == RW::ReadONLY) continue;
|
if( RegisterDPPList[p].GetType() == RW::ReadWrite) {
|
||||||
haha = RegisterDPPList[p];
|
haha = RegisterDPPList[p];
|
||||||
WriteRegister(haha, GetSettingFromMemory(haha), -1, false);
|
WriteRegister(haha, GetSettingFromMemory(haha), -1, false);
|
||||||
usleep(100 * 1000);
|
usleep(1 * 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// Channels Setting
|
/// Channels Setting
|
||||||
for( int ch = 0; ch < NChannel; ch ++){
|
for( int ch = 0; ch < NChannel; ch ++){
|
||||||
if( DPPType == V1730_DPP_PHA_CODE ){
|
if( DPPType == V1730_DPP_PHA_CODE ){
|
||||||
for( int p = 0; p < (int) RegisterPHAList[p]; p++){
|
for( int p = 0; p < (int) RegisterPHAList.size(); p++){
|
||||||
if( RegisterPHAList[p].GetType() == RW::ReadONLY) continue;
|
if( RegisterPHAList[p].GetType() == RW::ReadWrite ){
|
||||||
haha = RegisterPHAList[p];
|
haha = RegisterPHAList[p];
|
||||||
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
|
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
|
||||||
usleep(100 * 1000);
|
usleep(1 * 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( DPPType == V1730_DPP_PSD_CODE ){
|
if( DPPType == V1730_DPP_PSD_CODE ){
|
||||||
for( int p = 0; p < (int) RegisterPSDList[p]; p++){
|
for( int p = 0; p < (int) RegisterPSDList.size(); p++){
|
||||||
if( RegisterPSDList[p].GetType() == RW::ReadONLY) continue;
|
if( RegisterPSDList[p].GetType() == RW::ReadWrite){
|
||||||
haha = RegisterPHAList[p];
|
haha = RegisterPHAList[p];
|
||||||
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
|
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
|
||||||
usleep(100 * 1000);
|
usleep(1 * 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1229,21 +1229,21 @@ void DigiSettingsPanel::SaveSetting(int opt){
|
||||||
QDir dir(rawDataPath);
|
QDir dir(rawDataPath);
|
||||||
if( !dir.exists() ) dir.mkpath(".");
|
if( !dir.exists() ) dir.mkpath(".");
|
||||||
|
|
||||||
QString filePath = QFileDialog::getSaveFileName(this, "Save Settings File", rawDataPath, opt == 0 ? "Data file (*.dat)" : "Text file (*.txt)");
|
QString filePath = QFileDialog::getSaveFileName(this, "Save Settings File", rawDataPath, opt == 0 ? "Binary (*.bin)" : "Text file (*.txt)");
|
||||||
|
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
|
|
||||||
QFileInfo fileInfo(filePath);
|
QFileInfo fileInfo(filePath);
|
||||||
QString ext = fileInfo.suffix();
|
QString ext = fileInfo.suffix();
|
||||||
if( opt == 0 ){
|
if( opt == 0 ){
|
||||||
if( ext == "") filePath += ".dat";
|
if( ext == "") filePath += ".bin";
|
||||||
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str());
|
digi[ID]->SaveAllSettingsAsBin(filePath.toStdString().c_str());
|
||||||
leSaveFilePath[ID]->setText(filePath + " | update constantly");
|
leSaveFilePath[ID]->setText(filePath + " | dynamic update");
|
||||||
}
|
}
|
||||||
if( opt == 1 ){
|
if( opt == 1 ){
|
||||||
if( ext == "") filePath += ".txt";
|
if( ext == "") filePath += ".txt";
|
||||||
digi[ID]->SaveAllSettingsAsText(filePath.toStdString().c_str());
|
digi[ID]->SaveAllSettingsAsText(filePath.toStdString().c_str());
|
||||||
leSaveFilePath[ID]->setText(filePath);
|
leSaveFilePath[ID]->setText(filePath + " | not loadable!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SendLogMsg("Saved setting file <b>" + filePath + "</b>.");
|
SendLogMsg("Saved setting file <b>" + filePath + "</b>.");
|
||||||
|
@ -1256,7 +1256,7 @@ void DigiSettingsPanel::LoadSetting(){
|
||||||
QFileDialog fileDialog(this);
|
QFileDialog fileDialog(this);
|
||||||
fileDialog.setDirectory(rawDataPath);
|
fileDialog.setDirectory(rawDataPath);
|
||||||
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
fileDialog.setNameFilter("Data file (*.dat);;");
|
fileDialog.setNameFilter("Binary (*.bin);;");
|
||||||
int result = fileDialog.exec();
|
int result = fileDialog.exec();
|
||||||
|
|
||||||
if( ! (result == QDialog::Accepted) ) return;
|
if( ! (result == QDialog::Accepted) ) return;
|
||||||
|
@ -1265,12 +1265,12 @@ void DigiSettingsPanel::LoadSetting(){
|
||||||
|
|
||||||
QString fileName = fileDialog.selectedFiles().at(0);
|
QString fileName = fileDialog.selectedFiles().at(0);
|
||||||
|
|
||||||
leSaveFilePath[ID]->setText(fileName);
|
if( digi[ID]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
|
||||||
|
|
||||||
if( digi[ID]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) ){
|
|
||||||
SendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
|
SendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
|
||||||
|
leSaveFilePath[ID]->setText(fileName + " | dynamic update");
|
||||||
digi[ID]->ProgramSettingsToBoard();
|
digi[ID]->ProgramSettingsToBoard();
|
||||||
UpdatePanelFromMemory();
|
UpdatePanelFromMemory();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
SendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
|
SendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
|
||||||
}
|
}
|
||||||
|
|
76
FSUDAQ.cpp
76
FSUDAQ.cpp
|
@ -161,33 +161,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
programSettingsFilePath = QDir::current().absolutePath() + "/programSettings.txt";
|
programSettingsFilePath = QDir::current().absolutePath() + "/programSettings.txt";
|
||||||
LoadProgramSettings();
|
LoadProgramSettings();
|
||||||
|
|
||||||
{
|
|
||||||
scalar = new QMainWindow(this);
|
|
||||||
scalar->setWindowTitle("Scalar");
|
|
||||||
|
|
||||||
QScrollArea * scopeScroll = new QScrollArea(scalar);
|
|
||||||
scalar->setCentralWidget(scopeScroll);
|
|
||||||
scopeScroll->setWidgetResizable(true);
|
|
||||||
scopeScroll->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
|
|
||||||
QWidget * layoutWidget = new QWidget(scalar);
|
|
||||||
scopeScroll->setWidget(layoutWidget);
|
|
||||||
|
|
||||||
scalarLayout = new QGridLayout(layoutWidget);
|
|
||||||
scalarLayout->setSpacing(0);
|
|
||||||
scalarLayout->setAlignment(Qt::AlignTop);
|
|
||||||
|
|
||||||
leTrigger = nullptr;
|
|
||||||
leAccept = nullptr;
|
|
||||||
|
|
||||||
lbLastUpdateTime = nullptr;
|
|
||||||
lbScalarACQStatus = nullptr;
|
|
||||||
|
|
||||||
scalarThread = new TimingThread();
|
|
||||||
connect(scalarThread, &TimingThread::timeUp, this, &MainWindow::UpdateScalar);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========== disable widget
|
//=========== disable widget
|
||||||
WaitForDigitizersOpen(true);
|
WaitForDigitizersOpen(true);
|
||||||
|
|
||||||
|
@ -373,15 +346,30 @@ void MainWindow::OpenDigitizers(){
|
||||||
readDataThread = new ReadDataThread * [nDigi];
|
readDataThread = new ReadDataThread * [nDigi];
|
||||||
for( unsigned int i = 0; i < nDigi; i++){
|
for( unsigned int i = 0; i < nDigi; i++){
|
||||||
digi[i] = new Digitizer(portList[i].first, portList[i].second);
|
digi[i] = new Digitizer(portList[i].first, portList[i].second);
|
||||||
//TODO === load settings
|
|
||||||
digi[i]->Reset();
|
digi[i]->Reset();
|
||||||
digi[i]->ProgramPHABoard();
|
|
||||||
|
///============== load settings
|
||||||
|
QString fileName = rawDataPath + "/Digi-" + QString::number(digi[i]->GetSerialNumber()) + ".bin";
|
||||||
|
QFile file(fileName);
|
||||||
|
if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) {
|
||||||
|
LogMsg("<b>" + fileName + "</b> not found. Program predefined PHA settings."); //TODO, PSD?
|
||||||
|
digi[i]->ProgramPHABoard();
|
||||||
|
}else{
|
||||||
|
LogMsg("Found <b>" + fileName + "</b> for digitizer settings.");
|
||||||
|
|
||||||
|
if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
|
||||||
|
LogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
|
||||||
|
digi[i]->ProgramSettingsToBoard();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readDataThread[i] = new ReadDataThread(digi[i], i);
|
readDataThread[i] = new ReadDataThread(digi[i], i);
|
||||||
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
digi[0]->SaveAllSettingsAsText("setting.txt");
|
|
||||||
|
|
||||||
LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi));
|
LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi));
|
||||||
|
|
||||||
WaitForDigitizersOpen(false);
|
WaitForDigitizersOpen(false);
|
||||||
|
@ -413,8 +401,6 @@ void MainWindow::CloseDigitizers(){
|
||||||
for(unsigned int i = 0; i < nDigi; i ++){
|
for(unsigned int i = 0; i < nDigi; i ++){
|
||||||
digi[i]->CloseDigitizer();
|
digi[i]->CloseDigitizer();
|
||||||
delete digi[i];
|
delete digi[i];
|
||||||
digi[i] = nullptr;
|
|
||||||
|
|
||||||
delete readDataThread[i];
|
delete readDataThread[i];
|
||||||
}
|
}
|
||||||
delete [] digi;
|
delete [] digi;
|
||||||
|
@ -448,6 +434,30 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){
|
||||||
//***************************************************************
|
//***************************************************************
|
||||||
void MainWindow::SetupScalar(){
|
void MainWindow::SetupScalar(){
|
||||||
|
|
||||||
|
scalar = new QMainWindow(this);
|
||||||
|
scalar->setWindowTitle("Scalar");
|
||||||
|
|
||||||
|
QScrollArea * scopeScroll = new QScrollArea(scalar);
|
||||||
|
scalar->setCentralWidget(scopeScroll);
|
||||||
|
scopeScroll->setWidgetResizable(true);
|
||||||
|
scopeScroll->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
QWidget * layoutWidget = new QWidget(scalar);
|
||||||
|
scopeScroll->setWidget(layoutWidget);
|
||||||
|
|
||||||
|
scalarLayout = new QGridLayout(layoutWidget);
|
||||||
|
scalarLayout->setSpacing(0);
|
||||||
|
scalarLayout->setAlignment(Qt::AlignTop);
|
||||||
|
|
||||||
|
leTrigger = nullptr;
|
||||||
|
leAccept = nullptr;
|
||||||
|
|
||||||
|
lbLastUpdateTime = nullptr;
|
||||||
|
lbScalarACQStatus = nullptr;
|
||||||
|
|
||||||
|
scalarThread = new TimingThread();
|
||||||
|
connect(scalarThread, &TimingThread::timeUp, this, &MainWindow::UpdateScalar);
|
||||||
|
|
||||||
scalar->setGeometry(0, 0, 10 + nDigi * 180, 110 + MaxNChannels * 20);
|
scalar->setGeometry(0, 0, 10 + nDigi * 180, 110 + MaxNChannels * 20);
|
||||||
|
|
||||||
if( lbLastUpdateTime == nullptr ){
|
if( lbLastUpdateTime == nullptr ){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user