From 59a9c7b7c840d9a371431c2f86b9d6f0f4cfc9a0 Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Wed, 18 Feb 2015 13:37:37 +0100 Subject: [PATCH] added ascii output option for current scan --- user_interface/coral_scanner.pm | 33 +++++++++++++++++++++++++++++++++ user_interface/regio.pm | 8 ++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/user_interface/coral_scanner.pm b/user_interface/coral_scanner.pm index d66e523..e8d4c03 100644 --- a/user_interface/coral_scanner.pm +++ b/user_interface/coral_scanner.pm @@ -432,6 +432,39 @@ sub stop_scan { return " "; } +sub scan_to_ascii { + my $self = shift; + my %options = @_; + my $scan = $self->{scan_shm}->readShm(); + my $tc = $self->{table_control}; + + my $sample_rect_x1 = $tc->{settings}->{sample_rect_x1}; + my $sample_rect_x2 = $tc->{settings}->{sample_rect_x2}; + my $sample_rect_y1 = $tc->{settings}->{sample_rect_y1}; + my $sample_rect_y2 = $tc->{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 = $tc->{settings}->{sample_aperture_dia}; + + my $step_size = $scan->{meta}->{step_size}; + my $cols = $scan->{meta}->{cols}; + my $rows = $scan->{meta}->{rows}; + + my @rows = (); + for (my $i=0; $i < $rows; $i++) { + my @cols = (); + for (my $j=0; $j < $cols; $j++) { + my $counts = $scan->{data}->[$i]->[$j]; + push(@cols,$counts); + } + push(@rows,join("\t",@cols)); + } + print join("\n",@rows); + return " "; +} + sub scan_to_svg { my $self = shift; my %options = @_; diff --git a/user_interface/regio.pm b/user_interface/regio.pm index 2f2eb73..6016d51 100644 --- a/user_interface/regio.pm +++ b/user_interface/regio.pm @@ -74,6 +74,9 @@ sub new { $self->{port}->databits(8); $self->{port}->stopbits(1); $self->{port}->handshake("none"); + $self->{port}->are_match(""); + $self->{port}->read_char_time(1); # avg time between read char + $self->{port}->read_const_time(40); # const time for read (milliseconds) $self->{port}->write_settings; return $self; @@ -110,12 +113,9 @@ sub communicate { my $self = shift; my $command = shift; - my $ack_timeout=0.5; my $rstring; - $self->{port}->are_match(""); - $self->{port}->read_char_time(1); # avg time between read char - $self->{port}->read_const_time(2); # const time for read (milliseconds) + $self->{port}->lookclear; $self->{port}->write("$command\n"); -- 2.43.0