$self->{settings_file} = "./".__PACKAGE__.".settings";
$self->{default_settings} = { # hard default settings
- a => 1,
- b => 2
+ time_per_pixel => 1
};
$self->{settings_desc} = {
$self->{pmt_ro} = pmt_ro->new();
$self->{table_control} = table_control->new();
+ $self->load_settings();
return $self;
}
print "<p id='show_main_controls' class='quasibutton' >main controls</p>";
print "<div id='main_controls_container' class='stylishBox padded'>";
- print "<svg width=480 height=260>";
-# print '<script xlink:href="SVGPan.js"/>';
- $self->{table_control}->scan_pattern_to_svg();
- print "</svg>";
+ print '<div style="width: 600px; height: 270px; overflow-x: scroll;">';
+ $self->{table_control}->scan_pattern_to_svg(html_tag => 1);
+ print '</div>';
+
print br;
print "some content!";
print "</div>";
my $ro = $self->{pmt_ro};
$self->{current_scan}->{meta}->{points}++;
- my $counts = $ro->count(delay => 0.1, channel => "signal");
+ my $delay = $self->{settings}->{time_per_pixel};
+ my $counts = $ro->count(delay => $delay, channel => "signal");
my $col = $point->{col};
my $row = $point->{row};
}
+sub scan_ETA { #estimated time to complete a scan
+ my $self = shift;
+
+ my $tc = $self->{table_control};
+
+ my $speed = $tc->{settings}->{approx_speed}; #approximate speed in mm/sec
+ my $time_per_pixel = $self->{settings}->{time_per_pixel};
+
+ my $pattern_length = 0;
+ my $last_point;
+ my $pattern = $tc->scan_pattern();
+ for my $point (@$pattern){
+ unless(defined($last_point)){
+ $pattern_length += max($point->{x},$point->{y});
+ } else {
+ my $dx = abs($point->{x} - $last_point->{x});
+ my $dy = abs($point->{y} - $last_point->{y});
+ $pattern_length += max($dx,$dy);
+ }
+ $last_point = $point;
+ }
+
+ my $number_points = scalar(@$pattern);
+ return $pattern_length/$speed + $number_points*$time_per_pixel;
+
+
+}
+
sample_aperture_dia => 1,
scan_pattern_style => "meander",
- rows_to_scan => 10
+ rows_to_scan => 10,
+ mm_to_scan => 10
};
%options
};
bless($self, $class);
+ $self->load_settings();
return $self;
}
sub init_port {
my $self = shift;
- $self->require_run("load_settings");
+ #$self->require_run("load_settings");
my $baudrate = $self->{settings}->{baudrate};
my $tty = $self->{settings}->{tty};
my %options = @_;
my $style = $options{style} || $self->{settings}->{scan_pattern_style};
- $self->require_run("load_settings");
+ #$self->require_run("load_settings");
my $sample_rect_x1 = $self->{settings}->{sample_rect_x1};
my $sample_rect_x2 = $self->{settings}->{sample_rect_x2};
for( my $i = 0; $i < $steps_in_x; $i++ ) {
+ last if ($i >= $self->{settings}->{rows_to_scan});
+ last if ($i*$sample_step_size > $self->{settings}->{mm_to_scan});
+
+
for( my $j = 0; $j < $steps_in_y; $j++ ) {
if( $style eq "linebyline" ) {
my $self = shift;
my %options = @_;
my $style = $options{style};
+ my $html_tag = $options{html_tag};
- $self->require_run("load_settings");
+ #$self->require_run("load_settings");
my $svg_file = $options{svg_file};
my $sample_rect_y1 = $self->{settings}->{sample_rect_y1};
my $sample_rect_y2 = $self->{settings}->{sample_rect_y2};
+ my $sample_rect_size_x = $sample_rect_x2 - $sample_rect_x1;
+ my $sample_rect_size_y = $sample_rect_y2 - $sample_rect_y1;
+
my $aperture_dia = $self->{settings}->{sample_aperture_dia};
- my $mm2pix = 1; # pixels per mm
+ my $scale = 12; # pixel per mm
# create an SVG object with a size of 40x40 pixels
- my $pic_width = 480;
- my $pic_height = 260;
+ my $pic_width = ($sample_rect_size_x+5)*$scale;
+ my $pic_height = 250;
my $svg = SVG->new(
-printerror => 1,
height => $pic_height,
);
- my $scale = 12;
my $scaler = $svg->group(
transform => "scale($scale)"
);
- my $group1 = $scaler->group(
+ my $translate1 = $scaler->group(
transform => "translate($aperture_dia,$aperture_dia)"
);
-
- $group1->rectangle(
- x => -$aperture_dia/2 ,
- width => ($sample_rect_x2 -$sample_rect_x1)+$aperture_dia,
- y => -$aperture_dia/2 ,
- height => ($sample_rect_y2 - $sample_rect_y1)+$aperture_dia,
- style=>{
- 'stroke'=>'black',
- 'fill'=>'white',
- 'stroke-width'=>5/$scale,
+
+ for(my $x=0; $x<=$sample_rect_size_x; $x+=5) {
+
+ $translate1->line(
+ x1=> $x, y1=>$sample_rect_size_y + ( ($x % 10) ? 2 : 1 ),
+ x2=> $x, y2=>$sample_rect_size_y+3,
+ style=>{
+ 'stroke'=>'black',
+ 'fill'=>'none',
+ 'stroke-width'=> 1/$scale,
+ # 'stroke-opacity'=>'0.5',
+ # 'fill-opacity'=>'0.0'
+ }
+ );
+
+ unless($x % 10){
+ $translate1->text(
+ x=>$x+0.2, y=>$sample_rect_size_y+2.5,
+ style => 'font-size: 1.5px',
+ )->cdata($x);
}
- );
+ }
+
+ if(1){
+ $translate1->rectangle(
+ x => -$aperture_dia/2 ,
+ width => $sample_rect_size_x+$aperture_dia,
+ y => -$aperture_dia/2 ,
+ height => $sample_rect_size_y+$aperture_dia,
+ style=>{
+ 'stroke'=>'black',
+ 'fill'=>'white',
+ 'stroke-width'=>5/$scale,
+ }
+ );
+ };
my $lastpoint;
my $counter=0;
last if (
($point->{x_rel})*$scale > $pic_width
);
- last if (
- $point->{row} >= $self->{settings}->{rows_to_scan}
- );
+# last if (
+# $point->{row} >= $self->{settings}->{rows_to_scan}
+# );
if(1){
- $group1->circle(
+ $translate1->circle(
cx => $point->{x_rel} ,
cy => $point->{y_rel} ,
r => $aperture_dia/2 ,
}
if( defined ($lastpoint)) {
- $group1->line(
+ $translate1->line(
# id=>'l1.'.$counter++,
x1=> $lastpoint->{x_rel}, y1=>$lastpoint->{y_rel},
x2=> $point->{x_rel} , y2=>$point->{y_rel},
print SVGFILE $svg->xmlify;
close(SVGFILE);
} else {
+ print "<svg width=$pic_width height=$pic_height>" if $html_tag;
print $svg->xmlify;
+ print "</svg>" if $html_tag;
}
return " ";
my $method = $options{method};
my $object = $options{object};
- $self->require_run("load_settings");
+ #$self->require_run("load_settings");
for my $point (@{$self->scan_pattern()}) {
- last if ($point->{row} >= $self->{settings}->{rows_to_scan});
+# last if ($point->{row} >= $self->{settings}->{rows_to_scan});
$self->go_xy( x => $point->{x}, y => $point->{y});
eval $eval if defined($eval);