ENH:Support more SD card states
jira:[for sdcard] Change-Id: Ic09198a0ed357f827768ed2f8d8a9ed6266f749f
This commit is contained in:
parent
e0508a9e51
commit
c877405cab
|
@ -1484,6 +1484,8 @@ void MachineObject::parse_status(int flag)
|
|||
camera_recording = ((flag >> 5) & 0x1) != 0;
|
||||
ams_calibrate_remain_flag = ((flag >> 7) & 0x1) != 0;
|
||||
|
||||
sdcard_state = MachineObject::SdcardState(get_flag_bits(flag, 8, 2));
|
||||
|
||||
if (ams_print_option_count > 0)
|
||||
ams_print_option_count--;
|
||||
else {
|
||||
|
@ -1536,8 +1538,6 @@ void MachineObject::parse_status(int flag)
|
|||
is_support_upgrade_kit = ((flag >> 27) & 0x1) != 0;
|
||||
installed_upgrade_kit = ((flag >> 26) & 0x1) != 0;
|
||||
|
||||
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);
|
||||
|
||||
is_support_agora = ((flag >> 30) & 0x1) != 0;
|
||||
if (is_support_agora)
|
||||
is_support_tunnel_mqtt = false;
|
||||
|
@ -1586,11 +1586,6 @@ bool MachineObject::is_sdcard_printing()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool MachineObject::has_sdcard()
|
||||
{
|
||||
return (sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL);
|
||||
}
|
||||
|
||||
MachineObject::SdcardState MachineObject::get_sdcard_state()
|
||||
{
|
||||
return sdcard_state;
|
||||
|
@ -3382,6 +3377,16 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
if (jj["print_error"].is_number())
|
||||
print_error = jj["print_error"].get<int>();
|
||||
}
|
||||
|
||||
if (jj.contains("sdcard")) {
|
||||
if (jj["sdcard"].get<bool>())
|
||||
sdcard_state = MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
else
|
||||
sdcard_state = MachineObject::SdcardState::NO_SDCARD;
|
||||
} else {
|
||||
sdcard_state = MachineObject::SdcardState::NO_SDCARD;
|
||||
}
|
||||
|
||||
if (!key_field_only) {
|
||||
if (jj.contains("home_flag")) {
|
||||
home_flag = jj["home_flag"].get<int>();
|
||||
|
@ -3748,21 +3753,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
catch (...) {
|
||||
;
|
||||
}
|
||||
// media
|
||||
try {
|
||||
if (jj.contains("sdcard")) {
|
||||
if (jj["sdcard"].get<bool>())
|
||||
sdcard_state = MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
else
|
||||
sdcard_state = MachineObject::SdcardState::NO_SDCARD;
|
||||
} else {
|
||||
//do not check sdcard if no sdcard field
|
||||
sdcard_state = MachineObject::SdcardState::NO_SDCARD;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
if (!key_field_only) {
|
||||
|
|
|
@ -523,7 +523,8 @@ public:
|
|||
NO_SDCARD = 0,
|
||||
HAS_SDCARD_NORMAL = 1,
|
||||
HAS_SDCARD_ABNORMAL = 2,
|
||||
SDCARD_STATE_NUM = 3
|
||||
HAS_SDCARD_READONLY = 3,
|
||||
SDCARD_STATE_NUM = 4
|
||||
};
|
||||
|
||||
enum ActiveState {
|
||||
|
@ -980,7 +981,6 @@ public:
|
|||
std::string obj_subtask_id; // subtask_id == 0 for sdcard
|
||||
std::string subtask_name;
|
||||
bool is_sdcard_printing();
|
||||
bool has_sdcard();
|
||||
bool is_timelapse();
|
||||
bool is_recording_enable();
|
||||
bool is_recording();
|
||||
|
|
|
@ -72,7 +72,7 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
// File type
|
||||
StateColor background(
|
||||
std::make_pair(0xEEEEEE, (int) StateColor::Checked),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
m_type_panel = new ::StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
m_type_panel->SetBackgroundColor(*wxWHITE);
|
||||
|
@ -221,7 +221,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_lan_passwd = obj->get_access_code();
|
||||
m_dev_ver = obj->get_ota_version();
|
||||
m_device_busy = obj->is_camera_busy_off();
|
||||
m_sdcard_exist = obj->has_sdcard();
|
||||
m_sdcard_exist = obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL || obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_READONLY;
|
||||
m_local_proto = obj->file_local;
|
||||
m_remote_proto = obj->file_remote;
|
||||
m_model_download_support = obj->file_model_download;
|
||||
|
@ -341,7 +341,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
CallAfter([this, m = e.GetString()] {
|
||||
MessageDialog(this, m, _L("Download failed"), wxOK | wxICON_ERROR).ShowModal();
|
||||
});
|
||||
|
||||
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (result > 1 || result == 0) {
|
||||
json j;
|
||||
|
@ -539,16 +539,16 @@ void MediaFilePanel::doAction(size_t index, int action)
|
|||
auto fs = m_image_grid->GetFileSystem();
|
||||
if (action == 0) {
|
||||
if (index == -1) {
|
||||
MessageDialog dlg(this,
|
||||
MessageDialog dlg(this,
|
||||
wxString::Format(_L_PLURAL("You are going to delete %u file from printer. Are you sure to continue?",
|
||||
"You are going to delete %u files from printer. Are you sure to continue?", fs->GetSelectCount()),
|
||||
fs->GetSelectCount()),
|
||||
fs->GetSelectCount()),
|
||||
_L("Delete files"), wxYES_NO | wxICON_WARNING);
|
||||
if (dlg.ShowModal() != wxID_YES)
|
||||
return;
|
||||
} else {
|
||||
MessageDialog dlg(this,
|
||||
wxString::Format(_L("Do you want to delete the file '%s' from printer?"), from_u8(fs->GetFile(index).name)),
|
||||
MessageDialog dlg(this,
|
||||
wxString::Format(_L("Do you want to delete the file '%s' from printer?"), from_u8(fs->GetFile(index).name)),
|
||||
_L("Delete file"), wxYES_NO | wxICON_WARNING);
|
||||
if (dlg.ShowModal() != wxID_YES)
|
||||
return;
|
||||
|
@ -578,13 +578,13 @@ void MediaFilePanel::doAction(size_t index, int action)
|
|||
std::istringstream is(data);
|
||||
if (!Slic3r::load_gcode_3mf_from_stream(is, &config, &model, &plate_data_list, &file_version)
|
||||
|| plate_data_list.empty()) {
|
||||
MessageDialog(this,
|
||||
_L("Failed to parse model information."),
|
||||
MessageDialog(this,
|
||||
_L("Failed to parse model information."),
|
||||
_L("Print"), wxOK).ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto &file = fs->GetFile(index);
|
||||
|
||||
std::string file_path = file.path;
|
||||
|
@ -601,7 +601,7 @@ void MediaFilePanel::doAction(size_t index, int action)
|
|||
MessageDialog dlg(this, _L("The .gcode.3mf file contains no G-code data.Please slice it whth Bambu Studio and export a new .gcode.3mf file."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
auto res = dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -611,8 +611,8 @@ void MediaFilePanel::doAction(size_t index, int action)
|
|||
if (file.IsDownload() && file.DownloadProgress() >= -1) {
|
||||
if (!file.local_path.empty()) {
|
||||
if (!fs->DownloadCheckFile(index)) {
|
||||
MessageDialog(this,
|
||||
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
|
||||
MessageDialog(this,
|
||||
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
|
||||
_L("Error"), wxOK).ShowModal();
|
||||
Refresh();
|
||||
return;
|
||||
|
@ -637,8 +637,8 @@ void MediaFilePanel::doAction(size_t index, int action)
|
|||
if (file.IsDownload() && file.DownloadProgress() >= -1) {
|
||||
if (!file.local_path.empty()) {
|
||||
if (!fs->DownloadCheckFile(index)) {
|
||||
MessageDialog(this,
|
||||
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
|
||||
MessageDialog(this,
|
||||
wxString::Format(_L("File '%s' was lost! Please download it again."), from_u8(file.name)),
|
||||
_L("Error"), wxOK).ShowModal();
|
||||
Refresh();
|
||||
return;
|
||||
|
|
|
@ -181,7 +181,7 @@ MonitorPanel::~MonitorPanel()
|
|||
auto page = m_tabpanel->GetCurrentPage();
|
||||
if (page == m_media_file_panel) {
|
||||
auto title = m_tabpanel->GetPageText(m_tabpanel->GetSelection());
|
||||
m_media_file_panel->SwitchStorage(title == _L("SD Card"));
|
||||
m_media_file_panel->SwitchStorage(title == _L("Storage"));
|
||||
}
|
||||
page->SetFocus();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << " select :" << get_string_from_tab(PrinterTab(m_tabpanel->GetSelection()))
|
||||
|
@ -212,7 +212,7 @@ MonitorPanel::~MonitorPanel()
|
|||
m_tabpanel->AddPage(m_status_info_panel, _L("Status"), "", true);
|
||||
|
||||
m_media_file_panel = new MediaFilePanel(m_tabpanel);
|
||||
m_tabpanel->AddPage(m_media_file_panel, _L("SD Card"), "", false);
|
||||
m_tabpanel->AddPage(m_media_file_panel, _L("Storage"), "", false);
|
||||
//m_tabpanel->AddPage(m_media_file_panel, _L("Internal Storage"), "", false);
|
||||
|
||||
m_upgrade_panel = new UpgradePanel(m_tabpanel);
|
||||
|
@ -392,7 +392,7 @@ void MonitorPanel::update_all()
|
|||
m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj);
|
||||
m_media_file_panel->SetMachineObject(obj);
|
||||
m_side_tools->update_status(obj);
|
||||
|
||||
|
||||
if (!obj) {
|
||||
show_status((int)MONITOR_NO_PRINTER);
|
||||
m_hms_panel->clear_hms_tag();
|
||||
|
@ -468,7 +468,7 @@ bool MonitorPanel::Show(bool show)
|
|||
if (obj == nullptr) {
|
||||
dev->load_last_machine();
|
||||
obj = dev->get_selected_machine();
|
||||
if (obj)
|
||||
if (obj)
|
||||
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
|
||||
} else {
|
||||
obj->reset_update_time();
|
||||
|
@ -528,7 +528,7 @@ void MonitorPanel::show_status(int status)
|
|||
|
||||
BOOST_LOG_TRIVIAL(info) << "monitor: show_status = " << status;
|
||||
|
||||
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
m_upgrade_panel->update(nullptr);
|
||||
#endif
|
||||
|
@ -543,15 +543,15 @@ Freeze();
|
|||
if ((status & (int)MonitorStatus::MONITOR_NO_PRINTER) != 0) {
|
||||
set_default();
|
||||
m_tabpanel->Layout();
|
||||
} else if (((status & (int)MonitorStatus::MONITOR_NORMAL) != 0)
|
||||
|| ((status & (int)MonitorStatus::MONITOR_DISCONNECTED) != 0)
|
||||
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|
||||
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0) )
|
||||
} else if (((status & (int)MonitorStatus::MONITOR_NORMAL) != 0)
|
||||
|| ((status & (int)MonitorStatus::MONITOR_DISCONNECTED) != 0)
|
||||
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|
||||
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0) )
|
||||
{
|
||||
|
||||
if (((status & (int) MonitorStatus::MONITOR_DISCONNECTED) != 0)
|
||||
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|
||||
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0))
|
||||
if (((status & (int) MonitorStatus::MONITOR_DISCONNECTED) != 0)
|
||||
|| ((status & (int) MonitorStatus::MONITOR_DISCONNECTED_SERVER) != 0)
|
||||
|| ((status & (int)MonitorStatus::MONITOR_CONNECTING) != 0))
|
||||
{
|
||||
set_default();
|
||||
}
|
||||
|
|
|
@ -2354,7 +2354,7 @@ void SelectMachineDialog::on_send_print()
|
|||
m_print_job->task_ams_mapping_info = "";
|
||||
}
|
||||
|
||||
m_print_job->has_sdcard = obj_->has_sdcard();
|
||||
m_print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
|
||||
|
||||
bool timelapse_option = m_checkbox_list["timelapse"]->IsShown()?true:false;
|
||||
|
|
|
@ -571,7 +571,7 @@ BBL::PrintParams SendMultiMachinePage::request_params(MachineObject* obj)
|
|||
params.comments = "no_ip";
|
||||
else if (obj->is_support_cloud_print_only)
|
||||
params.comments = "low_version";
|
||||
else if (!obj->has_sdcard())
|
||||
else if (obj->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)
|
||||
params.comments = "no_sdcard";
|
||||
else if (params.password.empty())
|
||||
params.comments = "no_password";
|
||||
|
|
|
@ -199,7 +199,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
|
|||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
|
||||
m_scrollable_region = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_panel_image = new wxPanel(m_scrollable_region, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_panel_image->SetBackgroundColour(m_colour_def_color);
|
||||
|
@ -611,7 +611,7 @@ void SendToPrinterDialog::prepare(int print_plate_idx)
|
|||
m_print_plate_idx = print_plate_idx;
|
||||
}
|
||||
|
||||
void SendToPrinterDialog::update_priner_status_msg(wxString msg, bool is_warning)
|
||||
void SendToPrinterDialog::update_priner_status_msg(wxString msg, bool is_warning)
|
||||
{
|
||||
auto colour = is_warning ? wxColour(0xFF, 0x6F, 0x00) : wxColour(0x6B, 0x6B, 0x6B);
|
||||
m_statictext_printer_msg->SetForegroundColour(colour);
|
||||
|
@ -678,7 +678,7 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
|
|||
}
|
||||
this->EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
|
||||
void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: on_ok to send";
|
||||
|
@ -696,7 +696,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||
if (!dev) return;
|
||||
|
||||
MachineObject *obj_ = dev->get_selected_machine();
|
||||
|
||||
|
||||
if (obj_ == nullptr) {
|
||||
m_printer_last_select = "";
|
||||
m_comboBox_printer->SetTextLabel("");
|
||||
|
@ -773,7 +773,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||
fs::path default_output_file_path = boost::filesystem::path(default_output_file.c_str());
|
||||
file_name = default_output_file_path.filename().string();
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
m_send_job = std::make_shared<SendJob>(m_status_bar, m_plater, m_printer_last_select);
|
||||
|
@ -791,9 +791,9 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||
|
||||
m_send_job->connection_type = obj_->connection_type();
|
||||
m_send_job->cloud_print_only = true;
|
||||
m_send_job->has_sdcard = obj_->has_sdcard();
|
||||
m_send_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
m_send_job->set_project_name(m_current_project_name.utf8_string());
|
||||
|
||||
|
||||
enable_prepare_mode = false;
|
||||
|
||||
m_send_job->on_check_ip_address_fail([this](int result) {
|
||||
|
@ -1300,7 +1300,7 @@ void SendToPrinterDialog::set_default()
|
|||
m_comboBox_printer->Enable();
|
||||
// rset status bar
|
||||
m_status_bar->reset();
|
||||
|
||||
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent) {
|
||||
if (agent->is_user_login()) {
|
||||
|
@ -1327,7 +1327,7 @@ void SendToPrinterDialog::set_default()
|
|||
image = image.Rescale(FromDIP(256), FromDIP(256));
|
||||
m_thumbnailPanel->set_thumbnail(image);
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> materials;
|
||||
std::vector<std::string> display_materials;
|
||||
{
|
||||
|
@ -1349,7 +1349,7 @@ void SendToPrinterDialog::set_default()
|
|||
Layout();
|
||||
Fit();
|
||||
|
||||
|
||||
|
||||
wxSize screenSize = wxGetDisplaySize();
|
||||
auto dialogSize = this->GetSize();
|
||||
|
||||
|
|
|
@ -1217,7 +1217,7 @@ wxBoxSizer *StatusBasePanel::create_monitoring_page()
|
|||
m_setting_button->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
|
||||
m_setting_button->SetBackgroundColour(STATUS_TITLE_BG);
|
||||
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("SD Card"));
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("Storage"));
|
||||
m_bitmap_timelapse_img->SetToolTip(_L("Timelapse"));
|
||||
m_bitmap_recording_img->SetToolTip(_L("Video"));
|
||||
m_bitmap_vcamera_img->SetToolTip(_L("Go Live"));
|
||||
|
@ -1903,16 +1903,16 @@ void StatusPanel::update_camera_state(MachineObject* obj)
|
|||
if (m_last_sdcard != (int)obj->get_sdcard_state()) {
|
||||
if (obj->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) {
|
||||
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_no.bmp());
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("No SD Card"));
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("No Storage"));
|
||||
} else if (obj->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL) {
|
||||
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_normal.bmp());
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("SD Card"));
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("Storage"));
|
||||
} else if (obj->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL) {
|
||||
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_abnormal.bmp());
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("SD Card Abnormal"));
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("Storage Abnormal"));
|
||||
} else {
|
||||
m_bitmap_sdcard_img->SetBitmap(m_bitmap_sdcard_state_normal.bmp());
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("SD Card"));
|
||||
m_bitmap_sdcard_img->SetToolTip(_L("Storage"));
|
||||
}
|
||||
m_last_sdcard = (int)obj->get_sdcard_state();
|
||||
}
|
||||
|
|
|
@ -1318,7 +1318,7 @@ void CalibUtils::send_to_print(const CalibInfo &calib_info, wxString &error_mess
|
|||
print_job->m_project_name = get_calib_mode_name(cali_mode, flow_ratio_mode);
|
||||
print_job->set_calibration_task(true);
|
||||
|
||||
print_job->has_sdcard = obj_->has_sdcard();
|
||||
print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
print_job->set_print_config(MachineBedTypeString[bed_type], true, false, false, false, true, 0, 0, 0);
|
||||
print_job->set_print_job_finished_event(wxGetApp().plater()->get_send_calibration_finished_event(), print_job->m_project_name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue