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

background.c File Reference

Background threads. More...

#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include "background.h"
#include "uc.h"
#include "ccu.h"
#include "error.h"
#include "logfile.h"
#include "serial.h"
#include "gui.h"
#include "semaphore.h"
#include "acquisition.h"
#include "progress.h"
#include "instctrl.h"
#include "telescope.h"
#include "preview.h"
#include "auto.h"
#include "texoutput.h"
#include "iniconfig.h"
#include <time.h>

Functions

void background_start_download (char *dummy)
 starts the threaded download of the database (firmware) into to CCD Controller
int background_anything_running ()
 checks whether any background process is running, that has got anything to do with the CCD Controller
int background_anything_except_acquire_running ()
 checks whether any background process (except the acquisition process) is running, that has got anything to do with the CCD Controller
void threads_info (char *infostr)
 writes the pid and a given string into a logfile, is used to write the start into the logfile
void * task_serial (void *arg)
 thread for communication with the serial RS232 interface.
void * task_readout (void *arg)
 thread for CCD readout
void * task_instctrl (void *arg)
 thread for communication with the instrument control program.
void * task_exposure (void *arg)
 thread for exposure.
void * task_acquire (void *arg)
 thread for acquistion.
void * task_download (void *arg)
 thread for loading database (firmware) into the CCD Controller.
void * task_preview (void *arg)
 thread for sending the preview to the User Interface
void * task_texoutput (void *arg)
 thread for texoutput related background operations.
void * task_auto (void *arg)
 thread for automated functions.
void * task_postproc (void *arg)
 thread for postprocessing fits files.
void * task_terminal (void *arg)
 thread for interaction with the user interface.
void task_ser_test (void)
 initialization of uc.c (unused).
void task_readout_init (void)
 initialization of the readout thread
void task_instctrl_init (void)
 initialization of the insturment control communication thread
void task_preview_init (void)
 initialization of the preview thread
void task_auto_init (void)
 initialization of the auto thread
void task_texoutput_init (void)
 initialization of the LaTeX file output thread
void task_postproc_init (void)
 initialization of the fitsfile postprocessing thread
void task_exposure_init (void)
 initialization of the exposure thread
void task_acquire_init (void)
 initialization of the acquistion thread
void task_download_init (void)
 initialization of the CCD Controller loading thread
void task_serial_init (void)
 initializaties the thread for communication with the serial RS232 interface
void task_terminal_init (void)
 initializaties the thread for communication with the User Interface
void task_serial_done (void)
 destroys the thread for communication with the RS232 Interface
void task_readout_done (void)
 destroys the thread for communication CCD readout
void task_instctrl_done (void)
 destroys the thread for communication with instrument control program
void task_exposure_done (void)
 destroys the thread for exposures
void task_acquire_done (void)
 destroys the thread for acquisition control
void task_download_done (void)
 destroys the thread for loading a database (firmware) into the CCD Controller
void task_terminal_done (void)
 destroys the thread for user interface interaction
void task_preview_done (void)
 destroys the thread for copying preview
void task_auto_done (void)
 destroys the thread for automated flatfielding
void task_texoutput_done (void)
 destroys the thread for automated tex file logging
void task_postproc_done (void)
 destroys the thread for fitsfile postprocessing
void task_terminal_suspend (void)
 suspends the thread for user interface interaction
void task_exposure_suspend (void)
 suspends the thread for user interface interaction
void init_background_tasks (void)
 starts all background threads
int done_background_tasks (void)
 stops all background threads
int main_init_everything ()
 main intializer

Variables

volatile int program_is_running = 1
volatile int readout_is_running = 0
volatile int readout_is_stopped = 0
volatile int exposure_is_running = 0
volatile int exposure_is_stopped = 0
volatile int acquire_is_running = 0
volatile int acquire_restart = 0
volatile int acquire_stop = 0
volatile int auto_is_running = 0
volatile int auto_stop = 0
volatile int download_start = 0
volatile int download_is_running = 0
volatile int zero_volt_is_running = 0
volatile int zero_volt_start = 0
volatile int terminal_is_running = 1
volatile int terminal_is_stopped = 0
volatile int background_retries = 300
volatile int postproc_is_running = 0
volatile int gui_clock = 0
char acquire_stop_string [1000] = ""
char download_filename [1000] = ""
char postproc_filename [1000] = ""
float background_exposuretime
double background_time_begin
int background_acquisitions_done
int task_uc_avail = 0
int task_ccu_avail = 0
int task_ser_block = 1
sem_t terminalsem
GList * terminallist = NULL
pthread_t task_serial_thread
pthread_t task_readout_thread
pthread_t task_exposure_thread
pthread_t task_terminal_thread
pthread_t task_acquire_thread
pthread_t task_download_thread
pthread_t task_preview_thread
pthread_t task_auto_thread
pthread_t task_texoutput_thread
pthread_t task_postproc_thread
pthread_t task_instctrl_thread


