NEW:support the display of profile info in the mall model

Change-Id: Idab6bb5a4ef50df665ab7c8e5891efc5a8253eba
This commit is contained in:
tao wang 2023-04-24 16:59:45 +08:00 committed by Lane.Wei
parent 3fb007aedb
commit a64e0b2f82
10 changed files with 156 additions and 4 deletions

View file

@ -384,6 +384,7 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
dev_id(id),
dev_ip(ip),
subtask_(nullptr),
model_task(nullptr),
slice_info(nullptr),
m_is_online(false),
vt_tray(std::to_string(VIRTUAL_TRAY_ID))
@ -449,6 +450,11 @@ MachineObject::~MachineObject()
subtask_ = nullptr;
}
if (model_task) {
delete model_task;
model_task = nullptr;
}
if (get_slice_info_thread) {
if (get_slice_info_thread->joinable()) {
get_slice_info_thread->join();
@ -3689,6 +3695,16 @@ BBLSubTask* MachineObject::get_subtask()
return subtask_;
}
BBLModelTask* MachineObject::get_modeltask()
{
return model_task;
}
void MachineObject::set_modeltask(BBLModelTask* task)
{
model_task = task;
}
void MachineObject::update_slice_info(std::string project_id, std::string profile_id, std::string subtask_id, int plate_idx)
{
if (!m_agent) return;

View file

@ -678,6 +678,7 @@ public:
std::string m_gcode_file;
int gcode_file_prepare_percent = 0;
BBLSubTask* subtask_;
BBLModelTask* model_task;
std::string obj_subtask_id; // subtask_id == 0 for sdcard
std::string subtask_name;
bool is_sdcard_printing();
@ -793,6 +794,8 @@ public:
int publish_gcode(std::string gcode_str);
BBLSubTask* get_subtask();
BBLModelTask* get_modeltask();
void set_modeltask(BBLModelTask* task);
void update_slice_info(std::string project_id, std::string profile_id, std::string subtask_id, int plate_idx);
bool m_firmware_valid { false };

View file

@ -191,8 +191,8 @@ void PrintJob::process()
params.dev_id = m_dev_id;
params.ftp_folder = m_ftp_folder;
//params.project_name = project_name;
params.project_name = m_project_name;
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
params.filename = job_data._3mf_path.string();
params.config_filename = job_data._3mf_config_path.string();
params.plate_index = curr_plate_idx;
@ -222,6 +222,26 @@ void PrintJob::process()
}
catch(...) {}
}
auto profile_name = model_info->metadata_items.find(BBL_DESIGNER_PROFILE_TITLE_TAG);
if (profile_name != model_info->metadata_items.end()) {
try {
params.preset_name = profile_name->second;
}
catch (...) {}
}
auto model_name = model_info->metadata_items.find(BBL_DESIGNER_MODEL_TITLE_TAG);
if (model_name != model_info->metadata_items.end()) {
try {
params.project_name = model_name->second;
}
catch (...) {}
}
}
else {
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
params.project_name = m_project_name;
}
wxString error_text;

View file

@ -389,6 +389,17 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
m_printing_stage_value->SetForegroundColour(STAGE_TEXT_COL);
m_staticText_profile_value = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT | wxST_ELLIPSIZE_END);
m_staticText_profile_value->Wrap(-1);
#ifdef __WXOSX_MAC__
m_staticText_profile_value->SetFont(::Label::Body_11);
#else
m_staticText_profile_value->SetFont(wxFont(11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
#endif
m_staticText_profile_value->SetForegroundColour(0x6B6B6B);
auto m_panel_progress = new wxPanel(parent, wxID_ANY);
m_panel_progress->SetBackgroundColour(*wxWHITE);
auto m_sizer_progressbar = new wxBoxSizer(wxHORIZONTAL);
@ -534,6 +545,7 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
bSizer_subtask_info->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14));
bSizer_subtask_info->Add(bSizer_task_name, 0, wxEXPAND|wxRIGHT, FromDIP(18));
bSizer_subtask_info->Add(m_staticText_profile_value, 0, wxEXPAND | wxTOP, FromDIP(5));
bSizer_subtask_info->Add(m_printing_stage_value, 0, wxEXPAND | wxTOP, FromDIP(5));
bSizer_subtask_info->Add(penel_bottons, 0, wxEXPAND | wxTOP, FromDIP(10));
bSizer_subtask_info->Add(m_panel_progress, 0, wxEXPAND|wxRIGHT, FromDIP(25));
@ -2264,6 +2276,26 @@ void StatusPanel::update_basic_print_data(bool def)
}
}
void StatusPanel::update_model_info()
{
if (wxGetApp().getAgent() && obj) {
BBLSubTask* curr_task = obj->get_subtask();
if (curr_task) {
BBLModelTask* curr_model_task = obj->get_modeltask();
if (!curr_model_task) {
curr_model_task = new BBLModelTask();
curr_model_task->task_id = curr_task->task_id;
int result = wxGetApp().getAgent()->get_subtask(curr_model_task);
if (result > -1) {
obj->set_modeltask(curr_model_task);
}
}
}
}
}
void StatusPanel::update_subtask(MachineObject *obj)
{
if (!obj) return;
@ -2275,6 +2307,8 @@ void StatusPanel::update_subtask(MachineObject *obj)
m_staticText_layers->Hide();
}
update_model_info();
if (obj->is_system_printing()
|| obj->is_in_calibration()) {
reset_printing_values();
@ -2307,6 +2341,17 @@ void StatusPanel::update_subtask(MachineObject *obj)
m_staticText_layers->SetLabelText(wxString::Format(_L("Layer: %s"), NA_STR));
wxString subtask_text = wxString::Format("%s", GUI::from_u8(obj->subtask_name));
m_staticText_subtask_value->SetLabelText(subtask_text);
if (obj->get_modeltask() && obj->get_modeltask()->design_id > 0) {
if(!m_staticText_profile_value->IsShown()){ m_staticText_profile_value->Show();}
m_staticText_profile_value->SetLabelText(obj->get_modeltask()->profile_name);
}
else {
m_staticText_profile_value->SetLabelText(wxEmptyString);
m_staticText_profile_value->Hide();
}
update_basic_print_data(false);
} else {
if (obj->can_resume()) {
@ -2344,6 +2389,16 @@ void StatusPanel::update_subtask(MachineObject *obj)
}
wxString subtask_text = wxString::Format("%s", GUI::from_u8(obj->subtask_name));
m_staticText_subtask_value->SetLabelText(subtask_text);
if (obj->get_modeltask() && obj->get_modeltask()->design_id > 0) {
if(!m_staticText_profile_value->IsShown()){ m_staticText_profile_value->Show();}
m_staticText_profile_value->SetLabelText(obj->get_modeltask()->profile_name);
}
else {
m_staticText_profile_value->SetLabelText(wxEmptyString);
m_staticText_profile_value->Hide();
}
//update thumbnail
if (obj->is_sdcard_printing()) {
update_basic_print_data(false);
@ -2365,6 +2420,7 @@ void StatusPanel::update_cloud_subtask(MachineObject *obj)
if (!obj->subtask_) return;
if (is_task_changed(obj)) {
obj->set_modeltask(nullptr);
reset_printing_values();
BOOST_LOG_TRIVIAL(info) << "monitor: change to sub task id = " << obj->subtask_->task_id;
if (web_request.IsOk() && web_request.GetState() == wxWebRequest::State_Active) {
@ -2418,6 +2474,8 @@ void StatusPanel::reset_printing_values()
m_gauge_progress->SetValue(0);
m_staticText_subtask_value->SetLabelText(NA_STR);
m_staticText_profile_value->SetLabelText(wxEmptyString);
m_staticText_profile_value->Hide();
update_basic_print_data(false);
m_printing_stage_value->SetLabelText("");
m_staticText_progress_left->SetLabelText(NA_STR);

View file

@ -134,6 +134,7 @@ protected:
wxStaticBitmap *m_bitmap_thumbnail;
wxStaticText * m_staticText_subtask_value;
wxStaticText * m_printing_stage_value;
wxStaticText * m_staticText_profile_value;
ProgressBar* m_gauge_progress;
wxStaticText * m_staticText_progress_percent;
wxStaticText * m_staticText_progress_percent_icon;
@ -379,7 +380,8 @@ protected:
void show_printing_status(bool ctrl_area = true, bool temp_area = true);
void update_left_time(int mc_left_time);
void update_basic_print_data(bool def = false);
void update_subtask(MachineObject *obj);
void update_model_info();
void update_subtask(MachineObject* obj);
void update_cloud_subtask(MachineObject *obj);
void update_sdcard_subtask(MachineObject *obj);
void update_temp_ctrl(MachineObject *obj);