MARCCD

marccd_open
Opens a TCP/IP socket connection to the MAR host. Needs the Spectra symbol MARCCD_HOST. Assumes the server runs on port 2002. If this call is omitted, the other functions do it automatically.

marccd_close()
Closes the socket.

marccd_abort()
Sends the abort command.

marccd_get_state()
Returns the status info. It consists of two numbers, the first describes the previous state, the second the current state. See the following table for the meaning.

IDLE 0
ACQUIRE 1
READOUT 2
CORRECT 3
WRITING 4
ABORTING 5
UNAVAILABLE 6
ERROR 7
BUSY 8

marccd_start()
Sends the start command and waits for the state “81”.

marccd_readout()
Reads the CCD, which takes about 3 seconds, and waits for the state “20”.

marccd_readout_bg()
Reads the background image, which takes about 3 seconds, and waits for the state “20”.

marccd_readout_mr()
Reads the mr image and waits for the state “20”.

marccd_correct()
Subtracts the backgound from the image and waits for the state “30”.

marccd_send_header( $string)
Sends a string to the header.

marccd_writefile( $fileName)
Sends th writefile command and waits for the state “40”.

This is a typical sequence:

marccd_abort() or die "Failed to 'abort'"; 
marccd_start() or die "Failed to 'start'"; 
sleep 1;
marccd_readout_bg() or die "Failed to 'readout_bg'"; 
marccd_start() or die "Failed to 'start'"; 
sleep 1;
marccd_readout() or die "Failed to 'readout'"; 
marccd_correct() or die "Failed to 'correct'"; 
marccd_writefile( $fileName) or die "Failed to 'writefile'";

This is the implemantion as a virtual counter (VC):

if( $method =~ /reset/i)
{
    Spectra::marccd_abort(); 
    return Spectra::marccd_start(); 
}

if( $method =~ /read/i)
{
    Spectra::marccd_readout();
    Spectra::marccd_correct();
    my $fname = $Spectra::SYM{ scan_name} . "_" . $Spectra::SYM{ sindex}; 
    return Spectra::marccd_writefile( $fname); 
}

To be sure that the first image does not contain the previously collected noise, we provide the following extra-code for the 'before' script:

#
# clear the second shutter
#
Spectra::gra_command( "wor(oreg1) = 0");
#
# clear MARCCD
#
Spectra::marccd_readout();