Skip to content

Commit 0b921c4

Browse files
StoneLiBambulablanewei120
authored andcommitted
ENH: compatible with U0 firmware
Change-Id: I30a4702424fd0df2ad118505c62b6843968465da
1 parent 1555904 commit 0b921c4

5 files changed

Lines changed: 121 additions & 48 deletions

File tree

src/slic3r/GUI/DeviceManager.cpp

Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,50 @@ void MachineObject::_parse_ams_status(int ams_status)
455455
BOOST_LOG_TRIVIAL(trace) << "ams_debug: main = " << ams_status_main_int << ", sub = " << ams_status_sub;
456456
}
457457

458-
bool MachineObject::is_need_upgrade_for_ams()
458+
bool MachineObject::is_support_ams_mapping()
459459
{
460-
return false;
460+
AppConfig* config = Slic3r::GUI::wxGetApp().app_config;
461+
if (config) {
462+
if (config->get("check_ams_version") == "0")
463+
return false;
464+
}
465+
bool need_upgrade = false;
466+
if (has_ams()) {
467+
// compare ota version and ams version
468+
auto ota_ver_it = module_vers.find("ota");
469+
if (ota_ver_it != module_vers.end()) {
470+
if (!MachineObject::is_support_ams_mapping_version("ota", ota_ver_it->second.sw_ver)) {
471+
need_upgrade = true;
472+
}
473+
}
474+
for (int i = 0; i < 4; i++) {
475+
std::string ams_id = (boost::format("ams/%1%") % i).str();
476+
auto ams_ver_it = module_vers.find(ams_id);
477+
if (ams_ver_it != module_vers.end()) {
478+
if (!MachineObject::is_support_ams_mapping_version("ams", ams_ver_it->second.sw_ver)) {
479+
need_upgrade = true;
480+
}
481+
}
482+
}
483+
}
484+
return !need_upgrade;
485+
}
486+
487+
bool MachineObject::is_support_ams_mapping_version(std::string module, std::string version)
488+
{
489+
bool result = true;
490+
if (module == "ota") {
491+
if (version.compare("00.01.04.03") < 0)
492+
return false;
493+
}
494+
else if (module == "ams") {
495+
// omit ams version is empty
496+
if (version.empty())
497+
return true;
498+
if (version.compare("00.00.04.10") < 0)
499+
return false;
500+
}
501+
return result;
461502
}
462503

463504
bool MachineObject::is_only_support_cloud_print()
@@ -571,6 +612,44 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
571612
}
572613
}
573614

615+
// tray info list
616+
std::vector<FilamentInfo> tray_info_list;
617+
for (auto it = amsList.begin(); it != amsList.end(); it++) {
618+
for (int i = 0; i < 4; i++) {
619+
FilamentInfo info;
620+
auto tray_it = it->second->trayList.find(std::to_string(i));
621+
if (tray_it != it->second->trayList.end()) {
622+
info.id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
623+
info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
624+
info.color = tray_it->second->color;
625+
info.type = tray_it->second->type;
626+
}
627+
else {
628+
info.id = -1;
629+
info.tray_id = -1;
630+
}
631+
tray_info_list.push_back(info);
632+
}
633+
}
634+
635+
// is_support_ams_mapping
636+
if (!is_support_ams_mapping()) {
637+
for (int i = 0; i < filaments.size(); i++) {
638+
FilamentInfo info;
639+
if (i < tray_info_list.size()) {
640+
info.id = filaments[i].id;
641+
info.tray_id = filaments[i].id;
642+
info.color = tray_info_list[i].color;
643+
info.type = tray_info_list[i].type;
644+
} else {
645+
info.id = filaments[i].id;
646+
info.tray_id = -1;
647+
}
648+
result.push_back(info);
649+
}
650+
return 0;
651+
}
652+
574653
// calc distance map
575654
struct DisValue {
576655
int tray_id;
@@ -648,25 +727,6 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
648727
}
649728

650729
try {
651-
//ordering mapping
652-
std::vector<FilamentInfo> tray_info_list;
653-
for (auto it = amsList.begin(); it != amsList.end(); it++) {
654-
for (int i = 0; i < 4; i++) {
655-
FilamentInfo info;
656-
auto tray_it = it->second->trayList.find(std::to_string(i));
657-
if (tray_it != it->second->trayList.end()) {
658-
info.id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
659-
info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4;
660-
info.color = tray_it->second->color;
661-
info.type = tray_it->second->type;
662-
} else {
663-
info.id = -1;
664-
info.tray_id = -1;
665-
}
666-
tray_info_list.push_back(info);
667-
}
668-
}
669-
670730
// try to use ordering ams mapping
671731
bool order_mapping_result = true;
672732
for (int i = 0; i < filaments.size(); i++) {

src/slic3r/GUI/DeviceManager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ class MachineObject
347347
// parse amsStatusMain and ams_status_sub
348348
void _parse_ams_status(int ams_status);
349349
bool has_ams() { return ams_exist_bits != 0; }
350-
bool is_need_upgrade_for_ams();
350+
bool is_support_ams_mapping();
351351
bool is_only_support_cloud_print();
352-
352+
static bool is_support_ams_mapping_version(std::string module, std::string version);
353353

354354
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<int> exclude_id = std::vector<int>());
355355
bool is_valid_mapping_result(std::vector<FilamentInfo>& result);

src/slic3r/GUI/Plater.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,8 @@ Sidebar::Sidebar(Plater *parent)
599599

600600
ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament");
601601
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
602-
// BBS: limit filament choices to 16
603-
if (p->combos_filament.size() >= 16)
602+
// BBS: limit filament choices to 4
603+
if (p->combos_filament.size() >= 4)
604604
return;
605605

606606
int filament_count = p->combos_filament.size() + 1;

src/slic3r/GUI/SelectMachine.cpp

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,9 @@ void SelectMachineDialog::show_status(PrintDialogStatus status)
13521352
update_print_status_msg(msg_text, true);
13531353
Enable_Send_Button(true);
13541354
Enable_Refresh_Button(true);
1355+
} else if (status == PrintDialogStatus::PrintStatusAmsMappingByOrder) {
1356+
Enable_Send_Button(true);
1357+
Enable_Refresh_Button(true);
13551358
}
13561359
}
13571360

