mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	ENH: compatible with U0 firmware
Change-Id: I30a4702424fd0df2ad118505c62b6843968465da
This commit is contained in:
		
							parent
							
								
									1555904bef
								
							
						
					
					
						commit
						0b921c44a8
					
				
					 5 changed files with 118 additions and 45 deletions
				
			
		|  | @ -455,9 +455,50 @@ void MachineObject::_parse_ams_status(int ams_status) | |||
|     BOOST_LOG_TRIVIAL(trace) << "ams_debug: main = " << ams_status_main_int << ", sub = " << ams_status_sub; | ||||
| } | ||||
| 
 | ||||
| bool MachineObject::is_need_upgrade_for_ams() | ||||
| bool MachineObject::is_support_ams_mapping() | ||||
| { | ||||
|     return false; | ||||
|     AppConfig* config = Slic3r::GUI::wxGetApp().app_config; | ||||
|     if (config) { | ||||
|         if (config->get("check_ams_version") == "0") | ||||
|             return false; | ||||
|     } | ||||
|     bool need_upgrade = false; | ||||
|     if (has_ams()) { | ||||
|         // compare ota version and ams version
 | ||||
|         auto ota_ver_it = module_vers.find("ota"); | ||||
|         if (ota_ver_it != module_vers.end()) { | ||||
|             if (!MachineObject::is_support_ams_mapping_version("ota", ota_ver_it->second.sw_ver)) { | ||||
|                 need_upgrade = true; | ||||
|             } | ||||
|         } | ||||
|         for (int i = 0; i < 4; i++) { | ||||
|             std::string ams_id = (boost::format("ams/%1%") % i).str(); | ||||
|             auto ams_ver_it = module_vers.find(ams_id); | ||||
|             if (ams_ver_it != module_vers.end()) { | ||||
|                 if (!MachineObject::is_support_ams_mapping_version("ams", ams_ver_it->second.sw_ver)) { | ||||
|                     need_upgrade = true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     return !need_upgrade; | ||||
| } | ||||
| 
 | ||||
| bool MachineObject::is_support_ams_mapping_version(std::string module, std::string version) | ||||
| { | ||||
|     bool result = true; | ||||
|     if (module == "ota") { | ||||
|         if (version.compare("00.01.04.03") < 0) | ||||
|             return false; | ||||
|     } | ||||
|     else if (module == "ams") { | ||||
|         // omit ams version is empty
 | ||||
|         if (version.empty()) | ||||
|             return true; | ||||
|         if (version.compare("00.00.04.10") < 0) | ||||
|             return false; | ||||
|     } | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| bool MachineObject::is_only_support_cloud_print() | ||||
|  | @ -571,6 +612,44 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // tray info list
 | ||||
|     std::vector<FilamentInfo> tray_info_list; | ||||
|     for (auto it = amsList.begin(); it != amsList.end(); it++) { | ||||
|         for (int i = 0; i < 4; i++) { | ||||
|             FilamentInfo info; | ||||
|             auto tray_it = it->second->trayList.find(std::to_string(i)); | ||||
|             if (tray_it != it->second->trayList.end()) { | ||||
|                 info.id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4; | ||||
|                 info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4; | ||||
|                 info.color = tray_it->second->color; | ||||
|                 info.type = tray_it->second->type; | ||||
|             } | ||||
|             else { | ||||
|                 info.id = -1; | ||||
|                 info.tray_id = -1; | ||||
|             } | ||||
|             tray_info_list.push_back(info); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // is_support_ams_mapping
 | ||||
|     if (!is_support_ams_mapping()) { | ||||
|         for (int i = 0; i < filaments.size(); i++) { | ||||
|             FilamentInfo info; | ||||
|             if (i < tray_info_list.size()) { | ||||
|                 info.id = filaments[i].id; | ||||
|                 info.tray_id = filaments[i].id; | ||||
|                 info.color = tray_info_list[i].color; | ||||
|                 info.type = tray_info_list[i].type; | ||||
|             } else { | ||||
|                 info.id = filaments[i].id; | ||||
|                 info.tray_id = -1; | ||||
|             } | ||||
|             result.push_back(info); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     // calc distance map
 | ||||
|     struct DisValue { | ||||
|         int  tray_id; | ||||
|  | @ -648,25 +727,6 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std | |||
|     } | ||||
| 
 | ||||
|     try { | ||||
|         //ordering mapping
 | ||||
|         std::vector<FilamentInfo> tray_info_list; | ||||
|         for (auto it = amsList.begin(); it != amsList.end(); it++) { | ||||
|             for (int i = 0; i < 4; i++) { | ||||
|                 FilamentInfo info; | ||||
|                 auto tray_it = it->second->trayList.find(std::to_string(i)); | ||||
|                 if (tray_it != it->second->trayList.end()) { | ||||
|                     info.id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4; | ||||
|                     info.tray_id = atoi(tray_it->first.c_str()) + atoi(it->first.c_str()) * 4; | ||||
|                     info.color = tray_it->second->color; | ||||
|                     info.type  = tray_it->second->type; | ||||
|                 } else { | ||||
|                     info.id = -1; | ||||
|                     info.tray_id = -1; | ||||
|                 } | ||||
|                 tray_info_list.push_back(info); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // try to use ordering ams mapping
 | ||||
|         bool order_mapping_result = true; | ||||
|         for (int i = 0; i < filaments.size(); i++) { | ||||
|  |  | |||
|  | @ -347,9 +347,9 @@ public: | |||
|     // parse amsStatusMain and ams_status_sub
 | ||||
|     void _parse_ams_status(int ams_status); | ||||
|     bool has_ams() { return ams_exist_bits != 0; } | ||||
|     bool is_need_upgrade_for_ams(); | ||||
|     bool is_support_ams_mapping(); | ||||
|     bool is_only_support_cloud_print(); | ||||
|      | ||||
|     static bool is_support_ams_mapping_version(std::string module, std::string version); | ||||
| 
 | ||||
|     int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<int> exclude_id = std::vector<int>()); | ||||
|     bool is_valid_mapping_result(std::vector<FilamentInfo>& result); | ||||
|  |  | |||
|  | @ -599,8 +599,8 @@ Sidebar::Sidebar(Plater *parent) | |||
| 
 | ||||
|     ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament"); | ||||
|     add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){ | ||||
|         // BBS: limit filament choices to 16
 | ||||
|         if (p->combos_filament.size() >= 16) | ||||
|         // BBS: limit filament choices to 4
 | ||||
|         if (p->combos_filament.size() >= 4) | ||||
|             return; | ||||
| 
 | ||||
|         int filament_count = p->combos_filament.size() + 1; | ||||
|  |  | |||
|  | @ -1352,6 +1352,9 @@ void SelectMachineDialog::show_status(PrintDialogStatus status) | |||
|         update_print_status_msg(msg_text, true); | ||||
|         Enable_Send_Button(true); | ||||
|         Enable_Refresh_Button(true); | ||||
|     } else if (status == PrintDialogStatus::PrintStatusAmsMappingByOrder) { | ||||
|         Enable_Send_Button(true); | ||||
|         Enable_Refresh_Button(true); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -1469,7 +1472,10 @@ void SelectMachineDialog::on_ok(wxCommandEvent &event) | |||
|     m_print_job->m_dev_ip      = obj_->dev_ip; | ||||
|     m_print_job->m_access_code = obj_->access_code; | ||||
|     m_print_job->connection_type = obj_->connection_type(); | ||||
|     m_print_job->task_ams_mapping = ams_mapping_array; | ||||
|     if (obj_->is_support_ams_mapping()) | ||||
|         m_print_job->task_ams_mapping = ams_mapping_array; | ||||
|     else | ||||
|         m_print_job->task_ams_mapping = ""; | ||||
|      | ||||
|     if (obj_->has_sdcard()) { | ||||
|         m_print_job->has_sdcard = obj_->has_sdcard(); | ||||
|  | @ -1758,6 +1764,12 @@ void SelectMachineDialog::on_timer(wxTimerEvent &event) | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (!obj_->is_support_ams_mapping()) { | ||||
|         do_ams_mapping(obj_); | ||||
|         show_status(PrintDialogStatus::PrintStatusAmsMappingByOrder); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     // do ams mapping if no ams result
 | ||||
|     if (m_ams_mapping_result.empty()) { | ||||
|         do_ams_mapping(obj_); | ||||
|  | @ -1968,27 +1980,27 @@ void SelectMachineDialog::set_default() | |||
| 
 | ||||
|         // item->Layout();
 | ||||
| 
 | ||||
|         item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) { | ||||
|             auto    mouse_pos = ClientToScreen(e.GetPosition()); | ||||
|             wxPoint rect      = item->ClientToScreen(wxPoint(0, 0)); | ||||
|         //item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {
 | ||||
|         //    auto    mouse_pos = ClientToScreen(e.GetPosition());
 | ||||
|         //    wxPoint rect      = item->ClientToScreen(wxPoint(0, 0));
 | ||||
| 
 | ||||
|             auto    mapping = new AmsMapingPopup(this); | ||||
|             wxPoint pos     = item->ClientToScreen(wxPoint(0, 0)); | ||||
|             pos.y += item->GetRect().height; | ||||
|             mapping->Position(pos, wxSize(0, 0)); | ||||
|         //    auto    mapping = new AmsMapingPopup(this);
 | ||||
|         //    wxPoint pos     = item->ClientToScreen(wxPoint(0, 0));
 | ||||
|         //    pos.y += item->GetRect().height;
 | ||||
|         //    mapping->Position(pos, wxSize(0, 0));
 | ||||
| 
 | ||||
|             // update ams data
 | ||||
|             DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager(); | ||||
|             if (!dev_manager) return; | ||||
|             MachineObject *obj_        = dev_manager->get_selected_machine(); | ||||
|         //    // update ams data
 | ||||
|         //    DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
 | ||||
|         //    if (!dev_manager) return;
 | ||||
|         //    MachineObject *obj_        = dev_manager->get_selected_machine();
 | ||||
| 
 | ||||
|             if (obj_ && obj_->has_ams()) { | ||||
|                 mapping->update_ams_data(obj_->amsList); | ||||
|                 mapping->set_tag_texture(materials[extruder]); | ||||
|                 mapping->Popup(); | ||||
|             } | ||||
|             e.Skip(); | ||||
|         }); | ||||
|         //    if (obj_ && obj_->has_ams()) {
 | ||||
|         //        mapping->update_ams_data(obj_->amsList);
 | ||||
|         //        mapping->set_tag_texture(materials[extruder]);
 | ||||
|         //        mapping->Popup();
 | ||||
|         //    }
 | ||||
|         //    e.Skip();
 | ||||
|         //});
 | ||||
| 
 | ||||
|         item->Bind(wxEVT_LEFT_DOWN, [this, item, extruder](wxMouseEvent &e) { | ||||
|             Freeze(); | ||||
|  |  | |||
|  | @ -246,6 +246,7 @@ enum PrintDialogStatus { | |||
|     PrintStatusAmsMappingSuccess, | ||||
|     PrintStatusAmsMappingInvalid, | ||||
|     PrintStatusAmsMappingValid, | ||||
|     PrintStatusAmsMappingByOrder, | ||||
|     PrintStatusRefreshingMachineList, | ||||
|     PrintStatusSending, | ||||
|     PrintStatusSendingCanceled, | ||||
|  | @ -339,7 +340,7 @@ public: | |||
|     void      prepare_mode(); | ||||
|     void      sending_mode(); | ||||
|     void      finish_mode(); | ||||
|      | ||||
| 
 | ||||
|     bool      do_ams_mapping(MachineObject* obj_); | ||||
|     bool      get_ams_mapping_result(std::string &mapping_array_str); | ||||
|     void      prepare(int print_plate_idx); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Stone Li
						Stone Li