line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::GCN::Util::SWIFT; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
GCN::Util - utility routines |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use GCN::Util::SWIFT |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module contains a simple utility routines specific to the SWIFT mission. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
6431
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
69
|
|
18
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
119
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
require Exporter; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
12
|
use vars qw/$VERSION @EXPORT_OK @ISA /; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1389
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
@ISA = qw/Exporter/; |
25
|
|
|
|
|
|
|
@EXPORT_OK = qw/ convert_soln_status convert_trig_obs_num /; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
'$Revision: 1.1.1.1 $ ' =~ /.*:\s(.*)\s\$/ && ($VERSION = $1); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub convert_soln_status { |
31
|
0
|
|
|
0
|
0
|
|
my $soln_status = shift; |
32
|
0
|
|
|
|
|
|
print "Converting soln_status...\n"; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
print "Repacking into a big-endian long...\n"; |
35
|
0
|
|
|
|
|
|
my $bit_string = pack("N", $soln_status ); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
print "Unpacking to bit string...\n"; |
38
|
0
|
|
|
|
|
|
$bit_string = unpack( "B32", $bit_string ); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
print "Chopping up the bit string...\n"; |
41
|
0
|
|
|
|
|
|
my @bits; |
42
|
0
|
|
|
|
|
|
foreach my $i ( 0 ... 5 ) { |
43
|
0
|
|
|
|
|
|
my $bit = chop( $bit_string ); |
44
|
0
|
|
|
|
|
|
push @bits, $bit; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
print "Setting status flags...\n"; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my %status; |
50
|
0
|
0
|
|
|
|
|
if ( $bits[0] == 1 ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$status{"point_src"} = 1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} elsif ( $bits[1] == 1 ) { |
54
|
0
|
|
|
|
|
|
$status{"grb"} = 1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} elsif ( $bits[2] == 1 ) { |
57
|
0
|
|
|
|
|
|
$status{"interesting"} = 1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} elsif ( $bits[3] == 1 ) { |
60
|
0
|
|
|
|
|
|
$status{"catalog_src"} = 1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} elsif ( $bits[4] == 1 ) { |
63
|
0
|
|
|
|
|
|
$status{"image_trig"} = 1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} elsif ( $bits[5] == 1 ) { |
66
|
0
|
|
|
|
|
|
$status{"def_not_grb"} = 1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return %status; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub convert_trig_obs_num { |
73
|
0
|
|
|
0
|
0
|
|
my $trig_obs_num = shift; |
74
|
0
|
|
|
|
|
|
print "Converting trig_obs_num...\n"; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
print "Repacking into a big-endian long...\n"; |
77
|
0
|
|
|
|
|
|
my $bit_string = pack("N", $trig_obs_num ); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
print "Unpacking to bit string...\n"; |
80
|
0
|
|
|
|
|
|
$bit_string = unpack( "B32", $bit_string ); |
81
|
|
|
|
|
|
|
#print "bit_string = $bit_string\n"; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
print "Chopping up the bit string...\n"; |
84
|
0
|
|
|
|
|
|
my @bits; |
85
|
0
|
|
|
|
|
|
foreach my $i ( 0 ... 32 ) { |
86
|
0
|
|
|
|
|
|
my $bit = chop( $bit_string ); |
87
|
0
|
|
|
|
|
|
push @bits, $bit; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# TRIGGER NUMBER |
91
|
|
|
|
|
|
|
# -------------- |
92
|
0
|
|
|
|
|
|
print "Repacking first 24 bits into a bit string..\n"; |
93
|
0
|
|
|
|
|
|
my ( $lower_24_byte1, $lower_24_byte2, $lower_24_byte3 ); |
94
|
0
|
|
|
|
|
|
foreach my $j ( 0 ... 7 ) { |
95
|
0
|
|
|
|
|
|
$lower_24_byte1 = $lower_24_byte1 . "$bits[$j]"; |
96
|
0
|
|
|
|
|
|
$lower_24_byte2 = $lower_24_byte2 . "$bits[$j+8]"; |
97
|
0
|
|
|
|
|
|
$lower_24_byte3 = $lower_24_byte3 . "$bits[$j+16]"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
print "Lower 3 bytes: $lower_24_byte1 $lower_24_byte2 $lower_24_byte3\n"; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$lower_24_byte1 = pack("b8", $lower_24_byte1 ); |
103
|
0
|
|
|
|
|
|
$lower_24_byte2 = pack("b8", $lower_24_byte2 ); |
104
|
0
|
|
|
|
|
|
$lower_24_byte3 = pack("b8", $lower_24_byte3 ); |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$lower_24_byte1 = unpack( "C", $lower_24_byte1 ); |
107
|
0
|
|
|
|
|
|
$lower_24_byte2 = unpack( "C", $lower_24_byte2 ); |
108
|
0
|
|
|
|
|
|
$lower_24_byte3 = unpack( "C", $lower_24_byte3 ); |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my $trig_num = $lower_24_byte1 + ( $lower_24_byte2*256) + |
111
|
|
|
|
|
|
|
( $lower_24_byte3*256*256 ); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
print "Trigger Num. = $trig_num\n"; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# OBS NUMBER |
116
|
|
|
|
|
|
|
# ---------- |
117
|
0
|
|
|
|
|
|
print "Repacking upper 8 bits into a bit string..\n"; |
118
|
0
|
|
|
|
|
|
my $upper_8; |
119
|
0
|
|
|
|
|
|
foreach my $j ( 24 ... 32 ) { |
120
|
0
|
|
|
|
|
|
$upper_8 = $upper_8 . "$bits[$j]"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
print "Upper byte: $upper_8\n"; |
124
|
0
|
|
|
|
|
|
my $obs_num = pack("b8", $upper_8 ); |
125
|
0
|
|
|
|
|
|
$obs_num = unpack( "C", $obs_num ); |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
print "Obs. Num. = $obs_num\n"; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# RETURN results |
130
|
0
|
|
|
|
|
|
return ( $trig_num, $obs_num ); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 REVISION |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$Id: SWIFT.pm,v 1.1.1.1 2005/05/03 19:23:00 voevent Exp $ |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHORS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Copyright (C) 2003 Particle Physics and Astronomy Research |
147
|
|
|
|
|
|
|
Council. All Rights Reserved. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |