Main Page | Class List | Directories | File List | Class Members | File Members

ccu.h File Reference

CCU (communication with the CCD Control Unit). More...

#include <stdio.h>
#include "serial.h"
#include <sys/time.h>
#include <progress.h>

Go to the source code of this file.

Defines

#define __ccu_h   1
#define ccu_errorcode_ok   0
#define ccu_errorcode_domino   1
#define ccu_errorcode_load   2
#define ccu_errorcode_sequence   3
#define ccu_errorcode_copy_memory   4
#define ccu_errorcode_protocol   5
#define ccu_errorcode_time_out   6
#define ccu_errorcode_vme   7
#define ccu_origin_dummy_logic   1
#define ccu_origin_transfer   2
#define ccu_origin_image   3
#define ccu_origin_readout   4
#define ccu_origin_device   5
#define ccu_origin_load   6
#define ccu_origin_wait   7
#define ccu_status_idle   0
#define ccu_status_ok   1
#define ccu_status_busy   2
#define ccu_status_fail   3
#define ccu_status_readout   4
#define ccu_status_waiting   5
#define ccu_status_dummy_read   6
#define ccu_status_downloading   8
#define ccu_timeout   10
#define ccu_closed   0
#define ccu_open   1

Functions

void ui_ccu_progress_changed (struct ccu_status_struct)
 called by ccu.c whenever its progress-/status- property has changed.
void ui_ccu_switches_changed (struct ccu_status_struct)
 called by ccu.c whenever its switches property changed.
void ui_ccu_codes_changed (struct ccu_status_struct)
 called by ccu.c whenever its codes property changed.
void ui_ccu_ser_in (const char *str)
 called by ccu.c whenever something is received from the CCU's serial port.
void ui_ccu_ser_out (const char *str)
 called by ccu.c whenever something is send to the CCU's serial port.
void ui_ccu_sequences_changed (struct ccu_sequence_struct)
 called by ccu.c whenever the sequence list changed.
void ui_ccu_zero_volt_set (void)
 called by ccu.c whenever the zero volt sequence has been successfully executed.
int ccu_test_avail (void)
 tests whether the CCU is available and initalized it if possible.
int ccu_init (void)
 initializes ccu.c.
int ccu_zero_volt ()
 starts the zero volt sequence on the CCU.
void ccu_done (void)
 closes ccu.c.
int ccu_reset_kerneldriver ()
 resets the kernel driver.
void ccu_display_ser_in (const char *str)
void ccu_display_ser_out (const char *str)
int end_message_get_error_code (const char *endmsg)
 extracts the error code from an endmessage received from the CCU.
int ccu_quit ()
 sends a quit signal to the CCU
int ccu_quit_msg ()
 sends a quit signal to the CCU
int ccu_dummy_read ()
 starts a continues dummy read
int ccu_shutter_open ()
 opens the shutter.
int ccu_shutter_close ()
 closes the shutter.
int ccu_load_sequence_context (void)
 loads the sequence list from the CCU.
int ccu_parse_database ()
 loads and parses a database given in the .SQ file
int ccu_start_queue ()
 starts a queue in the ccu.
int ccu_clear_queue ()
 clears the queue CCU and empties the queue in ccu.c
int ccu_readout_user (char *str)
 starts a readout, with a user defined readout command.
int ccu_queue_pop_item (char *dummy)
 pops a command from the queue.
void ccu_queue_push_item (char *input)
 queues a new command into the queue.
int ccu_upload_database_file (char *filename)
 downloads a database into the CCU.
ccu_status_struct ccu_get_status ()
 returns the current status of the CCU.
char * ccu_function_origin_message (int funcorig)
 retruns a string corresponding to the given function origin code emitted by the CCU.
char * ccu_error_message (int error)
 retruns a string corresponding to the given error code emitted by the CCU.
void ccu_parse_endmessage (const char *endmsg)
 parses an endmessage and sets the status accordingly
int ccu_get_ysize ()
 returns the y size of the image beeing acquired currently.
