@@ -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
463504bool 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++) {
0 commit comments