jfjoch_viewer: Handle image buffer counter to stop updating
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 12m12s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m25s
Build Packages / Generate python client (push) Successful in 28s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 13m13s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m14s
Build Packages / build:rpm (rocky8) (push) Successful in 13m19s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 13m21s
Build Packages / Build documentation (push) Successful in 37s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m46s
Build Packages / build:rpm (rocky9) (push) Successful in 13m59s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m57s
Build Packages / Unit tests (push) Successful in 52m11s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 12m12s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m25s
Build Packages / Generate python client (push) Successful in 28s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 13m13s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m14s
Build Packages / build:rpm (rocky8) (push) Successful in 13m19s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 13m21s
Build Packages / Build documentation (push) Successful in 37s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m46s
Build Packages / build:rpm (rocky9) (push) Successful in 13m59s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m57s
Build Packages / Unit tests (push) Successful in 52m11s
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;
|
||||
|
||||
Reference in New Issue
Block a user