v1.0.0-rc.121 (#28)
All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 9m28s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m25s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 9m4s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m27s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 9m36s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / Build documentation (push) Successful in 45s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8) (push) Successful in 8m45s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m51s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m57s
Build Packages / build:rpm (rocky9) (push) Successful in 9m35s
Build Packages / Unit tests (push) Successful in 1h13m45s
All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 9m28s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m25s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 9m4s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m27s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 9m36s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / Build documentation (push) Successful in 45s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8) (push) Successful in 8m45s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m51s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m57s
Build Packages / build:rpm (rocky9) (push) Successful in 9m35s
Build Packages / Unit tests (push) Successful in 1h13m45s
This is an UNSTABLE release. * jfjoch_broker: Report changes in the image buffer, so viewer doesn't reload constantly * jfjoch_viewer: Improve performance of loading images * jfjoch_viewer: Auto-throttle image loading in HTTP-sync / movie modes * jfjoch_viewer: Auto-foreground calculated with histogram * jfjoch_viewer: Fix rare segmentation fault Reviewed-on: #28 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
This commit was merged in pull request #28.
This commit is contained in:
@@ -14,14 +14,11 @@ void JFJochHttpReader::Close() {
|
||||
std::unique_lock ul(http_mutex);
|
||||
addr = "";
|
||||
SetStartMessage({});
|
||||
last_image_buffer_counter = {};
|
||||
last_op_http_sync = false;
|
||||
}
|
||||
|
||||
uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
if (addr.empty())
|
||||
return 0;
|
||||
|
||||
ImageBufferStatus JFJochHttpReader::GetImageBufferStatus() const {
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
auto res = cli_cmd.Get("/image_buffer/status");
|
||||
@@ -31,13 +28,30 @@ uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
|
||||
try {
|
||||
org::openapitools::server::model::Image_buffer_status status = nlohmann::json::parse(res->body);
|
||||
return status.getMaxImageNumber() + 1;
|
||||
ImageBufferStatus ret{};
|
||||
ret.max_image_number = status.getMaxImageNumber();
|
||||
ret.min_image_number = status.getMinImageNumber();
|
||||
ret.available_slots = status.getAvailableSlots();
|
||||
ret.total_slots = status.getTotalSlots();
|
||||
ret.images_in_the_buffer = status.getImageNumbers();
|
||||
if (status.currentCounterIsSet())
|
||||
ret.current_counter = status.getCurrentCounter();
|
||||
return ret;
|
||||
} catch (std::exception &e) {
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Could not parse image buffer status");
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
if (addr.empty())
|
||||
return 0;
|
||||
auto status = GetImageBufferStatus();
|
||||
return status.max_image_number + 1;
|
||||
}
|
||||
|
||||
std::shared_ptr<JFJochReaderDataset> JFJochHttpReader::UpdateDataset_i() {
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
@@ -153,8 +167,26 @@ bool JFJochHttpReader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset
|
||||
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
bool buffer_changed = false;
|
||||
|
||||
// For autoupdate - if buffer didn't change don't update dataset
|
||||
auto status = GetImageBufferStatus();
|
||||
if (!last_image_buffer_counter.has_value() // No information on the previous buffer state - always assume it changed
|
||||
|| !status.current_counter.has_value() // No information on the current buffer state - e.g. old version of software
|
||||
|| last_image_buffer_counter.value() != status.current_counter.value()) // current counter value different from previous
|
||||
buffer_changed = true;
|
||||
last_image_buffer_counter = status.current_counter;
|
||||
|
||||
if (image_number == -1) {
|
||||
if (last_op_http_sync && !buffer_changed)
|
||||
return false;
|
||||
last_op_http_sync = true;
|
||||
} else {
|
||||
last_op_http_sync = false;
|
||||
}
|
||||
|
||||
// Always update dataset, as it might have changed from the last time
|
||||
if (update_dataset)
|
||||
if (buffer_changed && update_dataset)
|
||||
dataset = UpdateDataset_i();
|
||||
if (!dataset)
|
||||
return false;
|
||||
@@ -164,6 +196,10 @@ bool JFJochHttpReader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset
|
||||
if (!res || res->status != httplib::StatusCode::OK_200)
|
||||
return false;
|
||||
|
||||
if (res->body.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
buffer.resize(res->body.size());
|
||||
memcpy(buffer.data(), res->body.data(), res->body.size());
|
||||
|
||||
Reference in New Issue
Block a user