int ccu_get_xsize ()
 returns the x size of the image beeing acquired currently.
progress_struct ccu_get_progress ()
 returns the current progress of the CCU.
void ccu_ser_in (const char *str)
 called whenever something is received from the CCU
void ccu_ser_out (const char *str)
 called whenever something is sent to the CCU
char * ccu_status_message (int code)
 retruns a string corresponding to status code defined in ccu.h.
void ccu_reset_breakcondition ()
 resets the CCUs break condition flag.
void ccu_reset_warning ()
 resets the CCUs warning flag.
int ccu_wait_for_end_message (int timeout)
 waits for the CCU to send an end message.
void ccu_reset_com_problem (void)
 resets the CCUs communication problem flag.
void ccu_set_com_problem (void)
 sets the CCUs communication problem flag.
char * ccu_status_text (int code)
 retruns a string corresponding to status code defined in ccu.h.
int ccu_queue_file (char *filename)
 queues a list of commands read from a file.
int ccu_send_queue ()
 send a queue to the CCU.
size_t ccu_read_usb (unsigned char *data)
 reads 512 bytesfrom the usb kerneldriver.
int ccu_finish ()
 Destuctor.
void ccu_simulate_image ()
 Fills the image buffer with some pseudoastronimical data.
void ccu_start_database_dowload (char *str)
 starts a thread that will download the database into the CCU
void ccu_start_database_dowload_basename (char *str)
 starts a thread that will download the database into the CCU
void ccu_set_progress (char *msg, float f)
 sets the progress struct of ccu.c.
void ccu_start_zero_volt ()
 starts a thread that will run the zero volt sequence in the CCU

Variables

int command_block
double ccu_shutter_offset
char ccu_sequence_context_full [100][1000]
serdev * ccu_device
char ccu_sequence_context [100][1000]
FILE * ccu_usbdev_file
ccu_database_struct ccu_database [100]
char ccu_database_filename [1000]
char ccu_usbdev [1000]
char ccu_dev [1000]
char ccu_ctrldir [1000]
char logfile_name [1000]
char ccu_database_dir [1000]
int ccu_stty_baud
int ccu_channels
char ui_ccu_sequence_context [100][1000]


Detailed Description

CCU (communication with the CCD Control Unit).

Copyright (C) 2001-2003 Dirk Huenniger (dhun@astro.uni-bonn.de)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.


Function Documentation

int ccu_clear_queue  ) 
 

clears the queue CCU and empties the queue in ccu.c

Returns:
integer an error code
This function clears the queue CCU and empties the queue in ccu.c

void ccu_done void   ) 
 

closes ccu.c.

Returns:
void
This function closes ccu.c. It has to be called exatly one time. No function of ccu.c should be called after ccu_done has been called.

int ccu_dummy_read  ) 
 

starts a continues dummy read

Returns:
integer an error code
This function starts a continues dummy read. All charges on the chip are removed. Be carful, because it will take some time until the charge is actually removed from the chip. Use ccu_single_dummy read to make shure that the chip was cleased at least once.

char* ccu_error_message int  error  ) 
 

retruns a string corresponding to the given error code emitted by the CCU.

Parameters:
error the error code
Returns:
char* the error message string
This function retruns a string corresponding to the given error code emitted by the CCU.

int ccu_finish  ) 
 

Destuctor.

Returns:
error code
This function has to be called when you dont waht to use the ccd controller anymore. If just frees some memory.

char* ccu_function_origin_message int  funcorig  ) 
 

retruns a string corresponding to the given function origin code emitted by the CCU.

Parameters:
funcorig the function origin code
Returns:
char* the message string
This function retruns a string corresponding to the given function origin code emitted by the CCU.

struct progress_struct ccu_get_progress  ) 
 

returns the current progress of the CCU.

Returns:
progress_struct a struct describing the current progress of the CCU
This function returns a struct describing the current progress of the CCU.

struct ccu_status_struct ccu_get_status  ) 
 

returns the current status of the CCU.

