JFJochReceiver: minor modifications

This commit is contained in:
2023-05-08 20:27:18 +02:00
parent bca73c2ac1
commit 34ead0eee9
2 changed files with 8 additions and 28 deletions

View File

@@ -183,7 +183,7 @@ int64_t JFJochReceiver::AcquireThread(uint16_t data_stream) {
logger.Debug("Device thread {} start FPGA action", data_stream);
acquisition_device[data_stream]->StartAction(experiment);
} catch (const JFJochException &e) {
Abort(e);
Cancel(e);
data_acquisition_ready.count_down();
return -1;
}
@@ -194,7 +194,7 @@ int64_t JFJochReceiver::AcquireThread(uint16_t data_stream) {
logger.Debug("Device thread {} wait for FPGA action complete", data_stream);
acquisition_device[data_stream]->WaitForActionComplete();
} catch (const JFJochException &e) {
Abort(e);
Cancel(e);
}
logger.Info("Device thread {} done", data_stream);
@@ -248,7 +248,7 @@ int64_t JFJochReceiver::MeasurePedestalThread(uint16_t data_stream, uint16_t mod
pedestal_calc.Export(pedestal_result[offset]);
pedestal_result[offset].SetFrameCount(experiment.GetFrameNum());
pedestal_result[offset].SetCollectionTime(start_time.time_since_epoch().count() / 1e9);
} catch (const JFJochException &e) { Abort(e); }
} catch (const JFJochException &e) { Cancel(e); }
logger.Debug("Pedestal calculation thread for data stream {} module {} done", data_stream, module_number);
return delay;
}
@@ -309,7 +309,7 @@ int64_t JFJochReceiver::FrameTransformationThread() {
} catch (const JFJochException& e) {
frame_transformation_ready.count_down();
logger.Error("Error creating GPU spot finder");
Abort(e);
Cancel(e);
return -1;
}
@@ -475,7 +475,7 @@ int64_t JFJochReceiver::FrameTransformationThread() {
UpdateMaxImage(image_number);
images_sent++;
}
} catch (const JFJochException &e) { Abort(e); }
} catch (const JFJochException &e) { Cancel(e); }
}
spot_finder->UnregisterBuffer();
@@ -542,32 +542,16 @@ void JFJochReceiver::Cancel() {
acquisition_device[d]->ActionAbort();
}
void JFJochReceiver::Abort() {
// Remote abort: This tells FPGAs to stop, but doesn't do anything to CPU code
logger.Error("Aborting on request");
cancelled = true;
abort = 1;
for (int d = 0; d < ndatastreams; d++)
acquisition_device[d]->ActionAbort();
}
void JFJochReceiver::Abort(const JFJochException &e) {
logger.Error("Aborting data collection due to exception");
void JFJochReceiver::Cancel(const JFJochException &e) {
logger.Error("Cancelling data collection due to exception");
logger.ErrorException(e);
// Error abort: This tells FPGAs to stop and also prevents deadlock in CPU code, by setting abort to 1
cancelled = true;
abort = 1;
for (int d = 0; d < ndatastreams; d++)
acquisition_device[d]->ActionAbort();
}
int JFJochReceiver::GetStatus() const {
return abort;
}
double JFJochReceiver::GetIndexingRate() const {
return indexing_solution.Mean();
}
@@ -643,7 +627,6 @@ void JFJochReceiver::StopReceiver() {
}
JFJochReceiver::~JFJochReceiver() {
abort = 1;
if (measurement.valid())
measurement.get();
}

View File

@@ -56,7 +56,6 @@ class JFJochReceiver {
ImagePusher &image_pusher;
bool push_images_to_writer;
volatile int abort{0};
volatile bool cancelled{false};
std::vector<AcquisitionDevice *> &acquisition_device;
@@ -96,7 +95,7 @@ class JFJochReceiver {
int64_t MeasurePedestalThread(uint16_t data_stream, uint16_t module_number, uint16_t storage_cell);
int64_t MiniSummationThread(int d, int m, size_t image_number, bool &send_image,
FrameTransformation &transformation, DataMessage &message);
void Abort(const JFJochException &e);
void Cancel(const JFJochException &e);
void FinalizeMeasurement();
JFJochProtoBuf::DataProcessingSettings GetDataProcessingSettings();
@@ -115,9 +114,7 @@ public:
void StopReceiver();
void GetStatistics(JFJochProtoBuf::ReceiverOutput &out) const;
void Abort();
void Cancel();
int GetStatus() const;
double GetProgress() const;
double GetIndexingRate() const;
void SetDataProcessingSettings(const JFJochProtoBuf::DataProcessingSettings &data_processing_settings);