testing with digitizers

This commit is contained in:
carina@hades 2022-09-26 18:00:36 -04:00
parent f8ddccdac8
commit 8c7709daeb
4 changed files with 93 additions and 57 deletions

View File

@ -356,7 +356,10 @@ void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
}
uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){
if( !isConnected ) return 0;
if( !isConnected ) {
//TODO read from Setting file;
return 0;
}else{
uint32_t * data = new uint32_t[NChannel];
if( address < 0x8000) {
if( ch < 0 ) {
@ -370,6 +373,7 @@ uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){
ErrorMsg("ReadRegister:" + std::to_string(address));
if( str != "" ) printf("%s : 0x%08x \n", str.c_str(), data[0]);
return data[0];
}
}
void Digitizer::SetChannelMask(uint32_t mask){
@ -575,6 +579,7 @@ void Digitizer::OpenSettingBinary(string fileName){
CreateAndSaveSettingBinary(fileName);
}else{
settingFileExist = true;
printf("setting file already exist.\n");
}
}

View File

@ -23,6 +23,8 @@ enum MenuIdentifiers{
M_DIGITIZER_OPEN,
M_FILE_OPEN,
M_EXIT,
M_LOAD_SETTINGS,
M_VIEW_SETTINGS, // TODO
M_TRIGGER_SUMMARY,
M_CH_SETTING_PHA,
M_CH_SETTING_PSD,
@ -61,6 +63,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuDigitizers = new TGPopupMenu(gClient->GetRoot());
fMenuDigitizers->AddEntry("&Open Digitizers", M_DIGITIZER_OPEN);
fMenuDigitizers->AddEntry("&Load Settings", M_LOAD_SETTINGS);
fMenuDigitizers->AddEntry("&Trigger Summary", M_TRIGGER_SUMMARY);
fMenuDigitizers->AddSeparator();
fMenuDigitizers->AddEntry("Digitizer &Settings", M_BOARD_SETTINGS);
@ -71,7 +74,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
//fMenuDigitizers->DisableEntry( M_TRIGGER_SUMMARY);
fMenuDigitizers->DisableEntry( M_TRIGGER_SUMMARY);
fMenuDigitizers->DisableEntry( M_LOAD_SETTINGS);
//fMenuDigitizers->DisableEntry( M_BOARD_SETTINGS);
//fMenuDigitizers->DisableEntry( M_CH_SETTING);
@ -136,9 +140,9 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
LogMsg("Please \"Open Digitizers\" to start.");
//HandleMenu(M_DIGITIZER_OPEN);
//
//HandleMenu(M_BOARD_SETTINGS);
HandleMenu(M_DIGITIZER_OPEN);
HandleMenu(M_BOARD_SETTINGS);
//HandleMenu(M_CH_SETTING_PHA);
//HandleMenu(M_CH_SETTING_PSD);
@ -287,10 +291,12 @@ void MainWindow::OpenDigitizers(){
digi[i]->GetDPPTypeString().c_str(),
digi[i]->GetModelName().c_str()));
digi[i]->CreateAndSaveSettingBinary("setting_" + to_string(digi[i]->GetSerialNumber()) + ".bin");
digi[i]->OpenSettingBinary("setting_" + to_string(digi[i]->GetSerialNumber()) + ".bin");
}
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
fMenuDigitizers->EnableEntry( M_LOAD_SETTINGS);
fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY);
bOpenDigitizers->SetEnabled(false);
}

View File

