NEW:support new ext slot mapping
jira:[support new mapping] Change-Id: Iaf88f7bd57177df772a926ad162bd3b5a141327a
This commit is contained in:
parent
260a7202fc
commit
3b93bd2dd3
|
@ -462,7 +462,7 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
|
|||
if (obj) {
|
||||
// set filament
|
||||
if (is_virtual_tray()) {
|
||||
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_MAIN_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||
}
|
||||
else if(m_is_third){
|
||||
obj->command_ams_filament_settings(ams_id, tray_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||
|
@ -576,7 +576,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
// set filament
|
||||
if (m_is_third) {
|
||||
if (is_virtual_tray()) {
|
||||
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_MAIN_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||
}
|
||||
else {
|
||||
obj->command_ams_filament_settings(ams_id, tray_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||
|
@ -630,7 +630,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
CalibUtils::select_PA_calib_result(select_index_info);
|
||||
}
|
||||
else {
|
||||
obj->command_extrusion_cali_set(VIRTUAL_TRAY_ID, "", "", k, n);
|
||||
obj->command_extrusion_cali_set(VIRTUAL_TRAY_MAIN_ID, "", "", k, n);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -741,7 +741,7 @@ void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
|
|||
|
||||
bool AMSMaterialsSetting::is_virtual_tray()
|
||||
{
|
||||
if (tray_id == VIRTUAL_TRAY_ID)
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -1126,45 +1126,20 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||
}
|
||||
|
||||
m_comboBox_cali_result->Set(items);
|
||||
if (tray_id == VIRTUAL_TRAY_ID) {
|
||||
if (from_printer && (*from_printer == 1)) {
|
||||
AmsTray selected_tray = this->obj->vt_tray;
|
||||
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items, selected_tray.cali_idx);
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID) {
|
||||
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items,this->obj->vt_slot[0].cali_idx);
|
||||
if (cali_select_idx >= 0) {
|
||||
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
||||
} else {
|
||||
m_comboBox_cali_result->SetSelection(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifdef __APPLE__
|
||||
cali_select_idx = get_cali_index(m_comboBox_filament->GetValue().ToStdString());
|
||||
#else
|
||||
cali_select_idx = get_cali_index(m_comboBox_filament->GetLabel().ToStdString());
|
||||
#endif
|
||||
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (from_printer && (*from_printer == 1)) {
|
||||
Ams *selected_ams = this->obj->amsList[std::to_string(ams_id)];
|
||||
if (!selected_ams) return;
|
||||
AmsTray *selected_tray = selected_ams->trayList[std::to_string(tray_id)];
|
||||
if (!selected_tray) return;
|
||||
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
|
||||
if(!selected_ams) return;
|
||||
AmsTray* selected_tray = selected_ams->trayList[std::to_string(tray_id)];
|
||||
if(!selected_tray) return;
|
||||
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items, selected_tray->cali_idx);
|
||||
if (cali_select_idx >= 0) {
|
||||
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
||||
} else {
|
||||
m_comboBox_cali_result->SetSelection(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifdef __APPLE__
|
||||
cali_select_idx = get_cali_index(m_comboBox_filament->GetValue().ToStdString());
|
||||
#else
|
||||
cali_select_idx = get_cali_index(m_comboBox_filament->GetLabel().ToStdString());
|
||||
#endif
|
||||
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -296,12 +296,15 @@ void MaterialItem::doRender(wxDC& dc)
|
|||
Bind(wxEVT_LEFT_DOWN, &AmsMapingPopup::on_left_down, this);
|
||||
#endif
|
||||
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_ams = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_sizer_ams_left = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_ams_right = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_ams_basket_left = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_ams_basket_right = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
|
||||
auto title_panel = new wxPanel(this, wxID_ANY);
|
||||
|
@ -322,14 +325,45 @@ void MaterialItem::doRender(wxDC& dc)
|
|||
title_panel->Layout();
|
||||
title_panel->Fit();
|
||||
|
||||
auto left_ams_title_text = new wxStaticText(this, wxID_ANY, _L("Left Ams"));
|
||||
auto right_ams_title_text = new wxStaticText(this, wxID_ANY, _L("Right Ams"));
|
||||
m_left_marea_panel = new wxPanel(this);
|
||||
m_right_marea_panel = new wxPanel(this);
|
||||
|
||||
m_sizer_ams_left->Add(left_ams_title_text, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_ams_right->Add(right_ams_title_text, 0, wxALIGN_CENTER, 0);
|
||||
|
||||
m_sizer_ams->Add(m_sizer_ams_left, 0, wxEXPAND | wxALL, FromDIP(0));
|
||||
m_sizer_ams->Add(m_sizer_ams_right, 0, wxEXPAND | wxALL, FromDIP(0));
|
||||
/*left ext*/
|
||||
m_left_extra_slot = new MappingItem(m_left_marea_panel);
|
||||
m_left_extra_slot->m_ams_id = VIRTUAL_TRAY_DEPUTY_ID;
|
||||
m_left_extra_slot->m_slot_id = 0;
|
||||
m_left_extra_slot->SetSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
m_left_extra_slot->SetMinSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
m_left_extra_slot->SetMaxSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
|
||||
|
||||
|
||||
/*right ext*/
|
||||
m_right_extra_slot = new MappingItem(m_right_marea_panel);
|
||||
m_right_extra_slot->m_ams_id = VIRTUAL_TRAY_MAIN_ID;
|
||||
m_right_extra_slot->m_slot_id = 0;
|
||||
m_right_extra_slot->SetSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
m_right_extra_slot->SetMinSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
m_right_extra_slot->SetMaxSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
|
||||
m_sizer_ams_left->Add(create_split_sizer(m_left_marea_panel, _L("Left Ams")), 0, wxEXPAND, 0);
|
||||
m_sizer_ams_left->Add(m_sizer_ams_basket_left, 0, wxEXPAND|wxTOP, FromDIP(8));
|
||||
m_sizer_ams_left->Add(create_split_sizer(m_left_marea_panel, _L("External")), 0, wxEXPAND|wxTOP, FromDIP(8));
|
||||
m_sizer_ams_left->Add(m_left_extra_slot, 0, wxEXPAND|wxTOP, FromDIP(8));
|
||||
|
||||
m_sizer_ams_right->Add(create_split_sizer(m_right_marea_panel, _L("Right Ams")), 0, wxEXPAND, 0);
|
||||
m_sizer_ams_right->Add(m_sizer_ams_basket_right, 0, wxEXPAND|wxTOP, FromDIP(8));
|
||||
m_sizer_ams_right->Add(create_split_sizer(m_right_marea_panel, _L("External")), 0, wxEXPAND|wxTOP, FromDIP(8));
|
||||
m_sizer_ams_right->Add(m_right_extra_slot, 0, wxEXPAND|wxTOP, FromDIP(8));
|
||||
|
||||
|
||||
m_left_marea_panel->SetSizer(m_sizer_ams_left);
|
||||
m_right_marea_panel->SetSizer(m_sizer_ams_right);
|
||||
|
||||
m_sizer_ams->Add(m_left_marea_panel, 0, wxEXPAND, FromDIP(0));
|
||||
m_sizer_ams->Add(0, 0, 0, wxEXPAND, FromDIP(15));
|
||||
m_sizer_ams->Add(m_right_marea_panel, 0, wxEXPAND, FromDIP(0));
|
||||
|
||||
|
||||
m_warning_text = new wxStaticText(this, wxID_ANY, wxEmptyString);
|
||||
|
@ -341,7 +375,7 @@ void MaterialItem::doRender(wxDC& dc)
|
|||
m_warning_text->Wrap(FromDIP(248));
|
||||
|
||||
m_sizer_main->Add(title_panel, 0, wxEXPAND | wxALL, FromDIP(2));
|
||||
m_sizer_main->Add(m_sizer_ams, 0, wxEXPAND | wxALL, FromDIP(2));
|
||||
m_sizer_main->Add(m_sizer_ams, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(14));
|
||||
m_sizer_main->Add(m_warning_text, 0, wxEXPAND | wxALL, FromDIP(6));
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
|
@ -357,6 +391,22 @@ void MaterialItem::doRender(wxDC& dc)
|
|||
});
|
||||
}
|
||||
|
||||
wxBoxSizer* AmsMapingPopup::create_split_sizer(wxWindow* parent, wxString text)
|
||||
{
|
||||
wxBoxSizer* sizer_split_left_ams = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto left_ams_title_text = new Label(parent, text);
|
||||
left_ams_title_text->SetFont(::Label::Body_13);
|
||||
left_ams_title_text->SetForegroundColour(0x909090);
|
||||
auto m_split_left_line = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_split_left_line->SetBackgroundColour(0xeeeeee);
|
||||
m_split_left_line->SetMinSize(wxSize(-1, 1));
|
||||
m_split_left_line->SetMaxSize(wxSize(-1, 1));
|
||||
sizer_split_left_ams->Add(0, 0, 0, wxEXPAND, 0);
|
||||
sizer_split_left_ams->Add(left_ams_title_text, 0, wxALIGN_CENTER, 0);
|
||||
sizer_split_left_ams->Add(m_split_left_line, 1, wxALIGN_CENTER_VERTICAL, 0);
|
||||
return sizer_split_left_ams;
|
||||
}
|
||||
|
||||
wxString AmsMapingPopup::format_text(wxString &m_msg)
|
||||
{
|
||||
if (wxGetApp().app_config->get("language") != "zh_CN") { return m_msg; }
|
||||
|
@ -452,12 +502,14 @@ void AmsMapingPopup::update_ams_data_multi_machines()
|
|||
Fit();
|
||||
}
|
||||
|
||||
void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
|
||||
void AmsMapingPopup::update(MachineObject* obj)
|
||||
{
|
||||
std::map<std::string, Ams *>::iterator ams_iter;
|
||||
BOOST_LOG_TRIVIAL(trace) << "ams_mapping total count " << amsList.size();
|
||||
BOOST_LOG_TRIVIAL(info) << "ams_mapping nozzle count " << obj->m_np_nozzle_data.nozzle.size();
|
||||
BOOST_LOG_TRIVIAL(info) << "ams_mapping total count " << obj->amsList.size();
|
||||
|
||||
|
||||
if (!obj) {return;}
|
||||
|
||||
for (auto& ams_container : m_amsmapping_container_list) {
|
||||
ams_container->Destroy();
|
||||
}
|
||||
|
@ -466,32 +518,24 @@ void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
|
|||
m_amsmapping_container_sizer_list.clear();
|
||||
m_mapping_item_list.clear();
|
||||
|
||||
for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
|
||||
/*ext*/
|
||||
if (obj->vt_slot.size() == 1) {
|
||||
m_left_marea_panel->Hide();
|
||||
m_right_extra_slot->Hide();
|
||||
}
|
||||
else if (obj->vt_slot.size() > 1) {
|
||||
m_left_marea_panel->Show();
|
||||
m_right_extra_slot->Show();
|
||||
}
|
||||
|
||||
int ams_indx = atoi(ams_iter->first.c_str());
|
||||
int ams_type = ams_iter->second->type;
|
||||
int nozzle_id = ams_iter->second->nozzle;
|
||||
for (int i = 0; i < obj->vt_slot.size(); i++) {
|
||||
|
||||
if (ams_type == 1) {
|
||||
|
||||
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto ams_mapping_item_container = new MappingContainer(this);
|
||||
ams_mapping_item_container->SetSizer(sizer_mapping_list);
|
||||
ams_mapping_item_container->Layout();
|
||||
|
||||
m_has_unmatch_filament = false;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
|
||||
|
||||
Ams* ams_group = ams_iter->second;
|
||||
std::vector<TrayData> tray_datas;
|
||||
std::map<std::string, AmsTray*>::iterator tray_iter;
|
||||
|
||||
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) {
|
||||
AmsTray* tray_data = tray_iter->second;
|
||||
AmsTray* tray_data = &obj->vt_slot[i];
|
||||
TrayData td;
|
||||
|
||||
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
|
||||
td.id = std::stoi(tray_data->id);
|
||||
td.ams_id = std::stoi(tray_data->id);
|
||||
td.slot_id = 0;
|
||||
|
||||
if (!tray_data->is_exists) {
|
||||
td.type = EMPTY;
|
||||
|
@ -510,9 +554,66 @@ void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
|
|||
td.material_cols.push_back(AmsTray::decode_color(col));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->vt_slot[i].id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
m_right_extra_slot->send_win = send_win;
|
||||
add_ext_ams_mapping(td, m_right_extra_slot);
|
||||
}
|
||||
else if (obj->vt_slot[i].id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID)) {
|
||||
m_left_extra_slot->send_win = send_win;
|
||||
add_ext_ams_mapping(td, m_left_extra_slot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*ams*/
|
||||
for (std::map<std::string, Ams *>::iterator ams_iter = obj->amsList.begin(); ams_iter != obj->amsList.end(); ams_iter++) {
|
||||
|
||||
int ams_indx = atoi(ams_iter->first.c_str());
|
||||
int ams_type = ams_iter->second->type;
|
||||
int nozzle_id = ams_iter->second->nozzle;
|
||||
|
||||
if (ams_type == 1) {
|
||||
|
||||
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0? m_right_marea_panel:m_left_marea_panel);
|
||||
ams_mapping_item_container->SetSizer(sizer_mapping_list);
|
||||
ams_mapping_item_container->Layout();
|
||||
|
||||
m_has_unmatch_filament = false;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
|
||||
|
||||
Ams* ams_group = ams_iter->second;
|
||||
std::vector<TrayData> tray_datas;
|
||||
std::map<std::string, AmsTray*>::iterator tray_iter;
|
||||
|
||||
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) {
|
||||
AmsTray* tray_data = tray_iter->second;
|
||||
TrayData td;
|
||||
|
||||
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
|
||||
td.ams_id = std::stoi(ams_iter->second->id);
|
||||
td.slot_id = std::stoi(tray_iter->second->id);
|
||||
|
||||
if (!tray_data->is_exists) {
|
||||
td.type = EMPTY;
|
||||
}
|
||||
else {
|
||||
if (!tray_data->is_tray_info_ready()) {
|
||||
td.type = THIRD;
|
||||
}
|
||||
else {
|
||||
td.type = NORMAL;
|
||||
td.colour = AmsTray::decode_color(tray_data->color);
|
||||
td.name = tray_data->get_display_filament_type();
|
||||
td.filament_type = tray_data->get_filament_type();
|
||||
td.ctype = tray_data->ctype;
|
||||
for (auto col : tray_data->cols) {
|
||||
td.material_cols.push_back(AmsTray::decode_color(col));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tray_datas.push_back(td);
|
||||
|
@ -520,26 +621,20 @@ void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList)
|
|||
|
||||
ams_mapping_item_container->Show();
|
||||
add_ams_mapping(tray_datas, ams_mapping_item_container, sizer_mapping_list);
|
||||
|
||||
|
||||
m_amsmapping_container_sizer_list.push_back(sizer_mapping_list);
|
||||
m_amsmapping_container_list.push_back(ams_mapping_item_container);
|
||||
|
||||
//main nozzle = right nozzle
|
||||
if (nozzle_id == 0) {
|
||||
m_sizer_ams_right->Add(ams_mapping_item_container, 0, wxALIGN_CENTER, 0);
|
||||
if (nozzle_id == 0) { //right slot
|
||||
m_sizer_ams_basket_right->Add(ams_mapping_item_container, 0, wxALIGN_CENTER, 0);
|
||||
}
|
||||
else if (nozzle_id == 1) {
|
||||
m_sizer_ams_left->Add(ams_mapping_item_container, 0, wxALIGN_CENTER, 0);
|
||||
else if (nozzle_id == 1) { //left slot
|
||||
m_sizer_ams_basket_left->Add(ams_mapping_item_container, 0, wxALIGN_CENTER, 0);
|
||||
}
|
||||
|
||||
|
||||
//m_warning_text->Show(m_has_unmatch_filament);
|
||||
}
|
||||
}
|
||||
|
||||
/*extra tray*/
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
@ -589,26 +684,20 @@ std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, Am
|
|||
void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data, wxWindow* container, wxBoxSizer* sizer)
|
||||
{
|
||||
sizer->Add(0,0,0,wxLEFT,FromDIP(6));
|
||||
|
||||
for (auto i = 0; i < tray_data.size(); i++) {
|
||||
|
||||
// set number
|
||||
/* auto number = new wxStaticText(this, wxID_ANY, wxGetApp().transition_tridid(tray_data[i].id), wxDefaultPosition, wxDefaultSize, 0);
|
||||
number->SetFont(::Label::Body_13);
|
||||
number->SetForegroundColour(wxColour(0X6B, 0X6B, 0X6B));
|
||||
number->Wrap(-1);*/
|
||||
|
||||
|
||||
// set button
|
||||
MappingItem *m_mapping_item = new MappingItem(container);
|
||||
m_mapping_item->send_win = send_win;
|
||||
m_mapping_item->m_ams_id = tray_data[i].ams_id;
|
||||
m_mapping_item->m_slot_id = tray_data[i].slot_id;
|
||||
m_mapping_item->set_tray_index(wxGetApp().transition_tridid(tray_data[i].id));
|
||||
|
||||
m_mapping_item->SetSize(wxSize(FromDIP(68 * 0.7), FromDIP(100 * 0.6)));
|
||||
m_mapping_item->SetMinSize(wxSize(FromDIP(68 * 0.7), FromDIP(100 * 0.6)));
|
||||
m_mapping_item->SetMaxSize(wxSize(FromDIP(68 * 0.7), FromDIP(100 * 0.6)));
|
||||
m_mapping_item->SetSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
m_mapping_item->SetMinSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
m_mapping_item->SetMaxSize(wxSize(FromDIP(48), FromDIP(60)));
|
||||
|
||||
//m_mapping_item->SetCornerRadius(5);
|
||||
m_mapping_item->SetFont(::Label::Body_12);
|
||||
m_mapping_item_list.push_back(m_mapping_item);
|
||||
|
||||
if (tray_data[i].type == NORMAL) {
|
||||
|
@ -646,14 +735,50 @@ void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data, wxWindow*
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
//sizer_mapping_item->Add(number, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
//sizer_mapping_item->Add(m_mapping_item, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
m_mapping_item->set_tray_index(wxGetApp().transition_tridid(tray_data[i].id));
|
||||
sizer->Add(0,0,0,wxRIGHT,FromDIP(6));
|
||||
sizer->Add(0, 0, 0, wxRIGHT, FromDIP(6));
|
||||
sizer->Add(m_mapping_item, 0, wxTOP, FromDIP(1));
|
||||
}
|
||||
}
|
||||
|
||||
void AmsMapingPopup::add_ext_ams_mapping(TrayData tray_data, MappingItem* item)
|
||||
{
|
||||
// set button
|
||||
if (tray_data.type == NORMAL) {
|
||||
if (is_match_material(tray_data.filament_type)) {
|
||||
item->set_data(tray_data.colour, tray_data.name, tray_data);
|
||||
}
|
||||
else {
|
||||
item->set_data(wxColour(0xEE, 0xEE, 0xEE), tray_data.name, tray_data, true);
|
||||
m_has_unmatch_filament = true;
|
||||
}
|
||||
|
||||
item->Bind(wxEVT_LEFT_DOWN, [this, tray_data, item](wxMouseEvent& e) {
|
||||
if (!is_match_material(tray_data.filament_type)) return;
|
||||
item->send_event(m_current_filament_id);
|
||||
Dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// temp
|
||||
if (tray_data.type == EMPTY) {
|
||||
item->set_data(wxColour(0xCE, 0xCE, 0xCE), "-", tray_data);
|
||||
item->Bind(wxEVT_LEFT_DOWN, [this, tray_data,item](wxMouseEvent& e) {
|
||||
item->send_event(m_current_filament_id);
|
||||
Dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
// third party
|
||||
if (tray_data.type == THIRD) {
|
||||
item->set_data(wxColour(0xCE, 0xCE, 0xCE), "?", tray_data);
|
||||
item->Bind(wxEVT_LEFT_DOWN, [this, tray_data, item](wxMouseEvent& e) {
|
||||
item->send_event(m_current_filament_id);
|
||||
Dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
item->set_tray_index(_L("Ext"));
|
||||
}
|
||||
|
||||
void AmsMapingPopup::OnDismiss()
|
||||
|
@ -693,15 +818,17 @@ void AmsMapingPopup::paintEvent(wxPaintEvent &evt)
|
|||
|
||||
void MappingItem::send_event(int fliament_id)
|
||||
{
|
||||
auto number = wxGetApp().transition_tridid(m_tray_data.id);
|
||||
wxCommandEvent event(EVT_SET_FINISH_MAPPING);
|
||||
event.SetInt(m_tray_data.id);
|
||||
|
||||
wxString param = wxString::Format("%d|%d|%d|%d|%s|%d|%d|%d", m_coloul.Red(), m_coloul.Green(), m_coloul.Blue(), m_coloul.Alpha(), number, fliament_id,
|
||||
wxString param = wxString::Format("%d|%d|%d|%d|%s|%d|%d|%d", m_coloul.Red(), m_coloul.Green(), m_coloul.Blue(), m_coloul.Alpha(), m_tray_index, fliament_id,
|
||||
m_tray_data.ams_id, m_tray_data.slot_id);
|
||||
event.SetString(param);
|
||||
event.SetEventObject(this->GetParent()->GetParent());
|
||||
wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
|
||||
|
||||
if (send_win) {
|
||||
event.SetEventObject(send_win);
|
||||
wxPostEvent(send_win, event);
|
||||
}
|
||||
}
|
||||
|
||||
void MappingItem::msw_rescale()
|
||||
|
|
|
@ -113,6 +113,7 @@ public:
|
|||
void send_event(int fliament_id);
|
||||
void set_tray_index(wxString t_index) {m_tray_index = t_index;};
|
||||
|
||||
wxWindow*send_win{nullptr};
|
||||
wxString m_tray_index;
|
||||
wxColour m_coloul;
|
||||
wxString m_name;
|
||||
|
@ -145,8 +146,9 @@ class AmsMapingPopup : public PopupWindow
|
|||
{
|
||||
public:
|
||||
AmsMapingPopup(wxWindow *parent);
|
||||
~AmsMapingPopup(){};
|
||||
~AmsMapingPopup() {};
|
||||
|
||||
wxWindow* send_win{nullptr};
|
||||
wxStaticText * m_warning_text{nullptr};
|
||||
std::vector<std::string> m_materials_list;
|
||||
std::vector<wxBoxSizer*> m_amsmapping_container_sizer_list;
|
||||
|
@ -160,16 +162,27 @@ public:
|
|||
wxBoxSizer *m_sizer_ams{nullptr};
|
||||
wxBoxSizer *m_sizer_ams_left{nullptr};
|
||||
wxBoxSizer *m_sizer_ams_right{nullptr};
|
||||
wxBoxSizer* m_sizer_ams_basket_left{ nullptr };
|
||||
wxBoxSizer* m_sizer_ams_basket_right{ nullptr };
|
||||
wxBoxSizer *m_sizer_list{nullptr};
|
||||
wxWindow *m_parent_item{nullptr};
|
||||
|
||||
MappingItem* m_left_extra_slot{nullptr};
|
||||
MappingItem* m_right_extra_slot{nullptr};
|
||||
|
||||
wxPanel* m_left_marea_panel;
|
||||
wxPanel* m_right_marea_panel;
|
||||
|
||||
wxBoxSizer* create_split_sizer(wxWindow* parent, wxString text);
|
||||
wxString format_text(wxString &m_msg);
|
||||
void set_send_win(wxWindow* win) {send_win = win;};
|
||||
void update_materials_list(std::vector<std::string> list);
|
||||
void set_tag_texture(std::string texture);
|
||||
void update_ams_data(std::map<std::string, Ams *> amsList);
|
||||
void update(MachineObject* obj);
|
||||
void update_ams_data_multi_machines();
|
||||
void add_ams_mapping(std::vector<TrayData> tray_data, wxWindow* container, wxBoxSizer* sizer);
|
||||
void set_current_filament_id(int id){m_current_filament_id = id;};
|
||||
void add_ext_ams_mapping(TrayData tray_data, MappingItem* item);
|
||||
void set_current_filament_id(int id) { m_current_filament_id = id; };
|
||||
int get_current_filament_id(){return m_current_filament_id;};
|
||||
bool is_match_material(std::string material);
|
||||
void on_left_down(wxMouseEvent &evt);
|
||||
|
|
|
@ -1631,7 +1631,7 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
|
|||
|
||||
// init default for filament source
|
||||
// TODO if user change ams/ext, need to update
|
||||
if ( !obj->has_ams() || (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_ID)) )
|
||||
if ( !obj->has_ams() || (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_MAIN_ID)) )
|
||||
{
|
||||
m_ext_spool_radiobox->SetValue(true);
|
||||
m_ams_radiobox->SetValue(false);
|
||||
|
@ -1679,8 +1679,8 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
|
|||
}
|
||||
|
||||
// init virtual tray info
|
||||
if (full_filament_ams_list.find(VIRTUAL_TRAY_ID) != full_filament_ams_list.end()) {
|
||||
filament_ams_list[VIRTUAL_TRAY_ID] = full_filament_ams_list[VIRTUAL_TRAY_ID];
|
||||
if (full_filament_ams_list.find(VIRTUAL_TRAY_MAIN_ID) != full_filament_ams_list.end()) {
|
||||
filament_ams_list[VIRTUAL_TRAY_MAIN_ID] = full_filament_ams_list[VIRTUAL_TRAY_MAIN_ID];
|
||||
}
|
||||
|
||||
|
||||
|
@ -1883,14 +1883,14 @@ void CalibrationPresetPage::update_filament_combobox(std::string ams_id)
|
|||
/* update virtual tray combo box*/
|
||||
m_virtual_tray_comboBox->update_from_preset();
|
||||
auto it = std::find_if(filament_ams_list.begin(), filament_ams_list.end(), [](auto& entry) {
|
||||
return entry.first == VIRTUAL_TRAY_ID;
|
||||
return entry.first == VIRTUAL_TRAY_MAIN_ID;
|
||||
});
|
||||
|
||||
if (it != filament_ams_list.end()) {
|
||||
m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_ID, it->second);
|
||||
m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_MAIN_ID, it->second);
|
||||
}
|
||||
else {
|
||||
m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_ID, empty_config);
|
||||
m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_MAIN_ID, empty_config);
|
||||
}
|
||||
|
||||
if (filament_ams_list.empty())
|
||||
|
|
|
@ -53,7 +53,7 @@ static wxString get_default_name(wxString filament_name, CalibMode mode){
|
|||
static wxString get_tray_name_by_tray_id(int tray_id)
|
||||
{
|
||||
wxString tray_name;
|
||||
if (tray_id == VIRTUAL_TRAY_ID) {
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID) {
|
||||
tray_name = "Ext";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -581,8 +581,7 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
|
|||
subtask_(nullptr),
|
||||
model_task(nullptr),
|
||||
slice_info(nullptr),
|
||||
m_is_online(false),
|
||||
vt_tray(std::to_string(VIRTUAL_TRAY_ID))
|
||||
m_is_online(false)
|
||||
{
|
||||
m_agent = agent;
|
||||
|
||||
|
@ -637,6 +636,10 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
|
|||
printing_speed_lvl = PrintingSpeedLevel::SPEED_LEVEL_INVALID;
|
||||
|
||||
has_ipcam = true; // default true
|
||||
|
||||
|
||||
auto vslot = AmsTray(std::to_string(VIRTUAL_TRAY_MAIN_ID));
|
||||
vt_slot.push_back(vslot);
|
||||
}
|
||||
|
||||
MachineObject::~MachineObject()
|
||||
|
@ -755,8 +758,8 @@ Ams *MachineObject::get_curr_Ams()
|
|||
|
||||
AmsTray *MachineObject::get_curr_tray()
|
||||
{
|
||||
if (m_tray_now.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
|
||||
return &vt_tray;
|
||||
if (m_tray_now.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
return &vt_slot[0];
|
||||
}
|
||||
|
||||
Ams* curr_ams = get_curr_Ams();
|
||||
|
@ -1122,18 +1125,22 @@ bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result, b
|
|||
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
// invalid mapping result
|
||||
if (result[i].tray_id < 0)
|
||||
if (result[i].tray_id < 0) {
|
||||
if (result[i].ams_id.empty() && result[i].slot_id.empty()) {
|
||||
valid_ams_mapping_result = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int ams_id = result[i].tray_id / 4;
|
||||
auto ams_item = amsList.find(std::to_string(ams_id));
|
||||
auto ams_item = amsList.find(result[i].ams_id);
|
||||
if (ams_item == amsList.end()) {
|
||||
if ( (result[i].ams_id != std::to_string(VIRTUAL_TRAY_MAIN_ID)) &&
|
||||
(result[i].ams_id != std::to_string(VIRTUAL_TRAY_DEPUTY_ID))) {
|
||||
result[i].tray_id = -1;
|
||||
valid_ams_mapping_result = false;
|
||||
}
|
||||
} else {
|
||||
if (check_empty_slot) {
|
||||
int tray_id = result[i].tray_id % 4;
|
||||
auto tray_item = ams_item->second->trayList.find(std::to_string(tray_id));
|
||||
auto tray_item = ams_item->second->trayList.find(result[i].slot_id);
|
||||
if (tray_item == ams_item->second->trayList.end()) {
|
||||
result[i].tray_id = -1;
|
||||
valid_ams_mapping_result = false;
|
||||
|
@ -1882,7 +1889,7 @@ int MachineObject::command_ams_switch(int tray_index, int old_temp, int new_temp
|
|||
gcode = DeviceManager::load_gcode(printer_type, "ams_unload.gcode");
|
||||
}
|
||||
else {
|
||||
// include VIRTUAL_TRAY_ID
|
||||
// include VIRTUAL_TRAY_MAIN_ID
|
||||
gcode = DeviceManager::load_gcode(printer_type, "ams_load.gcode");
|
||||
boost::replace_all(gcode, "[next_extruder]", std::to_string(tray_index));
|
||||
boost::replace_all(gcode, "[new_filament_temp]", std::to_string(new_temp));
|
||||
|
@ -2648,7 +2655,14 @@ void MachineObject::reset()
|
|||
json empty_j;
|
||||
print_json.diff2all_base_reset(empty_j);
|
||||
|
||||
vt_tray.reset();
|
||||
for (auto i = 0; i < vt_slot.size(); i++) {
|
||||
vt_slot[i].reset();
|
||||
|
||||
if (i == 1) {
|
||||
vt_slot.erase(vt_slot.begin() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
subtask_ = nullptr;
|
||||
|
||||
|
@ -4162,7 +4176,9 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
<< __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
} else {
|
||||
curr_tray->setting_id = "";
|
||||
curr_tray->type = "";
|
||||
|
@ -4210,29 +4226,27 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
curr_tray->nozzle_temp_min = (*tray_it)["nozzle_temp_min"].get<std::string>();
|
||||
else
|
||||
curr_tray->nozzle_temp_min = "";
|
||||
if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") {
|
||||
if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) {
|
||||
need_checked_filament_id.insert(vt_tray.setting_id);
|
||||
|
||||
/*need for optimization*/
|
||||
/*if (curr_tray->nozzle_temp_min != "" && curr_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, curr_tray->setting_id,
|
||||
curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id);
|
||||
if (!is_equation) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__
|
||||
<< " ams filament is not match min max temp and reset, ams_id: " << ams_id
|
||||
<< " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id;
|
||||
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));
|
||||
}
|
||||
continue;
|
||||
} 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"))
|
||||
curr_tray->xcam_info = (*tray_it)["xcam_info"].get<std::string>();
|
||||
else
|
||||
|
@ -4320,150 +4334,46 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
/* vitrual tray*/
|
||||
if (!key_field_only) {
|
||||
try {
|
||||
if (jj.contains("vt_tray")) {
|
||||
if (jj["vt_tray"].contains("id"))
|
||||
vt_tray.id = jj["vt_tray"]["id"].get<std::string>();
|
||||
auto curr_time = std::chrono::system_clock::now();
|
||||
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - extrusion_cali_set_hold_start);
|
||||
if (diff.count() > HOLD_TIMEOUT || diff.count() < 0
|
||||
|| extrusion_cali_set_tray_id != VIRTUAL_TRAY_ID) {
|
||||
if (jj["vt_tray"].contains("k"))
|
||||
vt_tray.k = jj["vt_tray"]["k"].get<float>();
|
||||
if (jj["vt_tray"].contains("n"))
|
||||
vt_tray.n = jj["vt_tray"]["n"].get<float>();
|
||||
}
|
||||
ams_support_virtual_tray = true;
|
||||
if (jj.contains("vir_slot") && jj["vir_slot"].is_array()) {
|
||||
|
||||
if (vt_tray.hold_count > 0) {
|
||||
vt_tray.hold_count--;
|
||||
} else {
|
||||
if (jj["vt_tray"].contains("tag_uid"))
|
||||
vt_tray.tag_uid = jj["vt_tray"]["tag_uid"].get<std::string>();
|
||||
else
|
||||
vt_tray.tag_uid = "0";
|
||||
if (jj["vt_tray"].contains("tray_info_idx") && jj["vt_tray"].contains("tray_type")) {
|
||||
vt_tray.setting_id = jj["vt_tray"]["tray_info_idx"].get<std::string>();
|
||||
//std::string type = jj["vt_tray"]["tray_type"].get<std::string>();
|
||||
std::string type = setting_id_to_type(vt_tray.setting_id, jj["vt_tray"]["tray_type"].get<std::string>());
|
||||
if (vt_tray.setting_id == "GFS00") {
|
||||
vt_tray.type = "PLA-S";
|
||||
}
|
||||
else if (vt_tray.setting_id == "GFS01") {
|
||||
vt_tray.type = "PA-S";
|
||||
for (auto it = jj["vir_slot"].begin(); it != jj["vir_slot"].end(); it++) {
|
||||
auto vslot = parse_vt_tray(it.value().get<json>());
|
||||
|
||||
if (vslot.id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
auto it = std::next(vt_slot.begin(), 0);
|
||||
if (it != vt_slot.end()) {
|
||||
vt_slot[0] = vslot;
|
||||
}
|
||||
else {
|
||||
vt_tray.type = type;
|
||||
}
|
||||
if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' &&
|
||||
m_filament_list.find(vt_tray.setting_id) == m_filament_list.end()) {
|
||||
if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) {
|
||||
need_checked_filament_id.insert(vt_tray.setting_id);
|
||||
wxColour color = *wxWHITE;
|
||||
char col_buf[10];
|
||||
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
|
||||
try {
|
||||
BOOST_LOG_TRIVIAL(info) << "vt_tray.setting_id is not exist in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id;
|
||||
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;
|
||||
}
|
||||
vt_slot.push_back(vslot);
|
||||
}
|
||||
}
|
||||
else if (vslot.id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID)) {
|
||||
auto it = std::next(vt_slot.begin(), 1);
|
||||
if (it != vt_slot.end()) {
|
||||
vt_slot[1] = vslot;
|
||||
}
|
||||
else {
|
||||
vt_tray.setting_id = "";
|
||||
vt_tray.type = "";
|
||||
}
|
||||
if (jj["vt_tray"].contains("tray_sub_brands"))
|
||||
vt_tray.sub_brands = jj["vt_tray"]["tray_sub_brands"].get<std::string>();
|
||||
else
|
||||
vt_tray.sub_brands = "";
|
||||
if (jj["vt_tray"].contains("tray_weight"))
|
||||
vt_tray.weight = jj["vt_tray"]["tray_weight"].get<std::string>();
|
||||
else
|
||||
vt_tray.weight = "";
|
||||
if (jj["vt_tray"].contains("tray_diameter"))
|
||||
vt_tray.diameter = jj["vt_tray"]["tray_diameter"].get<std::string>();
|
||||
else
|
||||
vt_tray.diameter = "";
|
||||
if (jj["vt_tray"].contains("tray_temp"))
|
||||
vt_tray.temp = jj["vt_tray"]["tray_temp"].get<std::string>();
|
||||
else
|
||||
vt_tray.temp = "";
|
||||
if (jj["vt_tray"].contains("tray_time"))
|
||||
vt_tray.time = jj["vt_tray"]["tray_time"].get<std::string>();
|
||||
else
|
||||
vt_tray.time = "";
|
||||
if (jj["vt_tray"].contains("bed_temp_type"))
|
||||
vt_tray.bed_temp_type = jj["vt_tray"]["bed_temp_type"].get<std::string>();
|
||||
else
|
||||
vt_tray.bed_temp_type = "";
|
||||
if (jj["vt_tray"].contains("bed_temp"))
|
||||
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
|
||||
vt_tray.nozzle_temp_max = "";
|
||||
if (jj["vt_tray"].contains("nozzle_temp_min"))
|
||||
vt_tray.nozzle_temp_min = jj["vt_tray"]["nozzle_temp_min"].get<std::string>();
|
||||
else
|
||||
vt_tray.nozzle_temp_min = "";
|
||||
if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") {
|
||||
if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) {
|
||||
need_checked_filament_id.insert(vt_tray.setting_id);
|
||||
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) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " vt_tray filament is not match min max temp and reset, filament_id: " << vt_tray.setting_id;
|
||||
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
|
||||
vt_tray.xcam_info = "";
|
||||
if (jj["vt_tray"].contains("tray_uuid"))
|
||||
vt_tray.uuid = jj["vt_tray"]["tray_uuid"].get<std::string>();
|
||||
else
|
||||
vt_tray.uuid = "0";
|
||||
|
||||
if (jj["vt_tray"].contains("cali_idx"))
|
||||
vt_tray.cali_idx = jj["vt_tray"]["cali_idx"].get<int>();
|
||||
else
|
||||
vt_tray.cali_idx = -1;
|
||||
vt_tray.cols.clear();
|
||||
if (jj["vt_tray"].contains("cols")) {
|
||||
if (jj["vt_tray"].is_array()) {
|
||||
for (auto it = jj["vt_tray"].begin(); it != jj["vt_tray"].end(); it++) {
|
||||
vt_tray.cols.push_back(it.value().get<std::string>());
|
||||
vt_slot.push_back(vslot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jj["vt_tray"].contains("remain")) {
|
||||
vt_tray.remain = jj["vt_tray"]["remain"].get<int>();
|
||||
}
|
||||
else if (jj.contains("vt_tray")) {
|
||||
auto main_slot = parse_vt_tray(jj.contains("vt_tray"));
|
||||
main_slot.id = std::to_string(VIRTUAL_TRAY_MAIN_ID);
|
||||
|
||||
|
||||
auto it = std::next(vt_slot.begin(), 0);
|
||||
if (it != vt_slot.end()) {
|
||||
vt_slot[0] = main_slot;
|
||||
}
|
||||
else {
|
||||
vt_tray.remain = -1;
|
||||
vt_slot.push_back(main_slot);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
ams_support_virtual_tray = false;
|
||||
is_support_extrusion_cali = false;
|
||||
}
|
||||
|
@ -4529,16 +4439,16 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
if (jj.contains("tray_id")) {
|
||||
tray_id = jj["tray_id"].get<int>();
|
||||
}
|
||||
if (ams_id == 255 && tray_id == VIRTUAL_TRAY_ID) {
|
||||
if (ams_id == 255 && tray_id == VIRTUAL_TRAY_MAIN_ID) {
|
||||
BOOST_LOG_TRIVIAL(info) << "ams_filament_setting, parse tray info";
|
||||
vt_tray.nozzle_temp_max = std::to_string(jj["nozzle_temp_max"].get<int>());
|
||||
vt_tray.nozzle_temp_min = std::to_string(jj["nozzle_temp_min"].get<int>());
|
||||
vt_tray.color = jj["tray_color"].get<std::string>();
|
||||
vt_tray.setting_id = jj["tray_info_idx"].get<std::string>();
|
||||
vt_slot[0].nozzle_temp_max = std::to_string(jj["nozzle_temp_max"].get<int>());
|
||||
vt_slot[0].nozzle_temp_min = std::to_string(jj["nozzle_temp_min"].get<int>());
|
||||
vt_slot[0].color = jj["tray_color"].get<std::string>();
|
||||
vt_slot[0].setting_id = jj["tray_info_idx"].get<std::string>();
|
||||
//vt_tray.type = jj["tray_type"].get<std::string>();
|
||||
vt_tray.type = setting_id_to_type(vt_tray.setting_id, jj["tray_type"].get<std::string>());
|
||||
vt_slot[0].type = setting_id_to_type(vt_slot[0].setting_id, jj["tray_type"].get<std::string>());
|
||||
// delay update
|
||||
vt_tray.set_hold_count();
|
||||
vt_slot[0].set_hold_count();
|
||||
} else {
|
||||
auto ams_it = amsList.find(std::to_string(ams_id));
|
||||
if (ams_it != amsList.end()) {
|
||||
|
@ -4669,7 +4579,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
if (jj.contains("tray_id")) {
|
||||
try {
|
||||
curr_tray_id = jj["tray_id"].get<int>();
|
||||
if (curr_tray_id == VIRTUAL_TRAY_ID)
|
||||
if (curr_tray_id == VIRTUAL_TRAY_MAIN_ID)
|
||||
tray_id = curr_tray_id;
|
||||
else if (curr_tray_id >= 0 && curr_tray_id < 16){
|
||||
ams_id = curr_tray_id / 4;
|
||||
|
@ -4682,11 +4592,11 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
;
|
||||
}
|
||||
}
|
||||
if (tray_id == VIRTUAL_TRAY_ID) {
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID) {
|
||||
if (jj.contains("k_value"))
|
||||
vt_tray.k = jj["k_value"].get<float>();
|
||||
vt_slot[0].k = jj["k_value"].get<float>();
|
||||
if (jj.contains("n_coef"))
|
||||
vt_tray.n = jj["n_coef"].get<float>();
|
||||
vt_slot[0].n = jj["n_coef"].get<float>();
|
||||
} else {
|
||||
auto ams_item = this->amsList.find(std::to_string(ams_id));
|
||||
if (ams_item != this->amsList.end()) {
|
||||
|
@ -4720,7 +4630,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
if (jj.contains("tray_id")) {
|
||||
try {
|
||||
curr_tray_id = jj["tray_id"].get<int>();
|
||||
if (curr_tray_id == VIRTUAL_TRAY_ID)
|
||||
if (curr_tray_id == VIRTUAL_TRAY_MAIN_ID)
|
||||
tray_id = curr_tray_id;
|
||||
else if (curr_tray_id >= 0 && curr_tray_id < 16) {
|
||||
ams_id = curr_tray_id / 4;
|
||||
|
@ -4732,10 +4642,10 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
;
|
||||
}
|
||||
}
|
||||
if (tray_id == VIRTUAL_TRAY_ID) {
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID) {
|
||||
if (jj.contains("cali_idx")) {
|
||||
vt_tray.cali_idx = jj["cali_idx"].get<int>();
|
||||
vt_tray.set_hold_count();
|
||||
vt_slot[0].cali_idx = jj["cali_idx"].get<int>();
|
||||
vt_slot[0].set_hold_count();
|
||||
}
|
||||
} else {
|
||||
auto ams_item = this->amsList.find(std::to_string(ams_id));
|
||||
|
@ -5389,92 +5299,157 @@ std::string MachineObject::get_string_from_fantype(FanType type)
|
|||
return "";
|
||||
}
|
||||
|
||||
void MachineObject::update_filament_list()
|
||||
AmsTray MachineObject::parse_vt_tray(json vtray)
|
||||
{
|
||||
PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
|
||||
auto vt_tray = AmsTray(std::to_string(VIRTUAL_TRAY_MAIN_ID));
|
||||
|
||||
// custom filament
|
||||
std::map<std::string, std::pair<int, int>> filament_list;
|
||||
for (auto &preset : preset_bundle->filaments()) {
|
||||
if (preset.is_user() && preset.inherits() == "") {
|
||||
ConfigOption * printer_opt = const_cast<Preset&>(preset).config.option("compatible_printers");
|
||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||
for (const std::string &printer_str : printer_strs->values) {
|
||||
if (printer_str == m_printer_preset_name) {
|
||||
ConfigOption *opt_min = const_cast<Preset &>(preset).config.option("nozzle_temperature_range_low");
|
||||
int min_temp = -1;
|
||||
if (opt_min) {
|
||||
ConfigOptionInts *opt_min_ints = dynamic_cast<ConfigOptionInts *>(opt_min);
|
||||
min_temp = opt_min_ints->get_at(0);
|
||||
if (vtray.contains("id"))
|
||||
vt_tray.id = vtray["id"].get<std::string>();
|
||||
auto curr_time = std::chrono::system_clock::now();
|
||||
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - extrusion_cali_set_hold_start);
|
||||
if (diff.count() > HOLD_TIMEOUT || diff.count() < 0
|
||||
|| extrusion_cali_set_tray_id != VIRTUAL_TRAY_MAIN_ID) {
|
||||
if (vtray.contains("k"))
|
||||
vt_tray.k = vtray["k"].get<float>();
|
||||
if (vtray.contains("n"))
|
||||
vt_tray.n = vtray["n"].get<float>();
|
||||
}
|
||||
ConfigOption *opt_max = const_cast<Preset &>(preset).config.option("nozzle_temperature_range_high");
|
||||
int max_temp = -1;
|
||||
if (opt_max) {
|
||||
ConfigOptionInts *opt_max_ints = dynamic_cast<ConfigOptionInts *>(opt_max);
|
||||
max_temp = opt_max_ints->get_at(0);
|
||||
ams_support_virtual_tray = true;
|
||||
|
||||
if (vt_tray.hold_count > 0) {
|
||||
vt_tray.hold_count--;
|
||||
}
|
||||
filament_list[preset.filament_id] = std::make_pair(min_temp, max_temp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = filament_list.begin(); it != filament_list.end(); it++) {
|
||||
if (m_filament_list.find(it->first) != m_filament_list.end()) {
|
||||
assert(it->first.size() == 8 && it->first[0] == 'P');
|
||||
|
||||
if (it->second.first != m_filament_list[it->first].first) {
|
||||
BOOST_LOG_TRIVIAL(info) << "old min temp is not equal to new min temp and filament id: " << it->first;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (it->second.second != m_filament_list[it->first].second) {
|
||||
BOOST_LOG_TRIVIAL(info) << "old max temp is not equal to new max temp and filament id: " << it->first;
|
||||
continue;
|
||||
}
|
||||
|
||||
m_filament_list.erase(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_filament_list.begin(); it != m_filament_list.end(); it++) {
|
||||
m_checked_filament.erase(it->first);
|
||||
}
|
||||
|
||||
m_filament_list = filament_list;
|
||||
}
|
||||
|
||||
int MachineObject::get_flag_bits(std::string str, int start, int count)
|
||||
{
|
||||
int decimal_value = std::stoi(str, nullptr, 16);
|
||||
int mask = 0;
|
||||
for (int i = 0; i < count; i++) { mask += 1 << (start + i); }
|
||||
|
||||
int flag = (decimal_value & (mask)) >> start;
|
||||
return flag;
|
||||
}
|
||||
|
||||
int MachineObject::get_flag_bits(int num, int start, int count)
|
||||
{
|
||||
int decimal_value = num;
|
||||
int mask = 0;
|
||||
for (int i = 0; i < count; i++) { mask += 1 << (start + i); }
|
||||
|
||||
int flag = (decimal_value & (mask)) >> start;
|
||||
return flag;
|
||||
}
|
||||
|
||||
void MachineObject::update_printer_preset_name(const std::string &nozzle_diameter_str)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "start update preset_name";
|
||||
auto preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
|
||||
if (!preset_bundle) return;
|
||||
auto printer_set = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str);
|
||||
if (printer_set.size() > 0)
|
||||
m_printer_preset_name = *printer_set.begin();
|
||||
else {
|
||||
if (vtray.contains("tag_uid"))
|
||||
vt_tray.tag_uid = vtray["tag_uid"].get<std::string>();
|
||||
else
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " update printer preset name failed ";
|
||||
vt_tray.tag_uid = "0";
|
||||
if (vtray.contains("tray_info_idx") && vtray.contains("tray_type")) {
|
||||
vt_tray.setting_id = vtray["tray_info_idx"].get<std::string>();
|
||||
//std::string type = vtray["tray_type"].get<std::string>();
|
||||
std::string type = setting_id_to_type(vt_tray.setting_id, vtray["tray_type"].get<std::string>());
|
||||
if (vt_tray.setting_id == "GFS00") {
|
||||
vt_tray.type = "PLA-S";
|
||||
}
|
||||
else if (vt_tray.setting_id == "GFS01") {
|
||||
vt_tray.type = "PA-S";
|
||||
}
|
||||
else {
|
||||
vt_tray.type = type;
|
||||
}
|
||||
|
||||
/*need for optimization*/
|
||||
/*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 {
|
||||
BOOST_LOG_TRIVIAL(info) << "no filament_id in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id;
|
||||
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 = "";
|
||||
vt_tray.type = "";
|
||||
}
|
||||
if (vtray.contains("tray_sub_brands"))
|
||||
vt_tray.sub_brands = vtray["tray_sub_brands"].get<std::string>();
|
||||
else
|
||||
vt_tray.sub_brands = "";
|
||||
if (vtray.contains("tray_weight"))
|
||||
vt_tray.weight = vtray["tray_weight"].get<std::string>();
|
||||
else
|
||||
vt_tray.weight = "";
|
||||
if (vtray.contains("tray_diameter"))
|
||||
vt_tray.diameter = vtray["tray_diameter"].get<std::string>();
|
||||
else
|
||||
vt_tray.diameter = "";
|
||||
if (vtray.contains("tray_temp"))
|
||||
vt_tray.temp = vtray["tray_temp"].get<std::string>();
|
||||
else
|
||||
vt_tray.temp = "";
|
||||
if (vtray.contains("tray_time"))
|
||||
vt_tray.time = vtray["tray_time"].get<std::string>();
|
||||
else
|
||||
vt_tray.time = "";
|
||||
if (vtray.contains("bed_temp_type"))
|
||||
vt_tray.bed_temp_type = vtray["bed_temp_type"].get<std::string>();
|
||||
else
|
||||
vt_tray.bed_temp_type = "";
|
||||
if (vtray.contains("bed_temp"))
|
||||
vt_tray.bed_temp = vtray["bed_temp"].get<std::string>();
|
||||
else
|
||||
vt_tray.bed_temp = "";
|
||||
if (vtray.contains("tray_color")) {
|
||||
auto color = vtray["tray_color"].get<std::string>();
|
||||
vt_tray.update_color_from_str(color);
|
||||
}
|
||||
else {
|
||||
vt_tray.color = "";
|
||||
}
|
||||
if (vtray.contains("nozzle_temp_max"))
|
||||
vt_tray.nozzle_temp_max = vtray["nozzle_temp_max"].get<std::string>();
|
||||
else
|
||||
vt_tray.nozzle_temp_max = "";
|
||||
if (vtray.contains("nozzle_temp_min"))
|
||||
vt_tray.nozzle_temp_min = vtray["nozzle_temp_min"].get<std::string>();
|
||||
else
|
||||
vt_tray.nozzle_temp_min = "";
|
||||
|
||||
/*need for optimization*/
|
||||
/*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 (vtray.contains("xcam_info"))
|
||||
vt_tray.xcam_info = vtray["xcam_info"].get<std::string>();
|
||||
else
|
||||
vt_tray.xcam_info = "";
|
||||
if (vtray.contains("tray_uuid"))
|
||||
vt_tray.uuid = vtray["tray_uuid"].get<std::string>();
|
||||
else
|
||||
vt_tray.uuid = "0";
|
||||
|
||||
if (vtray.contains("cali_idx"))
|
||||
vt_tray.cali_idx = vtray["cali_idx"].get<int>();
|
||||
else
|
||||
vt_tray.cali_idx = -1;
|
||||
vt_tray.cols.clear();
|
||||
if (vtray.contains("cols")) {
|
||||
if (vtray.is_array()) {
|
||||
for (auto it = vtray.begin(); it != vtray.end(); it++) {
|
||||
vt_tray.cols.push_back(it.value().get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vtray.contains("remain")) {
|
||||
vt_tray.remain = vtray["remain"].get<int>();
|
||||
}
|
||||
else {
|
||||
vt_tray.remain = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return vt_tray;
|
||||
}
|
||||
|
||||
bool DeviceManager::EnableMultiMachine = false;
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
#define HOLD_COUNT_CAMERA 6
|
||||
#define GET_VERSION_RETRYS 10
|
||||
#define RETRY_INTERNAL 2000
|
||||
#define VIRTUAL_TRAY_ID 254
|
||||
#define VIRTUAL_TRAY_MAIN_ID 255
|
||||
#define VIRTUAL_TRAY_DEPUTY_ID 254
|
||||
#define START_SEQ_ID 20000
|
||||
#define END_SEQ_ID 30000
|
||||
#define SUBSCRIBE_RETRY_COUNT 5
|
||||
|
@ -502,8 +503,7 @@ public:
|
|||
|
||||
/* ams properties */
|
||||
std::map<std::string, Ams*> amsList; // key: ams[id], start with 0
|
||||
AmsTray vt_tray; // virtual tray
|
||||
std::vector<AmsTray> vt_trays; // virtual tray for new
|
||||
//AmsTray vt_tray; // virtual tray
|
||||
long ams_exist_bits = 0;
|
||||
long tray_exist_bits = 0;
|
||||
long tray_is_bbl_bits = 0;
|
||||
|
@ -1002,15 +1002,9 @@ public:
|
|||
bool is_enable_np{ false };
|
||||
NozzleData m_np_nozzle_data;
|
||||
|
||||
/* Device Filament Check */
|
||||
std::set<std::string> m_checked_filament;
|
||||
std::string m_printer_preset_name;
|
||||
std::map<std::string, std::pair<int, int>> m_filament_list; // filament_id, pair<min temp, max temp>
|
||||
void update_filament_list();
|
||||
int get_flag_bits(std::string str, int start, int count = 1);
|
||||
int get_flag_bits(int num, int start, int count = 1);
|
||||
void update_printer_preset_name(const std::string &nozzle_diameter_str);
|
||||
|
||||
/*vi slot data*/
|
||||
std::vector<AmsTray> vt_slot;
|
||||
AmsTray parse_vt_tray(json vtray);
|
||||
};
|
||||
|
||||
class DeviceManager
|
||||
|
|
|
@ -469,7 +469,7 @@ void ExtrusionCalibration::on_click_cali(wxCommandEvent& event)
|
|||
max_volumetric_speed = speed_opt->get_at(0);
|
||||
if (bed_temp >= 0 && nozzle_temp >= 0 && max_volumetric_speed >= 0) {
|
||||
int curr_tray_id = ams_id * 4 + tray_id;
|
||||
if (tray_id == VIRTUAL_TRAY_ID)
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID)
|
||||
curr_tray_id = tray_id;
|
||||
obj->command_start_extrusion_cali(curr_tray_id, nozzle_temp, bed_temp, max_volumetric_speed, it->setting_id);
|
||||
return;
|
||||
|
@ -597,7 +597,7 @@ void ExtrusionCalibration::on_click_save(wxCommandEvent &event)
|
|||
|
||||
// send command
|
||||
int curr_tray_id = ams_id * 4 + tray_id;
|
||||
if (tray_id == VIRTUAL_TRAY_ID)
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID)
|
||||
curr_tray_id = tray_id;
|
||||
obj->command_extrusion_cali_set(curr_tray_id, setting_id, name, k, n, bed_temp, nozzle_temp, max_volumetric_speed);
|
||||
Close();
|
||||
|
|
|
@ -1667,7 +1667,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
std::map<int, DynamicPrintConfig> filament_ams_list;
|
||||
if (!obj) return filament_ams_list;
|
||||
|
||||
auto vt_tray = obj->vt_tray;
|
||||
auto vt_tray = obj->vt_slot[0];
|
||||
if (obj->ams_support_virtual_tray) {
|
||||
DynamicPrintConfig vt_tray_config;
|
||||
vt_tray_config.set_key_value("filament_id", new ConfigOptionStrings{ vt_tray.setting_id });
|
||||
|
@ -1681,7 +1681,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
for (int i = 0; i < vt_tray.cols.size(); ++i) {
|
||||
vt_tray_config.opt<ConfigOptionStrings>("filament_multi_colors")->values.push_back(into_u8(wxColour("#" + vt_tray.cols[i]).GetAsString(wxC2S_HTML_SYNTAX)));
|
||||
}
|
||||
filament_ams_list.emplace(VIRTUAL_TRAY_ID, std::move(vt_tray_config));
|
||||
filament_ams_list.emplace(VIRTUAL_TRAY_MAIN_ID, std::move(vt_tray_config));
|
||||
}
|
||||
|
||||
auto list = obj->amsList;
|
||||
|
|
|
@ -1312,7 +1312,9 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
|
||||
|
||||
|
||||
m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
|
||||
m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
|
||||
m_statictext_ams_msg->SetMinSize(wxSize(FromDIP(600), -1));
|
||||
m_statictext_ams_msg->SetMaxSize(wxSize(FromDIP(600), -1));
|
||||
m_statictext_ams_msg->SetFont(::Label::Body_13);
|
||||
m_statictext_ams_msg->Hide();
|
||||
|
||||
|
@ -1512,7 +1514,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
m_sizer_main->Add(m_filament_panel, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(15));
|
||||
m_sizer_main->Add(m_sizer_filament_2extruder, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(15));
|
||||
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6));
|
||||
m_sizer_main->Add(m_statictext_ams_msg, 0, wxLEFT, 0);
|
||||
m_sizer_main->Add(m_statictext_ams_msg, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(15));
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(16));
|
||||
m_sizer_main->Add(sizer_split_options, 1, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15));
|
||||
m_sizer_main->Add(m_sizer_options, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT| wxRIGHT, FromDIP(15));
|
||||
|
@ -2081,9 +2083,7 @@ void SelectMachineDialog::update_ams_status_msg(wxString msg, bool is_warning)
|
|||
if (str_new != str_old) {
|
||||
if (m_statictext_ams_msg->GetLabel() != msg) {
|
||||
m_statictext_ams_msg->SetLabel(msg);
|
||||
m_statictext_ams_msg->SetMinSize(wxSize(FromDIP(400), -1));
|
||||
m_statictext_ams_msg->SetMaxSize(wxSize(FromDIP(400), -1));
|
||||
m_statictext_ams_msg->Wrap(FromDIP(400));
|
||||
m_statictext_ams_msg->Wrap(FromDIP(600));
|
||||
m_statictext_ams_msg->Show();
|
||||
Layout();
|
||||
Fit();
|
||||
|
@ -4178,7 +4178,8 @@ void SelectMachineDialog::reset_and_sync_ams_list()
|
|||
m_mapping_popup.set_parent_item(item);
|
||||
m_mapping_popup.set_current_filament_id(extruder);
|
||||
m_mapping_popup.set_tag_texture(materials[extruder]);
|
||||
m_mapping_popup.update_ams_data(obj_->amsList);
|
||||
m_mapping_popup.update(obj_);
|
||||
m_mapping_popup.set_send_win(this);
|
||||
m_mapping_popup.Popup();
|
||||
}
|
||||
}
|
||||
|
@ -4607,7 +4608,7 @@ void SelectMachineDialog::set_default_from_sdcard()
|
|||
m_mapping_popup.set_parent_item(item);
|
||||
m_mapping_popup.set_current_filament_id(fo.id);
|
||||
m_mapping_popup.set_tag_texture(fo.type);
|
||||
m_mapping_popup.update_ams_data(obj_->amsList);
|
||||
m_mapping_popup.update(obj_);
|
||||
m_mapping_popup.Popup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2613,7 +2613,8 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
m_ams_control->show_auto_refill(true);
|
||||
}
|
||||
|
||||
if (is_support_virtual_tray) m_ams_control->update_vams_kn_value(obj->vt_tray, obj);
|
||||
|
||||
if (is_support_virtual_tray) m_ams_control->update_vams_kn_value(obj->vt_slot[0], obj);
|
||||
if (m_filament_setting_dlg) m_filament_setting_dlg->update();
|
||||
|
||||
std::vector<AMSinfo> ams_info;
|
||||
|
@ -2637,11 +2638,11 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
std::string curr_ams_id = m_ams_control->GetCurentAms();
|
||||
std::string curr_can_id = m_ams_control->GetCurrentCan(curr_ams_id);
|
||||
bool is_vt_tray = false;
|
||||
if (obj->m_tray_tar == std::to_string(VIRTUAL_TRAY_ID))
|
||||
if (obj->m_tray_tar == std::to_string(VIRTUAL_TRAY_MAIN_ID))
|
||||
is_vt_tray = true;
|
||||
|
||||
// set segment 1, 2
|
||||
if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_ID) ) {
|
||||
if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_MAIN_ID) ) {
|
||||
m_ams_control->SetAmsStep(obj->m_ams_id, obj->m_tray_id, AMSPassRoadType::AMS_ROAD_TYPE_UNLOAD, AMSPassRoadSTEP::AMS_ROAD_STEP_NONE);
|
||||
}
|
||||
else {
|
||||
|
@ -2657,8 +2658,8 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
}
|
||||
|
||||
// set segment 3
|
||||
if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_ID)) {
|
||||
m_ams_control->SetExtruder(obj->is_filament_at_extruder(), true, obj->m_ams_id, obj->vt_tray.get_color());
|
||||
if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
m_ams_control->SetExtruder(obj->is_filament_at_extruder(), true, obj->m_ams_id, obj->vt_slot[0].get_color());
|
||||
} else {
|
||||
m_ams_control->SetExtruder(obj->is_filament_at_extruder(), false, obj->m_ams_id, m_ams_control->GetCanColour(obj->m_ams_id, obj->m_tray_id));
|
||||
}
|
||||
|
@ -2666,7 +2667,7 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
if (obj->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE) {
|
||||
update_filament_step();
|
||||
|
||||
if (obj->m_tray_tar == std::to_string(VIRTUAL_TRAY_ID) && (obj->m_tray_now != std::to_string(VIRTUAL_TRAY_ID) || obj->m_tray_now != "255")) {
|
||||
if (obj->m_tray_tar == std::to_string(VIRTUAL_TRAY_MAIN_ID) && (obj->m_tray_now != std::to_string(VIRTUAL_TRAY_MAIN_ID) || obj->m_tray_now != "255")) {
|
||||
// wait to heat hotend
|
||||
if (obj->ams_status_sub == 0x02) {
|
||||
m_ams_control->SetFilamentStep(FilamentStep::STEP_HEAT_NOZZLE, FilamentStepType::STEP_TYPE_VT_LOAD);
|
||||
|
@ -2773,7 +2774,7 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
}
|
||||
|
||||
bool is_curr_tray_selected = false;
|
||||
if (!curr_ams_id.empty() && !curr_can_id.empty() && (curr_ams_id != std::to_string(VIRTUAL_TRAY_ID)) ) {
|
||||
if (!curr_ams_id.empty() && !curr_can_id.empty() && (curr_ams_id != std::to_string(VIRTUAL_TRAY_MAIN_ID)) ) {
|
||||
if (curr_can_id == obj->m_tray_now) {
|
||||
is_curr_tray_selected = true;
|
||||
}
|
||||
|
@ -2793,7 +2794,7 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
is_curr_tray_selected = true;
|
||||
}
|
||||
}
|
||||
}else if (curr_ams_id == std::to_string(VIRTUAL_TRAY_ID)) {
|
||||
}else if (curr_ams_id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
if (curr_ams_id == obj->m_tray_now) {
|
||||
is_curr_tray_selected = true;
|
||||
}
|
||||
|
@ -2868,7 +2869,7 @@ void StatusPanel::update_ams_control_state(bool is_curr_tray_selected)
|
|||
enable[ACTION_BTN_LOAD] = true;
|
||||
enable[ACTION_BTN_UNLOAD] = false;
|
||||
}
|
||||
else if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_ID)) {
|
||||
else if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
enable[ACTION_BTN_LOAD] = false;
|
||||
enable[ACTION_BTN_UNLOAD] = true;
|
||||
}
|
||||
|
@ -2877,7 +2878,7 @@ void StatusPanel::update_ams_control_state(bool is_curr_tray_selected)
|
|||
|
||||
}
|
||||
else {
|
||||
if (obj->is_in_printing() /*&& obj->can_resume() && obj->m_tray_now != std::to_string(VIRTUAL_TRAY_ID) */) {
|
||||
if (obj->is_in_printing() /*&& obj->can_resume() && obj->m_tray_now != std::to_string(VIRTUAL_TRAY_MAIN_ID) */) {
|
||||
|
||||
if (!obj->can_resume()) {
|
||||
enable[ACTION_BTN_LOAD] = false;
|
||||
|
@ -2886,7 +2887,7 @@ void StatusPanel::update_ams_control_state(bool is_curr_tray_selected)
|
|||
else {
|
||||
if (obj->m_tray_now == "255") {
|
||||
|
||||
if ( m_ams_control->GetCurentAms() == std::to_string(VIRTUAL_TRAY_ID) ) {
|
||||
if ( m_ams_control->GetCurentAms() == std::to_string(VIRTUAL_TRAY_MAIN_ID) ) {
|
||||
enable[ACTION_BTN_LOAD] = true;
|
||||
enable[ACTION_BTN_UNLOAD] = false;
|
||||
}
|
||||
|
@ -2895,8 +2896,8 @@ void StatusPanel::update_ams_control_state(bool is_curr_tray_selected)
|
|||
enable[ACTION_BTN_UNLOAD] = false;
|
||||
}
|
||||
}
|
||||
else if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_ID)) {
|
||||
if (m_ams_control->GetCurentAms() == std::to_string(VIRTUAL_TRAY_ID)) {
|
||||
else if (obj->m_tray_now == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
if (m_ams_control->GetCurentAms() == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
enable[ACTION_BTN_LOAD] = false;
|
||||
enable[ACTION_BTN_UNLOAD] = true;
|
||||
}
|
||||
|
@ -3505,23 +3506,23 @@ void StatusPanel::on_ams_load_curr()
|
|||
|
||||
update_filament_step();
|
||||
//virtual tray
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
int old_temp = -1;
|
||||
int new_temp = -1;
|
||||
AmsTray* curr_tray = &obj->vt_tray;
|
||||
AmsTray* curr_tray = &obj->vt_slot[0];
|
||||
|
||||
if (!curr_tray) return;
|
||||
|
||||
try {
|
||||
if (!curr_tray->nozzle_temp_max.empty() && !curr_tray->nozzle_temp_min.empty())
|
||||
old_temp = (atoi(curr_tray->nozzle_temp_min.c_str()) + atoi(curr_tray->nozzle_temp_max.c_str())) / 2;
|
||||
if (!obj->vt_tray.nozzle_temp_max.empty() && !obj->vt_tray.nozzle_temp_min.empty())
|
||||
new_temp = (atoi(obj->vt_tray.nozzle_temp_min.c_str()) + atoi(obj->vt_tray.nozzle_temp_max.c_str())) / 2;
|
||||
if (!obj->vt_slot[0].nozzle_temp_max.empty() && !obj->vt_slot[0].nozzle_temp_min.empty())
|
||||
new_temp = (atoi(obj->vt_slot[0].nozzle_temp_min.c_str()) + atoi(obj->vt_slot[0].nozzle_temp_max.c_str())) / 2;
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
obj->command_ams_switch(VIRTUAL_TRAY_ID, old_temp, new_temp);
|
||||
obj->command_ams_switch(VIRTUAL_TRAY_MAIN_ID, old_temp, new_temp);
|
||||
}
|
||||
|
||||
std::map<std::string, Ams*>::iterator it = obj->amsList.find(curr_ams_id);
|
||||
|
@ -3561,7 +3562,7 @@ void StatusPanel::on_ams_load_curr()
|
|||
void StatusPanel::on_ams_load_vams(wxCommandEvent& event) {
|
||||
BOOST_LOG_TRIVIAL(info) << "on_ams_load_vams_tray";
|
||||
|
||||
m_ams_control->SwitchAms(std::to_string(VIRTUAL_TRAY_ID));
|
||||
m_ams_control->SwitchAms(std::to_string(VIRTUAL_TRAY_MAIN_ID));
|
||||
on_ams_load_curr();
|
||||
if (m_print_error_dlg) {
|
||||
m_print_error_dlg->on_hide();
|
||||
|
@ -3618,7 +3619,7 @@ void StatusPanel::on_filament_extrusion_cali(wxCommandEvent &event)
|
|||
m_extrusion_cali_dlg->obj = obj;
|
||||
std::string ams_id = m_ams_control->GetCurentAms();
|
||||
std::string tray_id = m_ams_control->GetCurrentCan(ams_id);
|
||||
if (tray_id.empty() && ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) != 0) {
|
||||
if (tray_id.empty() && ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) != 0) {
|
||||
wxString txt = _L("Please select an AMS slot before calibration");
|
||||
MessageDialog msg_dlg(nullptr, txt, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
|
@ -3630,8 +3631,8 @@ void StatusPanel::on_filament_extrusion_cali(wxCommandEvent &event)
|
|||
|
||||
|
||||
// set ams_filament id is is bbl filament
|
||||
if (ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
|
||||
tray_id_int = VIRTUAL_TRAY_ID;
|
||||
if (ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
tray_id_int = VIRTUAL_TRAY_MAIN_ID;
|
||||
m_extrusion_cali_dlg->ams_filament_id = "";
|
||||
}
|
||||
else {
|
||||
|
@ -3676,14 +3677,14 @@ void StatusPanel::on_filament_edit(wxCommandEvent &event)
|
|||
std::string ams_id = m_ams_control->GetCurentAms();
|
||||
int ams_id_int = 0;
|
||||
int tray_id_int = 0;
|
||||
if (ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
|
||||
tray_id_int = VIRTUAL_TRAY_ID;
|
||||
if (ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
tray_id_int = VIRTUAL_TRAY_MAIN_ID;
|
||||
m_filament_setting_dlg->ams_id = ams_id_int;
|
||||
m_filament_setting_dlg->tray_id = tray_id_int;
|
||||
wxString k_val;
|
||||
wxString n_val;
|
||||
k_val = wxString::Format("%.3f", obj->vt_tray.k);
|
||||
n_val = wxString::Format("%.3f", obj->vt_tray.n);
|
||||
k_val = wxString::Format("%.3f", obj->vt_slot[0].k);
|
||||
n_val = wxString::Format("%.3f", obj->vt_slot[0].n);
|
||||
m_filament_setting_dlg->Move(wxPoint(current_position_x, current_position_y));
|
||||
m_filament_setting_dlg->Popup(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString, k_val, n_val);
|
||||
} else {
|
||||
|
@ -3757,18 +3758,23 @@ void StatusPanel::on_ext_spool_edit(wxCommandEvent &event)
|
|||
if (obj) {
|
||||
m_filament_setting_dlg->obj = obj;
|
||||
try {
|
||||
m_filament_setting_dlg->tray_id = VIRTUAL_TRAY_ID;
|
||||
m_filament_setting_dlg->tray_id = VIRTUAL_TRAY_MAIN_ID;
|
||||
std::string sn_number;
|
||||
std::string filament;
|
||||
std::string temp_max;
|
||||
std::string temp_min;
|
||||
wxString k_val;
|
||||
wxString n_val;
|
||||
k_val = wxString::Format("%.3f", obj->vt_tray.k);
|
||||
n_val = wxString::Format("%.3f", obj->vt_tray.n);
|
||||
wxColor color = AmsTray::decode_color(obj->vt_tray.color);
|
||||
m_filament_setting_dlg->ams_filament_id = obj->vt_tray.setting_id;
|
||||
k_val = wxString::Format("%.3f", obj->vt_slot[0].k);
|
||||
n_val = wxString::Format("%.3f", obj->vt_slot[0].n);
|
||||
wxColor color = AmsTray::decode_color(obj->vt_slot[0].color);
|
||||
m_filament_setting_dlg->ams_filament_id = obj->vt_slot[0].setting_id;
|
||||
|
||||
std::vector<wxColour> cols;
|
||||
for (auto col : obj->vt_slot[0].cols) {
|
||||
cols.push_back(AmsTray::decode_color(col));
|
||||
}
|
||||
m_filament_setting_dlg->set_ctype(obj->vt_slot[0].ctype);
|
||||
|
||||
if (m_filament_setting_dlg->ams_filament_id.empty()) {
|
||||
m_filament_setting_dlg->set_empty_color(color);
|
||||
|
@ -3777,12 +3783,12 @@ void StatusPanel::on_ext_spool_edit(wxCommandEvent &event)
|
|||
m_filament_setting_dlg->set_color(color);
|
||||
}
|
||||
|
||||
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(obj->vt_tray.tag_uid);
|
||||
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(obj->vt_slot[0].tag_uid);
|
||||
if (!m_filament_setting_dlg->m_is_third) {
|
||||
sn_number = obj->vt_tray.uuid;
|
||||
filament = obj->vt_tray.sub_brands;
|
||||
temp_max = obj->vt_tray.nozzle_temp_max;
|
||||
temp_min = obj->vt_tray.nozzle_temp_min;
|
||||
sn_number = obj->vt_slot[0].uuid;
|
||||
filament = obj->vt_slot[0].sub_brands;
|
||||
temp_max = obj->vt_slot[0].nozzle_temp_max;
|
||||
temp_min = obj->vt_slot[0].nozzle_temp_min;
|
||||
}
|
||||
|
||||
m_filament_setting_dlg->Move(wxPoint(current_position_x,current_position_y));
|
||||
|
@ -3809,8 +3815,8 @@ void StatusPanel::on_ams_refresh_rfid(wxCommandEvent &event)
|
|||
}
|
||||
|
||||
std::string curr_ams_id = m_ams_control->GetCurentAms();
|
||||
// do not support refresh rfid for VIRTUAL_TRAY_ID
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
|
||||
// do not support refresh rfid for VIRTUAL_TRAY_MAIN_ID
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
return;
|
||||
}
|
||||
std::string curr_can_id = event.GetString().ToStdString();
|
||||
|
@ -3839,7 +3845,7 @@ void StatusPanel::on_ams_selected(wxCommandEvent &event)
|
|||
{
|
||||
if (obj) {
|
||||
std::string curr_ams_id = m_ams_control->GetCurentAms();
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
|
||||
if (curr_ams_id.compare(std::to_string(VIRTUAL_TRAY_MAIN_ID)) == 0) {
|
||||
//update_ams_control_state(curr_ams_id, true);
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -2651,7 +2651,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
m_panel_virtual->SetMaxSize(wxSize(AMS_CAN_LIB_SIZE.x + FromDIP(16), AMS_CANS_SIZE.y));
|
||||
|
||||
m_vams_info.material_state = AMSCanType::AMS_CAN_TYPE_VIRTUAL;
|
||||
m_vams_info.can_id = wxString::Format("%d", VIRTUAL_TRAY_ID).ToStdString();
|
||||
m_vams_info.can_id = wxString::Format("%d", VIRTUAL_TRAY_MAIN_ID).ToStdString();
|
||||
|
||||
auto vams_panel = new wxWindow(m_panel_virtual, wxID_ANY);
|
||||
vams_panel->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR);
|
||||
|
@ -3516,7 +3516,7 @@ void AMSControl::SwitchAms(std::string ams_id)
|
|||
{
|
||||
if(ams_id == m_current_show_ams){return;}
|
||||
|
||||
if (ams_id != std::to_string(VIRTUAL_TRAY_ID)) {
|
||||
if (ams_id != std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
|
||||
if (m_current_show_ams != ams_id) {
|
||||
m_current_show_ams = ams_id;
|
||||
m_extruder->OnAmsLoading(false);
|
||||
|
@ -3554,7 +3554,7 @@ void AMSControl::SwitchAms(std::string ams_id)
|
|||
}
|
||||
|
||||
if (!ready_selected) {
|
||||
m_current_ams = std::to_string(VIRTUAL_TRAY_ID);
|
||||
m_current_ams = std::to_string(VIRTUAL_TRAY_MAIN_ID);
|
||||
m_vams_lib->OnSelected();
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue