FIX: No data in the drop-down menu of the AMS settings page
Jira: 6342 6343 Change-Id: I6938fb4a7ae2816a4675d8d739622e25f219f469
This commit is contained in:
parent
c3d50c362a
commit
2cc42a0fd9
|
@ -1826,9 +1826,12 @@ void PresetBundle::set_calibrate_printer(std::string name)
|
|||
}
|
||||
}
|
||||
|
||||
std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, const std::string &nozzle_diameter_str)
|
||||
std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, std::string nozzle_diameter_str)
|
||||
{
|
||||
std::set<std::string> printer_names;
|
||||
if ("0.0" == nozzle_diameter_str) {
|
||||
nozzle_diameter_str = "0.4";
|
||||
}
|
||||
std::ostringstream stream;
|
||||
|
||||
for (auto printer_it = this->printers.begin(); printer_it != this->printers.end(); printer_it++) {
|
||||
|
@ -1848,6 +1851,67 @@ std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle
|
|||
return printer_names;
|
||||
}
|
||||
|
||||
bool PresetBundle::check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
|
||||
const std::string &printer_type, std::string& nozzle_diameter_str, std::string &setting_id, std::string &tag_uid, std::string &nozzle_temp_min, std::string &nozzle_temp_max, std::string& preset_setting_id)
|
||||
{
|
||||
bool is_equation = true;
|
||||
|
||||
std::map<std::string, std::vector<Preset const *>> filament_list = filaments.get_filament_presets();
|
||||
std::set<std::string> printer_names = get_printer_names_by_printer_type_and_nozzle(printer_type, nozzle_diameter_str);
|
||||
|
||||
for (const Preset *preset : filament_list.find(setting_id)->second) {
|
||||
if (tag_uid == "0" || (tag_uid.size() == 16 && tag_uid.substr(12, 2) == "01")) continue;
|
||||
if (preset && !preset->is_user()) continue;
|
||||
ConfigOption * printer_opt = const_cast<Preset *>(preset)->config.option("compatible_printers");
|
||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||
bool compared = false;
|
||||
for (const std::string &printer_str : printer_strs->values) {
|
||||
if (printer_names.find(printer_str) != printer_names.end()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "nozzle temp matching: preset name: " << preset->name << " printer name: " << printer_str;
|
||||
// Compare only once
|
||||
if (!compared) {
|
||||
compared = true;
|
||||
bool min_temp_equation = false, max_temp_equation = false;
|
||||
int min_nozzle_temp = std::stoi(nozzle_temp_min);
|
||||
int max_nozzle_temp = std::stoi(nozzle_temp_max);
|
||||
ConfigOption *opt_min = const_cast<Preset *>(preset)->config.option("nozzle_temperature_range_low");
|
||||
if (opt_min) {
|
||||
ConfigOptionInts *opt_min_ints = dynamic_cast<ConfigOptionInts *>(opt_min);
|
||||
min_nozzle_temp = opt_min_ints->get_at(0);
|
||||
if (std::to_string(min_nozzle_temp) == nozzle_temp_min)
|
||||
min_temp_equation = true;
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "tray min temp: " << nozzle_temp_min << " preset min temp: " << min_nozzle_temp;
|
||||
//nozzle_temp_min = std::to_string(min_nozzle_temp);
|
||||
}
|
||||
}
|
||||
ConfigOption *opt_max = const_cast<Preset *>(preset)->config.option("nozzle_temperature_range_high");
|
||||
if (opt_max) {
|
||||
ConfigOptionInts *opt_max_ints = dynamic_cast<ConfigOptionInts *>(opt_max);
|
||||
max_nozzle_temp = opt_max_ints->get_at(0);
|
||||
if (std::to_string(max_nozzle_temp) == nozzle_temp_max)
|
||||
max_temp_equation = true;
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "tray max temp: " << nozzle_temp_max << " preset min temp: " << max_nozzle_temp;
|
||||
//nozzle_temp_max = std::to_string(max_nozzle_temp);
|
||||
}
|
||||
}
|
||||
if (min_temp_equation && max_temp_equation) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "Determine if the temperature has changed: no changed";
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "Determine if the temperature has changed: has changed";
|
||||
preset_setting_id = preset->setting_id;
|
||||
is_equation = false;
|
||||
}
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_equation;
|
||||
}
|
||||
|
||||
//BBS: check whether this is the only edited filament
|
||||
bool PresetBundle::is_the_only_edited_filament(unsigned int filament_index)
|
||||
{
|
||||
|
|
|
@ -101,7 +101,14 @@ public:
|
|||
|
||||
void set_calibrate_printer(std::string name);
|
||||
|
||||
std::set<std::string> get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, const std::string &nozzle_diameter_str);
|
||||
std::set<std::string> get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, std::string nozzle_diameter_str);
|
||||
bool check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(const std::string &printer_type,
|
||||
std::string & nozzle_diameter_str,
|
||||
std::string & setting_id,
|
||||
std::string & tag_uid,
|
||||
std::string & nozzle_temp_min,
|
||||
std::string & nozzle_temp_max,
|
||||
std::string & preset_setting_id);
|
||||
|
||||
PresetCollection prints;
|
||||
PresetCollection sla_prints;
|
||||
|
|
|
@ -1846,7 +1846,7 @@ int MachineObject::command_ams_calibrate(int ams_id)
|
|||
int MachineObject::command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "command_ams_filament_settings, ams_id = " << ams_id << ", tray_id = " << tray_id << ", tray_color = " << tray_color
|
||||
<< ", tray_type = " << tray_type << ", setting_id = " << setting_id;
|
||||
<< ", tray_type = " << tray_type << ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max;
|
||||
json j;
|
||||
j["print"]["command"] = "ams_filament_setting";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
@ -3707,6 +3707,11 @@ int MachineObject::parse_json(std::string payload)
|
|||
catch (...) {
|
||||
;
|
||||
}
|
||||
PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
|
||||
std::map<std::string, std::vector<Preset const *>> filament_list = preset_bundle->filaments.get_filament_presets();
|
||||
std::ostringstream stream;
|
||||
stream << std::fixed << std::setprecision(1) << nozzle_diameter;
|
||||
std::string nozzle_diameter_str = stream.str();
|
||||
|
||||
if (jj.contains("ams")) {
|
||||
if (jj["ams"].contains("ams")) {
|
||||
|
@ -3784,13 +3789,6 @@ int MachineObject::parse_json(std::string payload)
|
|||
json j_ams = jj["ams"]["ams"];
|
||||
std::set<std::string> ams_id_set;
|
||||
|
||||
PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
|
||||
std::map<std::string, std::vector<Preset const *>> filament_list = preset_bundle->filaments.get_filament_presets();
|
||||
std::ostringstream stream;
|
||||
stream << std::fixed << std::setprecision(1) << nozzle_diameter;
|
||||
std::string nozzle_diameter_str = stream.str();
|
||||
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str);
|
||||
|
||||
for (auto it = amsList.begin(); it != amsList.end(); it++) {
|
||||
ams_id_set.insert(it->first);
|
||||
}
|
||||
|
@ -3934,44 +3932,19 @@ int MachineObject::parse_json(std::string payload)
|
|||
else
|
||||
curr_tray->nozzle_temp_min = "";
|
||||
if (curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") {
|
||||
for (const Preset *preset : filament_list.find(curr_tray->setting_id)->second) {
|
||||
ConfigOption *printer_opt = const_cast<Preset *>(preset)->config.option("compatible_printers");
|
||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||
bool compared = false, is_correct = false;
|
||||
for (const std::string &printer_str : printer_strs->values) {
|
||||
if (printer_names.find(printer_str) != printer_names.end()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "nozzle temp matching: preset name: " << preset->name
|
||||
<< " printer name: " << printer_str;
|
||||
// Compare only once
|
||||
if (!compared) {
|
||||
compared = true;
|
||||
bool min_temp_equation = false, max_temp_equation = false;
|
||||
ConfigOption *opt_min = const_cast<Preset *>(preset)->config.option("nozzle_temperature_range_low");
|
||||
if (opt_min) {
|
||||
ConfigOptionInts *opt_min_ints = dynamic_cast<ConfigOptionInts *>(opt_min);
|
||||
int min_nozzle_temp = opt_min_ints->get_at(0);
|
||||
if (std::to_string(min_nozzle_temp) == curr_tray->nozzle_temp_min) min_temp_equation = true;
|
||||
}
|
||||
ConfigOption *opt_max = const_cast<Preset *>(preset)->config.option("nozzle_temperature_range_high");
|
||||
if (opt_max) {
|
||||
ConfigOptionInts *opt_max_ints = dynamic_cast<ConfigOptionInts *>(opt_max);
|
||||
int max_nozzle_temp = opt_max_ints->get_at(0);
|
||||
if (std::to_string(max_nozzle_temp) == curr_tray->nozzle_temp_max) max_temp_equation = true;
|
||||
}
|
||||
if (min_temp_equation && max_temp_equation) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "Determine if the temperature has changed: no changed";
|
||||
is_correct = true;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "Determine if the temperature has changed: has changed";
|
||||
command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), preset->filament_id, preset->setting_id,
|
||||
curr_tray->color, curr_tray->type, std::stoi(curr_tray->nozzle_temp_min),
|
||||
std::stoi(curr_tray->nozzle_temp_max));
|
||||
}
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
try {
|
||||
std::string preset_setting_id;
|
||||
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
|
||||
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id,
|
||||
curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id);
|
||||
if (!is_equation) {
|
||||
command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id,
|
||||
curr_tray->color, curr_tray->type,
|
||||
std::stoi(curr_tray->nozzle_temp_min),
|
||||
std::stoi(curr_tray->nozzle_temp_max));
|
||||
}
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id"<<tray_id;
|
||||
}
|
||||
}
|
||||
if (tray_it->contains("xcam_info"))
|
||||
|
@ -4095,6 +4068,16 @@ int MachineObject::parse_json(std::string payload)
|
|||
else {
|
||||
vt_tray.type = type;
|
||||
}
|
||||
if (filament_list.find(vt_tray.setting_id) == filament_list.end()) {
|
||||
wxColour color = *wxWHITE;
|
||||
char col_buf[10];
|
||||
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
|
||||
try {
|
||||
this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0);
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
vt_tray.setting_id = "";
|
||||
|
@ -4128,6 +4111,12 @@ int MachineObject::parse_json(std::string payload)
|
|||
vt_tray.bed_temp = jj["vt_tray"]["bed_temp"].get<std::string>();
|
||||
else
|
||||
vt_tray.bed_temp = "";
|
||||
if (jj["vt_tray"].contains("tray_color")) {
|
||||
auto color = jj["vt_tray"]["tray_color"].get<std::string>();
|
||||
vt_tray.update_color_from_str(color);
|
||||
} else {
|
||||
vt_tray.color = "";
|
||||
}
|
||||
if (jj["vt_tray"].contains("nozzle_temp_max"))
|
||||
vt_tray.nozzle_temp_max = jj["vt_tray"]["nozzle_temp_max"].get<std::string>();
|
||||
else
|
||||
|
@ -4136,6 +4125,22 @@ int MachineObject::parse_json(std::string payload)
|
|||
vt_tray.nozzle_temp_min = jj["vt_tray"]["nozzle_temp_min"].get<std::string>();
|
||||
else
|
||||
vt_tray.nozzle_temp_min = "";
|
||||
if (vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") {
|
||||
try {
|
||||
std::string preset_setting_id;
|
||||
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
|
||||
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid,
|
||||
vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id);
|
||||
if (!is_equation) {
|
||||
command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type,
|
||||
std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max));
|
||||
}
|
||||
}
|
||||
catch(...) {
|
||||
BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id;
|
||||
}
|
||||
|
||||
}
|
||||
if (jj["vt_tray"].contains("xcam_info"))
|
||||
vt_tray.xcam_info = jj["vt_tray"]["xcam_info"].get<std::string>();
|
||||
else
|
||||
|
@ -4144,13 +4149,6 @@ int MachineObject::parse_json(std::string payload)
|
|||
vt_tray.uuid = jj["vt_tray"]["tray_uuid"].get<std::string>();
|
||||
else
|
||||
vt_tray.uuid = "0";
|
||||
if (jj["vt_tray"].contains("tray_color")) {
|
||||
auto color = jj["vt_tray"]["tray_color"].get<std::string>();
|
||||
vt_tray.update_color_from_str(color);
|
||||
}
|
||||
else {
|
||||
vt_tray.color = "";
|
||||
}
|
||||
|
||||
if (jj["vt_tray"].contains("cali_idx"))
|
||||
vt_tray.cali_idx = jj["vt_tray"]["cali_idx"].get<int>();
|
||||
|
|
Loading…
Reference in New Issue