Skip to content
Snippets Groups Projects
Verified Commit fde44896 authored by Tobias Triffterer's avatar Tobias Triffterer :house_with_garden:
Browse files

Process Histogram Updates from Server

This parses a command from the server with the contents of all the bins
to synchronize the client with the server.
parent 8b211029
No related branches found
No related tags found
No related merge requests found
Pipeline #3260 passed with stage
in 40 seconds
...@@ -66,6 +66,7 @@ ClientGui::ClientGui(const QString& name, const QString& token, std::unique_ptr< ...@@ -66,6 +66,7 @@ ClientGui::ClientGui(const QString& name, const QString& token, std::unique_ptr<
connect(_ui.cmdStopAdc, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::stopAdc)); connect(_ui.cmdStopAdc, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::stopAdc));
connect(_ui.cmdSaveData, &QPushButton::clicked, this, &ClientGui::saveRootFile); connect(_ui.cmdSaveData, &QPushButton::clicked, this, &ClientGui::saveRootFile);
connect(_ui.cmdClearHisto, &QPushButton::clicked, this, &ClientGui::clearHistogram); connect(_ui.cmdClearHisto, &QPushButton::clicked, this, &ClientGui::clearHistogram);
connect(_ui.cmdUpdateHisto, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::sendHistogramUpdate));
connect(_ui.cmdAdcThresholdUp, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::adcThresholdUp)); connect(_ui.cmdAdcThresholdUp, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::adcThresholdUp));
connect(_ui.cmdAdcThresholdDown, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::adcThresholdDown)); connect(_ui.cmdAdcThresholdDown, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::adcThresholdDown));
...@@ -119,6 +120,7 @@ void ClientGui::handleMessageFromServer(const QString& message) ...@@ -119,6 +120,7 @@ void ClientGui::handleMessageFromServer(const QString& message)
displayExperimentState(); displayExperimentState();
break; break;
case Protocol::Action::updateHistogram: case Protocol::Action::updateHistogram:
updateHistogram(command.arguments[QStringLiteral("bincontents")]);
break; break;
case Protocol::Action::fillHistogram: case Protocol::Action::fillHistogram:
fillEventsIntoHistogram(command.arguments[QStringLiteral("adcchannels")]); fillEventsIntoHistogram(command.arguments[QStringLiteral("adcchannels")]);
...@@ -259,6 +261,31 @@ void ClientGui::fillEventsIntoHistogram(const QString& adcchannels) ...@@ -259,6 +261,31 @@ void ClientGui::fillEventsIntoHistogram(const QString& adcchannels)
_rootcanvas.getCanvas()->Update(); _rootcanvas.getCanvas()->Update();
} }
void Fp311Online::ClientGui::updateHistogram(const QString& bincontents)
{
if (_state.adcState == ExperimentState::AdcState::Running)
return;
const QStringList binlist = bincontents.split(QChar(';'), QString::SkipEmptyParts, Qt::CaseInsensitive);
if (binlist.size() != ExperimentState::NumberOfAdcChannels)
{
logError("The number of bins in the “bincontents” argument of the ”updateHistogram” command does not match ExperimentState::NumberOfAdcChannels.");
return;
}
for(int i = 1; i <= ExperimentState::NumberOfAdcChannels; i++)
{
bool ok = false;
double content = binlist[i-1].toDouble(&ok);
if (ok)
_histo->SetBinContent(i, content);
else
logWarning(QStringLiteral("Cannot convert bin content string ") + binlist[i] + QStringLiteral(" to double."));
}
_histo->ResetStats();
_rootcanvas.getCanvas()->Modified();
_rootcanvas.getCanvas()->Update();
}
void ClientGui::clearHistogram(const bool fromServer) void ClientGui::clearHistogram(const bool fromServer)
{ {
for (int i = 0; i < ExperimentState::NumberOfAdcChannels - 1; i++) for (int i = 0; i < ExperimentState::NumberOfAdcChannels - 1; i++)
......
...@@ -88,6 +88,7 @@ private: ...@@ -88,6 +88,7 @@ private:
void displayExperimentState(); void displayExperimentState();
void fillEventsIntoHistogram(const QString& adcchannels); void fillEventsIntoHistogram(const QString& adcchannels);
void updateHistogram(const QString& bincontents);
void clearHistogram(const bool fromServer = false); void clearHistogram(const bool fromServer = false);
void saveRootFile(); void saveRootFile();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment