From: Michael Wiebusch Date: Tue, 20 Jan 2015 16:50:50 +0000 (+0100) Subject: progress X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=09a21ec9c98c528e6f48a1e6a84b44bcce3eeaca;p=coral.git progress --- diff --git a/user_interface/coral_scanner.pm b/user_interface/coral_scanner.pm index fba0522..55e48ba 100644 --- a/user_interface/coral_scanner.pm +++ b/user_interface/coral_scanner.pm @@ -37,8 +37,7 @@ sub new { $self->{settings_file} = "./".__PACKAGE__.".settings"; $self->{default_settings} = { # hard default settings - a => 1, - b => 2 + time_per_pixel => 1 }; $self->{settings_desc} = { @@ -58,6 +57,7 @@ sub new { $self->{pmt_ro} = pmt_ro->new(); $self->{table_control} = table_control->new(); + $self->load_settings(); return $self; } @@ -92,10 +92,10 @@ sub main_html { print "

main controls

"; print "
"; - print ""; -# print ''; - $self->{table_control}->scan_pattern_to_svg(); - print ""; + print '
'; + $self->{table_control}->scan_pattern_to_svg(html_tag => 1); + print '
'; + print br; print "some content!"; print "
"; @@ -147,7 +147,8 @@ sub scan_callback { 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}; @@ -182,6 +183,34 @@ sub save_scan_ascii { } +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; + + +} + diff --git a/user_interface/diff_spec.m b/user_interface/diff_spec.m new file mode 100644 index 0000000..fffaf0e --- /dev/null +++ b/user_interface/diff_spec.m @@ -0,0 +1,25 @@ + +backgnd_file="./cumul_spec_backgnd.dat"; +spec_file="./cumul_spec.dat"; +cumul_spec_backgnd=load(backgnd_file); +cumul_spec=load(spec_file); + + + +dspec=diff(cumul_spec(:,3)); +dbackgnd=diff(cumul_spec_backgnd(:,3)); +x=cumul_spec(:,2); +diffx=diff(x); +dx=x(1:end-1)+diffx./2; + + + +bar(dx,dspec); +hold +bar(dx,dbackgnd,"facecolor","r"); +xlabel("threshold setting"); +ylabel("counts"); +title("spectrum of Am source, 75 s per bin, -2750 to -759"); +hold off + + diff --git a/user_interface/pmt_ro.pm b/user_interface/pmt_ro.pm index 0324586..cd665dc 100644 --- a/user_interface/pmt_ro.pm +++ b/user_interface/pmt_ro.pm @@ -152,7 +152,7 @@ sub spectral_scan_onesided { my $verbose=$options{verbose}; my $tofile=$options{tofile}; - my $file = FileHandle->new("./test.dat", 'w'); + my $file = FileHandle->new("./cumul_spec.dat", 'w'); my $spec_width = $stop-$start; my $bin_width = $spec_width/$bins; diff --git a/user_interface/table_control.pm b/user_interface/table_control.pm index bfe968e..c66bf5d 100644 --- a/user_interface/table_control.pm +++ b/user_interface/table_control.pm @@ -52,7 +52,8 @@ sub new { sample_aperture_dia => 1, scan_pattern_style => "meander", - rows_to_scan => 10 + rows_to_scan => 10, + mm_to_scan => 10 }; @@ -85,6 +86,7 @@ sub new { %options }; bless($self, $class); + $self->load_settings(); return $self; } @@ -116,7 +118,7 @@ sub help { 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}; @@ -316,7 +318,7 @@ sub scan_pattern { 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}; @@ -335,6 +337,10 @@ sub scan_pattern { 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" ) { @@ -378,8 +384,9 @@ sub scan_pattern_to_svg { 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}; @@ -391,14 +398,17 @@ sub scan_pattern_to_svg { 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, @@ -414,27 +424,50 @@ sub scan_pattern_to_svg { 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; @@ -443,13 +476,13 @@ sub scan_pattern_to_svg { 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 , @@ -464,7 +497,7 @@ sub scan_pattern_to_svg { } 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}, @@ -490,7 +523,9 @@ sub scan_pattern_to_svg { print SVGFILE $svg->xmlify; close(SVGFILE); } else { + print "" if $html_tag; print $svg->xmlify; + print "" if $html_tag; } return " "; @@ -507,11 +542,11 @@ sub scan { 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);