]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
progress
authorMichael Wiebusch <m.wiebusch@gsi.de>
Tue, 20 Jan 2015 16:50:50 +0000 (17:50 +0100)
committerMichael Wiebusch <m.wiebusch@gsi.de>
Tue, 20 Jan 2015 16:50:50 +0000 (17:50 +0100)
user_interface/coral_scanner.pm
user_interface/diff_spec.m [new file with mode: 0644]
user_interface/pmt_ro.pm
user_interface/table_control.pm

index fba052274f97398e242d04e241b5986abd60fead..55e48bac32a39451a0141f2536edca336ffb4e5f 100644 (file)
@@ -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 "<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>";
@@ -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 (file)
index 0000000..fffaf0e
--- /dev/null
@@ -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
+
+
index 0324586dd5e5ba533fbed4ab89f6eb81b6a0f322..cd665dc8757ec40bf966a1672619ea566553de2d 100644 (file)
@@ -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;
index bfe968e9bc7d28e540884ed9c1a21b5b609736f8..c66bf5d06b35d741d302bf721088fe9c63fc5890 100644 (file)
@@ -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 "<svg width=$pic_width height=$pic_height>" if $html_tag;
     print $svg->xmlify;
+    print "</svg>" 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);