Detailed Description

Background threads.

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 background_anything_except_acquire_running void   ) 
 

checks whether any background process (except the acquisition process) is running, that has got anything to do with the CCD Controller

Returns:
1 if at least one such process is running, 0 otherwise
This function checks whether any background process (except the acquisition process) is running that has got anything to do with the CCD Controller

int background_anything_running void   ) 
 

checks whether any background process is running, that has got anything to do with the CCD Controller

Returns:
1 if at least such one process is running, 0 otherwise
This function checks whether any background process is running that has got anything to do with the CCD Controller

void background_start_download char *  dummy  ) 
 

starts the threaded download of the database (firmware) into to CCD Controller

Parameters:
dummy the name of the database file to be loaded into the CCD Controller
Returns:
void
This function starts the threaded download of the database (firmware) into to CCD Controller

int done_background_tasks void   ) 
 

stops all background threads

Returns:
void
This function stops all background threads

void init_background_tasks void   ) 
 

starts all background threads

Returns:
void
This function starts all background threads

int main_init_everything  ) 
 

main intializer

Returns:
void
This function initializes the full gboccia system. So this is the constructor of gboccia.

void* task_acquire void *  arg  ) 
 

thread for acquistion.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for acquistion. It manages the exposure and readout treads /systems.

void task_acquire_done void   ) 
 

destroys the thread for acquisition control

Returns:
void
Thread destructor.

void task_acquire_init void   ) 
 

initialization of the acquistion thread

Returns:
void
Thread initializer.

void* task_auto void *  arg  ) 
 

thread for automated functions.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for automated functions.

void task_auto_done void   ) 
 

destroys the thread for automated flatfielding

Returns:
void
Thread destructor.

void task_auto_init void   ) 
 

initialization of the auto thread

Returns:
void
Thread initializer.

void* task_download void *  arg  ) 
 

thread for loading database (firmware) into the CCD Controller.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for loading database (firmware) into the CCD Controller. Furthermore can run the Zero Volt sequence in the CCD Controller.

void task_download_done void   ) 
 

destroys the thread for loading a database (firmware) into the CCD Controller

Returns:
void
Thread destructor.

void task_download_init void   ) 
 

initialization of the CCD Controller loading thread

Returns:
void
Thread initializer.

void* task_exposure void *  arg  ) 
 

thread for exposure.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for exposures. It waits for a given time and starts the readout systems and thread afterwards.

void task_exposure_done void   ) 
 

destroys the thread for exposures

Returns:
void
Thread destructor.

void task_exposure_init void   ) 
 

initialization of the exposure thread

Returns:
void
Thread initializer.

void task_exposure_suspend void   ) 
 

suspends the thread for user interface interaction

Returns:
void
suspends the thread for user interface interaction

void* task_instctrl void *  arg  ) 
 

thread for communication with the instrument control program.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for communication with the instrument control program. The communication is file based. This is bad, because of synchronization problems and questions of automatization. Please do not repeat this mistake. This thread parses several files and write some others.

void task_instctrl_done void   ) 
 

destroys the thread for communication with instrument control program

Returns:
void
Thread destructor.

void task_instctrl_init void   ) 
 

initialization of the insturment control communication thread

Returns:
void
Thread initializer.

void* task_postproc void *  arg  ) 
 

thread for postprocessing fits files.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for postprocessing fits files.

void task_postproc_done void   ) 
 

destroys the thread for fitsfile postprocessing

Returns:
void
Thread destructor.

void task_postproc_init void   ) 
 

initialization of the fitsfile postprocessing thread

Returns:
void
Thread initializer.

void* task_preview void *  arg  ) 
 

thread for sending the preview to the User Interface

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread sends the preview to the user interface.

void task_preview_done void   ) 
 

destroys the thread for copying preview

Returns:
void
Thread destructor.

void task_preview_init void   ) 
 

initialization of the preview thread

Returns:
void
Thread initializer.

void* task_readout void *  arg  ) 
 

thread for CCD readout

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for CCD readout. It contnuesly trys to read from the Kernel driver every 0.05 seconds. If it could not receive any thing for a certain number of tryes it stops. This decreasing number is stored in background_retries. It also checks if all expected bytes were read and stops if this is the case.

void task_readout_done void   ) 
 

destroys the thread for communication CCD readout

Returns:
void
Thread destructor.

void task_readout_init void   ) 
 

initialization of the readout thread

Returns:
void
Thread initializer.

void task_ser_test void   ) 
 

initialization of uc.c (unused).

Returns:
void
This is a thread is unused.

void* task_serial void *  arg  ) 
 

thread for communication with the serial RS232 interface.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for communication with the serial RS232 interface

void task_serial_done void   ) 
 

destroys the thread for communication with the RS232 Interface

