From fc5aac0ff66638291e4bec4e96e5115fb7ab1145 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 23 Dec 2013 01:19:02 +0100 Subject: [PATCH] Bugfix: fan wasn't turned on for bridges when vibration limit or another internal post-processor was enabled. Includes regression test. #1533 --- lib/Slic3r/GCode/Reader.pm | 2 +- t/cooling.t | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GCode/Reader.pm b/lib/Slic3r/GCode/Reader.pm index 251f1f2bd..d2a7c184e 100644 --- a/lib/Slic3r/GCode/Reader.pm +++ b/lib/Slic3r/GCode/Reader.pm @@ -18,11 +18,11 @@ sub parse { print "$raw_line\n" if $Verbose || $ENV{SLIC3R_TESTS_GCODE}; my $line = $raw_line; $line =~ s/\s*;(.*)//; # strip comment - next if $line eq ''; my %info = (comment => $1, raw => $raw_line); # parse command my ($command, @args) = split /\s+/, $line; + $command //= ''; my %args = map { /([A-Z])(.*)/; ($1 => $2) } @args; # check motion diff --git a/t/cooling.t b/t/cooling.t index 5cd156e3c..87d3dff39 100644 --- a/t/cooling.t +++ b/t/cooling.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 8; +plan tests => 11; BEGIN { use FindBin; @@ -10,6 +10,7 @@ BEGIN { } use Slic3r; +use Slic3r::Test; sub buffer { my $config = shift || Slic3r::Config->new_from_defaults; @@ -86,4 +87,39 @@ $config->set('disable_fan_first_layers', 0); like $gcode, qr/M106/, 'fan activation is computed on all objects printing at different Z'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('cooling', 1); + $config->set('bridge_fan_speed', 100); + $config->set('fan_below_layer_time', 0); + $config->set('slowdown_below_layer_time', 0); + $config->set('bridge_speed', 99); + $config->set('top_solid_layers', 1); # internal bridges use solid_infil speed + $config->set('bottom_solid_layers', 1); # internal bridges use solid_infil speed + $config->set('vibration_limit', 30); # test that fan is turned on even when vibration limit (or other G-code post-processor) is enabled + + my $print = Slic3r::Test::init_print('overhang', config => $config); + my $fan = 0; + my $fan_with_incorrect_speeds = my $fan_with_incorrect_print_speeds = 0; + my $bridge_with_no_fan = 0; + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if ($cmd eq 'M106') { + $fan = $args->{S}; + $fan_with_incorrect_speeds++ if $fan != 255; + } elsif ($cmd eq 'M107') { + $fan = 0; + } elsif ($info->{extruding} && $info->{dist_XY} > 0) { + $fan_with_incorrect_print_speeds++ + if ($fan > 0) && ($args->{F} // $self->F) != 60*$config->bridge_speed; + $bridge_with_no_fan++ + if !$fan && ($args->{F} // $self->F) == 60*$config->bridge_speed; + } + }); + ok !$fan_with_incorrect_speeds, 'bridge fan speed is applied correctly'; + ok !$fan_with_incorrect_print_speeds, 'bridge fan is only turned on for bridges'; + ok !$bridge_with_no_fan, 'bridge fan is turned on for all bridges'; +} + __END__