~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to utils/post-processing/flowrate.pl

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -i
 
2
 
 
3
#
 
4
# Post-processing script for calculating flow rate for each move
 
5
 
 
6
use strict;
 
7
use warnings;
 
8
 
 
9
my $E = 0;
 
10
my ($X, $Y);
 
11
while (<>) {
 
12
    if (/^G1 X([0-9.]+) Y([0-9.]+).*? E([0-9.]+)/) {
 
13
        my ($x, $y, $e) = ($1, $2, $3);
 
14
        my $e_length = $e - $E;
 
15
        if ($e_length > 0 && defined $X && defined $Y) {
 
16
            my $dist = sqrt( (($x-$X)**2) + (($y-$Y)**2) );
 
17
            if ($dist > 0) {
 
18
                my $flowrate = sprintf '%.2f', $e_length / $dist;
 
19
                s/(\R+)/ ; XY dist = $dist ; E dist = $e_length ; E\/XY = $flowrate mm\/mm$1/;
 
20
            }
 
21
        }
 
22
        $E = $e;
 
23
        $X = $x;
 
24
        $Y = $y;
 
25
    }
 
26
    if (/^G1 X([0-9.]+) Y([0-9.]+)/) {
 
27
        $X = $1;
 
28
        $Y = $2;
 
29
    }
 
30
    if (/^G1.*? E([0-9.]+)/) {
 
31
        $E = $1;
 
32
    }
 
33
    if (/^G92 E0/) {
 
34
        $E = 0;
 
35
    }
 
36
    print;
 
37
}
 
38
 
 
39
__END__