]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
implemented a working callback system for the scan
authormaps <maps@jspc07.x-matter.uni-frankfurt.de>
Mon, 19 Jan 2015 10:59:32 +0000 (11:59 +0100)
committermaps <maps@jspc07.x-matter.uni-frankfurt.de>
Mon, 19 Jan 2015 10:59:32 +0000 (11:59 +0100)
user_interface/coral_scanner.pm
user_interface/table_control.pm

index 0a0565a7195cb380adcfb717544f378ae4aa19d5..f42e5433339221aee6d02761d6140be5b1c75743 100644 (file)
@@ -3,7 +3,7 @@ package coral_scanner;
 
 use strict;
 use warnings;
-use Time::HiRes;
+use Time::HiRes qw/sleep/;
 use POSIX qw/strftime/;
 use POSIX;
 use Device::SerialPort;
@@ -122,20 +122,25 @@ sub scan_sample {
   
   my $tc = $self->{table_control};
 
-  $tc->home();
-  $tc->scan( eval => 'print("test");' );
+#   $tc->home();
+#   $tc->scan( eval => 'print("test\n");' );
+  $tc->scan( object => $self, method => 'scan_callback' );
+
   
   
 
 }
 
 sub scan_callback {
-  my $point=shift;
+  my $self  = shift;
+  my $point = shift;
   
-  printf("evaluate sth. at point %d %d" , $point->{row},$point->{col});
-  my $ro = $self->{pmt_ro};
+  printf("evaluate sth. at point %d %d\n" , $point->{row},$point->{col});
+  my $ro = $self->{pmt_ro};
   
-#   print $ro->count(delay => 0.5, channel => "signal");
+#   print $ro->count(delay => 0.1, channel => "signal");
+  sleep 2;
+  print "\n\n";
 
 
 }
@@ -144,4 +149,6 @@ sub scan_callback {
 
 
 
+
+
 1;
index f2efdd6fac165727db8610b42b29d7dd5fb31840..bfe968e9bc7d28e540884ed9c1a21b5b609736f8 100644 (file)
@@ -264,7 +264,7 @@ sub go_xy {
     
     my $answer = $self->receive(wait => $travel_timeout);
   
-    if($new_x - $answer->{x_pos} < $self->{settings}->{table_precision} 
+    if(abs($new_x - $answer->{x_pos}) < $self->{settings}->{table_precision} 
     || $answer->{xend2_sw} || $answer->{xend1_sw} ){
       $self->{setpos}->{x}  = $new_x;
       $self->{realpos}->{x} = $answer->{x_pos};
@@ -272,7 +272,7 @@ sub go_xy {
     }
     
     
-    if($new_y - $answer->{y_pos} < $self->{settings}->{table_precision} 
+    if(abs($new_y - $answer->{y_pos}) < $self->{settings}->{table_precision} 
     || $answer->{yend2_sw} || $answer->{yend1_sw} ){
       $self->{setpos}->{y}  = $new_y;
       $self->{realpos}->{y} = $answer->{y_pos};
@@ -504,6 +504,9 @@ sub scan {
   my $eval   = $options{eval};
   my $subref = $options{subref};
   
+  my $method = $options{method};
+  my $object = $options{object};
+  
   $self->require_run("load_settings");
   
   for my $point (@{$self->scan_pattern()}) {
@@ -513,6 +516,9 @@ sub scan {
     $self->go_xy( x => $point->{x}, y => $point->{y});
     eval $eval  if defined($eval);
     $subref->($point) if defined($subref);
+    if(defined($object) && defined($method)){
+      $object->$method($point);
+    }
   }
   
 }