FIX: Adjust error information storage method

Jira: XXXX
Change-Id: If6564f6425678faa2df9b08d9c7642afb7ffbe50
This commit is contained in:
zhimin.zeng 2023-09-18 14:51:43 +08:00 committed by Lane.Wei
parent cd7437946c
commit 264f02e8d8
8 changed files with 61 additions and 15 deletions

View file

@ -7335,8 +7335,16 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << PLATE_TAG << ">\n";
//plate index
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATE_IDX_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->plate_index + 1 << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"" << int(config.opt_enum<TimelapseType>("timelapse_type")) << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_ERROR_CODE_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->timelapse_warning_code << "\"/>\n";
int timelapse_type = int(config.opt_enum<TimelapseType>("timelapse_type"));
for (auto it = plate_data->warnings.begin(); it != plate_data->warnings.end(); it++) {
if (it->msg == NOT_GENERATE_TIMELAPSE) {
timelapse_type = -1;
break;
}
}
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"" << timelapse_type << "\"/>\n";
//stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_ERROR_CODE_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->timelapse_warning_code << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_PREDICTION_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_prediction_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_WEIGHT_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_weight_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OUTSIDE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->toolpath_outside << "\"/>\n";

View file

@ -1169,6 +1169,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
m_timelapse_warning_code += (1 << 1);
}
m_processor.result().timelapse_warning_code = m_timelapse_warning_code;
m_processor.result().support_traditional_timelapse = m_support_traditional_timelapse;
m_processor.finalize(true);
// DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics);
DoExport::update_print_estimated_stats(m_processor, m_writer.extruders(), print->m_print_statistics);
@ -3542,6 +3543,9 @@ GCode::LayerResult GCode::process_layer(
log_memory_info();
if (!has_wipe_tower && need_insert_timelapse_gcode_for_traditional && !has_insert_timelapse_gcode) {
if (m_support_traditional_timelapse)
m_support_traditional_timelapse = false;
gcode += this->retract(false, false, LiftType::NormalLift);
m_writer.add_object_change_labels(gcode);

View file

@ -492,6 +492,7 @@ private:
std::string _encode_label_ids_to_base64(std::vector<size_t> ids);
int m_timelapse_warning_code = 0;
bool m_support_traditional_timelapse = true;
bool m_silent_time_estimator_enabled;

View file

@ -4335,12 +4335,26 @@ void GCodeProcessor::update_slice_warnings()
// bbs:HRC checker
warning.params.clear();
warning.level = 1;
if (m_result.timelapse_warning_code != 0) {
if (!m_result.support_traditional_timelapse) {
warning.msg = NOT_SUPPORT_TRADITIONAL_TIMELAPSE;
warning.error_code = "1000C003";
m_result.warnings.push_back(warning);
}
if (m_result.timelapse_warning_code != 0) {
if (m_result.timelapse_warning_code & 1) {
warning.msg = NOT_GENERATE_TIMELAPSE;
warning.error_code = "1001C001";
m_result.warnings.push_back(warning);
}
if ((m_result.timelapse_warning_code >> 1) & 1) {
warning.msg = NOT_GENERATE_TIMELAPSE;
warning.error_code = "1001C002";
m_result.warnings.push_back(warning);
}
}
m_result.warnings.shrink_to_fit();
}

View file

@ -21,6 +21,7 @@ namespace Slic3r {
#define NOZZLE_HRC_CHECKER "the_actual_nozzle_hrc_smaller_than_the_required_nozzle_hrc"
#define BED_TEMP_TOO_HIGH_THAN_FILAMENT "bed_temperature_too_high_than_filament"
#define NOT_SUPPORT_TRADITIONAL_TIMELAPSE "not_support_traditional_timelapse"
#define NOT_GENERATE_TIMELAPSE "not_generate_timelapse"
enum class EMoveType : unsigned char
{
@ -181,6 +182,7 @@ namespace Slic3r {
//BBS: add object_label_enabled
bool label_object_enabled;
int timelapse_warning_code {0};
bool support_traditional_timelapse{true};
float printable_height;
SettingsIds settings_ids;
size_t extruders_count;

View file

@ -2841,7 +2841,10 @@ wxString Plater::get_slice_warning_string(GCodeProcessorResult::SliceWarning& wa
return _L("The nozzle hardness required by the filament is higher than the default nozzle hardness of the printer. Please replace the hardened nozzle or filament, otherwise, the nozzle will be attrited or damaged.");
} else if (warning.msg == NOT_SUPPORT_TRADITIONAL_TIMELAPSE) {
return _L("Enabling traditional timelapse photography may cause surface imperfections. It is recommended to change to smooth mode.");
} else {
} else if (warning.msg == NOT_GENERATE_TIMELAPSE) {
return wxString();
}
else {
return wxString(warning.msg);
}
}

View file

@ -2160,13 +2160,18 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
Enable_Send_Button(false);
Enable_Refresh_Button(true);
} else if (status == PrintDialogStatus::PrintStatusTimelapseWarning) {
int error_code = get_timelapse_warning_code();
wxString msg_text;
if (error_code & 1) {
PartPlate *plate = m_plater->get_partplate_list().get_curr_plate();
for (auto warning : plate->get_slice_result()->warnings) {
if (warning.msg == NOT_GENERATE_TIMELAPSE) {
if (warning.error_code == "1001C001") {
msg_text = _L("When enable spiral vase mode, machines with I3 structure will not generate timelapse videos.");
} else if ((error_code >> 1) & 1) {
}
else if (warning.error_code == "1001C002") {
msg_text = _L("When print by object, machines with I3 structure will not generate timelapse videos.");
}
}
}
update_print_status_msg(msg_text, true, true);
Enable_Send_Button(true);
Enable_Refresh_Button(true);
@ -2291,6 +2296,9 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
has_slice_warnings = true;
}
}
else if (warning.msg == NOT_GENERATE_TIMELAPSE) {
continue;
}
else {
wxString error_info = Plater::get_slice_warning_string(warning);
if (error_info.IsEmpty()) {
@ -3197,7 +3205,7 @@ void SelectMachineDialog::update_show_status()
}
}
if (get_timelapse_warning_code() != 0) {
if (has_timelapse_warning()) {
show_status(PrintDialogStatus::PrintStatusTimelapseWarning);
return;
}
@ -3268,16 +3276,22 @@ void SelectMachineDialog::update_show_status()
}
}
int SelectMachineDialog::get_timelapse_warning_code()
bool SelectMachineDialog::has_timelapse_warning()
{
PartPlate *plate = m_plater->get_partplate_list().get_curr_plate();
return plate->timelapse_warning_code();
for (auto warning : plate->get_slice_result()->warnings) {
if (warning.msg == NOT_GENERATE_TIMELAPSE) {
return true;
}
}
return false;
}
void SelectMachineDialog::update_timelapse_enable_status()
{
AppConfig *config = wxGetApp().app_config;
if (get_timelapse_warning_code() == 0) {
if (!has_timelapse_warning()) {
if (!config || config->get("print", "timelapse") == "0")
m_checkbox_list["timelapse"]->SetValue(false);
else

View file

@ -444,7 +444,7 @@ public:
void update_print_error_info(int code, std::string msg, std::string extra);
void set_flow_calibration_state(bool state);
bool is_show_timelapse();
int get_timelapse_warning_code();
bool has_timelapse_warning();
void update_timelapse_enable_status();
bool is_same_printer_model();
bool is_blocking_printing();