Returns:
ccu_status_struct a struct describing the current status of the CCU
This function returns a struct describing the current status of the CCU.

int ccu_get_xsize  ) 
 

returns the x size of the image beeing acquired currently.

Returns:
integere the x size in pixels of the current image This function returns the x size of the image beeing acquired currently.

int ccu_get_ysize  ) 
 

returns the y size of the image beeing acquired currently.

Returns:
integer the y size in pixels of the current image This function returns the y size of the image beeing acquired currently.

int ccu_init void   ) 
 

initializes ccu.c.

Returns:
integer (0 on success, an errorcode described in error.h otherwise)
This function initializes ccu.c. It has to be called exatly one time. It has to called before any other function of ccu.c is called.

int ccu_load_sequence_context void   ) 
 

loads the sequence list from the CCU.

Returns:
integer an error code
This function loads the sequence list from the CCU. the sequencst list is loaded until it two subsequncet trys lead to an identical sequence list. If this condition cannot be fullfilled by the 4th try an error is returned.

int ccu_parse_database  ) 
 

loads and parses a database given in the .SQ file

Returns:
integer an error code
This function loads and parses a database given in the .SQ file. The results are stored in ccu_database.

void ccu_parse_endmessage const char *  endmsg  ) 
 

parses an endmessage and sets the status accordingly

Parameters:
endmsg the endmessage received form the CCU
Returns:
void
This function parses an endmessage received from the CCU and sets the ccu_status_struct accordingly.

int ccu_queue_file char *  filename  ) 
 

queues a list of commands read from a file.

Parameters:
filename the name of the file to be read
Returns:
integer error/success code
This function queues a list of commands read from a file. Later on the queue can be transferred to the ccu via ccu_send_queue and started using ccu_start_queue.

int ccu_queue_pop_item char *  dummy  ) 
 

pops a command from the queue.

Parameters:
dummy a pointer to the region in memory where the poped command shall be stored
Returns:
integer 0 on success, -1 on failure
This function pops a command from the queue.

void ccu_queue_push_item char *  input  ) 
 

queues a new command into the queue.

Parameters:
input the command to be queued
Returns:
void
This function queues a command into the queue. Later on the queue can be transferred to the ccu via ccu_send_queue and started using ccu_start_queue.

int ccu_quit  ) 
 

sends a quit signal to the CCU

Returns:
integer an error code
This function sends a quit signal to the CCU. Any operastion on the CCU is stopped.

int ccu_quit_msg  ) 
 

sends a quit signal to the CCU

Returns:
integer an error code
This function sends a quit signal to the CCU. Any operastion on the CCU is stopped.

size_t ccu_read_usb unsigned char *  data  ) 
 

reads 512 bytesfrom the usb kerneldriver.

Parameters:
data a pointer to 512 byte of memory to store the data
Returns:
size_t 1 if 512 byte have been read, 0 otherwise
This function reads up 512 byte from the usb kerneldriver. It retruns 1 if a 512 byte block has been read, and 0 otherwise.

int ccu_readout_user char *  str  ) 
 

starts a readout, with a user defined readout command.

Parameters:
str the user defined readout command
Returns:
integer an error code
This function starts a readout with a readout command given by the parameter.

void ccu_reset_breakcondition  ) 
 

resets the CCUs break condition flag.

Returns:
void This function resets the CCUs break condition flag.

void ccu_reset_com_problem void   ) 
 

resets the CCUs communication problem flag.

Returns:
void This function resets the CCUs communication problem flag.

int ccu_reset_kerneldriver  ) 
 

resets the kernel driver.

Returns:
integer an error code
The deltails of this routine are still subject of ongoing research. Open for writing removes all usb request block from the queue in the usb kernel subsystem and resets the cypress chip totally. For reasons not fully understood jet it is necessary to reset the kernel driver twice before it can finally be opened for reading.

void ccu_reset_warning  ) 
 

resets the CCUs warning flag.

Returns:
void This function resets the CCUs warning flag.

int ccu_send_queue  ) 
 

