#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <termios.h>
#include <fcntl.h>
#include <signal.h>
#include <math.h>
Go to the source code of this file.
Defines | |
| #define | SH_OPEN 1 |
| Shutter is open. | |
| #define | SH_CLOSED 0 |
| Shutter is closed. | |
| #define | IDLE 0 |
| Server is idle and awaiting commands. | |
| #define | READOUT 1 |
| Server is busy reading out the detector. | |
| #define | EXPOSING 2 |
| Server is busy exposing (integrating) the detector. | |
| #define | PAUSE 3 |
| Server is busy with a paused exposure. | |
| #define | DT670 0 |
| Temperature sensor is a DT670 diode. | |
| #define | AD590 1 |
| Temperature sensor is an AD590 IC temperature transducer. | |
| #define | N914 3 |
| Temperature sensor is a 1N914 diode (weirdness of C, doesn't allow a #def to begin with a number). | |
| #define | DARK_IMAGE 0 |
| Dark image, keep shutter closed during integration. | |
| #define | LIGHT_IMAGE 1 |
| Light image, open shutter during integration. | |
| #define | TDI 2 |
| TDI mode, shutter open during readout (unsupported, for future expansion). | |
| #define | EXP_NOWAIT 0 |
| Do not wait for exposure to complete, return immediately from StartExposure. | |
| #define | EXP_WAIT 1 |
| Wait for exposure to complete before returning status from StartExposure. | |
| #define | IMMEDIATE 0 |
| Readout occurs immediately after integration. | |
| #define | DEFERRED 1 |
| Readout is deferred until explicit readout request. | |
| #define | STDFITS 1 |
| Write image as Standard FITS format. | |
| #define | BINARY 2 |
| Write image as raw Binary format. | |
| #define | EXTFITS 3 |
| Write image as Extended FITS (MEF) format. | |
| #define | GUIDER_CLIENT 1 |
| [Open] a persistent guider client socket | |
| #define | GUIDER_CLOSE 2 |
| Close a guider client socket. | |
| #define | MESSAGE_CLIENT 3 |
| [Open] a persistent message client socket | |
| #define | MESSAGE_CLOSE 4 |
| Close a message client socket. | |
| #define | DISPLAY_CLIENT 5 |
| Set hostname/port of a display client socket. | |
| #define | FILE_CLIENT 6 |
| Set hostname/port of a file client socket. | |
| #define | SINGLE_AMP 0 |
| Single-amplifier readout mode. | |
| #define | TWO_AMP_PARALLEL 1 |
| 2-amplifier, split parallels, diagonally opposed corners readout | |
| #define | TWO_AMP_SERIAL 2 |
| 2-amplifier, split serials | |
| #define | FOUR_AMP_QUAD 3 |
| 4-amplifier, quad radout | |
| #define | MOSAIC 6 |
| Multi-detector mosaic. | |
| #define | NO_SPLIT 0 |
| Detector has no split registers. | |
| #define | SPLIT_SERIAL 1 |
| Detector has split serial registers (2-amp readout). | |
| #define | SPLIT_PARALLEL 2 |
| Detector has split parallel registers (2-amp readout). | |
| #define | SPLIT_QUAD 3 |
| Detector has split parallel and serial registers (4-amp readout). | |
Typedefs | |
| typedef azcam | azcam_t |
| AzCam Server Parameter Table. | |
Functions | |
| int | OpenAzCam (azcam_t *, char *) |
| Open a TCP socket connection to an AzCamServer. | |
| void | CloseAzCam (azcam_t *) |
| Terminate an AzCam client session and close the server socket. | |
| int | WriteAzCam (azcam_t *, char *) |
| Write data to an AzCam server TCP socket. | |
| int | ReadAzCam (azcam_t *, char *) |
| Read data from an AzCam server TCP socket. | |
| int | AzCamCommand (azcam_t *, char *, char *) |
| Send a command to the AzCam server and await a reply. | |
| int | CloseConnection (azcam_t *, char *) |
| Close the AzCam Server Connection. | |
| int | RunScript (azcam_t *, char *, char *) |
| Execute an AzCam command script on the server. | |
| int | SetParameter (azcam_t *, char *, char *, char *, char *) |
| Set a FITS card in the AzCam server's header database. | |
| int | GetParameter (azcam_t *, char *, char *, char *) |
| Get the value of a FITS card in the AzCam server's header database. | |
| int | ClearParameter (azcam_t *, char *) |
| Clear the AzCam server's FITS header database. | |
| int | SetSocket (azcam_t *, int, char *, int, char *) |
| Open/Close socket connections to various AzCam server clients. | |
| int | WriteImage (azcam_t *, char *, char *) |
| Write an image from memory to disk. | |
| int | SendImage (azcam_t *, int, char *, int, char *) |
| Send the image in memory to the named client. | |
| int | ClearArray (azcam_t *, char *) |
| Clear (erase) the detector array. | |
| int | StartExposure (azcam_t *, int, char *) |
| Start an exposure (integration). | |
| int | SetExposure (azcam_t *, float, char *) |
| Set the exposure (integration) time. | |
| int | ReadExposure (azcam_t *, char *) |
| Query the AzCam server for the current elapsed exposure time. | |
| int | AbortExposure (azcam_t *, char *) |
| Abort an exposure in progress. | |
| int | PauseExposure (azcam_t *, char *) |
| Pause an exposure in progress. | |
| int | ResumeExposure (azcam_t *, char *) |
| Resume a paused exposure. | |
| int | SetFormat (azcam_t *, char *) |
| Define the detector format in unbinned pixels. | |
| int | SetConfiguration (azcam_t *, char *) |
| Define the detector readout configuration. | |
| int | SetROI (azcam_t *, char *) |
| Define the detector region of interest for the next readout. | |
| int | OpenShutter (azcam_t *, char *) |
| Open the Shutter. | |
| int | CloseShutter (azcam_t *, char *) |
| Close the Shutter. | |
| int | RowShift (azcam_t *, int, char *) |
| Shift the image on the array by a given number of rows. | |
| int | GetDetPars (azcam_t *, char *) |
| Query the AzCam server for the current image size. | |
| int | GetPixelCount (azcam_t *, char *) |
| Query the AzCam server for the number of pixels readout. | |
| int | SetShutterMode (azcam_t *, int, char *) |
| Set the shutter mode. | |
| int | SetReadoutMode (azcam_t *, int, char *) |
| Set the detector readout mode. | |
| int | GetTemp (azcam_t *, char *) |
| Get the Detector and Dewar temperatures. | |
| int | SetTemp (azcam_t *, float, char *) |
| Set the CCD temperature set point. | |
| int | SetTempCal (azcam_t *, int, int, int, char *) |
| Set the calibration curves used for each temperature sensor. | |
| void | InitAzCam (azcam_t *) |
| Initialize an azcam data structure. | |
| void | AzCamInfo (azcam_t *) |
| Print the contents of the struct on stdout. | |
| int | ARCCommand (azcam_t *, char *, char *) |
| Send a raw command to the ARC Controller. | |
2005 May 17 - updated and cleaned up Doxygen hooks [rwp/osu]
|
|
Shutter is open.
|
|
|
Shutter is closed.
|
|
|
Server is idle and awaiting commands.
|
|
|
Server is busy reading out the detector.
|
|
|
Server is busy exposing (integrating) the detector.
|
|
|
Server is busy with a paused exposure.
|
|
|
Temperature sensor is a DT670 diode.
|
|
|
Temperature sensor is an AD590 IC temperature transducer.
|
|
|
Temperature sensor is a 1N914 diode (weirdness of C, doesn't allow a #def to begin with a number).
|
|
|
Dark image, keep shutter closed during integration.
|
|
|
Light image, open shutter during integration.
|
|
|
TDI mode, shutter open during readout (unsupported, for future expansion).
|
|
|
Do not wait for exposure to complete, return immediately from StartExposure.
|
|
|
Wait for exposure to complete before returning status from StartExposure.
|
|
|
Readout occurs immediately after integration.
|
|
|
Readout is deferred until explicit readout request.
|
|
|
Write image as Standard FITS format.
|
|
|
Write image as raw Binary format.
|
|
|
Write image as Extended FITS (MEF) format.
|
|
|
[Open] a persistent guider client socket
|
|
|
Close a guider client socket.
|
|
|
[Open] a persistent message client socket
|
|
|
Close a message client socket.
|
|
|
Set hostname/port of a display client socket.
|
|
|
Set hostname/port of a file client socket.
|
|
|
Single-amplifier readout mode.
|
|
|
2-amplifier, split parallels, diagonally opposed corners readout
|
|
|
2-amplifier, split serials
|
|
|
4-amplifier, quad radout
|
|
|
Multi-detector mosaic.
|
|
|
Detector has no split registers.
|
|
|
Detector has split serial registers (2-amp readout).
|
|
|
Detector has split parallel registers (2-amp readout).
|
|
|
Detector has split parallel and serial registers (4-amp readout).
|
|
|
AzCam Server Parameter Table. Contains basic information about the AzCam server configuration we're using. It starts simple and will become more complex as required. |
|
||||||||||||
|
Open a TCP socket connection to an AzCamServer.
For socket communications we use INET streams (SOCK_STREAM) with a persistent client connection.
|
|
|
Terminate an AzCam client session and close the server socket.
|
|
||||||||||||
|
Write data to an AzCam server TCP socket.
On errors, it returns an error message in cmdstr.
|
|
||||||||||||
|
Read data from an AzCam server TCP socket.
|
|
||||||||||||||||
|
Send a command to the AzCam server and await a reply.
|
|
||||||||||||
|
Close the AzCam Server Connection.
|
|
||||||||||||||||
|
Execute an AzCam command script on the server.
|
|
||||||||||||||||||||||||
|
Set a FITS card in the AzCam server's header database.
This feature of AzCam is somewhat inflexible in that all parameters are treated as string type FITS header keywords. A sensible AzCam client application will employ a postprocessing routine to launder the non-standard FITS headers coming from the AzCam server into more conventional form.
|
|
||||||||||||||||||||
|
Get the value of a FITS card in the AzCam server's header database.
Note that the AzCam server stores all user-defined header parameters as strings. The calling application will need to translate that string into the appropriate data type (int, float, boolean, or string) as required.
|
|
||||||||||||
|
Clear the AzCam server's FITS header database.
|
|
||||||||||||||||||||||||
|
Open/Close socket connections to various AzCam server clients.
Supported client codes are:
GUIDER_CLIENT - opens a connection to an autoguider client
GUIDER_CLOSE - closes a connection to an autoguider client
MESSAGE_CLIENT - opens a connection to a message client (sees all status messages)
MESSAGE_CLOSE - closes a connection to a messge client
DISPLAY_CLIENT - defines a display client (SendImage() will open/close socket)
FILE_CLIENT - defines a file handler client (SendImage() will open/close socket)
There are two classes of clients at work: persistent clients whose socket connections are opened or closed by this function (Guider and Message clients), and non-persistent clients that are opened/closed by the SendImage() function.
|
|
||||||||||||||||
|
Write an image from memory to disk.
The filename provided must be the full name of the file including all counters, paths, etc. The calling application is responsible for building a full valid filename; this function cannot do validation. The path must be a valid file path on the AzCam server proper. On successful completion, this function sets the azcam::LastFile datum to tell the calling application the name of the file just written. It does not, however advance file counters. That is the responsibility of the calling application (since counters are optional). |
|
||||||||||||||||||||||||
|
Send the image in memory to the named client.
If client is DISPLAY_CLIENT, the AzCam server opens the client socket, sends the data, then closes the client socket. If client is FILE_CLIENT, the AzCam server opens the client socket, sends the complete image (header+data), then closes the client socket. If client is GUIDER_CLIENT, the AzCam server sends the image data to the client. The AzCam server does not first open the guider client, this must be done with a previous call to SetSocket(). |
|
||||||||||||
|
Clear (erase) the detector array.
|
|
||||||||||||||||
|
Start an exposure (integration).
If wait=EXP_WAIT, the AzCam server will not return status until the integration is completed. This is usually only done for zero-length (ZERO or BIAS) images, or very short integrations where the application decides not to poll the exposure progress using ReadExposure() calls. If wait=EXP_NOWAIT, the AzCam server will return status immediately after starting the integration. Integration progress can be monitored using the ReadExposure() function. IMPORTANT: if wait=EXP_WAIT, the timeout interval for the AzCam server communications (azcam::Timeout) must be set long enough as as to not timeout before the integration is complete. To ensure that this does not happen, we store the current default timeout, compute a new timeout of the exposure time + 10 seconds, and then make the call, resetting the default timeout after completion (or error). The exposure time used is the value in the azcam::ExpTime data member.
|
|
||||||||||||||||
|
Set the exposure (integration) time.
|
|
||||||||||||
|
Query the AzCam server for the current elapsed exposure time.
|
|
||||||||||||
|
Abort an exposure in progress.
Because of some odd hardware interactions that we have observed, an AbortExposure() command must be preceeded by PauseExposure(). We do not know if this is generic to all ARC controllers or just the ones we're working with at OSU. Applications calling this API should call AbortExposure() with some circumspection. |
|
||||||||||||
|
Pause an exposure in progress.
A PauseExposure should be followed by either AbortExposure() or ResumeExposure(). We test the value of the azcam::State flag and only send a PauseExposure command if EXPOSING. Sending a PauseExposure directive otherwise may be unpredictable.
|
|
||||||||||||
|
Resume a paused exposure.
Does not send ResumeExposure if the controller is not in a PAUSE state. If you send a ResumeExposure() command when the AzCam server is not actually in a paused state, very bad things can happen (e.g., it crashes and reboots its host computer).
|
|
||||||||||||
|
Define the detector format in unbinned pixels.
azcam::NCtotal - Total number of columns (serial pixels)
azcam::NCpredark - Number of physical dark prescan columns
azcam::NCunderscan - Number of underscan columns to read
azcam::NCoverscan - Number of overscan columns to read
azcam::NRtotal - Total number of rows (lines)
azcam::NRpredark - Number of physical dark prescan rows
azcam::NRunderscan - Number of underscan rows to read
azcam::NRoverscan - Number of overscan rows to read
azcam::NRframexfer - Number of rows to shift for frame transfer mode
A calling application would first set the various parameters in the azcam struct and then call this function to send them to the AzCam server.
|
|
||||||||||||
|
Define the detector readout configuration.
azcam::ReadMode - Readout Mode, one of SINGLE_AMP, TWO_AMP_PARALLEL,
TWO_AMP_SERIAL, FOUR_AMP_QUAD, or MOSAIC
azcam::Splits - Split register flag, one of NO_SPLIT, SPLIT_SERIAL,
SPLIT_PARALLEL, or SPLIT_QUAD
azcam::NumDetX - Number of X (columns) direction detectors in a
multi-detector mosaic
azcam::NumDetY - Number of Y (rows) direction detectors in a
multi-detector mosaic
azcam::AmpConfig - Amplifier configuration string, one parameter per
amp, 0=no flip, 1=flip cols, 2=flip rows, 3=flip both
A calling application would first set the various parameters in the azcam struct and then call this function to send them to the AzCam server.Note, if the ReadMode is changed, you must call SetROI immediately after, or bad things will happen.
|
|
||||||||||||
|
Define the detector region of interest for the next readout.
azcam::FirstCol - first column to read in unbinned pixels
azcam::LastCol - last column to read in unbinned pixels
azcam::ColBin - column-axis binning factor
azcam::FirstRow - first row to read in unbinned pixels
azcam::LastRow - last row to read in unbinned pixels
azcam::RowBin - row-axis binning factor
Note that regions of interest that are smaller than the physical size of the device in unbinned pixels are only supported for single-amplifier readout modes. |
|
||||||||||||
|
Open the Shutter.
|
|
||||||||||||
|
Close the Shutter.
|
|
||||||||||||||||
|
Shift the image on the array by a given number of rows.
We allow nrows=0 as a way to take repeated images without row shifts (commonly done for shutter shading correction images). If nrows=0, it returns success rather than sending "ParShift 0" to the server. This function implements the ParShift server command. We elected to call it RowShift since that syntax is closer to what we do in other OSU instruments (ParShift stands for "PARallel SHIFT": the ITL folks use "Parallel" and "Serial" the same way OSU folks use "Vertical" and "Horizontal"). |
|
||||||||||||
|
Query the AzCam server for the current image size.
|
|
||||||||||||
|
Query the AzCam server for the number of pixels readout.
Note that unlike ReadExposure(), experiments have so far shown that calling GetPixelCount() is benign in all circumstances.
|
|
||||||||||||||||
|
Set the shutter mode.
DARK_IMAGE: shutter kept closed during integration
LIGHT_IMAGE: shutter is opened during integration
TDI: shutter open during readout (currently unsupported)
Shutter mode settings stay in force for the rest of the AzCam session unless changed.This function implements the "SetMode 1 X" server command.
|
|
||||||||||||||||
|
Set the detector readout mode.
IMMEDIATE: readout is initiated immediately after integration
DEFERRED: readout is deferred until an explicit readout is requested
IMMEDIATE mode should be used for all normal exposures, whereas DEFERRED is used for custom multiple exposures like focus plates, nod-and-shuffle, shutter shading calibrations, etc.This function implements the "SetMode 2 X" server command, where we have introduced the "immediate" and "deferred" mode names.
|
|
||||||||||||
|
Get the Detector and Dewar temperatures.
|
|
||||||||||||||||
|
Set the CCD temperature set point.
The new setpoint temperature is stored in azcam::SetPoint data member for use by the application. SetTemp implements the SetTemperature server command. The name was shortened to match the syntax of the related GetTemp and SetTempCal server commands.
|
|
||||||||||||||||||||||||
|
Set the calibration curves used for each temperature sensor.
DT670 - DT670 diode
AD590 - AD590 sensor
N914 - 1N914 diode
Note that there is an oddity about C in that parameters defined as "macros" with #define statements apparently cannot begin with numbers, which is why for the 1N914 diode we use N914 not 1N914 as the value passed to the subroutine. Go figure.
|
|
|
Initialize an azcam data structure.
This function should be called to clear out the azcam struct before filling it with valid data (e.g., from a setup file loaded by the application). |
|
|
Print the contents of the struct on stdout.
|
|
||||||||||||||||
|
Send a raw command to the ARC Controller.
A complete list of valid ARC Controller commands can be found in section 11 of the AzCam Programmers Reference Manual. |
1.4.2