v1.0.0-rc.34
This commit is contained in:
@@ -437,6 +437,10 @@ namespace {
|
||||
msg.max_count = GetCBORInt(map_value);
|
||||
else if (key == "pixels")
|
||||
msg.pixels = GetCBORUInt(map_value);
|
||||
else if (key == "x_weighted_sum")
|
||||
msg.x_weighted = GetCBORInt(map_value);
|
||||
else if (key == "y_weighted_sum")
|
||||
msg.y_weighted = GetCBORInt(map_value);
|
||||
else
|
||||
cbor_value_advance(&map_value);
|
||||
}
|
||||
@@ -626,6 +630,41 @@ namespace {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ProcessROIConfig(StartMessage &message, const nlohmann::json &j) {
|
||||
if (!j.is_array())
|
||||
return;
|
||||
|
||||
for (const auto &jr: j) {
|
||||
ROIConfig cfg;
|
||||
try {
|
||||
cfg.name = jr["name"];
|
||||
|
||||
if (jr["type"] == "box") {
|
||||
cfg.type = ROIConfig::ROIType::Box;
|
||||
cfg.box.xmin = jr["xmin"];
|
||||
cfg.box.xmax = jr["xmax"];
|
||||
cfg.box.ymin = jr["ymin"];
|
||||
cfg.box.ymax = jr["ymax"];
|
||||
message.rois.emplace_back(std::move(cfg));
|
||||
} else if (jr["type"] == "circle") {
|
||||
cfg.type = ROIConfig::ROIType::Circle;
|
||||
cfg.circle.r = jr["r"];
|
||||
cfg.circle.x = jr["x"];
|
||||
cfg.circle.y = jr["y"];
|
||||
message.rois.emplace_back(std::move(cfg));
|
||||
} else if (jr["type"] == "azim") {
|
||||
cfg.type = ROIConfig::ROIType::Azim;
|
||||
cfg.azim.qmin = jr["qmin"];
|
||||
cfg.azim.qmax = jr["qmax"];
|
||||
message.rois.emplace_back(std::move(cfg));
|
||||
} else
|
||||
continue;
|
||||
} catch (...) {
|
||||
// For now ignore things that are incorrect
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessGoniometerMap(StartMessage &message, CborValue &value) {
|
||||
CborValue map_value;
|
||||
|
||||
@@ -656,6 +695,18 @@ namespace {
|
||||
cborErr(cbor_value_leave_container(&value, &map_value));
|
||||
}
|
||||
|
||||
std::optional<FileWriterFileFormat> ProcessHDF5Format(int input) {
|
||||
auto tmp = static_cast<FileWriterFileFormat>(input);
|
||||
switch (tmp) {
|
||||
case FileWriterFileFormat::DataOnly:
|
||||
case FileWriterFileFormat::NXmxLegacy:
|
||||
case FileWriterFileFormat::NXmxVDS:
|
||||
return tmp;
|
||||
default:
|
||||
// don't throw exception, just do default
|
||||
return {};
|
||||
}
|
||||
}
|
||||
void ProcessStartUserData(StartMessage &message, CborValue &value) {
|
||||
try {
|
||||
const std::string s = GetCBORString(value);
|
||||
@@ -687,10 +738,10 @@ namespace {
|
||||
}
|
||||
if (j.contains("space_group_number"))
|
||||
message.space_group_number = j["space_group_number"];
|
||||
if (j.contains("roi"))
|
||||
ProcessROIConfig(message, j["roi"]);
|
||||
if (j.contains("gain_file_names"))
|
||||
message.gain_file_names = j["gain_file_names"];
|
||||
if (j.contains("roi_names"))
|
||||
message.roi_names = j["roi_names"];
|
||||
if (j.contains("write_master_file"))
|
||||
message.write_master_file = j["write_master_file"];
|
||||
if (j.contains("data_reduction_factor_serialmx"))
|
||||
@@ -712,7 +763,7 @@ namespace {
|
||||
if (j.contains("xfel_pulse_id"))
|
||||
message.overwrite = j["xfel_pulse_id"];
|
||||
if (j.contains("hdf5_format_version"))
|
||||
message.hdf5_format_version = j["hdf5_format_version"];
|
||||
message.hdf5_format_version = ProcessHDF5Format(j["hdf5_format_version"]);
|
||||
} catch (const std::exception &e) {
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError,
|
||||
"Cannot parse user_data as valid JSON " + std::string(e.what()));
|
||||
|
||||
Reference in New Issue
Block a user