Add: option to setup a cost per hour per printer #571 (#2247)

This commit is contained in:
niklasb 2023-09-29 17:44:05 +02:00 committed by GitHub
parent ca138794d9
commit 7a7187f9ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 6 deletions

View file

@ -1286,10 +1286,11 @@ namespace DoExport {
// get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A"; // get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A";
// } // }
static void update_print_estimated_stats(const GCodeProcessor& processor, const std::vector<Extruder>& extruders, PrintStatistics& print_statistics) static void update_print_estimated_stats(const GCodeProcessor& processor, const std::vector<Extruder>& extruders, PrintStatistics& print_statistics, const PrintConfig& config)
{ {
const GCodeProcessorResult& result = processor.get_result(); const GCodeProcessorResult& result = processor.get_result();
print_statistics.estimated_normal_print_time = get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].time); double normal_print_time = result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].time;
print_statistics.estimated_normal_print_time = get_time_dhms(normal_print_time);
print_statistics.estimated_silent_print_time = processor.is_stealth_time_estimator_enabled() ? print_statistics.estimated_silent_print_time = processor.is_stealth_time_estimator_enabled() ?
get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A"; get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A";
@ -1327,7 +1328,9 @@ namespace DoExport {
total_weight += weight; total_weight += weight;
total_cost += weight * extruder->filament_cost() * 0.001; total_cost += weight * extruder->filament_cost() * 0.001;
} }
total_cost += config.time_cost.getFloat() * (normal_print_time/3600.0);
print_statistics.total_extruded_volume = total_extruded_volume; print_statistics.total_extruded_volume = total_extruded_volume;
print_statistics.total_used_filament = total_used_filament; print_statistics.total_used_filament = total_used_filament;
print_statistics.total_weight = total_weight; print_statistics.total_weight = total_weight;
@ -1488,7 +1491,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
// Post-process the G-code to update time stamps. // Post-process the G-code to update time stamps.
m_processor.finalize(true); m_processor.finalize(true);
// DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics); // 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); DoExport::update_print_estimated_stats(m_processor, m_writer.extruders(), print->m_print_statistics, print->config());
if (result != nullptr) { if (result != nullptr) {
*result = std::move(m_processor.extract_result()); *result = std::move(m_processor.extract_result());
// set the filename to the correct value // set the filename to the correct value

View file

@ -814,7 +814,7 @@ static std::vector<std::string> s_Preset_printer_options {
"default_print_profile", "inherits", "default_print_profile", "inherits",
"silent_mode", "silent_mode",
// BBS // BBS
"scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time", "machine_pause_gcode", "template_custom_gcode", "scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time","time_cost", "machine_pause_gcode", "template_custom_gcode",
"nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types", "retract_lift_enforce", "nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types", "retract_lift_enforce",
//SoftFever //SoftFever
"host_type", "print_host", "printhost_apikey", "host_type", "print_host", "printhost_apikey",

View file

@ -2090,6 +2090,14 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0)); def->set_default_value(new ConfigOptionFloat(0));
def = this->add("time_cost", coFloat);
def->label = L("Time cost");
def->tooltip = L("The printer cost per hour");
def->sidetext = L("money/h");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("gcode_flavor", coEnum); def = this->add("gcode_flavor", coEnum);
def->label = L("G-code flavor"); def->label = L("G-code flavor");
def->tooltip = L("What kind of gcode the printer is compatible with"); def->tooltip = L("What kind of gcode the printer is compatible with");

View file

@ -878,7 +878,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, gcode_add_line_number)) ((ConfigOptionBool, gcode_add_line_number))
((ConfigOptionBool, bbl_bed_temperature_gcode)) ((ConfigOptionBool, bbl_bed_temperature_gcode))
((ConfigOptionEnum<GCodeFlavor>, gcode_flavor)) ((ConfigOptionEnum<GCodeFlavor>, gcode_flavor))
((ConfigOptionFloat, time_cost))
((ConfigOptionString, layer_change_gcode)) ((ConfigOptionString, layer_change_gcode))
((ConfigOptionFloat, max_volumetric_extrusion_rate_slope)) ((ConfigOptionFloat, max_volumetric_extrusion_rate_slope))

View file

@ -3126,6 +3126,7 @@ void TabPrinter::build_fff()
// optgroup->append_single_option_line("spaghetti_detector"); // optgroup->append_single_option_line("spaghetti_detector");
optgroup->append_single_option_line("machine_load_filament_time"); optgroup->append_single_option_line("machine_load_filament_time");
optgroup->append_single_option_line("machine_unload_filament_time"); optgroup->append_single_option_line("machine_unload_filament_time");
optgroup->append_single_option_line("time_cost");
optgroup = page->new_optgroup(L("Cooling Fan")); optgroup = page->new_optgroup(L("Cooling Fan"));
Line line = Line{ L("Fan speed-up time"), optgroup->get_option("fan_speedup_time").opt.tooltip }; Line line = Line{ L("Fan speed-up time"), optgroup->get_option("fan_speedup_time").opt.tooltip };