JFJochStateMachine: Limit ProtoBuf structures
This commit is contained in:
@@ -400,33 +400,34 @@ JFJochStateMachine::~JFJochStateMachine() {
|
||||
void JFJochStateMachine::SetFullMeasurementOutput(const JFJochServicesOutput &output) {
|
||||
std::unique_lock<std::mutex> ul(last_receiver_output_mutex);
|
||||
|
||||
auto tmp = JFJochProtoBuf::MeasurementStatistics(); // reset last measurement statistics
|
||||
MeasurementStatistics tmp{}; // reset last measurement statistics
|
||||
|
||||
tmp.set_file_prefix(experiment.GetFilePrefix());
|
||||
tmp.set_detector_width(experiment.GetXPixelsNum());
|
||||
tmp.set_detector_height(experiment.GetYPixelsNum());
|
||||
tmp.set_detector_pixel_depth(experiment.GetPixelDepth());
|
||||
tmp.file_prefix = experiment.GetFilePrefix();
|
||||
tmp.detector_width = experiment.GetXPixelsNum();
|
||||
tmp.detector_height = experiment.GetYPixelsNum();
|
||||
tmp.detector_pixel_depth = experiment.GetPixelDepth();
|
||||
|
||||
tmp.set_compression_ratio(output.receiver_output.compressed_ratio);
|
||||
tmp.set_collection_efficiency(output.receiver_output.efficiency);
|
||||
tmp.set_images_collected(output.receiver_output.images_sent);
|
||||
tmp.set_cancelled(output.receiver_output.cancelled);
|
||||
tmp.set_max_image_number_sent(output.receiver_output.max_image_number_sent);
|
||||
tmp.set_max_receive_delay(output.receiver_output.max_receive_delay);
|
||||
tmp.set_indexing_rate(output.receiver_output.indexing_rate);
|
||||
tmp.set_bkg_estimate(output.receiver_output.bkg_estimate);
|
||||
tmp.compression_ratio = output.receiver_output.compressed_ratio;
|
||||
tmp.collection_efficiency = output.receiver_output.efficiency;
|
||||
tmp.images_collected = output.receiver_output.images_sent;
|
||||
tmp.cancelled = output.receiver_output.cancelled;
|
||||
tmp.max_image_number_sent = output.receiver_output.max_image_number_sent;
|
||||
tmp.max_receive_delay = output.receiver_output.max_receive_delay;
|
||||
tmp.indexing_rate = output.receiver_output.indexing_rate;
|
||||
tmp.bkg_estimate = output.receiver_output.bkg_estimate;
|
||||
|
||||
measurement_statistics = tmp;
|
||||
}
|
||||
|
||||
void JFJochStateMachine::ClearAndSetMeasurementStatistics() {
|
||||
std::unique_lock<std::mutex> ul(last_receiver_output_mutex);
|
||||
measurement_statistics = JFJochProtoBuf::MeasurementStatistics();
|
||||
MeasurementStatistics tmp{};
|
||||
|
||||
measurement_statistics->set_file_prefix(experiment.GetFilePrefix());
|
||||
measurement_statistics->set_detector_height(experiment.GetXPixelsNum());
|
||||
measurement_statistics->set_detector_width(experiment.GetYPixelsNum());
|
||||
measurement_statistics->set_detector_pixel_depth(experiment.GetPixelDepth());
|
||||
tmp.file_prefix = experiment.GetFilePrefix();
|
||||
tmp.detector_height = experiment.GetXPixelsNum();
|
||||
tmp.detector_width = experiment.GetYPixelsNum();
|
||||
tmp.detector_pixel_depth = experiment.GetPixelDepth();
|
||||
measurement_statistics = tmp;
|
||||
}
|
||||
|
||||
void JFJochStateMachine::ClearMeasurementStatistics() {
|
||||
@@ -434,7 +435,7 @@ void JFJochStateMachine::ClearMeasurementStatistics() {
|
||||
measurement_statistics.reset();
|
||||
}
|
||||
|
||||
std::optional<JFJochProtoBuf::MeasurementStatistics> JFJochStateMachine::GetMeasurementStatistics() const {
|
||||
std::optional<MeasurementStatistics> JFJochStateMachine::GetMeasurementStatistics() const {
|
||||
std::unique_lock<std::mutex> ul(last_receiver_output_mutex);
|
||||
return measurement_statistics;
|
||||
}
|
||||
@@ -499,35 +500,15 @@ DiffractionExperiment &JFJochStateMachine::NotThreadSafe_Experiment() {
|
||||
return experiment;
|
||||
}
|
||||
|
||||
JFJochProtoBuf::BrokerStatus JFJochStateMachine::GetStatus() const {
|
||||
JFJochProtoBuf::BrokerStatus ret;
|
||||
|
||||
switch (state) {
|
||||
case JFJochState::Inactive:
|
||||
ret.set_broker_state(JFJochProtoBuf::NOT_INITIALIZED);
|
||||
break;
|
||||
case JFJochState::Idle:
|
||||
ret.set_broker_state(JFJochProtoBuf::IDLE);
|
||||
break;
|
||||
case JFJochState::Measuring:
|
||||
ret.set_broker_state(JFJochProtoBuf::DATA_COLLECTION);
|
||||
break;
|
||||
case JFJochState::Error:
|
||||
ret.set_broker_state(JFJochProtoBuf::ERROR);
|
||||
break;
|
||||
case JFJochState::Busy:
|
||||
ret.set_broker_state(JFJochProtoBuf::BUSY);
|
||||
break;
|
||||
case JFJochState::Pedestal:
|
||||
ret.set_broker_state(JFJochProtoBuf::PEDESTAL);
|
||||
break;
|
||||
}
|
||||
BrokerStatus JFJochStateMachine::GetStatus() const {
|
||||
BrokerStatus ret{};
|
||||
|
||||
ret.broker_state = state;
|
||||
try {
|
||||
auto rcv_status = services.GetReceiverStatus();
|
||||
ret.set_progress(rcv_status.progress);
|
||||
ret.set_indexing_rate(rcv_status.indexing_rate);
|
||||
ret.set_receiver_send_buffers_avail(rcv_status.send_buffers_avail);
|
||||
ret.progress = rcv_status.progress;
|
||||
ret.indexing_rate = rcv_status.indexing_rate;
|
||||
ret.receiver_send_buffers_avail = rcv_status.send_buffers_avail;
|
||||
} catch (JFJochException &e) {} // ignore exception in getting receiver status (don't really care, e.g. if receiver is down)
|
||||
|
||||
return ret;
|
||||
@@ -573,19 +554,20 @@ void JFJochStateMachine::AddDetectorSetup(const DetectorSetup &setup) {
|
||||
detector_setup.emplace_back(setup);
|
||||
}
|
||||
|
||||
JFJochProtoBuf::DetectorList JFJochStateMachine::GetDetectorsList() {
|
||||
DetectorList JFJochStateMachine::GetDetectorsList() {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
JFJochProtoBuf::DetectorList ret;
|
||||
DetectorList ret;
|
||||
|
||||
for (int i = 0; i < detector_setup.size(); i++) {
|
||||
auto tmp = ret.add_detector();
|
||||
tmp->set_description(detector_setup[i].GetDescription());
|
||||
tmp->set_nmodules(detector_setup[i].GetModulesNum());
|
||||
tmp->set_id(i);
|
||||
DetectorListElement tmp;
|
||||
tmp.description = detector_setup[i].GetDescription();
|
||||
tmp.nmodules = detector_setup[i].GetModulesNum();
|
||||
tmp.id = i;
|
||||
ret.detector.emplace_back(std::move(tmp));
|
||||
}
|
||||
|
||||
ret.set_current_id(current_detector_setup);
|
||||
ret.set_current_description(experiment.GetDetectorDescription());
|
||||
ret.current_id = current_detector_setup;
|
||||
ret.current_description = experiment.GetDetectorDescription();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user