fix ReadData logic problem

This commit is contained in:
Ryan Tang 2023-09-22 17:57:43 -04:00
parent 95310aa1c2
commit e13713c299
8 changed files with 277 additions and 252 deletions

View File

@ -545,7 +545,8 @@ void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){
}
//TODO Statistic handle and endpoint
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha/stats", &stat_handle);
if( FPGAType == DPPType::PHA ) ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha/stats", &stat_handle);
if( FPGAType == DPPType::PSD ) ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppsd/stats", &stat_handle);
ret |= CAEN_FELib_SetReadDataFormat(stat_handle,
" [ \
{ \"name\": \"REAL_TIME_NS\", \"type\": \"U64\", \"dim\": 1 }, \
@ -575,22 +576,24 @@ int Digitizer2Gen::ReadStat(){
if (ret != CAEN_FELib_Success) ErrorMsg("Read Statistics");
for( int ch = 0; ch < nChannels; ch++) ReadValue( PHA::CH::SelfTrgRate, ch);
return ret;
}
void Digitizer2Gen::PrintStat(){
printf("ch | Real Time[ns] | Dead Time[ns] | Live Time[ns] | Trigger | Saved | Rate[Hz] \n");
for( int i = 0; i < MaxNumberOfChannel; i++){
printf("ch | Real Time[ns] | Dead Time[ns] | Live Time[ns] | Trigger | Saved | Rate[Hz] | Self Trig Rate [Hz] \n");
for( int i = 0; i < nChannels; i++){
if( triggerCount[i] == 0 ) continue;
printf("%02d | %13lu | %13lu | %13lu | %7u | %7u | %.3f\n",
i, realTime[i], deadTime[i], liveTime[i], triggerCount[i], savedEventCount[i], triggerCount[i]*1e9*1.0/realTime[i]);
printf("%02d | %13lu | %13lu | %13lu | %7u | %7u | %8.3f | %d\n",
i, realTime[i], deadTime[i], liveTime[i], triggerCount[i], savedEventCount[i], triggerCount[i]*1e9*1.0/realTime[i], atoi(chSettings[i][0].GetValue().c_str()));
}
}
int Digitizer2Gen::ReadData(){
//printf("========= %s \n", __func__);
//printf("Digitizer2Gen::%s, DPP : %s, dataFormat : %d \n", __func__, FPGAType.c_str(), evt->dataType);
if( FPGAType != DPPType::PHA || FPGAType != DPPType::PSD ) return -404;
if( FPGAType != DPPType::PHA && FPGAType != DPPType::PSD ) return -404;
if( evt->dataType == DataFormat::ALL ){
if( FPGAType == DPPType::PHA ){
@ -621,6 +624,8 @@ int Digitizer2Gen::ReadData(){
&evt->aggCounter,
&evt->event_size
);
//printf("ch:%02d, trace Length %ld \n", evt->channel, evt->traceLenght);
}else{
ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel,
@ -860,7 +865,7 @@ void Digitizer2Gen::SaveDataToFile(){
//###########################################
void Digitizer2Gen::Reset(){ SendCommand("/cmd/Reset"); }
void Digitizer2Gen::ProgramDPPBoard(){
void Digitizer2Gen::ProgramBoard(){
if( !isConnected ) return ;
//============= Board
@ -880,22 +885,15 @@ void Digitizer2Gen::ProgramDPPBoard(){
WriteValue("/par/EnAutoDisarmAcq" , "true");
WriteValue("/par/EnStatEvents" , "true");
WriteValue("/par/EnAutoDisarmAcq" , "False");
WriteValue("/par/BoardVetoWidth" , "0");
WriteValue("/par/VolatileClockOutDelay" , "0");
WriteValue("/par/PermanentClockOutDelay" , "0");
WriteValue("/par/DACoutMode" , "ChInput");
WriteValue("/par/DACoutStaticLevel" , "8192");
WriteValue("/par/DACoutChSelect" , "0");
//============== Test pulse
//WriteValue("/par/TestPulsePeriod" , "1000000"); // 1.0 msec = 1000Hz, tested, 1 trace recording
//WriteValue("/par/TestPulseWidth" , "1000"); // nsec
//WriteValue("/par/TestPulseLowLevel" , "0");
//WriteValue("/par/TestPulseHighLevel" , "10000");
//============== ITL
WriteValue("/par/ITLAMainLogic" , "OR");
WriteValue("/par/ITLAMajorityLev" , "2");
@ -909,10 +907,9 @@ void Digitizer2Gen::ProgramDPPBoard(){
WriteValue("/par/ITLBPolarity" , "Direct");
WriteValue("/par/ITLBGateWidth" , "100");
}
void Digitizer2Gen::ProgramPHAChannels(bool testPulse){
void Digitizer2Gen::ProgramChannels(bool testPulse){
// Channel setting
@ -932,39 +929,84 @@ void Digitizer2Gen::ProgramPHAChannels(bool testPulse){
}else{
//======== Self trigger for each channel
WriteValue("/ch/0..63/par/ChEnable" , "true");
WriteValue("/ch/0..63/par/WaveDaatSource" , "ADC_DATA");
WriteValue("/ch/0..63/par/ChEnable" , "True");
WriteValue("/ch/0..63/par/DCOffset" , "50");
WriteValue("/ch/0..63/par/TriggerThr" , "1000");
WriteValue("/ch/0..63/par/WaveDataSource" , "ADC_DATA");
WriteValue("/ch/0..63/par/PulsePolarity" , "Positive");
WriteValue("/ch/0..63/par/ChRecordLengthT" , "4096"); /// 4096 ns, S and T are not Sync
WriteValue("/ch/0..63/par/ChPreTriggerT" , "1000");
WriteValue("/ch/0..63/par/WaveResolution" , "RES8"); /// 8 ns
WriteValue("/ch/0..63/par/WaveSaving" , "OnRequest");
WriteValue("/ch/0..63/par/PulsePolarity" , "Positive");
WriteValue("/ch/0..63/par/EnergyFilterLFLimitation" , "Off");
WriteValue("/ch/0..63/par/DCOffset" , "10"); /// 10%
WriteValue("/ch/0..63/par/TriggerThr" , "1000");
WriteValue("/ch/0..63/par/WaveSaving" , "OnRequest");
WriteValue("/ch/0..63/par/WaveResolution" , "RES8");
WriteValue("/ch/0..63/par/TimeFilterRiseTimeS" , "10"); // 80 ns
WriteValue("/ch/0..63/par/TimeFilterRetriggerGuardS" , "10"); // 80 ns
WriteValue("/ch/0..63/par/ChRecordLengthT" , "4096"); /// 4096 ns, S and T are not Sync
WriteValue("/ch/0..63/par/ChPreTriggerT" , "1000"); /// 1000 ns
if( FPGAType == DPPType::PHA){
//======== Trapezoid setting
WriteValue("/ch/0..63/par/EnergyFilterRiseTimeS" , "62"); // 496 ns
WriteValue("/ch/0..63/par/EnergyFilterFlatTopS" , "200"); // 1600 ns
WriteValue("/ch/0..63/par/EnergyFilterPoleZeroS" , "6250"); // 50 us
WriteValue("/ch/0..63/par/EnergyFilterPeakingPosition" , "20"); // 20 % = Flatup * 20% = 320 ns
WriteValue("/ch/0..63/par/EnergyFilterBaselineGuardS" , "100"); // 800 ns
WriteValue("/ch/0..63/par/EnergyFilterPileupGuardS" , "10"); // 80 ns
WriteValue("/ch/0..63/par/EnergyFilterBaselineAvg" , "Medium"); // 1024 sample
WriteValue("/ch/0..63/par/EnergyFilterFineGain" , "1.0");
WriteValue("/ch/0..63/par/EnergyFilterPeakingAvg" , "LowAVG");
WriteValue("/ch/0..63/par/TimeFilterRiseTimeT" , "80"); // 80 ns
WriteValue("/ch/0..63/par/TimeFilterRetriggerGuardT" , "80"); // 80 ns
//======== Probe Setting
WriteValue("/ch/0..63/par/WaveAnalogProbe0" , "ADCInput");
WriteValue("/ch/0..63/par/WaveAnalogProbe1" , "EnergyFilterMinusBaseline");
WriteValue("/ch/0..63/par/WaveDigitalProbe0" , "Trigger");
WriteValue("/ch/0..63/par/WaveDigitalProbe1" , "EnergyFilterPeaking");
WriteValue("/ch/0..63/par/WaveDigitalProbe2" , "TimeFilterArmed");
WriteValue("/ch/0..63/par/WaveDigitalProbe3" , "EnergyFilterPeakReady");
WriteValue("/ch/0..63/par/EnergyFilterLFLimitation" , "Off");
//======== Trapezoid setting
WriteValue("/ch/0..63/par/EnergyFilterRiseTimeT" , "496"); // 496 ns
WriteValue("/ch/0..63/par/EnergyFilterFlatTopT" , "1600"); // 1600 ns
WriteValue("/ch/0..63/par/EnergyFilterPoleZeroT" , "50000"); // 50 us
WriteValue("/ch/0..63/par/EnergyFilterPeakingPosition" , "20"); // 20 % = Flatup * 20% = 320 ns
WriteValue("/ch/0..63/par/EnergyFilterBaselineGuardT" , "800"); // 800 ns
WriteValue("/ch/0..63/par/EnergyFilterPileupGuardT" , "80"); // 80 ns
WriteValue("/ch/0..63/par/EnergyFilterBaselineAvg" , "Medium"); // 1024 sample
WriteValue("/ch/0..63/par/EnergyFilterFineGain" , "1.0");
WriteValue("/ch/0..63/par/EnergyFilterPeakingAvg" , "LowAVG");
//======== Probe Setting
WriteValue("/ch/0..63/par/WaveAnalogProbe0" , "ADCInput");
WriteValue("/ch/0..63/par/WaveAnalogProbe1" , "EnergyFilterMinusBaseline");
WriteValue("/ch/0..63/par/WaveDigitalProbe0" , "Trigger");
WriteValue("/ch/0..63/par/WaveDigitalProbe1" , "EnergyFilterPeaking");
WriteValue("/ch/0..63/par/WaveDigitalProbe2" , "TimeFilterArmed");
WriteValue("/ch/0..63/par/WaveDigitalProbe3" , "EnergyFilterPeakReady");
}
if( FPGAType == DPPType::PSD ){
WriteValue("/ch/0..63/par/WaveAnalogProbe0" , "ADCInput");
WriteValue("/ch/0..63/par/WaveAnalogProbe1" , "CFDFilter");
WriteValue("/ch/0..63/par/WaveDigitalProbe0" , "Trigger");
WriteValue("/ch/0..63/par/WaveDigitalProbe1" , "LongGate");
WriteValue("/ch/0..63/par/WaveDigitalProbe2" , "ShortGate");
WriteValue("/ch/0..63/par/WaveDigitalProbe3" , "ChargeReady");
//=========== QDC
WriteValue("/ch/0..63/par/GateLongLengthT" , "400");
WriteValue("/ch/0..63/par/GateShortLengthT" , "100");
WriteValue("/ch/0..63/par/GateOffsetT" , "50");
WriteValue("/ch/0..63/par/LongChargeIntegratorPedestal" , "0");
WriteValue("/ch/0..63/par/ShortChargeIntegratorPedestal" , "0");
WriteValue("/ch/0..63/par/EnergyGain" , "x1");
//=========== Discrimination
WriteValue("/ch/0..63/par/TriggerFilterSelection" , "LeadingEdge");
WriteValue("/ch/0..63/par/CFDDelayT" , "32");
WriteValue("/ch/0..63/par/CFDFraction" , "25");
WriteValue("/ch/0..63/par/TimeFilterSmoothing" , "Disabled");
WriteValue("/ch/0..63/par/ChargeSmoothing" , "Disabled");
WriteValue("/ch/0..63/par/SmoothingFactor" , "1");
WriteValue("/ch/0..63/par/PileupGap" , "1000");
//=========== Input
WriteValue("/ch/0..63/par/ADCInputBaselineAvg" , "MediumHigh");
WriteValue("/ch/0..63/par/AbsoluteBaseline" , "1000");
WriteValue("/ch/0..63/par/ADCInputBaselineGuardT" , "0");
WriteValue("/ch/0..63/par/TimeFilterRetriggerGuardT" , "0");
WriteValue("/ch/0..63/par/TriggerHysteresis" , "Enabled");
//========== Other
WriteValue("/ch/0..63/par/NeutronThreshold" , "0");
WriteValue("/ch/0..63/par/EventNeutronReject" , "Disabled");
WriteValue("/ch/0..63/par/WaveNeutronReject" , "Disabled");
}
//======== Trigger setting
WriteValue("/ch/0..63/par/EventTriggerSource" , "ChSelfTrigger");
@ -983,46 +1025,58 @@ void Digitizer2Gen::ProgramPHAChannels(bool testPulse){
WriteValue("/ch/0..63/par/EnergySkimHighDiscriminator" , "0");
WriteValue("/ch/0..63/par/ITLConnect" , "Disabled");
}
}
void Digitizer2Gen::ProgramPSDChannels(bool testPulse){
if( testPulse){
WriteValue("/ch/0..63/par/ChEnable" , "false");
WriteValue("/ch/0..63/par/ChEnable" , "true");
void Digitizer2Gen::PrintBoardSettings(){
WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource"); // EventTriggerSource enought
for(int i = 0; i < (int) boardSettings.size(); i++){
if( boardSettings[i].ReadWrite() == RW::WriteOnly) continue;
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse");
WriteValue("/par/TestPulsePeriod" , "1000000"); // 1.0 msec = 1000Hz, tested, 1 trace recording
WriteValue("/par/TestPulseWidth" , "1000"); // nsec
WriteValue("/par/TestPulseLowLevel" , "0");
WriteValue("/par/TestPulseHighLevel" , "10000");
}else{
//TODO not finished.
//======== Self trigger for each channel
WriteValue("/ch/0..63/par/ChEnable" , "true");
WriteValue("/ch/0..63/par/WaveDaatSource" , "ADC_DATA");
WriteValue("/ch/0..63/par/WaveResolution" , "RES8"); /// 8 ns
WriteValue("/ch/0..63/par/WaveSaving" , "OnRequest");
WriteValue("/ch/0..63/par/PulsePolarity" , "Positive");
WriteValue("/ch/0..63/par/DCOffset" , "20"); /// 20%
WriteValue("/ch/0..63/par/TriggerThr" , "1000");
WriteValue("/ch/0..63/par/EventNeutronReject", "Disabled");
WriteValue("/ch/0..63/par/WaveNeutronReject", "Disabled");
WriteValue("/ch/0..63/par/WaveAnalogProbe0" , "ADCInput");
WriteValue("/ch/0..63/par/ChRecordLengthT" , "4096"); /// 4096 ns, S and T are not Sync
WriteValue("/ch/0..63/par/ChPreTriggerT" , "1000"); /// 1000 ns
//--- exclude some TempSens for Not VX2745
if( ModelName != "VX2745" &&
( boardSettings[i].GetPara() == PHA::DIG::TempSensADC1.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC2.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC3.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC4.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC5.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC6.GetPara() ) ) {
continue;
}
printf("%-45s %d %s\n", boardSettings[i].GetFullPara().c_str(),
boardSettings[i].ReadWrite() ,
boardSettings[i].GetValue().c_str());
}
if( ModelName == "VX2745" && FPGAType == DPPType::PHA) {
for(int i = 0; i < 4 ; i ++){
printf("%-45s %d %s\n", VGASetting[i].GetFullPara(i).c_str(),
VGASetting[i].ReadWrite(),
VGASetting[i].GetValue().c_str());
}
}
for( int i = 0; i < (int) LVDSSettings[0].size(); i++){
for( int index = 0; index < 4; index++){
if( LVDSSettings[index][i].ReadWrite() == RW::WriteOnly) continue;
printf("%-45s %d %s\n", LVDSSettings[index][i].GetFullPara(index).c_str(),
LVDSSettings[index][i].ReadWrite(),
LVDSSettings[index][i].GetValue().c_str());
}
}
}
void Digitizer2Gen::PrintChannelSettings(unsigned short ch){
for( int i = 0; i < (int) chSettings[0].size(); i++){
if( chSettings[ch][i].ReadWrite() == RW::WriteOnly) continue;
printf("%-45s %d %s\n", chSettings[ch][i].GetFullPara(ch).c_str(),
chSettings[ch][i].ReadWrite(),
chSettings[ch][i].GetValue().c_str());
}
}
std::string Digitizer2Gen::ErrorMsg(const char * funcName){

View File

@ -115,9 +115,11 @@ class Digitizer2Gen {
uint64_t GetRealTime(int ch) const {return realTime[ch];}
void Reset();
void ProgramDPPBoard();
void ProgramPHAChannels(bool testPulse = false);
void ProgramPSDChannels(bool testPulse = false);
void ProgramBoard();
void ProgramChannels(bool testPulse = false);
void PrintBoardSettings();
void PrintChannelSettings(unsigned short ch);
unsigned short GetNChannels() const {return nChannels;}
unsigned short GetCh2ns() const {return ch2ns;}

View File

@ -588,25 +588,40 @@ namespace PHA{
const Reg ITLConnect ("ITLConnect", RW::ReadWrite, TYPE::CH, {{"Disabled", "Disabled"},{"ITLA", "ITLA"}, {"ITLB", "ITLB"}});
const std::vector<Reg> AllSettings = {
SelfTrgRate ,
ChannelStatus ,
GainFactor ,
ADCToVolts ,
Energy_Nbit ,
ChannelRealtime ,
ChannelDeadtime ,
ChannelTriggerCount ,
ChannelSavedCount ,
ChannelWaveCount ,
ChannelEnable ,
DC_Offset ,
TriggerThreshold ,
Polarity ,
WaveDataSource ,
RecordLength ,
WaveSaving ,
WaveResolution ,
PreTrigger ,
SelfTrgRate , // 0
ChannelStatus , // 1
GainFactor , // 2
ADCToVolts , // 3
Energy_Nbit , // 4
ChannelRealtime , // 5
ChannelDeadtime , // 6
ChannelTriggerCount , // 7
ChannelSavedCount , // 8
ChannelWaveCount , // 9
ChannelEnable , // 0
DC_Offset , // 1
TriggerThreshold , // 2
Polarity , // 3
WaveDataSource , // 4
RecordLength , // 5
PreTrigger , // 6
WaveSaving , // 7
WaveResolution , // 8
EventTriggerSource , // 9
ChannelsTriggerMask , // 10
ChannelVetoSource , // 11
WaveTriggerSource , // 12
EventSelector , // 13
WaveSelector , // 14
CoincidenceMask , // 15
AntiCoincidenceMask , // 16
CoincidenceLength , // 17
ADCVetoWidth , // 18
EnergySkimLowDiscriminator , // 19
EnergySkimHighDiscriminator, // 20
ITLConnect , // 21
TimeFilterRiseTime ,
TimeFilterRetriggerGuard ,
EnergyFilterRiseTime ,
@ -625,19 +640,8 @@ namespace PHA{
WaveDigitalProbe1 ,
WaveDigitalProbe2 ,
WaveDigitalProbe3 ,
EventTriggerSource ,
ChannelsTriggerMask ,
ChannelVetoSource ,
WaveTriggerSource ,
EventSelector ,
WaveSelector ,
CoincidenceMask ,
AntiCoincidenceMask ,
CoincidenceLength ,
CoincidenceLengthSample ,
ADCVetoWidth ,
EnergySkimLowDiscriminator ,
EnergySkimHighDiscriminator,
RecordLengthSample ,
PreTriggerSample ,
TimeFilterRiseTimeSample ,
@ -646,8 +650,7 @@ namespace PHA{
EnergyFilterFlatTopSample ,
EnergyFilterPoleZeroSample ,
EnergyFilterBaselineGuardSample ,
EnergyFilterPileUpGuardSample ,
ITLConnect
EnergyFilterPileUpGuardSample
};
}
@ -657,7 +660,7 @@ namespace PHA{
namespace PSD{
namespace DIG{
namespace DIG{ // the PSD::DIG are identical to PHA::DIG
///============== read only
const Reg CupVer = PHA::DIG::CupVer;
@ -870,7 +873,6 @@ namespace PSD{
//LVDSTrgMask
};
}
namespace VGA{
@ -1057,56 +1059,61 @@ namespace PSD{
ChannelTriggerCount , // 6
ChannelSavedCount , // 7
ChannelWaveCount , // 8
ChannelEnable , // 9
DC_Offset , // 10
TriggerThreshold , // 11
Polarity , // 12
WaveDataSource , // 13
RecordLength , // 14
WaveSaving , // 15
WaveResolution , // 16
PreTrigger , // 17
WaveAnalogProbe0 , // 18
WaveAnalogProbe1 , // 19
WaveDigitalProbe0 , // 20
WaveDigitalProbe1 , // 21
WaveDigitalProbe2 , // 22
WaveDigitalProbe3 , // 23
EventTriggerSource , // 24
ChannelsTriggerMask , // 25
ChannelVetoSource , // 26
WaveTriggerSource , // 27
EventSelector , // 28
WaveSelector , // 29
CoincidenceMask , // 30
AntiCoincidenceMask , // 31
CoincidenceLength , // 32
CoincidenceLengthSample , // 33
ADCVetoWidth , // 34
EnergySkimLowDiscriminator , // 35
EnergySkimHighDiscriminator, // 36
RecordLengthSample , // 37
PreTriggerSample , // 38
ITLConnect , // 39
ADCInputBaselineAvg , // 40
AbsoluteBaseline , // 41
ADCInputBaselineGuard , // 42
SmoothingFactor , // 43
ChargeSmoothing , // 44
TimeFilterSmoothing , // 45
TriggerFilterSelection , // 46
CFDDelay , // 47
CFDFraction , // 48
TimeFilterRetriggerGuard , // 49
TriggerHysteresis , // 50
PileupGap , // 51
GateLongLength , // 52
GateShortLength , // 53
GateOffset , // 54
ChannelEnable , // 0
DC_Offset , // 1
TriggerThreshold , // 2
Polarity , // 3
WaveDataSource , // 4
RecordLength , // 5
PreTrigger , // 6
WaveSaving , // 7
WaveResolution , // 8
EventTriggerSource , // 9
ChannelsTriggerMask , // 10
ChannelVetoSource , // 11
WaveTriggerSource , // 12
EventSelector , // 13
WaveSelector , // 14
CoincidenceMask , // 15
AntiCoincidenceMask , // 16
CoincidenceLength , // 17
ADCVetoWidth , // 18
EnergySkimLowDiscriminator , // 19
EnergySkimHighDiscriminator, // 20
ITLConnect , // 21
EventNeutronReject ,
WaveNeutronReject ,
ADCInputBaselineAvg ,
AbsoluteBaseline ,
ADCInputBaselineGuard ,
SmoothingFactor ,
ChargeSmoothing ,
TimeFilterSmoothing ,
TriggerFilterSelection ,
CFDDelay ,
CFDFraction ,
TimeFilterRetriggerGuard ,
TriggerHysteresis ,
PileupGap ,
GateLongLength ,
GateShortLength ,
GateOffset ,
LongChargeIntegratorPedestal, //
ShortChargeIntegratorPedestal, //
EnergyGain ,
NeutronThreshold ,
WaveAnalogProbe0 , //
WaveAnalogProbe1 , //
WaveDigitalProbe0 , //
WaveDigitalProbe1 , //
WaveDigitalProbe2 , //
WaveDigitalProbe3 , //
RecordLengthSample , // 21
PreTriggerSample , // 22
CoincidenceLengthSample , //
ADCInputBaselineGuardSample,
CFDDelaySample ,
TimeFilterRetriggerGuardSample,

View File

@ -1980,8 +1980,8 @@ void DigiSettingsPanel::LoadSettings(){
void DigiSettingsPanel::SetDefaultPHASettigns(){
SendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA.");
digi[ID]->ProgramDPPBoard();
digi[ID]->ProgramPHAChannels();
digi[ID]->ProgramBoard();
digi[ID]->ProgramChannels();
RefreshSettings();
}

View File

@ -696,7 +696,7 @@ void MainWindow::OpenDigitizers(){
digi[i]->SetSettingFileName("");
//LogMsg("Reset digitizer And set default PHA settings.");
//digi[i]->Reset();
//digi[i]->ProgramDPPBoard(false);
//digi[i]->ProgramBoard(false);
}
digi[i]->ReadAllSettings();

View File

@ -22,6 +22,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
allowChange = false;
originalValueSet = false;
plot = new Trace();
for( int i = 0; i < 6; i++) {
@ -112,7 +113,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
//digi[iDigi]->Reset();
digi[iDigi]->ProgramPHAChannels();
digi[iDigi]->ProgramChannels();
//SendLogMsg("Reset Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " and Set Default PHA.");
ReadScopeSettings();
UpdateOtherPanels();
@ -474,7 +475,9 @@ void Scope::StartScope(){
}
digi[iDigi]->SetDataFormat(0); //TODO Should be only trace?
originalValueSet = true;
digi[iDigi]->SetDataFormat(DataFormat::ALL);
digi[iDigi]->StartACQ();
readDataThread[iDigi]->SetSaveData(false);
@ -507,12 +510,15 @@ void Scope::StopScope(){
digiMTX[i].lock();
digi[i]->StopACQ();
for( int ch2 = 0 ; ch2 < digi[i]->GetNChannels(); ch2 ++){
digi[i]->WriteValue(PHA::CH::ChannelEnable, channelEnable[i][ch2], ch2);
}
if( i == cbScopeDigi->currentIndex() ) {
digi[i]->WriteValue(PHA::CH::WaveTriggerSource, waveTriggerSource, cbScopeCh->currentIndex());
digi[i]->WriteValue(PHA::CH::WaveSaving, waveSaving, cbScopeCh->currentIndex());
if( originalValueSet ){
for( int ch2 = 0 ; ch2 < digi[i]->GetNChannels(); ch2 ++){
digi[i]->WriteValue(PHA::CH::ChannelEnable, channelEnable[i][ch2], ch2);
}
if( i == cbScopeDigi->currentIndex() ) {
digi[i]->WriteValue(PHA::CH::WaveTriggerSource, waveTriggerSource, cbScopeCh->currentIndex());
digi[i]->WriteValue(PHA::CH::WaveSaving, waveSaving, cbScopeCh->currentIndex());
}
originalValueSet = false;
}
digiMTX[i].unlock();
}

View File

@ -202,6 +202,7 @@ private:
bool allowChange;
// remembee setting, once the scope stop, restore it.
bool originalValueSet;
std::string channelEnable[MaxNumberOfDigitizer][MaxNumberOfChannel];
std::string waveSaving;
std::string waveTriggerSource;

View File

@ -20,11 +20,13 @@ InfluxDB * influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/", false
unsigned int readCount = 0;
bool ThreadStop = false;
timespec ta, tb;
static void ReadDataLoop(){
clock_gettime(CLOCK_REALTIME, &ta);
//while(digi->IsAcqOn() && readCount < maxRead){
while(true){
while(!ThreadStop){
digiMTX.lock();
int ret = digi->ReadData();
digiMTX.unlock();
@ -35,7 +37,7 @@ static void ReadDataLoop(){
digi->ErrorMsg("No more data");
break;
}else{
digi->ErrorMsg("ReadDataLoop()");
//digi->ErrorMsg("ReadDataLoop()");
}
//if( readCount % 1000 == 0 ) {
// clock_gettime(CLOCK_REALTIME, &tb);
@ -56,21 +58,20 @@ static void StatLoop(){
digiMTX.lock();
digi->ReadStat();
for(int i = 0; i < 64; i++){
sprintf(cmdStr, "/ch/%d/par/SelfTrgRate", i);
std::string haha = digi->ReadValue( cmdStr, false);
influx->AddDataPoint("Rate,Bd=0,Ch=" + std::to_string(i) + " value=" + haha);
}
//digi->ReadValue("/ch/4/par/ChRealtimeMonitor", true);
//digi->ReadValue("/ch/4/par/ChDeadtimeMonitor", true);
//digi->ReadValue("/ch/4/par/ChTriggerCnt", true);
//digi->ReadValue("/ch/4/par/ChSavedEventCnt", true);
//digi->ReadValue("/ch/4/par/ChWaveCnt", true);
// for(int i = 0; i < 64; i++){
// digi->ReadValue( PHA::CH::SelfTrgRate, i, false);
// //influx->AddDataPoint("Rate,Bd=0,Ch=" + std::to_string(i) + " value=" + haha);
// }
// digi->ReadValue("/ch/4/par/ChRealtimeMonitor", true);
// digi->ReadValue("/ch/4/par/ChDeadtimeMonitor", true);
// digi->ReadValue("/ch/4/par/ChTriggerCnt", true);
// digi->ReadValue("/ch/4/par/ChSavedEventCnt", true);
// digi->ReadValue("/ch/4/par/ChWaveCnt", true);
digiMTX.unlock();
//influx->PrintDataPoints();
influx->WriteData("testing");
influx->ClearDataPointsBuffer();
//influx->WriteData("testing");
//influx->ClearDataPointsBuffer();
digi->PrintStat();
usleep(1000*1000); // every 1000 msec
}
@ -90,63 +91,17 @@ int main(int argc, char* argv[]){
const char * url = "dig2://192.168.0.254/";
digi->OpenDigitizer(url);
digi->Reset();
//digi->ReadValue(PSD::DIG::CupVer, -1, true);
digi->ReadAllSettings();
//digi->Reset();
//digi->ReadAllSettings();
for( int ch = 0; ch < 64; ch++ ) {
printf( "|%s| \n", digi->GetSettingValue(PSD::CH::TimeFilterRetriggerGuard, ch).c_str());
}
//digi->ProgramBoard();
//digi->WriteValue(PSD::CH::TriggerThreshold, "1000", -1);
digi->PrintChannelSettings(0);
digi->SaveSettingsToFile("test_setting.txt");
//digi->ProgramDPPBoard(false);
//printf("--------%s \n", digi->ReadChValue("0..63", "WaveAnalogprobe0", true).c_str());
//digi->SaveSettingsToFile(("settings_" + std::to_string(digi->GetSerialNumber()) + ".dat").c_str());
//printf("===================================\n");
//printf("======== index : %d \n", digi->FindIndex(PHA::CH::ChannelEnable));
//digi->LoadSettingsFromFile("settings_21245.dat");
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
//printf("%s \n", digi->ReadValue("/par/MaxRawDataSize").c_str());
/*///======================= Play with handle
uint64_t parHandle;
parHandle = digi->GetHandle("/ch/0/par/ChRealtimeMonitor"); printf("%lu|%lX\n", parHandle, parHandle);
parHandle = digi->GetHandle("/ch/1/par/ChRealtimeMonitor"); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
*/
/*
digi->ReadDigitizerSettings();
digi->SetPHADataFormat(1);
//printf("0x%X \n", atoi(digi->ReadValue("/par/AcquisitionStatus").c_str()) & 0x3F );
digi->SetDataFormat(DataFormat::OneTrace);
digi->OpenOutFile("haha");
@ -164,6 +119,8 @@ int main(int argc, char* argv[]){
c = getchar();
}while( c != 'q');
ThreadStop = true;
digiMTX.lock();
digi->StopACQ();
digiMTX.unlock();
@ -178,8 +135,6 @@ int main(int argc, char* argv[]){
digi->CloseOutFile();
*/
digi->CloseDigitizer();
delete digi;