JFJochReceiver: Plot is C++ struct
This commit is contained in:
@@ -2,6 +2,49 @@
|
||||
|
||||
#include "JFJochReceiverService.h"
|
||||
|
||||
PlotRequest Convert(const JFJochProtoBuf::PlotRequest& request) {
|
||||
PlotRequest ret;
|
||||
ret.binning = request.binning();
|
||||
switch (request.type()) {
|
||||
case JFJochProtoBuf::BKG_ESTIMATE:
|
||||
ret.type = PlotType::BkgEstimate;
|
||||
break;
|
||||
case JFJochProtoBuf::RAD_INT:
|
||||
ret.type = PlotType::RadInt;
|
||||
break;
|
||||
case JFJochProtoBuf::SPOT_COUNT:
|
||||
ret.type = PlotType::SpotCount;
|
||||
break;
|
||||
case JFJochProtoBuf::INDEXING_RATE:
|
||||
ret.type = PlotType::IndexingRate;
|
||||
break;
|
||||
case JFJochProtoBuf::INDEXING_RATE_PER_FILE:
|
||||
ret.type = PlotType::IndexingRatePerFile;
|
||||
break;
|
||||
default:
|
||||
case JFJochProtoBuf::ADU_HISTOGRAM:
|
||||
ret.type = PlotType::ADUHistorgram;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Convert(const Plot& input, JFJochProtoBuf::Plot &output) {
|
||||
if (!input.x.empty())
|
||||
*output.mutable_x() = {input.x.begin(), input.x.end()};
|
||||
if (!input.y.empty())
|
||||
*output.mutable_y() = {input.y.begin(), input.y.end()};
|
||||
|
||||
}
|
||||
|
||||
void Convert(const RadialIntegrationProfiles& input, JFJochProtoBuf::RadialIntegrationProfiles& output) {
|
||||
for (const auto &i: input.profiles) {
|
||||
auto tmp = output.add_profiles();
|
||||
tmp->set_title(i.title);
|
||||
Convert(i.plot, *tmp->mutable_plot());
|
||||
}
|
||||
}
|
||||
|
||||
JFJochReceiverService::JFJochReceiverService(std::vector<AcquisitionDevice *> &open_capi_device,
|
||||
Logger &in_logger, ImagePusher &pusher) :
|
||||
logger(in_logger), aq_devices(open_capi_device),
|
||||
@@ -175,7 +218,7 @@ grpc::Status JFJochReceiverService::GetDataProcessingPlots(grpc::ServerContext *
|
||||
// Need to hold mutex, as receiver might not exist here, if state is idle
|
||||
std::unique_lock<std::mutex> ul(state_mutex);
|
||||
if (receiver)
|
||||
*response = receiver->GetPlots(*request);
|
||||
Convert(receiver->GetPlots(Convert(*request)), *response);
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
|
||||
@@ -185,7 +228,7 @@ grpc::Status JFJochReceiverService::GetRadialIntegrationProfiles(grpc::ServerCon
|
||||
// Need to hold mutex, as receiver might not exist here, if state is idle
|
||||
std::unique_lock<std::mutex> ul(state_mutex);
|
||||
if (receiver)
|
||||
*response = receiver->GetRadialIntegrationProfiles();
|
||||
Convert(receiver->GetRadialIntegrationProfiles(), *response);
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user