@@ -1469,7 +1472,10 @@ void SelectMachineDialog::on_ok(wxCommandEvent &event)
14691472
m_print_job->m_dev_ip = obj_->dev_ip;
14701473
m_print_job->m_access_code = obj_->access_code;
14711474
m_print_job->connection_type = obj_->connection_type();
1472-
m_print_job->task_ams_mapping = ams_mapping_array;
1475+
if (obj_->is_support_ams_mapping())
1476+
m_print_job->task_ams_mapping = ams_mapping_array;
1477+
else
1478+
m_print_job->task_ams_mapping = "";
14731479

14741480
if (obj_->has_sdcard()) {
14751481
m_print_job->has_sdcard = obj_->has_sdcard();
@@ -1758,6 +1764,12 @@ void SelectMachineDialog::on_timer(wxTimerEvent &event)
17581764
return;
17591765
}
17601766

1767+
if (!obj_->is_support_ams_mapping()) {
1768+
do_ams_mapping(obj_);
1769+
show_status(PrintDialogStatus::PrintStatusAmsMappingByOrder);
1770+
return;
1771+
}
1772+
17611773
// do ams mapping if no ams result
17621774
if (m_ams_mapping_result.empty()) {
17631775
do_ams_mapping(obj_);
@@ -1968,27 +1980,27 @@ void SelectMachineDialog::set_default()
19681980

19691981
// item->Layout();
19701982

1971-
item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {
1972-
auto mouse_pos = ClientToScreen(e.GetPosition());
1973-
wxPoint rect = item->ClientToScreen(wxPoint(0, 0));
1974-
1975-
auto mapping = new AmsMapingPopup(this);
1976-
wxPoint pos = item->ClientToScreen(wxPoint(0, 0));
1977-
pos.y += item->GetRect().height;
1978-
mapping->Position(pos, wxSize(0, 0));
1979-
1980-
// update ams data
1981-
DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
1982-
if (!dev_manager) return;
1983-
MachineObject *obj_ = dev_manager->get_selected_machine();
1984-
1985-
if (obj_ && obj_->has_ams()) {
1986-
mapping->update_ams_data(obj_->amsList);
1987-
mapping->set_tag_texture(materials[extruder]);
1988-
mapping->Popup();
1989-
}
1990-
e.Skip();
1991-
});
1983+
//item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {
1984+
// auto mouse_pos = ClientToScreen(e.GetPosition());
1985+
// wxPoint rect = item->ClientToScreen(wxPoint(0, 0));
1986+
1987+
// auto mapping = new AmsMapingPopup(this);
1988+
// wxPoint pos = item->ClientToScreen(wxPoint(0, 0));
1989+
// pos.y += item->GetRect().height;
1990+
// mapping->Position(pos, wxSize(0, 0));
1991+
1992+
// // update ams data
1993+
// DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
1994+
// if (!dev_manager) return;
1995+
// MachineObject *obj_ = dev_manager->get_selected_machine();
1996+
1997+
// if (obj_ && obj_->has_ams()) {
1998+
// mapping->update_ams_data(obj_->amsList);
1999+
// mapping->set_tag_texture(materials[extruder]);
2000+
// mapping->Popup();
2001+
// }
2002+
// e.Skip();
2003+
//});
19922004

19932005
item->Bind(wxEVT_LEFT_DOWN, [this, item, extruder](wxMouseEvent &e) {
19942006
Freeze();

src/slic3r/GUI/SelectMachine.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ enum PrintDialogStatus {
246246
PrintStatusAmsMappingSuccess,
247247
PrintStatusAmsMappingInvalid,
248248
PrintStatusAmsMappingValid,
249+
PrintStatusAmsMappingByOrder,
249250
PrintStatusRefreshingMachineList,
250251
PrintStatusSending,
251252
PrintStatusSendingCanceled,
@@ -339,7 +340,7 @@ class SelectMachineDialog : public DPIDialog
339340
void prepare_mode();
340341
void sending_mode();
341342
void finish_mode();
342-
343+
343344
bool do_ams_mapping(MachineObject* obj_);
344345
bool get_ams_mapping_result(std::string &mapping_array_str);
345346
void prepare(int print_plate_idx);

0 commit comments

Comments
 (0)