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 //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, ret |= CAEN_FELib_SetReadDataFormat(stat_handle,
" [ \ " [ \
{ \"name\": \"REAL_TIME_NS\", \"type\": \"U64\", \"dim\": 1 }, \ { \"name\": \"REAL_TIME_NS\", \"type\": \"U64\", \"dim\": 1 }, \
@ -575,22 +576,24 @@ int Digitizer2Gen::ReadStat(){
if (ret != CAEN_FELib_Success) ErrorMsg("Read Statistics"); if (ret != CAEN_FELib_Success) ErrorMsg("Read Statistics");
for( int ch = 0; ch < nChannels; ch++) ReadValue( PHA::CH::SelfTrgRate, ch);
return ret; return ret;
} }
void Digitizer2Gen::PrintStat(){ void Digitizer2Gen::PrintStat(){
printf("ch | Real Time[ns] | Dead Time[ns] | Live Time[ns] | Trigger | Saved | Rate[Hz] \n"); 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 < MaxNumberOfChannel; i++){ for( int i = 0; i < nChannels; i++){
if( triggerCount[i] == 0 ) continue; if( triggerCount[i] == 0 ) continue;
printf("%02d | %13lu | %13lu | %13lu | %7u | %7u | %.3f\n", 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]); 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(){ 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( evt->dataType == DataFormat::ALL ){
if( FPGAType == DPPType::PHA ){ if( FPGAType == DPPType::PHA ){
@ -621,6 +624,8 @@ int Digitizer2Gen::ReadData(){
&evt->aggCounter, &evt->aggCounter,
&evt->event_size &evt->event_size
); );
//printf("ch:%02d, trace Length %ld \n", evt->channel, evt->traceLenght);
}else{ }else{
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &evt->channel,
@ -860,7 +865,7 @@ void Digitizer2Gen::SaveDataToFile(){
//########################################### //###########################################
void Digitizer2Gen::Reset(){ SendCommand("/cmd/Reset"); } void Digitizer2Gen::Reset(){ SendCommand("/cmd/Reset"); }
void Digitizer2Gen::ProgramDPPBoard(){ void Digitizer2Gen::ProgramBoard(){
if( !isConnected ) return ; if( !isConnected ) return ;
//============= Board //============= Board
@ -880,22 +885,15 @@ void Digitizer2Gen::ProgramDPPBoard(){
WriteValue("/par/EnAutoDisarmAcq" , "true"); WriteValue("/par/EnAutoDisarmAcq" , "true");
WriteValue("/par/EnStatEvents" , "true"); WriteValue("/par/EnStatEvents" , "true");
WriteValue("/par/EnAutoDisarmAcq" , "False");
WriteValue("/par/BoardVetoWidth" , "0"); WriteValue("/par/BoardVetoWidth" , "0");
WriteValue("/par/VolatileClockOutDelay" , "0"); WriteValue("/par/VolatileClockOutDelay" , "0");
WriteValue("/par/PermanentClockOutDelay" , "0"); WriteValue("/par/PermanentClockOutDelay" , "0");
WriteValue("/par/DACoutMode" , "ChInput"); WriteValue("/par/DACoutMode" , "ChInput");
WriteValue("/par/DACoutStaticLevel" , "8192");
WriteValue("/par/DACoutChSelect" , "0"); 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 //============== ITL
WriteValue("/par/ITLAMainLogic" , "OR"); WriteValue("/par/ITLAMainLogic" , "OR");
WriteValue("/par/ITLAMajorityLev" , "2"); WriteValue("/par/ITLAMajorityLev" , "2");
@ -909,10 +907,9 @@ void Digitizer2Gen::ProgramDPPBoard(){
WriteValue("/par/ITLBPolarity" , "Direct"); WriteValue("/par/ITLBPolarity" , "Direct");
WriteValue("/par/ITLBGateWidth" , "100"); WriteValue("/par/ITLBGateWidth" , "100");
} }
void Digitizer2Gen::ProgramPHAChannels(bool testPulse){ void Digitizer2Gen::ProgramChannels(bool testPulse){
// Channel setting // Channel setting
@ -932,39 +929,84 @@ void Digitizer2Gen::ProgramPHAChannels(bool testPulse){
}else{ }else{
//======== Self trigger for each channel //======== Self trigger for each channel
WriteValue("/ch/0..63/par/ChEnable" , "true"); WriteValue("/ch/0..63/par/ChEnable" , "True");
WriteValue("/ch/0..63/par/WaveDaatSource" , "ADC_DATA"); 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/WaveSaving" , "OnRequest"); WriteValue("/ch/0..63/par/WaveResolution" , "RES8");
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/TimeFilterRiseTimeS" , "10"); // 80 ns if( FPGAType == DPPType::PHA){
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
//======== Trapezoid setting WriteValue("/ch/0..63/par/TimeFilterRiseTimeT" , "80"); // 80 ns
WriteValue("/ch/0..63/par/EnergyFilterRiseTimeS" , "62"); // 496 ns WriteValue("/ch/0..63/par/TimeFilterRetriggerGuardT" , "80"); // 80 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");
//======== Probe Setting WriteValue("/ch/0..63/par/EnergyFilterLFLimitation" , "Off");
WriteValue("/ch/0..63/par/WaveAnalogProbe0" , "ADCInput");
WriteValue("/ch/0..63/par/WaveAnalogProbe1" , "EnergyFilterMinusBaseline"); //======== Trapezoid setting
WriteValue("/ch/0..63/par/WaveDigitalProbe0" , "Trigger"); WriteValue("/ch/0..63/par/EnergyFilterRiseTimeT" , "496"); // 496 ns
WriteValue("/ch/0..63/par/WaveDigitalProbe1" , "EnergyFilterPeaking"); WriteValue("/ch/0..63/par/EnergyFilterFlatTopT" , "1600"); // 1600 ns
WriteValue("/ch/0..63/par/WaveDigitalProbe2" , "TimeFilterArmed"); WriteValue("/ch/0..63/par/EnergyFilterPoleZeroT" , "50000"); // 50 us
WriteValue("/ch/0..63/par/WaveDigitalProbe3" , "EnergyFilterPeakReady"); 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 //======== Trigger setting
WriteValue("/ch/0..63/par/EventTriggerSource" , "ChSelfTrigger"); 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/EnergySkimHighDiscriminator" , "0");
WriteValue("/ch/0..63/par/ITLConnect" , "Disabled"); WriteValue("/ch/0..63/par/ITLConnect" , "Disabled");
} }
} }
void Digitizer2Gen::ProgramPSDChannels(bool testPulse){ void Digitizer2Gen::PrintBoardSettings(){
if( testPulse){
WriteValue("/ch/0..63/par/ChEnable" , "false");
WriteValue("/ch/0..63/par/ChEnable" , "true");
WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource"); for(int i = 0; i < (int) boardSettings.size(); i++){
WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource"); // EventTriggerSource enought if( boardSettings[i].ReadWrite() == RW::WriteOnly) continue;
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse"); //--- exclude some TempSens for Not VX2745
WriteValue("/par/TestPulsePeriod" , "1000000"); // 1.0 msec = 1000Hz, tested, 1 trace recording if( ModelName != "VX2745" &&
WriteValue("/par/TestPulseWidth" , "1000"); // nsec ( boardSettings[i].GetPara() == PHA::DIG::TempSensADC1.GetPara() ||
WriteValue("/par/TestPulseLowLevel" , "0"); boardSettings[i].GetPara() == PHA::DIG::TempSensADC2.GetPara() ||
WriteValue("/par/TestPulseHighLevel" , "10000"); boardSettings[i].GetPara() == PHA::DIG::TempSensADC3.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC4.GetPara() ||
}else{ boardSettings[i].GetPara() == PHA::DIG::TempSensADC5.GetPara() ||
boardSettings[i].GetPara() == PHA::DIG::TempSensADC6.GetPara() ) ) {
//TODO not finished. continue;
}
//======== 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
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){ std::string Digitizer2Gen::ErrorMsg(const char * funcName){

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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