Skip to content

Commit

Permalink
Add: option to setup a cost per hour per printer #571 (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasb22 authored Sep 29, 2023
1 parent ca13879 commit 7a7187f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,11 @@ namespace DoExport {
// 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();
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() ?
get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A";

Expand Down Expand Up @@ -1327,7 +1328,9 @@ namespace DoExport {
total_weight += weight;
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_used_filament = total_used_filament;
print_statistics.total_weight = total_weight;
Expand Down Expand Up @@ -1488,7 +1491,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
// Post-process the G-code to update time stamps.
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);
DoExport::update_print_estimated_stats(m_processor, m_writer.extruders(), print->m_print_statistics, print->config());
if (result != nullptr) {
*result = std::move(m_processor.extract_result());
// set the filename to the correct value
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ static std::vector<std::string> s_Preset_printer_options {
"default_print_profile", "inherits",
"silent_mode",
// 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",
//SoftFever
"host_type", "print_host", "printhost_apikey",
Expand Down
8 changes: 8 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,14 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comAdvanced;
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->label = L("G-code flavor");
def->tooltip = L("What kind of gcode the printer is compatible with");
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, gcode_add_line_number))
((ConfigOptionBool, bbl_bed_temperature_gcode))
((ConfigOptionEnum<GCodeFlavor>, gcode_flavor))

((ConfigOptionFloat, time_cost))
((ConfigOptionString, layer_change_gcode))

((ConfigOptionFloat, max_volumetric_extrusion_rate_slope))
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3126,6 +3126,7 @@ void TabPrinter::build_fff()
// optgroup->append_single_option_line("spaghetti_detector");
optgroup->append_single_option_line("machine_load_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"));
Line line = Line{ L("Fan speed-up time"), optgroup->get_option("fan_speedup_time").opt.tooltip };
Expand Down

0 comments on commit 7a7187f

Please sign in to comment.