can load setting file to program board when digitizer exist
This commit is contained in:
parent
fcd3463c70
commit
8c8de7faa5
|
@ -363,29 +363,44 @@ void Digitizer::WriteRegister(uint32_t registerAddress, uint32_t value, int ch )
|
||||||
if( ch < 0 ){
|
if( ch < 0 ){
|
||||||
for( int i = 0; i < NChannel/2; i++){
|
for( int i = 0; i < NChannel/2; i++){
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 4*i, value);
|
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 4*i, value);
|
||||||
if( ret == 0 ) SetSettingToMemory(registerAddress, value, i);
|
if( ret == 0 ) {
|
||||||
|
SetSettingToMemory(registerAddress, value, i);
|
||||||
|
SaveSettingToFile(registerAddress, value, i);
|
||||||
|
}
|
||||||
///ReadRegister(registerAddress, i);
|
///ReadRegister(registerAddress, i);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 4*(ch/2), value);
|
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 4*(ch/2), value);
|
||||||
if( ret == 0 ) SetSettingToMemory(registerAddress, value, ch);
|
if( ret == 0 ) {
|
||||||
|
SetSettingToMemory(registerAddress, value, ch);
|
||||||
|
SaveSettingToFile(registerAddress, value, ch);
|
||||||
|
}
|
||||||
///ReadRegister(registerAddress, ch);
|
///ReadRegister(registerAddress, ch);
|
||||||
}
|
}
|
||||||
}else if( registerAddress < 0x8000){
|
}else if( registerAddress < 0x8000){
|
||||||
if( ch < 0 ) {
|
if( ch < 0 ) {
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 0x7000, value);
|
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 0x7000, value);
|
||||||
if( ret == 0 ){
|
if( ret == 0 ){
|
||||||
for( int i = 0; i < NChannel; i++) SetSettingToMemory(registerAddress, value, i);
|
for( int i = 0; i < NChannel; i++) {
|
||||||
|
SetSettingToMemory(registerAddress, value, i);
|
||||||
|
SaveSettingToFile(registerAddress, value, i);
|
||||||
|
}
|
||||||
///for( int i = 0; i < NChannel; i++) ReadRegister(registerAddress, i);
|
///for( int i = 0; i < NChannel; i++) ReadRegister(registerAddress, i);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + (ch<<8), value);
|
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + (ch<<8), value);
|
||||||
if( ret == 0 ) SetSettingToMemory(registerAddress, value, ch);
|
if( ret == 0 ) {
|
||||||
|
SetSettingToMemory(registerAddress, value, ch);
|
||||||
|
SaveSettingToFile(registerAddress, value, ch);
|
||||||
|
}
|
||||||
///ReadRegister(registerAddress, ch);
|
///ReadRegister(registerAddress, ch);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress, value);
|
ret = CAEN_DGTZ_WriteRegister(handle, registerAddress, value);
|
||||||
if( ret == 0 ) SetSettingToMemory(registerAddress, value);
|
if( ret == 0 ) {
|
||||||
|
SetSettingToMemory(registerAddress, value);
|
||||||
|
SaveSettingToFile(registerAddress, value);
|
||||||
|
}
|
||||||
//ReadRegister(registerAddress);
|
//ReadRegister(registerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +412,10 @@ void Digitizer::WriteRegister(uint32_t registerAddress, uint32_t value, int ch )
|
||||||
registerAddress == Register::DPP::TriggerValidationMask_G
|
registerAddress == Register::DPP::TriggerValidationMask_G
|
||||||
){
|
){
|
||||||
//ReadRegister(registerAddress, ch + (ch%2 == 1 ? -1 : +1));
|
//ReadRegister(registerAddress, ch + (ch%2 == 1 ? -1 : +1));
|
||||||
if( ret == 0 ) SetSettingToMemory(registerAddress, value, ch);
|
if( ret == 0 ) {
|
||||||
|
SetSettingToMemory(registerAddress, value, ch);
|
||||||
|
SaveSettingToFile(registerAddress, value, ch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorMsg("WriteRegister:" + std::to_string(registerAddress));
|
ErrorMsg("WriteRegister:" + std::to_string(registerAddress));
|
||||||
|
@ -834,13 +852,14 @@ void Digitizer::PrintSettingFromMemory(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::OpenSettingBinary(string fileName){
|
void Digitizer::OpenSettingBinary(string fileName){
|
||||||
settingFile = NULL;
|
delete settingFile;
|
||||||
this->settingFileName = fileName;
|
|
||||||
settingFile = fopen(fileName.c_str(), "r+");
|
settingFile = fopen(fileName.c_str(), "r+");
|
||||||
if( settingFile == NULL ){
|
if( settingFile == NULL ){
|
||||||
|
this->settingFileName = "";
|
||||||
printf("cannot open file %s. \n", fileName.c_str());
|
printf("cannot open file %s. \n", fileName.c_str());
|
||||||
CreateAndSaveSettingToFile(fileName);
|
CreateAndSaveSettingToFile(fileName);
|
||||||
}else{
|
}else{
|
||||||
|
this->settingFileName = fileName;
|
||||||
settingFileExist = true;
|
settingFileExist = true;
|
||||||
printf("setting file already exist.\n");
|
printf("setting file already exist.\n");
|
||||||
}
|
}
|
||||||
|
@ -866,8 +885,7 @@ void Digitizer::CreateAndSaveSettingToFile(string fileName){
|
||||||
|
|
||||||
void Digitizer::LoadSettingBinary(string fileName){
|
void Digitizer::LoadSettingBinary(string fileName){
|
||||||
|
|
||||||
settingFileName = fileName;
|
settingFile = fopen(fileName.c_str(), "r+");
|
||||||
settingFile = fopen(settingFileName.c_str(), "r");
|
|
||||||
|
|
||||||
if( settingFile == NULL ) {
|
if( settingFile == NULL ) {
|
||||||
printf(" %s does not exist.\n", fileName.c_str());
|
printf(" %s does not exist.\n", fileName.c_str());
|
||||||
|
@ -876,6 +894,8 @@ void Digitizer::LoadSettingBinary(string fileName){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
settingFileExist = true;
|
settingFileExist = true;
|
||||||
|
settingFileName = fileName;
|
||||||
|
|
||||||
size_t dummy = fread( setting, SETTINGSIZE * sizeof(unsigned int), 1, settingFile);
|
size_t dummy = fread( setting, SETTINGSIZE * sizeof(unsigned int), 1, settingFile);
|
||||||
|
|
||||||
if( isConnected ) {
|
if( isConnected ) {
|
||||||
|
|
|
@ -122,11 +122,13 @@ class Digitizer{
|
||||||
|
|
||||||
void SetSettingFromMemory (uint32_t registerAddress, int ch = -1);
|
void SetSettingFromMemory (uint32_t registerAddress, int ch = -1);
|
||||||
|
|
||||||
void OpenSettingBinary (string fileName);
|
void OpenSettingBinary (string fileName); /// Open setting file, if file not exist, call CreateAndSaveSetiingFile, if file exit simple set the settignFileName
|
||||||
void LoadSettingBinary (string fileName); /// load settign file to memory
|
void LoadSettingBinary (string fileName); /// load settign file to memory, if digitizer connected, program digitizer
|
||||||
void CreateAndSaveSettingToFile (string fileName);
|
void CreateAndSaveSettingToFile (string fileName);
|
||||||
void SaveSettingToFile (uint32_t registerAddress, unsigned int value, int ch = -1);
|
void SaveSettingToFile (uint32_t registerAddress, unsigned int value, int ch = -1);
|
||||||
unsigned int ReadSettingFromFile (uint32_t registerAddress, int ch = -1); /// read from setting binary
|
unsigned int ReadSettingFromFile (uint32_t registerAddress, int ch = -1); /// read from setting binary
|
||||||
|
|
||||||
|
string GetSettingFileName() {return settingFileName;}
|
||||||
|
|
||||||
virtual int ProgramBoard();
|
virtual int ProgramBoard();
|
||||||
|
|
||||||
|
|
|
@ -219,8 +219,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
|
|
||||||
LogMsg((char*)"Please \"Open Digitizers\" to start.");
|
LogMsg((char*)"Please \"Open Digitizers\" to start.");
|
||||||
|
|
||||||
//HandleMenu(M_DIGITIZER_OPEN);
|
HandleMenu(M_DIGITIZER_OPEN);
|
||||||
//HandleMenu(M_BOARD_SETTINGS);
|
HandleMenu(M_BOARD_SETTINGS);
|
||||||
//HandleMenu(M_CH_SETTING_PHA);
|
//HandleMenu(M_CH_SETTING_PHA);
|
||||||
//HandleMenu(M_CH_SETTING_PSD);
|
//HandleMenu(M_CH_SETTING_PSD);
|
||||||
//HandleMenu(M_REGISTER_SETTING);
|
//HandleMenu(M_REGISTER_SETTING);
|
||||||
|
@ -405,7 +405,7 @@ void MainWindow::OpenDigitizers(){
|
||||||
digi[i]->GetDPPTypeString().c_str(),
|
digi[i]->GetDPPTypeString().c_str(),
|
||||||
digi[i]->GetModelName().c_str()));
|
digi[i]->GetModelName().c_str()));
|
||||||
|
|
||||||
digi[i]->OpenSettingBinary("setting_" + to_string(digi[i]->GetSerialNumber()) + ".bin");
|
digi[i]->OpenSettingBinary("./setting_" + to_string(digi[i]->GetSerialNumber()) + ".bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
|
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
|
||||||
|
|
|
@ -66,11 +66,27 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
|
||||||
|
|
||||||
TGTextButton * bSoftwareReset = new TGTextButton(hframe0, "Reset Settings to default"); hframe0->AddFrame(bSoftwareReset, layoutHints);
|
TGTextButton * bSoftwareReset = new TGTextButton(hframe0, "Reset Settings to default"); hframe0->AddFrame(bSoftwareReset, layoutHints);
|
||||||
bSoftwareReset->Connect("Clicked()", "BoardSetting", this, "ResetSettingToDefault()");
|
bSoftwareReset->Connect("Clicked()", "BoardSetting", this, "ResetSettingToDefault()");
|
||||||
|
|
||||||
TGTextButton * bSoftwareClear = new TGTextButton(hframe0, "Clear Buffer"); hframe0->AddFrame(bSoftwareClear, layoutHints);
|
TGTextButton * bSoftwareClear = new TGTextButton(hframe0, "Clear Buffer"); hframe0->AddFrame(bSoftwareClear, layoutHints);
|
||||||
bSoftwareClear->Connect("Clicked()", "BoardSetting", this, "ClearBuffer()");
|
bSoftwareClear->Connect("Clicked()", "BoardSetting", this, "ClearBuffer()");
|
||||||
|
|
||||||
|
{///=========== Setting file
|
||||||
|
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hframe1, new TGLayoutHints(kLHintsLeft, 5, 5, 0, 0));
|
||||||
|
|
||||||
|
TGTextButton * bProgramBoardFromFile = new TGTextButton(hframe1, "Open File"); hframe1->AddFrame(bProgramBoardFromFile, new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||||
|
bProgramBoardFromFile->Connect("Clicked()", "BoardSetting", this, "ProgramBoardFromFile()");
|
||||||
|
|
||||||
|
TGLabel * lbSettingFile = new TGLabel(hframe1, "Setting file :"); hframe1->AddFrame(lbSettingFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,4,2));
|
||||||
|
txtSettingFile = new TGTextEntry(hframe1, ""); hframe1->AddFrame(txtSettingFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||||
|
txtSettingFile->SetEnabled(false);
|
||||||
|
txtSettingFile->Resize(650, 20);
|
||||||
|
if( digi != NULL ) txtSettingFile->SetText( digi[boardID]->GetSettingFileName().c_str());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
{///============ fixed info
|
{///============ fixed info
|
||||||
TGHorizontalFrame * hframeInfo = new TGHorizontalFrame(vframe); vframe->AddFrame(hframeInfo, new TGLayoutHints(kLHintsExpandX));
|
TGGroupFrame * gInfo = new TGGroupFrame(vframe, "Board Info", kHorizontalFrame); vframe->AddFrame(gInfo, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0));
|
||||||
|
TGHorizontalFrame * hframeInfo = new TGHorizontalFrame(gInfo); gInfo->AddFrame(hframeInfo, new TGLayoutHints(kLHintsExpandX));
|
||||||
|
|
||||||
int numCol = 3;
|
int numCol = 3;
|
||||||
TGVerticalFrame * vframeInfo[numCol];
|
TGVerticalFrame * vframeInfo[numCol];
|
||||||
|
@ -212,8 +228,6 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
|
||||||
TGTextButton * bProgramDefaultBoard = new TGTextButton(hRow0, "Program Default Board"); hRow0->AddFrame(bProgramDefaultBoard, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
|
TGTextButton * bProgramDefaultBoard = new TGTextButton(hRow0, "Program Default Board"); hRow0->AddFrame(bProgramDefaultBoard, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
|
||||||
bProgramDefaultBoard->Connect("Clicked()", "BoardSetting", this, "ProgramDefaultBoard()");
|
bProgramDefaultBoard->Connect("Clicked()", "BoardSetting", this, "ProgramDefaultBoard()");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status and Settings"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
|
TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status and Settings"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
|
||||||
bUpdateStatus->Connect("Clicked()", "BoardSetting", this, "ChangeBoard()");
|
bUpdateStatus->Connect("Clicked()", "BoardSetting", this, "ChangeBoard()");
|
||||||
|
|
||||||
|
@ -794,6 +808,9 @@ void BoardSetting::ChangeBoard(){
|
||||||
|
|
||||||
int boardID = boardIDEntry->GetNumber();
|
int boardID = boardIDEntry->GetNumber();
|
||||||
|
|
||||||
|
txtSettingFile->SetText( digi[boardID]->GetSettingFileName().c_str() );
|
||||||
|
|
||||||
|
|
||||||
for( int i = 0; i < NUM_BOARD_INFO; i++){
|
for( int i = 0; i < NUM_BOARD_INFO; i++){
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0 : entry[i]->SetText( Form("%s", (digi[boardID]->GetModelName()).c_str()) ); break;
|
case 0 : entry[i]->SetText( Form("%s", (digi[boardID]->GetModelName()).c_str()) ); break;
|
||||||
|
@ -1346,8 +1363,7 @@ void BoardSetting::ReadData(){
|
||||||
data->PrintStat();
|
data->PrintStat();
|
||||||
|
|
||||||
//Fill Histogram
|
//Fill Histogram
|
||||||
|
|
||||||
|
|
||||||
data->ClearData();
|
data->ClearData();
|
||||||
|
|
||||||
ReadStatus();
|
ReadStatus();
|
||||||
|
@ -1368,3 +1384,32 @@ void BoardSetting::ProgramDefaultBoard(){
|
||||||
|
|
||||||
ChangeBoard();
|
ChangeBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BoardSetting::ProgramBoardFromFile(){
|
||||||
|
const char *filetypes[] = { "Setting File", "*.bin",
|
||||||
|
"ROOT files", "*.root",
|
||||||
|
"ROOT macros", "*.C",
|
||||||
|
"Text files", "*.[tT][xX][tT]",
|
||||||
|
0, 0 };
|
||||||
|
|
||||||
|
static TString dir(".");
|
||||||
|
TGFileInfo fi;
|
||||||
|
fi.fFileTypes = filetypes;
|
||||||
|
fi.SetIniDir(dir);
|
||||||
|
printf("fIniDir = %s\n", fi.fIniDir);
|
||||||
|
new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi);
|
||||||
|
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
|
||||||
|
dir = fi.fIniDir;
|
||||||
|
|
||||||
|
txtSettingFile->SetText(fi.fFilename);
|
||||||
|
|
||||||
|
if( digi == NULL ) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
int boardID = boardIDEntry->GetNumber();
|
||||||
|
digi[boardID]->LoadSettingBinary( fi.fFilename );
|
||||||
|
|
||||||
|
ChangeBoard();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ class BoardSetting{
|
||||||
TGNumberEntry * boardIDEntry;
|
TGNumberEntry * boardIDEntry;
|
||||||
|
|
||||||
TGTextEntry * entry[NUM_BOARD_INFO];
|
TGTextEntry * entry[NUM_BOARD_INFO];
|
||||||
|
|
||||||
|
TGTextEntry * txtSettingFile;
|
||||||
|
|
||||||
int nDigi;
|
int nDigi;
|
||||||
Digitizer ** digi;
|
Digitizer ** digi;
|
||||||
|
@ -175,5 +177,6 @@ class BoardSetting{
|
||||||
|
|
||||||
void ReadData();
|
void ReadData();
|
||||||
void ProgramDefaultBoard();
|
void ProgramDefaultBoard();
|
||||||
|
void ProgramBoardFromFile();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -264,6 +264,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
|
||||||
TGLabel * lbTrapScale = new TGLabel(vfDPPCtrl11, "Trap. Scaling [bit] :"); vfDPPCtrl11->AddFrame(lbTrapScale, haha);
|
TGLabel * lbTrapScale = new TGLabel(vfDPPCtrl11, "Trap. Scaling [bit] :"); vfDPPCtrl11->AddFrame(lbTrapScale, haha);
|
||||||
numTrapScale = new TGNumberEntry(vfDPPCtrl12, 14, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative ); vfDPPCtrl12->AddFrame(numTrapScale);
|
numTrapScale = new TGNumberEntry(vfDPPCtrl12, 14, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative ); vfDPPCtrl12->AddFrame(numTrapScale);
|
||||||
numTrapScale->Resize(width, 20);
|
numTrapScale->Resize(width, 20);
|
||||||
|
numTrapScale->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()");
|
||||||
|
|
||||||
TGLabel * lbDecimation = new TGLabel(vfDPPCtrl11, "Decimation :"); vfDPPCtrl11->AddFrame(lbDecimation, haha);
|
TGLabel * lbDecimation = new TGLabel(vfDPPCtrl11, "Decimation :"); vfDPPCtrl11->AddFrame(lbDecimation, haha);
|
||||||
cbDecimation = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbDecimation);
|
cbDecimation = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbDecimation);
|
||||||
|
@ -623,7 +624,7 @@ void ChannelSettingPHA::SetDPPAlgorithm1(){
|
||||||
unsigned short ch2ns = digi[boardID]->GetCh2ns();
|
unsigned short ch2ns = digi[boardID]->GetCh2ns();
|
||||||
|
|
||||||
uint32_t bit = 0;
|
uint32_t bit = 0;
|
||||||
bit += numTrapScale->GetNumber();
|
bit += (unsigned int) numTrapScale->GetNumber();
|
||||||
bit += ((cbDecimation->GetSelected() & 0x3) << 8) ;
|
bit += ((cbDecimation->GetSelected() & 0x3) << 8) ;
|
||||||
bit += ((cbDecimationGain->GetSelected() & 0x3) << 10);
|
bit += ((cbDecimationGain->GetSelected() & 0x3) << 10);
|
||||||
bit += ((cbPeakMean->GetSelected() & 0x3) << 12);
|
bit += ((cbPeakMean->GetSelected() & 0x3) << 12);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user