Astro-Aladin

 view release on metacpan or  search on metacpan

Aladin.pm  view on Meta::CPAN


use 5.7.3;

use strict;
use vars qw/ $VERSION /;

use File::Spec;
use POSIX qw/sys_wait_h/;
use Errno qw/EAGAIN/;
use Carp;
use threads;
use threads::shared;
use Astro::Aladin::LowLevel;

'$Revision: 1.3 $ ' =~ /.*:\s(.*)\s\$/ && ($VERSION = $1);

# Check for threading
#use Config;
#print "Config: useithreads = " . $Config{'useithreads'} . "\n";
#print "Config: threads::shared loaded\n" if($threads::shared::threads_shared);


# A N O N Y M O U S   S U B R O U T I N E S ---------------------------------

my $threaded_supercos_catalog = sub {
    my ( $ra, $dec, $radius, $band, $file ) = @_;
  
    # create a lowlevel object
    my $aladin = new Astro::Aladin::LowLevel( );

    # grab waveband
    my $waveband = undef;
    if( $band eq "UKST Red" ) {
       $waveband = "2";  
    } elsif ( $band eq "UKST Infrared" ) {

Aladin.pm  view on Meta::CPAN


  my $status = "bibble";

  share( $ra );
  share( $dec );
  share( $radius );
  share( $band );
  share( $file );
  share( $status );

  my $supercos_thread = threads->create( sub { 
  
     $status = &$threaded_supercos_catalog( $ra, $dec, $radius, $band, $file ); 
  });   
  
  # wait for the supercos thread to join
  $supercos_thread->join();
  
  # return the status, with luck this will be set to $file, however
  # if we get an error (and sucessfully pick up on it) it will be undef
  return $status;
  
}

# C O N F I G U R E -------------------------------------------------------

=back

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;
use Config;

# Astro::Aladin uses threads and threads::shared to manage the
# lowevel Astro::Aladin::LowLevel module, which in turn drives
# the CDS Aladin Java Application. However ithreads support only
# got introduced in Perl 5.7.3, so we need to check we have a
# shiny new version of Perl and not the distressingly common 5.6.1

print "Checking Perl version...\n";
if( $] < 5.007003 ) {
   print "Perl 5.7.3 or above needed to build and use " .
         "the Astro::Aladin module.\n";
   exit;
} else {
   print "Looks good.\n";  
}

# Good start, but alot of Perl distributions aren't compiled
# to use ithreads, so we need to check that ithreads support
# has actually been compiled into the binary

print "Checking to see whether your Perl uses ithreads...\n";
unless( $Config{'useithreads'} eq "define") {
   print "It doesn't! You need to recompile Perl with ithreads support.\n";
   exit;
} else {
   print "Looks good.\n"; 
}

# Almost there, make or break, can we actually load the threading
# modules?

eval('use threads;');
eval('use threads::shared;');

print "Checking to see whether threads::shared is loaded...\n";
unless( $threads::shared::threads_shared ) {
   print "Nope! threads::shared doesn't seem to be loaded.\n";
   exit;
} else {
   print "Looks good.\n"; 
}

# You've got a Perl binary with ithreads support, this thing
# might actually work out.

WriteMakefile( 
      'NAME'           => 'Astro::Aladin',
      'VERSION'        => '2.0.2',
      'PREREQ_PM'      => { },
      'dist'           => { COMPRESS => "gzip -9f"},
      ($] >= 5.005 ?   
	( ABSTRACT => 'Perl class giving access to images and catalogues',
	  AUTHOR   => 'Alasdair Allan <aa@astro.ex.ac.uk>') : ()),

t/aladin.t  view on Meta::CPAN

  }
  exit;
}

# load modules
use Astro::Aladin;

# debugging
use Data::Dumper;

# Check for threading
use Config;
print "# Config: useithreads = " . $Config{'useithreads'} . "\n";
print "# Config: threads::shared loaded\n" if($threads::shared::threads_shared);

# T E S T   H A R N E S S --------------------------------------------------

# Check Perl version number
print "# Perl Version $]\n";
print "# \$ALADIN_JAR $ENV{ALADIN_JAR}\n" if defined $ENV{ALADIN_JAR};

# test the test system
ok(1);



( run in 0.992 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )