speed.t 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. use Test::More tests => 2;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. use local::lib "$FindBin::Bin/../local-lib";
  8. }
  9. use List::Util qw(none);
  10. use Slic3r;
  11. use Slic3r::Geometry qw(epsilon);
  12. use Slic3r::Test;
  13. {
  14. my $config = Slic3r::Config->new_from_defaults;
  15. my $test = sub {
  16. my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
  17. my %speeds_by_z = (); # z => []
  18. Slic3r::GCode::Reader->new->parse(my $gcode = Slic3r::Test::gcode($print), sub {
  19. my ($self, $cmd, $args, $info) = @_;
  20. if ($cmd eq 'G1' && $info->{dist_E} > 0 && $info->{dist_XY} > 0) {
  21. $speeds_by_z{$self->Z} //= [];
  22. push @{ $speeds_by_z{$self->Z} }, $self->F/60;
  23. }
  24. });
  25. return %speeds_by_z;
  26. };
  27. {
  28. $config->set('perimeter_speed', 0);
  29. $config->set('external_perimeter_speed', 0);
  30. $config->set('infill_speed', 0);
  31. $config->set('support_material_speed', 0);
  32. $config->set('solid_infill_speed', 0);
  33. $config->set('first_layer_speed', '50%');
  34. $config->set('first_layer_height', 0.25);
  35. my %speeds_by_z = $test->();
  36. ok !!(none { $_ > $config->max_print_speed/2+&epsilon } @{ $speeds_by_z{$config->first_layer_height} }),
  37. 'percent first_layer_speed is applied over autospeed';
  38. }
  39. {
  40. $config->set('first_layer_speed', 33);
  41. my %speeds_by_z = $test->();
  42. ok !!(none { $_ > $config->first_layer_speed } @{ $speeds_by_z{$config->first_layer_height} }),
  43. 'absolute first_layer_speed overrides autospeed';
  44. }
  45. }
  46. __END__