TCP: Allow to get written image count
This commit is contained in:
@@ -37,6 +37,10 @@ void ZMQStream2Pusher::SendImage(ZeroCopyReturnValue &z) {
|
||||
}
|
||||
|
||||
void ZMQStream2Pusher::StartDataCollection(StartMessage& message) {
|
||||
{
|
||||
std::unique_lock ul(images_written_mutex);
|
||||
images_written = std::nullopt;
|
||||
}
|
||||
if (message.images_per_file < 1)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Images per file cannot be zero or negative");
|
||||
@@ -93,6 +97,7 @@ std::string ZMQStream2Pusher::Finalize() {
|
||||
std::string ret;
|
||||
if (transmission_error)
|
||||
ret += "Timeout sending images (e.g., writer disabled during data collection);";
|
||||
uint64_t images = 0;
|
||||
if (writer_notification_socket) {
|
||||
for (int i = 0; i < socket.size(); i++) {
|
||||
auto n = writer_notification_socket->Receive(run_number, run_name);
|
||||
@@ -100,10 +105,18 @@ std::string ZMQStream2Pusher::Finalize() {
|
||||
ret += "Writer " + std::to_string(i) + ": no end notification received within 1 minute from collection end";
|
||||
else if (n->socket_number >= socket.size())
|
||||
ret += "Writer " + std::to_string(i) + ": mismatch in socket number";
|
||||
else if (!n->ok)
|
||||
ret += "Writer " + std::to_string(i) + ": " + n->error;
|
||||
else {
|
||||
if (!n->ok)
|
||||
ret += "Writer " + std::to_string(i) + ": " + n->error;
|
||||
images += n->processed_images;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock ul(images_written_mutex);
|
||||
images_written = images;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -125,3 +138,8 @@ std::string ZMQStream2Pusher::PrintSetup() const {
|
||||
output += s->GetEndpointName() + " ";
|
||||
return output;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> ZMQStream2Pusher::GetImagesWritten() const {
|
||||
std::unique_lock ul(images_written_mutex);
|
||||
return images_written;
|
||||
}
|
||||
Reference in New Issue
Block a user