Returns:
void
Thread destructor.

void task_serial_init void   ) 
 

initializaties the thread for communication with the serial RS232 interface

Returns:
void
Thread initializer.

void* task_terminal void *  arg  ) 
 

thread for interaction with the user interface.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for interaction with the user interface.

void task_terminal_done void   ) 
 

destroys the thread for user interface interaction

Returns:
void
Thread destructor.

void task_terminal_init void   ) 
 

initializaties the thread for communication with the User Interface

Returns:
void
Thread initializer.

void task_terminal_suspend void   ) 
 

suspends the thread for user interface interaction

Returns:
void
suspends the thread for user interface interaction

void* task_texoutput void *  arg  ) 
 

thread for texoutput related background operations.

Parameters:
arg custom reference (not used)
Returns:
void
This is a thread for texoutput related background operations. See texoutput.c for details.

void task_texoutput_done void   ) 
 

destroys the thread for automated tex file logging

Returns:
void
Thread destructor.

void task_texoutput_init void   ) 
 

initialization of the LaTeX file output thread

Returns:
void
Thread initializer.

void threads_info char *  infostr  ) 
 

writes the pid and a given string into a logfile, is used to write the start into the logfile

Parameters:
void 
Returns:
1 if at least one such process is running, 0 otherwise
This function writes the pid and a given string into a logfile, is used to write the start into the logfile


Variable Documentation

volatile int acquire_is_running = 0
 

1 if the acquisition thread is running

volatile int acquire_restart = 0
 

set to 1 in order to ask the acquisition threat to (re)start

volatile int acquire_stop = 0
 

set to 1 in order to ask the acquisition threat to stop

char acquire_stop_string[1000] = ""
 

a string describing why the readout thread was stopped

volatile int auto_is_running = 0
 

1 if the auto thread is running

volatile int auto_stop = 0
 

set to 1 in order to ask the auto threat to stop

int background_acquisitions_done
 

the number of acquistions done

float background_exposuretime
 

the exposuretime of to be passed to the exposure thread

volatile int background_retries = 300
 

the number of retries to read new data from the USB Kernel driver

double background_time_begin
 

the time when the exposure thread was started

char download_filename[1000] = ""
 

the name of the Database (firmware) to be loaded into the CCU

volatile int download_is_running = 0
 

1 if the Databese (firmware) download into the CCU is running

volatile int download_start = 0
 

set to 1 in order to start the download of the Database (firmware) into the CCD Controller

volatile int exposure_is_running = 0
 

1 if the exposure thread is active, 0 otherwise, set to 0 in order to ask the the thread to stop

volatile int exposure_is_stopped = 0
 

1 if the exposure thread was stopped

volatile int gui_clock = 0
 

a counter couinting from one to 20 once pers second

char postproc_filename[1000] = ""
 

the name of the fitsfile to be postprocessed

volatile int postproc_is_running = 0
 

1 if the fits file postprocessing thread is running

volatile int program_is_running = 1
 

1 if the programm is running 0 otherwise

volatile int readout_is_running = 0
 

1 if the readout thread is active, 0 otherwise

volatile int readout_is_stopped = 0
 

1 if the readout thread was stopped, set to 0 in order to ask the the thread to stop

pthread_t task_acquire_thread
 

the thread for acquisition

pthread_t task_auto_thread
 

the thread for automated flatfield and focus systems

int task_ccu_avail = 0
 

ask Oliver Cord23es 2

pthread_t task_download_thread
 

the thread for database (firmware) loading from the PC to the CCD Controller

pthread_t task_exposure_thread
 

the thread for exposure

pthread_t task_instctrl_thread
 

the thread for communication with the instrument control programm

pthread_t task_postproc_thread
 

the thread for .fits file postprocessing

pthread_t task_preview_thread
 

the thread that is sending the online display (preview) information to the GUI

pthread_t task_readout_thread
 

the thread for readout

int task_ser_block = 1
 

ask Oliver Cor23des

pthread_t task_serial_thread
 

the thread for the serial interface

pthread_t task_terminal_thread
 

the thread for unser interface interaction

pthread_t task_texoutput_thread
 

the thread for LaTeX logging

int task_uc_avail = 0
 

ask Oliver Corde312s

volatile int terminal_is_running = 1
 

1 if the terminal (User interface interaction) thread is running

volatile int terminal_is_stopped = 0
 

1 if the terminal (User interface interaction) thread is stopped

GList* terminallist = NULL
 

A queue to decople the GTK user interface from the rest of treaded evironment

sem_t terminalsem
 

semaphore and List for terminal thead, protoecting terminallist and terminallist2, only needed for direct GTK binding

volatile int zero_volt_is_running = 0
 

1 if the zero volt thread is running

volatile int zero_volt_start = 0
 

set to 1 in order to start the zero Volt Sequence in the CCU


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