Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ess-dmsc/daquiri
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenjc committed Feb 23, 2022
2 parents bb230ef + 25dce41 commit fe4fd2f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
5 changes: 3 additions & 2 deletions source/daqlite/ESSConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ uint32_t ESSConsumer::processEV42Data(RdKafka::Message *Msg) {
// printf("Error: invalid pixel id: %d, min: %d, max: %d\n",
// Pixel, mMinPixel, mMaxPixel);
// exit(0);
PixelDiscard++;
EventDiscard++;
} else {
EventAccept++;
Pixel = Pixel - mConfig.Geometry.Offset;
mHistogram[Pixel]++;
Tof = std::min(Tof, mConfig.TOF.MaxValue);
mHistogramTof[Tof * mConfig.TOF.BinSize / mConfig.TOF.MaxValue]++;
}
}
PixelCount += PixelIds->size();
EventCount += PixelIds->size();
return PixelIds->size();
}

Expand Down
8 changes: 6 additions & 2 deletions source/daqlite/ESSConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ class ESSConsumer {
std::vector<uint32_t> mHistogram;
std::vector<uint32_t> mHistogramTofPlot;
std::vector<uint32_t> mHistogramTof;
uint64_t PixelCount{0};
uint64_t PixelDiscard{0};

uint64_t EventCount{0};
uint64_t EventAccept{0};
uint64_t EventDiscard{0};



private:
RdKafka::Conf *mConf;
Expand Down
23 changes: 16 additions & 7 deletions source/daqlite/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,30 @@ void MainWindow::startKafkaConsumerThread() {
}

// SLOT
void MainWindow::handleKafkaData(int EventRate) {
void MainWindow::handleKafkaData(uint64_t ElapsedCountMS) {
auto Consumer = KafkaConsumerThread->consumer();

uint64_t EventRate = Consumer->EventCount * 1000ULL/ElapsedCountMS;
uint64_t EventAccept = Consumer->EventAccept * 1000ULL/ElapsedCountMS;
uint64_t EventDiscardRate = Consumer->EventDiscard * 1000ULL/ElapsedCountMS;

ui->lblEventRateText->setText(QString::number(EventRate));
ui->lblDiscardedPixelsText->setText(
QString::number(KafkaConsumerThread->consumer()->PixelDiscard));
ui->lblAcceptRateText->setText(QString::number(EventAccept));
ui->lblDiscardedPixelsText->setText(QString::number(EventDiscardRate));

KafkaConsumerThread->mutex.lock();
if (!TOF) {
Plot2DXY->addData(KafkaConsumerThread->consumer()->mHistogramPlot);
Plot2DXY->addData(Consumer->mHistogramPlot);
if (mConfig.Geometry.ZDim > 1) {
Plot2DXZ->addData(KafkaConsumerThread->consumer()->mHistogramPlot);
Plot2DYZ->addData(KafkaConsumerThread->consumer()->mHistogramPlot);
Plot2DXZ->addData(Consumer->mHistogramPlot);
Plot2DYZ->addData(Consumer->mHistogramPlot);
}
} else {
PlotTOF->addData(KafkaConsumerThread->consumer()->mHistogramTofPlot);
PlotTOF->addData(Consumer->mHistogramTofPlot);
}
Consumer->EventCount = 0;
Consumer->EventAccept = 0;
Consumer->EventDiscard = 0;
KafkaConsumerThread->mutex.unlock();
}

Expand Down
2 changes: 1 addition & 1 deletion source/daqlite/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public slots:
void handleGradientButton();
void handleInvertButton();
void handleAutoScaleButton();
void handleKafkaData(int EventRate);
void handleKafkaData(uint64_t ElapsedCountNS);

private:
Ui::MainWindow *ui;
Expand Down
30 changes: 28 additions & 2 deletions source/daqlite/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Event rate:</string>
<string>Evts/s:</string>
</property>
</widget>
</item>
Expand All @@ -102,6 +102,32 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblAcceptRate">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Accept/s:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblAcceptRateText">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblDiscardedPixels">
<property name="sizePolicy">
Expand All @@ -111,7 +137,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Discarded:</string>
<string>Discard/s:</string>
</property>
</widget>
</item>
Expand Down
7 changes: 2 additions & 5 deletions source/daqlite/WorkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void WorkerThread::run() {
while (1) {
auto Msg = Consumer->consume();

/// \todo return counts so we can calculate count rates
Consumer->handleMessage(Msg);

t2 = std::chrono::high_resolution_clock::now();
Expand All @@ -26,11 +25,9 @@ void WorkerThread::run() {
Consumer->mHistogramTofPlot = Consumer->mHistogramTof;
mutex.unlock();

uint64_t Rate =
(uint64_t)((Consumer->PixelCount * 1000000000ULL) / elapsed.count());
emit resultReady(Rate);
uint64_t ElapsedCountMS = elapsed.count()/1000000;
emit resultReady(ElapsedCountMS);

Consumer->PixelCount = 0;
std::fill(Consumer->mHistogram.begin(), Consumer->mHistogram.end(), 0);
std::fill(Consumer->mHistogramTof.begin(), Consumer->mHistogramTof.end(),
0);
Expand Down

0 comments on commit fe4fd2f

Please sign in to comment.