send a queue to the CCU.

Returns:
integer error/success code
This function sends the queue to the CCU.

void ccu_ser_in const char *  str  ) 
 

called whenever something is received from the CCU

Parameters:
str the string received from the CCU
Returns:
void
This function is called whenever something is received from the CCU.

void ccu_ser_out const char *  str  ) 
 

called whenever something is sent to the CCU

Parameters:
str the string sent to the CCU
Returns:
void
This function is called whenever something is sent to the CCU.

void ccu_set_com_problem void   ) 
 

sets the CCUs communication problem flag.

Returns:
void This function sets the CCUs communication problem flag.

void ccu_set_progress char *  msg,
float  f
 

sets the progress struct of ccu.c.

Parameters:
msg a progress message.
f a number between 0 and 1 descibing how much progress has allready been made
Returns:
void This function sets the progress struct of the CCU. The abstract function ui_ccu_progress_changed is called in order to inform the ui about this change.

int ccu_shutter_close  ) 
 

closes the shutter.

Returns:
integer an error code
This function closes the shutter.

int ccu_shutter_open  ) 
 

opens the shutter.

Returns:
integer an error code
This function opens the shutter.

void ccu_simulate_image  ) 
 

Fills the image buffer with some pseudoastronimical data.

Parameters:
bias the bias value (the mean value of the image).
the maximum value of the noise.
image the image buffer, must be 16bit*xsize*ysize
Returns:
void This function fills the image buffer with some pseudoastronimical data.

void ccu_start_database_dowload char *  str  ) 
 

starts a thread that will download the database into the CCU

Parameters:
str the filename of the database to be downloaded without ".DB"
Returns:
void
This function starts a thread that will download the database into the CCU. For example if you would like to donwload "/user/classic.DB" you have to pass the string "/user/classic"

void ccu_start_database_dowload_basename char *  str  ) 
 

starts a thread that will download the database into the CCU

Parameters:
str the basename of the database to be downloaded.
Returns:
void
This function starts a thread that will download the database into the CCU. For example if you would like to donwload "/user/classic.DB" you have to pass the string "classic". Note that the database must be in the directory given by ccu_database_dir

int ccu_start_queue  ) 
 

starts a queue in the ccu.

Returns:
integer an error code
This function starts a queue in the ccu. You have to do queue your command with ccu_queue_push_item. Than you can send them with ccu_send_queue. And finally you can start it using this function.

void ccu_start_zero_volt  ) 
 

starts a thread that will run the zero volt sequence in the CCU

Returns:
void
This function starts a thread that will run the zero volt sequence in the CCU.

char* ccu_status_message int  code  ) 
 

retruns a string corresponding to status code defined in ccu.h.

Parameters:
code the status code
Returns:
char* the message string (pango markup)
This function retruns a string corresponding to status code defined in ccu.h.

char* ccu_status_text int  code  ) 
 

retruns a string corresponding to status code defined in ccu.h.

Parameters:
code the status code
Returns:
char* the message string (lain text)
This function retruns a string corresponding to status code defined in ccu.h.

int ccu_test_avail void   ) 
 

tests whether the CCU is available and initalized it if possible.

Returns:
integer an error code
This function tests whether the CCU is available. If so it reads the sequence context stored in the CCU and compares it with the data stored in the current .SQ file. The bits break waraning comproblem are reset. An error/success code is returned.

int ccu_upload_database_file char *  filename  ) 
 

downloads a database into the CCU.

Parameters:
filename the name of the file containing the database
Returns:
integer error/success code
This function downloads a database into the CCU.

int ccu_wait_for_end_message int  timeout  ) 
 

waits for the CCU to send an end message.

Parameters:
timeout timeout in seconds
Returns:
integer an error code
This function waits until an endmessage has been received from the CCU or the timeout condition has been reached.

int ccu_zero_volt  ) 
 

starts the zero volt sequence on the CCU.

Returns:
integer an error code
This function runs the zero volt sequnce. It is needed during the chip removal/installation procedure.

