v1.0.0-rc.70
This commit is contained in:
@@ -9,11 +9,15 @@
|
||||
#include "../broker/gen/model/Image_buffer_status.h"
|
||||
#include "../broker/gen/model/Plots.h"
|
||||
|
||||
void JFJochHttpReader::Close() {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
void JFJochHttpReader::Close_i() {
|
||||
addr = "";
|
||||
SetStartMessage({});
|
||||
|
||||
}
|
||||
|
||||
void JFJochHttpReader::Close() {
|
||||
std::unique_lock ul(http_mutex);
|
||||
Close_i();
|
||||
}
|
||||
|
||||
uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
@@ -38,9 +42,7 @@ uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochHttpReader::UpdateDataset() {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
std::shared_ptr<JFJochReaderDataset> JFJochHttpReader::UpdateDataset_i() {
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
auto res = cli_cmd.Get("/image_buffer/start.cbor");
|
||||
@@ -52,7 +54,7 @@ void JFJochHttpReader::UpdateDataset() {
|
||||
auto msg = CBORStream2Deserialize(res->body);
|
||||
|
||||
if (msg->msg_type != CBORImageType::START)
|
||||
return;
|
||||
return {};
|
||||
|
||||
auto dataset = std::make_shared<JFJochReaderDataset>();
|
||||
|
||||
@@ -93,29 +95,32 @@ void JFJochHttpReader::UpdateDataset() {
|
||||
dataset->experiment.RingCurrent_mA(msg->start_message->ring_current_mA);
|
||||
dataset->experiment.IncidentEnergy_keV(msg->start_message->incident_energy / 1000.0);
|
||||
|
||||
dataset->bkg_estimate = GetPlot("bkg_estimate");
|
||||
dataset->spot_count = GetPlot("spot_count");
|
||||
dataset->indexing_result = GetPlot("indexing_rate");
|
||||
dataset->mosaicity = GetPlot("mosaicity");
|
||||
SetStartMessage(dataset);
|
||||
dataset->bkg_estimate = GetPlot_i("bkg_estimate");
|
||||
dataset->spot_count = GetPlot_i("spot_count");
|
||||
dataset->indexing_result = GetPlot_i("indexing_rate");
|
||||
dataset->mosaicity = GetPlot_i("mosaicity");
|
||||
return dataset;
|
||||
} catch (std::exception &e) {
|
||||
Close();
|
||||
Close_i();
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Could not load dataset");
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochHttpReader::ReadURL(const std::string &url) {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
addr = url;
|
||||
if (url.empty())
|
||||
Close();
|
||||
UpdateDataset();
|
||||
Close_i();
|
||||
SetStartMessage(UpdateDataset_i());
|
||||
}
|
||||
|
||||
bool JFJochHttpReader::LoadImage_i(const JFJochReaderDataset &dataset,
|
||||
bool JFJochHttpReader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset,
|
||||
DataMessage &message,
|
||||
std::vector<uint8_t> &buffer,
|
||||
int64_t image_number) {
|
||||
int64_t image_number,
|
||||
bool update_dataset) {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
if (addr.empty())
|
||||
@@ -124,7 +129,8 @@ bool JFJochHttpReader::LoadImage_i(const JFJochReaderDataset &dataset,
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
// Always update dataset, as it might have changed from the last time
|
||||
UpdateDataset();
|
||||
if (update_dataset)
|
||||
dataset = UpdateDataset_i();
|
||||
|
||||
auto res = cli_cmd.Get("/image_buffer/image.cbor?id=" + std::to_string(image_number));
|
||||
|
||||
@@ -147,9 +153,7 @@ bool JFJochHttpReader::LoadImage_i(const JFJochReaderDataset &dataset,
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<float> JFJochHttpReader::GetPlot(const std::string &plot_type, float fill_value) const {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
std::vector<float> JFJochHttpReader::GetPlot_i(const std::string &plot_type, float fill_value) const {
|
||||
if (addr.empty())
|
||||
return {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user