Release 1.0.0_rc.9
This commit is contained in:
@@ -528,30 +528,38 @@ namespace {
|
||||
cborErr(cbor_value_leave_container(&value, &array_value));
|
||||
}
|
||||
|
||||
void ProcessGoniometerOmega(StartMessage &message, CborValue &value) {
|
||||
GoniometerAxis ProcessGoniometerOmega(std::string &name, CborValue &value) {
|
||||
GoniometerAxis ret;
|
||||
ret.name = name;
|
||||
|
||||
CborValue map_value;
|
||||
|
||||
cborErr(cbor_value_enter_container(&value, &map_value));
|
||||
while (!cbor_value_at_end(&map_value)) {
|
||||
auto key = GetCBORString(map_value);
|
||||
if (key == "increment")
|
||||
message.omega.increment = GetCBORFloat(map_value);
|
||||
ret.increment = GetCBORFloat(map_value);
|
||||
else if (key == "start")
|
||||
message.omega.start = GetCBORFloat(map_value);
|
||||
ret.start = GetCBORFloat(map_value);
|
||||
else
|
||||
cbor_value_advance(&value);
|
||||
}
|
||||
cborErr(cbor_value_leave_container(&value, &map_value));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ProcessGoniometerMap(StartMessage &message, CborValue &value) {
|
||||
CborValue map_value;
|
||||
|
||||
if (GetCBORMapLen(value) > 1)
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError, "Max one rotation angle allowed");
|
||||
|
||||
cborErr(cbor_value_enter_container(&value, &map_value));
|
||||
while (!cbor_value_at_end(&map_value)) {
|
||||
GoniometerAxis axis;
|
||||
auto key = GetCBORString(map_value);
|
||||
if (key == "omega")
|
||||
ProcessGoniometerOmega(message, map_value);
|
||||
message.goniometer = ProcessGoniometerOmega(key, map_value);
|
||||
}
|
||||
cborErr(cbor_value_leave_container(&value, &map_value));
|
||||
}
|
||||
@@ -615,6 +623,8 @@ namespace {
|
||||
message.sample_name = j["sample_name"];
|
||||
if (j.contains("source_name"))
|
||||
message.source_name = j["source_name"];
|
||||
if (j.contains("source_type"))
|
||||
message.source_type = j["source_type"];
|
||||
if (j.contains("source_name_short"))
|
||||
message.source_name_short = j["source_name_short"];
|
||||
if (j.contains("instrument_name"))
|
||||
@@ -625,10 +635,10 @@ namespace {
|
||||
message.total_flux = j["total_flux"];
|
||||
if (j.contains("attenuator_transmission"))
|
||||
message.attenuator_transmission = j["attenuator_transmission"];
|
||||
if (j.contains("omega_rotation_axis") && j["omega_rotation_axis"].is_array() &&
|
||||
(j["omega_rotation_axis"].size() == 3)) {
|
||||
if (j.contains("rotation_axis") && j["rotation_axis"].is_array() &&
|
||||
(j["rotation_axis"].size() == 3)) {
|
||||
for (int i = 0; i < 3; i++)
|
||||
message.omega.axis[i] = j["omega_rotation_axis"][i];
|
||||
message.rotation_axis[i] = j["rotation_axis"][i];
|
||||
}
|
||||
if (j.contains("space_group_number"))
|
||||
message.space_group_number = j["space_group_number"];
|
||||
@@ -640,6 +650,11 @@ namespace {
|
||||
message.write_master_file = j["write_master_file"];
|
||||
if (j.contains("data_reduction_factor_serialmx"))
|
||||
message.data_reduction_factor_serialmx = j["data_reduction_factor_serialmx"];
|
||||
if (j.contains("experiment_group"))
|
||||
message.experiment_group = j["experiment_group"];
|
||||
if (j.contains("jfjoch_release"))
|
||||
message.jfjoch_release = j["jfjoch_release"];
|
||||
|
||||
} 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