int end_message_get_error_code const char *  endmsg  ) 
 

extracts the error code from an endmessage received from the CCU.

Parameters:
endmsg the endmessage revceived from the CCU
Returns:
integer (0 means: no error)
This function extracts the error code from an endmessage received from the CCU.

void ui_ccu_codes_changed struct ccu_status_struct  input  ) 
 

called by ccu.c whenever its codes property changed.

Parameters:
status a ccu_status_struct preresenting the current status of ccu.c
Returns:
void
This function is called by ccu.c whenever its codes property changed. It is declared as an abstract function in ccu.h and implemented here.

void ui_ccu_progress_changed struct ccu_status_struct  status  ) 
 

called by ccu.c whenever its progress-/status- property has changed.

Parameters:
status a ccu_status_struct preresenting the current status of ccu.c
Returns:
void
This function is called by ccu.c whenever its progress-/status- property has changed. It is declared as an abstract function in ccu.h and implemented here.

void ui_ccu_sequences_changed struct ccu_sequence_struct  input  ) 
 

called by ccu.c whenever the sequence list changed.

Parameters:
sequence_context a ccu_status_struct preresenting the current status of ccu.c
Returns:
void
This function is called by ccu.c whenever the sequence list changed. It is declared as an abstract function in ccu.h and implemented here.

void ui_ccu_ser_in const char *  str  ) 
 

called by ccu.c whenever something is received from the CCU's serial port.

Parameters:
str the string recieved form the serial port
Returns:
void
This function is called by ccu.c whenever something is received from the CCU's serial port. It is declaredas an abstract function in ccu.h and implemented here.

void ui_ccu_ser_out const char *  str  ) 
 

called by ccu.c whenever something is send to the CCU's serial port.

Parameters:
str the string send to the serial port
Returns:
void
This function is called by ccu.c whenever something is send to the CCU's serial port. It is declared as an abstract function in ccu.h and implemented here.

void ui_ccu_switches_changed struct ccu_status_struct  input  ) 
 

called by ccu.c whenever its switches property changed.

Parameters:
status a ccu_status_struct preresenting the current status of ccu.c
Returns:
void
This function is called by ccu.c whenever its switches property changed. It is declared as an abstract function in ccu.h and implemented here.

void ui_ccu_zero_volt_set void   ) 
 

called by ccu.c whenever the zero volt sequence has been successfully executed.

Returns:
void
This function is called by ccu.c whenever the zero volt sequence has been successfully executed. It is declared as an abstract function in ccu.h and implemented here.


Variable Documentation

int ccu_channels
 

the number of channels to be read out simutaneously

char ccu_ctrldir[1000]
 

the name of the directory for ccu control files received via network

struct ccu_database_struct ccu_database[100]
 

the CCU Database as read form the ".SQ" file

char ccu_database_dir[1000]
 

the name of the directory containing the .DB and .SQ files to be selected

char ccu_database_filename[1000]
 

the name of the ".DB" file containing the sequences

char ccu_dev[1000]
 

the name of the file representing the serial port the CCU is connected to

serdev* ccu_device
 

serial device

char ccu_sequence_context[100][1000]
 

the names of the sequences as read from the CCU

char ccu_sequence_context_full[100][1000]
 

the full description of the sequences as read from the CCU, via H 13

double ccu_shutter_offset
 

Correction for incorrect shutter open time exposuretime_send_to_controlller=exposuretime_set_by_user-ccu_shutter_offset

int ccu_stty_baud
 

the baud rate of the serial (ttyS) port used by the CCU

char ccu_usbdev[1000]
 

the name of the file representing the usb device for fast data transfer form the CCU into the computer

FILE* ccu_usbdev_file
 

a file pointer for data acquistion via usb

int command_block
 

if this is not 0, any command to be sent to the ccu will be blocked

char ui_ccu_sequence_context[100][1000]
 

the names of the sequences for display in a user interface


Generated on Fri Dec 16 22:23:37 2005 for gboccia by  doxygen 1.4.2