@ -210,9 +210,9 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
bOpenChannelSetting->SetHeight(40);
bOpenChannelSetting->Connect("Clicked()", "BoardSetting", this, "OpenChannelSetting()");
TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status & Settings"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0));
bUpdateStatus->SetHeight(40);
bUpdateStatus->Connect("Clicked()", "BoardSetting", this, "ReadStatus()");
bUpdateStatus->Connect("Clicked()", "BoardSetting", this, "ChangeBoard()");
TGHorizontalFrame * hRow1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hRow1, new TGLayoutHints( kLHintsExpandX));
@ -342,6 +342,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGLabel * lbFanCtrl = new TGLabel(vBdCfga_label, "Fan Speed Control", kHorizontalFrame); vBdCfga_label->AddFrame(lbFanCtrl, kaka);
cbFanCtrl = new TGComboBox(vBdCfga_CBox, "",1); vBdCfga_CBox->AddFrame(cbFanCtrl);
cbFanCtrl->EnableTextInput(false);
cbFanCtrl->AddEntry("N/A",0);
cbFanCtrl->AddEntry("Slow/Auto",0x30);
cbFanCtrl->AddEntry("Fast", 0x38);
cbFanCtrl->Resize(100, 20);
@ -410,9 +411,14 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGHorizontalFrame * hframeTRGCfg = new TGHorizontalFrame(vTRGCfg); vTRGCfg->AddFrame(hframeTRGCfg, new TGLayoutHints(kLHintsCenterY, 2,2,2,2));
TGVerticalFrame * vTRGType = new TGVerticalFrame(hframeTRGCfg); hframeTRGCfg->AddFrame(vTRGType, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
///"Disable External Trigger",
bEnableExtTRG = new TGCheckButton(vTRGType, "Enable Ext. Trigger", 1); vTRGType->AddFrame(bEnableExtTRG);
bEnableExtTRG->Connect("Clicked()", "BoardSetting", this, "SetEnableExternalTrigger()");
TGLabel * lbdummy0 = new TGLabel(vTRGType, "");
vTRGType->AddFrame(lbdummy0, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 5, 5, 3, 4));
vTRGType->AddFrame(lbdummy0, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 5, 5, 3, 4));
//vTRGType->AddFrame(lbdummy0, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 5, 5, 3, 4));
TGLayoutHints * haha = new TGLayoutHints(kLHintsCenterX , 2, 2, 3, 3);
@ -526,15 +532,11 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGHorizontalFrame * hframeTRGCfg2 = new TGHorizontalFrame(vTRGCfg); vTRGCfg->AddFrame(hframeTRGCfg2, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2,2,2,2));
///"Disable External Trigger",
bEnableExtTRG = new TGCheckButton(hframeTRGCfg2, "Enable Ext. Trigger", 1); hframeTRGCfg2->AddFrame(bEnableExtTRG, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4));
bEnableExtTRG->Connect("Clicked()", "BoardSetting", this, "SetEnableExternalTrigger()");
///"Extended Veto Delay",
TGLabel * lbExtendVetoDelay = new TGLabel(hframeTRGCfg2, "Extended Veto Delay"); hframeTRGCfg2->AddFrame(lbExtendVetoDelay, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4));
numExtendVetoDelay = new TGNumberEntry(hframeTRGCfg2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hframeTRGCfg2->AddFrame(numExtendVetoDelay, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4));
numExtendVetoDelay->Resize(70, 17);
numExtendVetoDelay->Connect("Modified()", "BoardSetting", this, "SetExtendedVetoDelay()");
///"Extended Veto Delay", only when bit[9] of 0x8100 = 1
///TGLabel * lbExtendVetoDelay = new TGLabel(hframeTRGCfg2, "Extended Veto Delay"); hframeTRGCfg2->AddFrame(lbExtendVetoDelay, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4));
///numExtendVetoDelay = new TGNumberEntry(hframeTRGCfg2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hframeTRGCfg2->AddFrame(numExtendVetoDelay, new TGLayoutHints(kLHintsCenterY , 5, 5, 3, 4));
///numExtendVetoDelay->Resize(70, 17);
///numExtendVetoDelay->Connect("Modified()", "BoardSetting", this, "SetExtendedVetoDelay()");
}
TGHorizontalFrame * hRow2 = new TGHorizontalFrame(vframe); vframe->AddFrame(hRow2, new TGLayoutHints(kLHintsExpandX));
@ -561,7 +563,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
TGLabel * lbTRGOUTMODE2 = new TGLabel(vFrontIOCtrl_label, "TRG-OUT Mode"); vFrontIOCtrl_label->AddFrame(lbTRGOUTMODE2, haha);
cbTRGOUTmode = new TGComboBox(vFrontIOCtrl_CBox, "",1); vFrontIOCtrl_CBox->AddFrame(cbTRGOUTmode);
cbTRGOUTmode->EnableTextInput(false);
cbTRGOUTmode->AddEntry("Disable", 0x00001); /// this is TRG_OUT high imped. 0x811C bit[1]
cbTRGOUTmode->AddEntry("Disable", 0x00002); /// this is TRG_OUT high imped. 0x811C bit[1]
cbTRGOUTmode->AddEntry("force TRG-OUT is 0", 0x08000);
cbTRGOUTmode->AddEntry("force TRG-OUT is 1", 0x0C000);
cbTRGOUTmode->AddEntry("Trigger", 0x00000);
@ -702,7 +704,7 @@ void BoardSetting::ReadStatus(){
int boardID = boardIDEntry->GetNumber();
/// ACQ Status
digi[boardID]->PrintRegister(Register::DPP::AcquisitionStatus, "ACQ Status");
///digi[boardID]->PrintRegister(Register::DPP::AcquisitionStatus, "ACQ Status");
uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::AcquisitionStatus);
txtACQStatus ->SetText( ((temp >> 2) & 0x1) == 0 ? "ACQ is stopped" : "ACQ is Running", false); txtACQStatus->SetTextColor( ((temp >> 2) & 0x1) == 0 ? 1 : blue);
@ -723,7 +725,7 @@ void BoardSetting::ReadStatus(){
txtACQTemp3->SetText( ((temp >> 23) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp3->SetTextColor( ((temp >> 23) & 0x1) == 0 ? 1 : red);
/// Redaout Status
digi[boardID]->PrintRegister(Register::DPP::ReadoutStatus, "Readout Status");
///digi[boardID]->PrintRegister(Register::DPP::ReadoutStatus, "Readout Status");
temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus);
if( (temp & 0x1) == 1 ){
txtEventReady->SetText( "Event Ready" , false); txtEventReady->SetTextColor(blue);
@ -744,8 +746,8 @@ void BoardSetting::ReadStatus(){
}
///================ Board Failure Status
digi[boardID]->PrintRegister(Register::DPP::BoardFailureStatus, "Board Fail");
temp = digi[boardID]->ReadRegister(Register::DPP::BoardFailureStatus, -1, "Board Fail");
///digi[boardID]->PrintRegister(Register::DPP::BoardFailureStatus, "Board Fail");
temp = digi[boardID]->ReadRegister(Register::DPP::BoardFailureStatus);
if( ((temp >> 4) & 0x1) == 0 ) {
enPLLStatus->SetText( "OK" , false); enPLLStatus->SetTextColor(1);
}else{
@ -808,10 +810,19 @@ void BoardSetting::ChangeBoard(){
cbAggOrg->Select( digi[boardID]->ReadRegister(Register::DPP::AggregateOrganization) , false);
numAggBLT->SetNumber( digi[boardID]->ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer) , false);
if( digi[boardID]->GetNChannel() == 8 ){
///FAN Speed control only for desktop version
cbFanCtrl->SetEnabled(true);
cbFanCtrl->Select( digi[boardID]->ReadRegister(Register::DPP::FanSpeedControl) , false);
}else{
cbFanCtrl->SetEnabled(false);
cbFanCtrl->Select( 0 , false);
}
numRunStartStopDelay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::RunStartStopDelay), false);
bEnableExtTRG->SetState( (digi[boardID]->ReadRegister(Register::DPP::DisableExternalTrigger) & 0x1) ? kButtonDown : kButtonUp, false);
numExtendVetoDelay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::ExtendedVetoDelay) , false);
///numExtendVetoDelay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::ExtendedVetoDelay) , false);
cbAnaMonitor->Select( digi[boardID]->ReadRegister(Register::DPP::AnalogMonitorMode) & 0x7 , false);
numBufferOccpGain->SetNumber( digi[boardID]->ReadRegister(Register::DPP::BufferOccupancyGain) & 0xf, false);
@ -922,7 +933,15 @@ void BoardSetting::ChangeBoard(){
bWFRecord->SetState( ((tempBits >> 16) & 0x1) ? kButtonDown : kButtonUp, false );
bTrigPropa->SetState( ((tempBits >> 2) & 0x1) ? kButtonDown : kButtonUp, false );
bExtrac2->SetState( ((tempBits >> 17) & 0x1) ? kButtonDown : kButtonUp, false );
bDualTrace->SetState( ((tempBits >> 11) & 0x1) ? kButtonDown : kButtonUp, false );
if( (tempBits >> 11) & 0x1 ){
bDualTrace->SetState( kButtonDown , false );
cbAP2->SetEnabled(true);
}else{
bDualTrace->SetState( kButtonUp , false );
cbAP2->SetEnabled(false);
}
cbAP1->Select( ((tempBits >> 12) & 0x3) , false);
cbAP2->Select( ((tempBits >> 14) & 0x3) , false);
cbDP1->Select( ((tempBits >> 20) & 0x7) , false);
@ -1038,12 +1057,12 @@ void BoardSetting::SetBoardConfiguration(){
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
uint32_t bit = 0;
uint32_t bit = (3 << 18); /// timestamp and energy recording
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ) {
uint32_t bit = (3 << 18); /// timestamp and energy recording
bit += (18 << 3) ; /// Reserved must be 0010010 for bit[10:3]
if( bAutoDataFlush->GetState() == kButtonDown ) bit += 1;
printf("bit : 0x%x \n", bit);
if( bAutoDataFlush->GetState() == kButtonDown ) { bit += 1; printf("bit : 0x%x \n", bit);};
if( bDecimateWF->GetState() == kButtonDown ) bit += (1 << 1);
if( bWFRecord->GetState() == kButtonDown ) bit += ( 1 << 16);
if( bTrigPropa->GetState() == kButtonDown ) bit += ( 1 << 2);
@ -1062,7 +1081,6 @@ void BoardSetting::SetBoardConfiguration(){
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
uint32_t bit = (3 << 18); /// timestamp and energy recording
bit += (18 << 3) ; /// Reserved must be 0010010 for bit[10:3]
if( bAutoDataFlush->GetState() == kButtonDown ) bit += 1;
if( bDecimateWF->GetState() == kButtonDown ) bit += (1 << 1);
@ -1211,7 +1229,7 @@ void BoardSetting::SetExtendedVetoDelay(){ /// same for PHA and PSD
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
digi[boardID]->WriteRegister(Register::DPP::ExtendedVetoDelay, (unsigned int) numExtendVetoDelay->GetNumber() );
///digi[boardID]->WriteRegister(Register::DPP::ExtendedVetoDelay, (unsigned int) numExtendVetoDelay->GetNumber() );
}
void BoardSetting::SetFrontPanelIO(){ /// bit[20] different, bit[20] (PSD) not impletemented, PHA, bit[20] not use
@ -1221,10 +1239,13 @@ void BoardSetting::SetFrontPanelIO(){ /// bit[20] different, bit[20] (PSD) not
uint32_t bit = 0;
bit += ( cbLEMOIO->GetSelected() );
if( cbTRGOUTmode->GetSelected() != 1 ) { /// has TRG-OUT
bit += 0x2; /// TRG-OUT
bit += ( cbTRGOUTmode->GetSelected() << 14 ) ;
}
bit += cbTRGOUTmode->GetSelected() ;
//if( cbTRGOUTmode->GetSelected() != 2 ) { /// has TRG-OUT
// bit += cbTRGOUTmode->GetSelected() ;
//}else{
// bit += 0x2; /// TRG-OUT (high0impedance) or off
//}
bit += ( cbTRGINCtrl->GetSelected() << 10 );
bit += ( cbTRGINMezzanines->GetSelected() << 11 );

View File

@ -385,6 +385,9 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
ch2ns = 4;
isOpened = true;
ChangeBoard();
}
ChannelSettingPHA::~ChannelSettingPHA(){
@ -567,7 +570,8 @@ void ChannelSettingPHA::SetChannelMask(){
short ch = chIDEntry->GetNumber();
unsigned short val = cbOnOff->GetSelected();
uint32_t chMask = ((digi[boardID]->GetChannelMask()) & ( val << ch) );
uint32_t bitMask = (1 << ch);
uint32_t chMask = ((digi[boardID]->GetChannelMask() & ~bitMask) | ( val << ch) );
printf("mask : 0x%x \n", chMask);
digi[boardID]->SetChannelMask(chMask);
@ -589,16 +593,16 @@ void ChannelSettingPHA::SetDPPAlgorithm1(){
digi[boardID]->WriteRegister(Register::DPP::RecordLength_G, temp , ch);
uint32_t bit = 0;
bit += numTrapScale->GetNumber();
bit += ((cbDecimation->GetSelected() << 8) & 0x3);
bit += ((cbDecimationGain->GetSelected() << 10) & 0x3);
bit += ((cbPeakMean->GetSelected() << 12) & 0x3);
bit += ((cbPolarity->GetSelected() << 16) & 0x3);
bit += ((cbTriggerMode->GetSelected() << 18) & 0x3);
bit += ((cbBaseLineAvg->GetSelected() << 20) & 0x7);
bit += ((cbDisableSelfTrigger->GetSelected() << 24) & 0x1);
bit += ((cbRollOver->GetSelected() << 26) & 0x1);
bit += ((cbPileUp->GetSelected() << 27) & 0x1);
bit = bit + numTrapScale->GetNumber();
bit = bit + ((cbDecimation->GetSelected() << 8) & 0x3);
bit = bit + ((cbDecimationGain->GetSelected() << 10) & 0x3);
bit = bit + ((cbPeakMean->GetSelected() << 12) & 0x3);
bit = bit + ((cbPolarity->GetSelected() << 16) & 0x3);
bit = bit + ((cbTriggerMode->GetSelected() << 18) & 0x3);
bit = bit + ((cbBaseLineAvg->GetSelected() << 20) & 0x7);
bit = bit + ((cbDisableSelfTrigger->GetSelected() << 24) & 0x1);
bit = bit + ((cbRollOver->GetSelected() << 26) & 0x1);
bit = bit + ((cbPileUp->GetSelected() << 27) & 0x1);
printf(" DPP1 bit: 0x%x\n", bit);
digi[boardID]->WriteRegister(Register::DPP::DPPAlgorithmControl, bit, ch);