1
0
Fork 0
mirror of https://github.com/gwm17/Daqromancy.git synced 2024-11-22 10:58:49 -05:00

Fix several small bugs in the digitizer classes, serialization, aquisition. Overhaul scope, was basically useless in original form

This commit is contained in:
Gordon McCann 2022-10-06 22:31:24 -04:00
parent 53c6ec5833
commit 344bfd8809
8 changed files with 75 additions and 66 deletions

View File

@ -31,7 +31,7 @@ namespace YAML {
args.type = (CAEN_DGTZ_ConnectionType) node["ConnectionType"].as<int>();
args.linkNumber = node["LinkNumber"].as<int>();
args.conetNode = node["ConetNode"].as<int>();
args.conetNode = node["CONETNode"].as<int>();
args.vmeAddress = node["VMEAddress"].as<uint32_t>();
args.handle = node["Handle"].as<int>();
args.model = (CAEN_DGTZ_BoardModel_t) node["Model"].as<int>();

View File

@ -63,14 +63,13 @@ namespace Daqromancy {
m_args.model = CAEN_DGTZ_BoardModel_t::CAEN_DGTZ_V1740;
else
m_args.model = CAEN_DGTZ_BoardModel_t::CAEN_DGTZ_DT5720;
m_args.name = info.ModelName + std::to_string(info.SerialNumber);
m_args.name = info.ModelName + std::string("_") + std::to_string(info.SerialNumber);
m_args.firmware = CAEN_DGTZ_DPPFirmware_PHA;
m_args.channels = info.Channels;
m_channelParams.resize(info.Channels);
m_eventCountsPerChannel = new uint32_t[info.Channels];
m_eventData = new CAEN_DGTZ_DPP_PHA_Event_t*[info.Channels];
m_waveData = new CAEN_DGTZ_DPP_PHA_Waveforms_t*[info.Channels];
for (int i = 0; i < info.Channels; i++)
{
@ -277,16 +276,14 @@ namespace Daqromancy {
m_args.status |= CAEN_DGTZ_MallocReadoutBuffer(m_args.handle, &m_lowBuffer, &m_lowBufferSize);
//void casts are soooo bad .... but required by CAEN API
m_args.status |= CAEN_DGTZ_MallocDPPEvents(m_args.handle, (void**)(m_eventData), &m_eventBufferSize);
for(int channel=0; channel<m_internalData.Channels; channel++)
m_args.status |= CAEN_DGTZ_MallocDPPWaveforms(m_args.handle, (void**)(&m_waveData[channel]), &m_waveBufferSize);
m_args.status |= CAEN_DGTZ_MallocDPPWaveforms(m_args.handle, (void**)(&m_waveData), &m_waveBufferSize);
}
void DigitizerPHA::DeallocateMemory()
{
m_args.status |= CAEN_DGTZ_FreeReadoutBuffer(&m_lowBuffer);
m_args.status |= CAEN_DGTZ_FreeDPPEvents(m_args.handle, (void**)(m_eventData));
for(int i=0; i<m_internalData.Channels; i++)
m_args.status |= CAEN_DGTZ_FreeDPPWaveforms(m_args.handle, (void*)(m_waveData[i]));
m_args.status |= CAEN_DGTZ_FreeDPPWaveforms(m_args.handle, (void*)(m_waveData));
}
void DigitizerPHA::ReadData(std::vector<DYData>& buffer)
@ -300,7 +297,7 @@ namespace Daqromancy {
return;
}
m_args.status |= CAEN_DGTZ_GetDPPEvents(m_args.handle, m_lowBuffer, m_lowBufferSize, (void**)(&m_eventData), m_eventCountsPerChannel);
m_args.status |= CAEN_DGTZ_GetDPPEvents(m_args.handle, m_lowBuffer, m_lowBufferSize, (void**)(m_eventData), m_eventCountsPerChannel);
size_t waveSize;
DYData tempData;
tempData.board = m_args.handle;
@ -318,15 +315,15 @@ namespace Daqromancy {
if(m_digitizerParams.dppAcqMode != CAEN_DGTZ_DPP_ACQ_MODE_List)
{
CAEN_DGTZ_DecodeDPPWaveforms(m_args.handle, (void*)&(m_eventData[i][j]), m_waveData);
tempData.waveSize = m_waveData[i]->Ns;
waveSize = m_waveData[i]->Ns;
tempData.waveSize = m_waveData->Ns;
waveSize = m_waveData->Ns;
if(waveSize != 0)
{
//Copy the data to our vectors PHA supports 2 analog traces and 2 digital traces
tempData.trace1Samples.assign(m_waveData[i]->Trace1, m_waveData[i]->Trace1 + waveSize);
tempData.trace2Samples.assign(m_waveData[i]->Trace2, m_waveData[i]->Trace2 + waveSize); //This is all zero if in single analog trace mode
tempData.digitalTrace1Samples.assign(m_waveData[i]->DTrace1, m_waveData[i]->DTrace1 + waveSize);
tempData.digitalTrace2Samples.assign(m_waveData[i]->DTrace2, m_waveData[i]->DTrace2 + waveSize);
tempData.trace1Samples.assign(m_waveData->Trace1, m_waveData->Trace1 + waveSize);
tempData.trace2Samples.assign(m_waveData->Trace2, m_waveData->Trace2 + waveSize); //This is all zero if in single analog trace mode
tempData.digitalTrace1Samples.assign(m_waveData->DTrace1, m_waveData->DTrace1 + waveSize);
tempData.digitalTrace2Samples.assign(m_waveData->DTrace2, m_waveData->DTrace2 + waveSize);
}
}
buffer.push_back(tempData);
@ -358,14 +355,13 @@ namespace Daqromancy {
m_args.model = CAEN_DGTZ_BoardModel_t::CAEN_DGTZ_V1740;
else
m_args.model = CAEN_DGTZ_BoardModel_t::CAEN_DGTZ_DT5720;
m_args.name = info.ModelName + std::to_string(info.SerialNumber);
m_args.name = info.ModelName + std::string(" ") + std::to_string(info.SerialNumber);
m_args.firmware = CAEN_DGTZ_DPPFirmware_PSD;
m_args.channels = info.Channels;
m_channelParams.resize(info.Channels);
m_eventCountsPerChannel = new uint32_t[info.Channels];
m_eventData = new CAEN_DGTZ_DPP_PSD_Event_t*[info.Channels];
m_waveData = new CAEN_DGTZ_DPP_PSD_Waveforms_t*[info.Channels];
LoadDigitizerParameters();
LoadChannelParameters();
//Must load default parameters here to generate a buffer
@ -560,16 +556,14 @@ namespace Daqromancy {
m_args.status |= CAEN_DGTZ_MallocReadoutBuffer(m_args.handle, &m_lowBuffer, &m_lowBufferSize);
//void casts are soooo bad .... but required by CAEN API
m_args.status |= CAEN_DGTZ_MallocDPPEvents(m_args.handle, (void**)(m_eventData), &m_eventBufferSize);
for(int channel=0; channel<m_internalData.Channels; channel++)
m_args.status |= CAEN_DGTZ_MallocDPPWaveforms(m_args.handle, (void**)(&m_waveData[channel]), &m_waveBufferSize);
m_args.status |= CAEN_DGTZ_MallocDPPWaveforms(m_args.handle, (void**)(&m_waveData), &m_waveBufferSize);
}
void DigitizerPSD::DeallocateMemory()
{
m_args.status |= CAEN_DGTZ_FreeReadoutBuffer(&m_lowBuffer);
m_args.status |= CAEN_DGTZ_FreeDPPEvents(m_args.handle, (void**)(m_eventData));
for(int i=0; i<m_internalData.Channels; i++)
m_args.status |= CAEN_DGTZ_FreeDPPWaveforms(m_args.handle, (void*)(m_waveData[i]));
m_args.status |= CAEN_DGTZ_FreeDPPWaveforms(m_args.handle, (void*)(m_waveData));
}
void DigitizerPSD::ReadData(std::vector<DYData>& buffer)
@ -583,7 +577,7 @@ namespace Daqromancy {
return;
}
m_args.status |= CAEN_DGTZ_GetDPPEvents(m_args.handle, m_lowBuffer, m_lowBufferSize, (void**)(&m_eventData), m_eventCountsPerChannel);
m_args.status |= CAEN_DGTZ_GetDPPEvents(m_args.handle, m_lowBuffer, m_lowBufferSize, (void**)(m_eventData), m_eventCountsPerChannel);
size_t waveSize;
DYData tempData;
tempData.board = m_args.handle;
@ -602,15 +596,15 @@ namespace Daqromancy {
if(m_digitizerParams.dppAcqMode != CAEN_DGTZ_DPP_ACQ_MODE_List)
{
CAEN_DGTZ_DecodeDPPWaveforms(m_args.handle, (void*)&(m_eventData[i][j]), m_waveData);
tempData.waveSize = m_waveData[i]->Ns;
waveSize = m_waveData[i]->Ns;
tempData.waveSize = m_waveData->Ns;
waveSize = m_waveData->Ns;
if(tempData.waveSize != 0)
{
//Copy the data to our vectors PHA supports 2 analog traces and 2 digital traces
tempData.trace1Samples.assign(m_waveData[i]->Trace1, m_waveData[i]->Trace1 + waveSize);
tempData.trace2Samples.assign(m_waveData[i]->Trace2, m_waveData[i]->Trace2 + waveSize); //This is all zero if in single analog trace mode
tempData.digitalTrace1Samples.assign(m_waveData[i]->DTrace1, m_waveData[i]->DTrace1 + waveSize);
tempData.digitalTrace2Samples.assign(m_waveData[i]->DTrace2, m_waveData[i]->DTrace2 + waveSize);
tempData.trace1Samples.assign(m_waveData->Trace1, m_waveData->Trace1 + waveSize);
tempData.trace2Samples.assign(m_waveData->Trace2, m_waveData->Trace2 + waveSize); //This is all zero if in single analog trace mode
tempData.digitalTrace1Samples.assign(m_waveData->DTrace1, m_waveData->DTrace1 + waveSize);
tempData.digitalTrace2Samples.assign(m_waveData->DTrace2, m_waveData->DTrace2 + waveSize);
}
}
buffer.push_back(tempData);

View File

@ -179,7 +179,7 @@ namespace Daqromancy {
//CAEN required data storage, does not interface to other parts of the program
CAEN_DGTZ_DPP_PHA_Event_t** m_eventData;
CAEN_DGTZ_DPP_PHA_Waveforms_t** m_waveData;
CAEN_DGTZ_DPP_PHA_Waveforms_t* m_waveData;
CAEN_DGTZ_DPP_PHA_Params_t m_caenParams;
std::vector<PHAParameters> m_channelParams;
@ -218,7 +218,7 @@ namespace Daqromancy {
//CAEN required data storage, does not interface to other parts of the program
CAEN_DGTZ_DPP_PSD_Event_t** m_eventData;
CAEN_DGTZ_DPP_PSD_Waveforms_t** m_waveData;
CAEN_DGTZ_DPP_PSD_Waveforms_t* m_waveData;
CAEN_DGTZ_DPP_PSD_Params_t m_caenParams;
std::vector<PSDParameters> m_channelParams;

View File

@ -64,7 +64,7 @@ namespace Daqromancy {
switch (mode)
{
case DPPAcqMode::List: modeIn = CAEN_DGTZ_DPP_ACQ_MODE_List; break;
case DPPAcqMode::Waves: modeIn = CAEN_DGTZ_DPP_ACQ_MODE_Oscilloscope; break;
case DPPAcqMode::Waves: modeIn = CAEN_DGTZ_DPP_ACQ_MODE_Mixed; break;
case DPPAcqMode::None: DY_WARN("Attempted to set DPPAcqMode::None!"); return;
}

View File

@ -242,17 +242,17 @@ namespace Daqromancy {
//Option of dual analog, which types (digital probe 2 is always trigger for PHA)
struct PHAWaveParameters
{
CAEN_DGTZ_DPP_VirtualProbe_t isDual = CAEN_DGTZ_DPP_VIRTUALPROBE_SINGLE; //Default to a single analog trace
PHAVirtualProbe1Options analogProbe1 = PHAVirtualProbe1Options::PHAVP1_Input; //Main analog trace defaults to input signal;
PHAVirtualProbe2Options analogProbe2 = PHAVirtualProbe2Options::PHAVP2_None; //Default val; in default config wont be displayed
PHADigitalProbe1Options digitalProbe1 = PHADigitalProbe1Options::PHADP_TriggerWindow; //Idk guess this is good default
CAEN_DGTZ_DPP_VirtualProbe_t isDual = CAEN_DGTZ_DPP_VIRTUALPROBE_DUAL; //Default to a single analog trace
PHAVirtualProbe1Options analogProbe1 = PHAVirtualProbe1Options::PHAVP1_Delta2; //Main analog trace defaults to delta2;
PHAVirtualProbe2Options analogProbe2 = PHAVirtualProbe2Options::PHAVP2_Input; //Default val; in default config wont be displayed
PHADigitalProbe1Options digitalProbe1 = PHADigitalProbe1Options::PHADP_Peaking; //Idk guess this is good default
};
struct PSDWaveParameters
{
CAEN_DGTZ_DPP_VirtualProbe_t isDual = CAEN_DGTZ_DPP_VIRTUALPROBE_SINGLE; //Default to a single analog trace
CAEN_DGTZ_DPP_VirtualProbe_t isDual = CAEN_DGTZ_DPP_VIRTUALPROBE_DUAL; //Default to a single analog trace
PSDVirtualProbe1Options analogProbe1 = PSDVirtualProbe1Options::PSDVP1_Input; //Main trace defaults to input
PSDVirtualProbe2Options analogProbe2 = PSDVirtualProbe2Options::PSDVP2_None; //Defaults to off
PSDVirtualProbe2Options analogProbe2 = PSDVirtualProbe2Options::PSDVP2_Baseline; //Defaults to off
PSDDigitalProbe1Options digitalProbe1 = PSDDigitalProbe1Options::PSDDP1_Gate; //Defaults to long gate
PSDDigitalProbe2Options digitalProbe2 = PSDDigitalProbe2Options::PSDDP2_GateShort; //Defaults to short gate
};

View File

@ -231,7 +231,7 @@ namespace Daqromancy {
AcqDPPModeEvent e;
m_eventCallback(e);
m_scopePanel = new ScopePanel(m_digiPanels.size());
m_scopePanel = new ScopePanel(m_project);
}
ImGui::EndCombo();
}

View File

@ -1,18 +1,16 @@
#include "ScopePanel.h"
#include "DAQ/DigitizerDefs.h"
#include "imgui.h"
#include "implot.h"
namespace Daqromancy {
ScopePanel::ScopePanel(int nboards) :
m_dataReady(false), m_selectedBoard(0), m_selectedChannel(0), m_maxNumBoards(nboards)
ScopePanel::ScopePanel(const DYProject::Ref& project) :
m_dataReady(false), m_selectedBoard(-1), m_selectedChannel(-1), m_selectedSamplingPeriod(0.0), m_project(project)
{
m_dataHandle = DataDistributor::Connect();
for (int i = 0; i < nboards; i++)
m_boardListForImGui.push_back(fmt::format("{0}", i));
for (int i = 0; i < 16; i++) //bad hardcode, fix later
m_channelListForImGui.push_back(fmt::format("{0}", i));
}
ScopePanel::~ScopePanel()
@ -31,9 +29,7 @@ namespace Daqromancy {
if (hit.board == m_selectedBoard && hit.channel == m_selectedChannel)
{
m_selectedHit = hit;
m_selectedXAxis.clear();
for (int i = 0; i < hit.waveSize; i++)
m_selectedXAxis.push_back(i);
m_selectedSamplingPeriod = GetSamplingPeriod(m_project->GetDigitizerArgs(m_selectedBoard).model);
break;
}
}
@ -42,45 +38,65 @@ namespace Daqromancy {
void ScopePanel::OnImGuiRender()
{
static std::string selectedBoardString = fmt::format("{0}", m_selectedBoard);
static std::string selectedChannelString = fmt::format("{0}", m_selectedChannel);
static std::string selectedBoardString = "";
static std::string selectedChannelString = "";
static int availChannels = -1;
static std::string analog1 = "##analog1";
static std::string analog2 = "##analog2";
static std::string digital1 = "##digital1";
static std::string digital2 = "##digital2";
if (ImGui::Begin("Oscilloscope"))
{
if (ImGui::BeginCombo("Board", selectedBoardString.c_str()))
{
for (int board=0; board<m_maxNumBoards; board++)
for (const auto& boardArgs : m_project->GetDigitizerArgsList())
{
if (ImGui::Selectable(m_boardListForImGui[board].c_str(), board == m_selectedBoard))
if (ImGui::Selectable(boardArgs.name.c_str(), boardArgs.handle == m_selectedBoard))
{
m_selectedBoard = board;
m_selectedBoard = boardArgs.handle;
availChannels = boardArgs.channels;
selectedBoardString = fmt::format("{0}", m_selectedBoard);
m_selectedXAxis.clear();
if (boardArgs.firmware == CAEN_DGTZ_DPPFirmware_PHA)
{
const auto& phaParams = m_project->GetPHAWaveParameters(boardArgs.handle);
analog1 = PHAVirtualProbe1ToString(phaParams.analogProbe1);
analog2 = PHAVirtualProbe2ToString(phaParams.analogProbe2);
digital1 = PHADigitalProbeToString(phaParams.digitalProbe1);
digital2 = "Trigger";
}
else if (boardArgs.firmware == CAEN_DGTZ_DPPFirmware_PSD)
{
const auto& psdParams = m_project->GetPSDWaveParameters(boardArgs.handle);
analog1 = PSDVirtualProbe1ToString(psdParams.analogProbe1);
analog2 = PSDVirtualProbe2ToString(psdParams.analogProbe2);
digital1 = PSDDigitalProbe1ToString(psdParams.digitalProbe1);
digital2 = PSDDigitalProbe2ToString(psdParams.digitalProbe2);
}
}
}
ImGui::EndCombo();
}
if (ImGui::BeginCombo("Channel", selectedChannelString.c_str()))
{
for (int channel = 0; channel < 16; channel++) //hardcoded bad, fix later
for (int channel = 0; channel < availChannels; channel++)
{
if (ImGui::Selectable(m_channelListForImGui[channel].c_str(), channel == m_selectedChannel))
if (ImGui::Selectable(fmt::format("{0}", channel).c_str(), channel == m_selectedChannel))
{
m_selectedChannel = channel;
selectedChannelString = fmt::format("{0}", m_selectedChannel);
m_selectedXAxis.clear();
}
}
ImGui::EndCombo();
}
if (ImPlot::BeginPlot("ScopeView", ImVec2(-1,-1)))
{
if (m_selectedXAxis.size() != 0)
if (m_selectedHit.waveSize != 0)
{
ImPlot::PlotLine("AnalogProbe1", (ImU16*)m_selectedXAxis.data(), (ImU16*)m_selectedHit.trace1Samples.data(), m_selectedXAxis.size());
ImPlot::PlotLine("AnalogProbe2", (ImU16*)m_selectedXAxis.data(), (ImU16*)m_selectedHit.trace2Samples.data(), m_selectedXAxis.size());
ImPlot::PlotLine("DigitialProbe1", (ImU16*)m_selectedXAxis.data(), (ImU16*)m_selectedHit.digitalTrace1Samples.data(), m_selectedXAxis.size());
ImPlot::PlotLine("DigitialProbe2", (ImU16*)m_selectedXAxis.data(), (ImU16*)m_selectedHit.digitalTrace2Samples.data(), m_selectedXAxis.size());
ImPlot::PlotLine(analog1.c_str(), (ImU16*)m_selectedHit.trace1Samples.data(), m_selectedHit.trace1Samples.size(), m_selectedSamplingPeriod);
ImPlot::PlotLine(analog2.c_str(), (ImU16*)m_selectedHit.trace2Samples.data(), m_selectedHit.trace2Samples.size(), m_selectedSamplingPeriod);
ImPlot::PlotLine(digital1.c_str(), (ImU8*)m_selectedHit.digitalTrace1Samples.data(), m_selectedHit.digitalTrace1Samples.size(), m_selectedSamplingPeriod);
ImPlot::PlotLine(digital2.c_str(), (ImU8*)m_selectedHit.digitalTrace2Samples.data(), m_selectedHit.digitalTrace2Samples.size(), m_selectedSamplingPeriod);
}
ImPlot::EndPlot();
}

View File

@ -3,32 +3,31 @@
#include "DAQ/DigitizerDefs.h"
#include "Core/DataDistributor.h"
#include "Core/DYProject.h"
namespace Daqromancy {
class ScopePanel
{
public:
ScopePanel(int nboards);
ScopePanel(const DYProject::Ref& project);
~ScopePanel();
void OnUpdate();
void OnImGuiRender();
private:
//uint64_t m_consumerID;
DistributorClient m_dataHandle;
std::vector<DYData> m_buffer; //Buffered data retrieved from ring
DYData m_selectedHit; //Hit associated with selected board/channel
std::vector<int16_t> m_selectedXAxis; //X data is not given by DAQ, has to be made based on number of wave samples
bool m_dataReady;
int m_selectedBoard;
int m_selectedChannel;
int m_maxNumBoards;
double m_selectedSamplingPeriod;
std::vector<std::string> m_boardListForImGui;
std::vector<std::string> m_channelListForImGui;
DYProject::Ref m_project;
};
}