ENH:Do not display printing time and grams

JIRA:4255
Change-Id: Ia37cb6e14b0b444f5d7ee9b5afc5695e790c3162
This commit is contained in:
hu.wang 2023-10-19 15:42:26 +08:00 committed by Lane.Wei
parent 2f4191e958
commit 7e0c831358

View File

@ -4637,7 +4637,8 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
if (plate_idx >= 0) { if (plate_idx >= 0) {
plate_index = plate_idx; plate_index = plate_idx;
} else { }
else {
std::string subtask_json; std::string subtask_json;
unsigned http_code = 0; unsigned http_code = 0;
@ -4656,7 +4657,33 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
if (task_j.contains("context") && task_j["context"].contains("plates")) { if (task_j.contains("context") && task_j["context"].contains("plates")) {
for (int i = 0; i < task_j["context"]["plates"].size(); i++) { for (int i = 0; i < task_j["context"]["plates"].size(); i++) {
if (task_j["context"]["plates"][i].contains("index") && task_j["context"]["plates"][i]["index"].get<int>() == plate_index) { if (task_j["context"]["plates"][i].contains("index") && task_j["context"]["plates"][i]["index"].get<int>() == plate_index) {
if (task_j["context"]["plates"][i].contains("thumbnail") && task_j["context"]["plates"][i]["thumbnail"].contains("url")) {
slice_info->thumbnail_url = task_j["context"]["plates"][i]["thumbnail"]["url"].get<std::string>(); slice_info->thumbnail_url = task_j["context"]["plates"][i]["thumbnail"]["url"].get<std::string>();
}
if (task_j["context"]["plates"][i].contains("prediction")) {
slice_info->prediction = task_j["context"]["plates"][i]["prediction"].get<int>();
}
if (task_j["context"]["plates"][i].contains("weight")) {
slice_info->weight = task_j["context"]["plates"][i]["weight"].get<float>();
}
if (!task_j["context"]["plates"][i]["filaments"].is_null()) {
for (auto filament : task_j["context"]["plates"][i]["filaments"]) {
FilamentInfo f;
if(filament.contains("color")){
f.color = filament["color"].get<std::string>();
}
if (filament.contains("type")) {
f.type = filament["type"].get<std::string>();
}
if (filament.contains("used_g")) {
f.used_g = stof(filament["used_g"].get<std::string>());
}
if (filament.contains("used_m")) {
f.used_m = stof(filament["used_m"].get<std::string>());
}
slice_info->filaments_info.push_back(f);
}
}
BOOST_LOG_TRIVIAL(trace) << "task_info: thumbnail url=" << slice_info->thumbnail_url; BOOST_LOG_TRIVIAL(trace) << "task_info: thumbnail url=" << slice_info->thumbnail_url;
} }
} }
@ -4668,40 +4695,41 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
} }
catch (...) { catch (...) {
} }
} else { }
else {
BOOST_LOG_TRIVIAL(error) << "task_info: get subtask id failed!"; BOOST_LOG_TRIVIAL(error) << "task_info: get subtask id failed!";
} }
} }
//if (plate_index >= 0) {
// std::string slice_json;
// m_agent->get_slice_info(project_id, profile_id, plate_index, &slice_json);
// if (slice_json.empty()) return;
// //parse json
// try {
// json j = json::parse(slice_json);
// if (!j["prediction"].is_null())
// slice_info->prediction = j["prediction"].get<int>();
// if (!j["weight"].is_null())
// slice_info->weight = j["weight"].get<float>();
// if (!j["thumbnail"].is_null()) {
// //slice_info->thumbnail_url = j["thumbnail"]["url"].get<std::string>();
// BOOST_LOG_TRIVIAL(trace) << "slice_info: thumbnail url=" << slice_info->thumbnail_url;
// }
// if (!j["filaments"].is_null()) {
// for (auto filament : j["filaments"]) {
// FilamentInfo f;
// f.color = filament["color"].get<std::string>();
// f.type = filament["type"].get<std::string>();
// f.used_g = stof(filament["used_g"].get<std::string>());
// f.used_m = stof(filament["used_m"].get<std::string>());
// slice_info->filaments_info.push_back(f);
// }
// }
// } catch(...) {
// ;
// }
//}
if (plate_index >= 0) {
std::string slice_json;
m_agent->get_slice_info(project_id, profile_id, plate_index, &slice_json);
if (slice_json.empty()) return;
//parse json
try {
json j = json::parse(slice_json);
if (!j["prediction"].is_null())
slice_info->prediction = j["prediction"].get<int>();
if (!j["weight"].is_null())
slice_info->weight = j["weight"].get<float>();
if (!j["thumbnail"].is_null()) {
//slice_info->thumbnail_url = j["thumbnail"]["url"].get<std::string>();
BOOST_LOG_TRIVIAL(trace) << "slice_info: thumbnail url=" << slice_info->thumbnail_url;
}
if (!j["filaments"].is_null()) {
for (auto filament : j["filaments"]) {
FilamentInfo f;
f.color = filament["color"].get<std::string>();
f.type = filament["type"].get<std::string>();
f.used_g = string_to_float(filament["used_g"].get<std::string>());
f.used_m = string_to_float(filament["used_m"].get<std::string>());
slice_info->filaments_info.push_back(f);
}
}
} catch(...) {
;
}
}
}); });
} }
} }