XRCF - various routines for easing work on XRCF related things
use lib '/proj/axaf/simul/lib/perl'; use XRCF;
$sum = shutter_parseflags( $flags ); %sum = shutter_parseflags( $flags );
@flags = shutter_parsecmdb( $cmdb_spec );
$day = irig2day( $irig ); $date = irig2date( $irig );
This module encapsulates a few useful routines for dealing with XRCF data.
$sum = shutter_parseflags( $flags ); %sum = shutter_parseflags( $flags );
shutter_parseflags parses a set of shutter open/close flags and returns a summary of the
shells which have open shutters and which shutter was open. The flags are
passed as a string. The flags should be in four groups of four flags, with
the outer grouping being the four shells ( 1, 3, 4, and 6, in that order),
and the inner groups being the four shutters ( top, north, bottom, and
south). Each flag is either a 'c' indicating a closed shutter, or an 'o',
indicating an open shutter. The shell groups may be separated by blanks, |, or underlines or shoved together.
The value returned depends upon the context of the call. If
shutter_parse is called in a scalar context, it returns a string consisting of underscore
separated fields, one per shell which had
an open shutter. Each field contains a shell number and a concatenation of the shutters
which were open. Open shutters are designated by the first letter of their
position (i.e. t for top,
b for bottom, n for north, and s for south). If all of the shutters were closed it returns closed. If all shells had the same shutter configuration, a single summary is
returned.
In an array context, shutter_parse returns an associative array with the shell numbers as the keys and the
open shutters (in the same format as above) as their values. If no shutters
are open, the value is the string none.
If the input string has errors, it returns either undef, in a scalar context, or an empty array in an array context.
For example, given the input string,
cocc|ccco|cocc|ococ
in a scalar context shutter_parse returns the string
1n_3s_4n_6tb
while in an array context it returns the associative array
'1' => 'n' '3' => 's' '4' => 'n' '6' => 'tb'
If the shells have the same shutter configuration,
ococ|ococ|ococ|ococ
the descriptions are collapsed to
tb
If all of the shutters are open, an empty string is returned.
shutter_parsecmdb interprets shutter configuration information given by the CMDB Shutters field. It returns a set of shutter flags suitable for use with the quad_shutter aperture module, ie.
shell 1111 3333 4444 6666 quadrant tnbs tnbs tnbs tnbs output xxxx_xxxx_xxxx_xxxx
where the x's in output are replaced with c or o, depending upon the state of the shutter. If a SCAN is requested, four shutter flag sets are returned, one for each
configuration in the scan.
Note that shutter_parsecmdb returns an array, not a scalar. If it detects an error, it returns an empty array.
Some examples:
{1,ALL} -> oooo_cccc_cccc_cccc
{1,SCAN} -> occc_cccc_cccc_cccc,
cocc_cccc_cccc_cccc,
ccoc_cccc_cccc_cccc,
ccco_cccc_cccc_cccc
{CLOSED} -> cccc_cccc_cccc_cccc
{DISCRETE,T-,N-,B-,S1346} -> ccco_ccco_ccco_ccco
{DISCRETE,T1346,N1346,B136,S146} -> oooo_oooc_ooco_oooo
{HEG,ALL} -> cccc_cccc_oooo_oooo
{MEG,ALL} -> oooo_oooo_cccc_cccc
IRIG times are generally given as the day number followed by the time, in hours, minutes, and seconds. IRIG times are always GMT. Since there's no year specified in the IRIG time (although one can get up to 1000 days), there's a bit of ambiguity. Here we follow what happened at the XRCF: the day field is used to specify the cardinal index of the day in the year. Thus the day counter was reset on 1 Jan 1997, so that days less than 200 are in 1997, greater than 200 are in 1996.
There are several IRIG time input formats which are recognized. Things in brackets are optional:
dddhhmmssfff
[dd]d/[h]h:[m]m:[s]s[.f[ff]]
[dd]d:[h]h:[m]m:[s]s[.f[ff]]
This function is useful when comparing to IRIG times. It converts an IRIG time into fractional days. It maintains the sequential ordering of days across the 1 Jan 1997 XRCF IRIG reset; day 001 becomes day 367.
It returns the fractional day.
This takes an IRIG time and produces a date and time parseable by humans or databases. It takes an optional argument denoting the formatting of the output date. The format is one of
which produces a date like
1996-12-15 01:20:6.4333-00
which produces a date like
12 15 01:20:6.4333 1996 AD GMT
It defaults to ISO
Local times are generally given as a two digit year followed by the month, day of the month, and the time, in hours, minutes, and seconds.
There is only one local time output format recognized.
YYMMDD:hh:mm:ss
This takes an local time and produces a date and time parseable by humans or databases. It takes an optional argument denoting the formatting of the output date. The format is one of
which produces a date like
1996-12-15 01:20:6.4333-00
which produces a date like
12 15 01:20:6.4333 1996 AD GMT
It defaults to ISO