NEW:support the display of profile info in the mall model
Change-Id: Idab6bb5a4ef50df665ab7c8e5891efc5a8253eba
This commit is contained in:
parent
3fb007aedb
commit
a64e0b2f82
10 changed files with 156 additions and 4 deletions
|
@ -24,7 +24,9 @@ struct ThumbnailData;
|
|||
#define EMBEDDED_FILAMENT_FILE_FORMAT "Metadata/filament_settings_%1%.config"
|
||||
#define EMBEDDED_PRINTER_FILE_FORMAT "Metadata/machine_settings_%1%.config"
|
||||
|
||||
#define BBL_DESIGNER_MODEL_TITLE_TAG "Title"
|
||||
#define BBL_DESIGNER_PROFILE_ID_TAG "DesignProfileId"
|
||||
#define BBL_DESIGNER_PROFILE_TITLE_TAG "ProfileTitle"
|
||||
#define BBL_DESIGNER_MODEL_ID_TAG "DesignModelId"
|
||||
|
||||
|
||||
|
|
|
@ -185,4 +185,11 @@ namespace Slic3r {
|
|||
project_path.clear();
|
||||
}
|
||||
|
||||
BBLModelTask::BBLModelTask()
|
||||
{
|
||||
job_id = -1;
|
||||
design_id = -1;
|
||||
profile_id = -1;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace Slic3r {
|
|||
class BBLProject;
|
||||
class BBLProfile;
|
||||
class BBLTask;
|
||||
class BBLModelTask;
|
||||
|
||||
|
||||
enum MachineBedType {
|
||||
|
@ -95,6 +96,20 @@ enum TaskUserOptions {
|
|||
OPTIONS_RECORD_TIMELAPSE = 4
|
||||
};
|
||||
|
||||
class BBLModelTask {
|
||||
public:
|
||||
BBLModelTask();
|
||||
~BBLModelTask() {}
|
||||
|
||||
int job_id;
|
||||
int design_id;
|
||||
int profile_id;
|
||||
std::string task_id;
|
||||
std::string model_id;
|
||||
std::string model_name;
|
||||
std::string profile_name;
|
||||
};
|
||||
|
||||
class BBLSubTask {
|
||||
public:
|
||||
enum SubTaskStatus {
|
||||
|
@ -112,6 +127,7 @@ public:
|
|||
BBLSubTask(const BBLSubTask& obj) {
|
||||
task_id = obj.task_id;
|
||||
parent_id = obj.parent_id;
|
||||
task_model_id = obj.task_model_id;
|
||||
task_project_id = obj.task_project_id;
|
||||
task_profile_id = obj.task_profile_id;
|
||||
task_name = obj.task_name;
|
||||
|
@ -127,9 +143,14 @@ public:
|
|||
task_flow_cali = obj.task_flow_cali;
|
||||
task_vibration_cali = obj.task_vibration_cali;
|
||||
task_layer_inspect = obj.task_layer_inspect;
|
||||
|
||||
job_id = obj.job_id;
|
||||
origin_model_name = obj.origin_model_name;
|
||||
origin_profile_name = obj.origin_profile_name;
|
||||
}
|
||||
|
||||
std::string task_id; /* plate id */
|
||||
std::string task_model_id; /* model id */
|
||||
std::string task_project_id; /* project id */
|
||||
std::string task_profile_id; /* profile id*/
|
||||
std::string task_name; /* task name, generally filename as task name */
|
||||
|
@ -161,6 +182,10 @@ public:
|
|||
BBLTask* parent_task_;
|
||||
std::string parent_id;
|
||||
|
||||
int job_id;
|
||||
std::string origin_model_name;
|
||||
std::string origin_profile_name;
|
||||
|
||||
int parse_content_json(std::string json_str);
|
||||
static BBLSubTask::SubTaskStatus parse_status(std::string status);
|
||||
static BBLSubTask::SubTaskStatus parse_user_service_task_status(int status);
|
||||
|
@ -186,6 +211,7 @@ public:
|
|||
std::wstring task_dst_url; /* put task to dest url in machine */
|
||||
BBLProfile* profile_;
|
||||
std::string task_project_id;
|
||||
std::string task_model_id;
|
||||
std::string task_profile_id;
|
||||
std::vector<BBLSubTask*> subtasks;
|
||||
std::map<std::string, BBLSliceInfo*> slice_info; /* slice info of subtasks, key: plate idx, 1, 2, 3, etc... */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -98,6 +98,7 @@ func_get_profile_3mf NetworkAgent::get_profile_3mf_ptr = nullptr;
|
|||
func_get_model_publish_url NetworkAgent::get_model_publish_url_ptr = nullptr;
|
||||
func_get_model_mall_home_url NetworkAgent::get_model_mall_home_url_ptr = nullptr;
|
||||
func_get_model_mall_detail_url NetworkAgent::get_model_mall_detail_url_ptr = nullptr;
|
||||
func_get_subtask NetworkAgent::get_subtask_ptr = nullptr;
|
||||
func_get_my_profile NetworkAgent::get_my_profile_ptr = nullptr;
|
||||
func_track_enable NetworkAgent::track_enable_ptr = nullptr;
|
||||
func_track_event NetworkAgent::track_event_ptr = nullptr;
|
||||
|
@ -245,6 +246,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
start_publish_ptr = reinterpret_cast<func_start_pubilsh>(get_network_function("bambu_network_start_publish"));
|
||||
get_profile_3mf_ptr = reinterpret_cast<func_get_profile_3mf>(get_network_function("bambu_network_get_profile_3mf"));
|
||||
get_model_publish_url_ptr = reinterpret_cast<func_get_model_publish_url>(get_network_function("bambu_network_get_model_publish_url"));
|
||||
get_subtask_ptr = reinterpret_cast<func_get_subtask>(get_network_function("bambu_network_get_subtask"));
|
||||
get_model_mall_home_url_ptr = reinterpret_cast<func_get_model_mall_home_url>(get_network_function("bambu_network_get_model_mall_home_url"));
|
||||
get_model_mall_detail_url_ptr = reinterpret_cast<func_get_model_mall_detail_url>(get_network_function("bambu_network_get_model_mall_detail_url"));
|
||||
get_my_profile_ptr = reinterpret_cast<func_get_my_profile>(get_network_function("bambu_network_get_my_profile"));
|
||||
|
@ -347,8 +349,9 @@ int NetworkAgent::unload_network_module()
|
|||
start_publish_ptr = nullptr;
|
||||
get_profile_3mf_ptr = nullptr;
|
||||
get_model_publish_url_ptr = nullptr;
|
||||
get_subtask_ptr = nullptr;
|
||||
get_model_mall_home_url_ptr = nullptr;
|
||||
get_model_mall_detail_url_ptr = nullptr;
|
||||
get_model_mall_detail_url_ptr = nullptr;
|
||||
get_my_profile_ptr = nullptr;
|
||||
track_enable_ptr = nullptr;
|
||||
track_event_ptr = nullptr;
|
||||
|
@ -1137,6 +1140,18 @@ int NetworkAgent::get_model_publish_url(std::string* url)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_subtask(BBLModelTask* task)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && get_subtask_ptr) {
|
||||
ret = get_subtask_ptr(network_agent, task);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_model_mall_home_url(std::string* url)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef int (*func_get_design_staffpick)(void *agent, int offset, int limit, std
|
|||
typedef int (*func_start_pubilsh)(void *agent, PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
|
||||
typedef int (*func_get_profile_3mf)(void *agent, BBLProfile* profile);
|
||||
typedef int (*func_get_model_publish_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_subtask)(void *agent, BBLModelTask* task);
|
||||
typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_model_mall_detail_url)(void *agent, std::string* url, std::string id);
|
||||
typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body);
|
||||
|
@ -167,6 +168,7 @@ public:
|
|||
int start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
|
||||
int get_profile_3mf(BBLProfile* profile);
|
||||
int get_model_publish_url(std::string* url);
|
||||
int get_subtask(BBLModelTask* task);
|
||||
int get_model_mall_home_url(std::string* url);
|
||||
int get_model_mall_detail_url(std::string* url, std::string id);
|
||||
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body);
|
||||
|
@ -247,6 +249,7 @@ private:
|
|||
static func_start_pubilsh start_publish_ptr;
|
||||
static func_get_profile_3mf get_profile_3mf_ptr;
|
||||
static func_get_model_publish_url get_model_publish_url_ptr;
|
||||
static func_get_subtask get_subtask_ptr;
|
||||
static func_get_model_mall_home_url get_model_mall_home_url_ptr;
|
||||
static func_get_model_mall_detail_url get_model_mall_detail_url_ptr;
|
||||
static func_get_my_profile get_my_profile_ptr;
|
||||
|
|
Loading…
Reference in a new issue