added total cost/weight to Extruder statistics, mocked up addendum to status bar change.
This commit is contained in:
parent
3846d9e734
commit
203a965b3d
5 changed files with 30 additions and 6 deletions
|
@ -1343,6 +1343,7 @@ sub on_export_completed {
|
|||
} else {
|
||||
$message = "G-code file exported to " . $self->{export_gcode_output_file};
|
||||
}
|
||||
$message .= sprintf(" Cost: %.2f" , $self->{print}->total_cost);
|
||||
} else {
|
||||
$message = "Export failed";
|
||||
}
|
||||
|
|
|
@ -321,8 +321,8 @@ sub export {
|
|||
$self->print->clear_filament_stats;
|
||||
$self->print->total_used_filament(0);
|
||||
$self->print->total_extruded_volume(0);
|
||||
my $total_filament_weight = 0.0;
|
||||
my $total_filament_cost = 0.0;
|
||||
$self->print->total_weight(0);
|
||||
$self->print->total_cost(0);
|
||||
foreach my $extruder (@{$gcodegen->writer->extruders}) {
|
||||
my $used_filament = $extruder->used_filament;
|
||||
my $extruded_volume = $extruder->extruded_volume;
|
||||
|
@ -333,11 +333,11 @@ sub export {
|
|||
printf $fh "; filament used = %.1fmm (%.1fcm3)\n",
|
||||
$used_filament, $extruded_volume/1000;
|
||||
if ($filament_weight > 0) {
|
||||
$total_filament_weight += $filament_weight;
|
||||
$self->print->total_weight($self->print->total_weight + $filament_weight);
|
||||
printf $fh "; filament used = %.1fg\n",
|
||||
$filament_weight;
|
||||
if ($filament_cost > 0) {
|
||||
$total_filament_cost += $filament_cost;
|
||||
$self->print->total_cost($self->print->total_cost + $filament_cost);
|
||||
printf $fh "; filament cost = %.1f\n",
|
||||
$filament_cost;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ sub export {
|
|||
$self->print->total_extruded_volume($self->print->total_extruded_volume + $extruded_volume);
|
||||
}
|
||||
printf $fh "; total filament cost = %.1f\n",
|
||||
$total_filament_cost;
|
||||
$self->print->total_cost;
|
||||
|
||||
# append full config
|
||||
print $fh "\n";
|
||||
|
|
|
@ -268,6 +268,8 @@ sub generate_support_material {
|
|||
}
|
||||
|
||||
$self->set_step_done(STEP_SUPPORTMATERIAL);
|
||||
my $stats = "Weight: %.1fg, Cost: %.1f" , $self->print->total_weight, $self->print->total_cost;
|
||||
$self->print->status_cb->(85, $stats);
|
||||
}
|
||||
|
||||
# Idempotence of this method is guaranteed by the fact that we don't remove things from
|
||||
|
|
|
@ -192,7 +192,7 @@ class Print
|
|||
PrintRegionPtrs regions;
|
||||
PlaceholderParser placeholder_parser;
|
||||
// TODO: status_cb
|
||||
double total_used_filament, total_extruded_volume;
|
||||
double total_used_filament, total_extruded_volume, total_cost, total_weight;
|
||||
std::map<size_t,float> filament_stats;
|
||||
PrintState<PrintStep> state;
|
||||
|
||||
|
|
|
@ -276,5 +276,26 @@ Print::total_extruded_volume(...)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
|
||||
double
|
||||
Print::total_weight(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->total_weight = (double)SvNV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->total_weight;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
double
|
||||
Print::total_cost(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->total_cost = (double)SvNV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->total_cost;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue