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

instctrl.c File Reference

communication with the instrument control programm More...

#include <stdlib.h>
#include "instctrl.h"
#include "semaphore.h"
#include "error.h"
#include "glib.h"
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdio.h>

Functions

void intctrl_set_lockbusy (double time)
 a horrible patch to overcome a synchroniztion problem.
void instctrl_push_item (struct instctrl_struct input)
 queues a new command into the instctrl queue.
int instctrl_pop_item (struct instctrl_struct *dummy)
 pops a command from the instctrl queue.
void instctrl_set_status_async (struct instctrl_status_struct input)
 sets the status of the instrument control (for internal use by instctrl.c only).
void instctrl_set_status (struct instctrl_status_struct input)
 sets the status of the instrument control.
int instctrl_parse_statusfile ()
 parses the statusfile of the instrument control program.
int instctrl_parse_statuslightfile ()
 parses the statuslightfile of the instrument control program.
void instctrl_set_filters (struct instctrl_filterlist_struct input)
 updates the filterlist.
instctrl_filterlist_struct instctrl_get_filters ()
 returns the filterlist.
int instctrl_parse_filterfile ()
 parses the filterlistfile
int instctrl_send_commands ()
 sends commands from the command queue to the instrument control program
void instctrl_set_telescopefocus (long focus)
 queues the command to set the telescope focus.
void instctrl_set_filter (char *filter)
 queues the command to set a filter.
char * instctrl_status_message (int code)
 retruns a string corresponding to status code defined in instctrl.h.
void instctrl_set_filenames (struct instctrl_filename_struct input)
 sets the names of the files to be used to communicate with the instrument control program
instctrl_filename_struct instctrl_get_filenames ()
 retruns a strcut containing the names of the files currently used to communicate with the instrument control program
instctrl_status_struct instctrl_get_status ()
 returns the current status of the instrument control.
volatile double instctrl_get_tel_focus ()
 returns the current focus of the telescope.
void instctrl_init ()
 (constructor) initialzes the communcation with the instrument control program.

Variables

GList * instctrl_list = NULL
sem_t instctrl_sem
sem_t instctrl_status_sem
instctrl_status_struct instctrl_status
instctrl_filename_struct instctrl_filenames
sem_t instctrl_filters_sem
instctrl_filter_struct instctrl_filters [100]


Detailed Description

communication with the instrument control programm

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

struct instctrl_filename_struct instctrl_get_filenames  ) 
 

retruns a strcut containing the names of the files currently used to communicate with the instrument control program

Returns:
a struct contraining the filename currrently in use
This function etruns a strcut containing the names of the files currently used to communicate with the instrument control program

struct instctrl_filterlist_struct instctrl_get_filters  ) 
 

returns the filterlist.

Returns:
void This function returns the filterlist

struct instctrl_status_struct instctrl_get_status  ) 
 

returns the current status of the instrument control.

Returns:
instctrl_status_struct a struct describing the current status of the instrument control
This function returns a struct describing the current status of the ínstrument control.

volatile double instctrl_get_tel_focus  ) 
 

returns the current focus of the telescope.

Returns:
instctrl_status_struct a struct describing the current status of the instrument control
This function returns the current focus of the telescope.

void instctrl_init  ) 
 

(constructor) initialzes the communcation with the instrument control program.

Returns:
void
This function initialzes the communcation with the instrument control program. It has to be called before any other function of this file is called.

int instctrl_parse_filterfile  ) 
 

parses the filterlistfile

Returns:
integer an error code
This function parses the filterlistfile and calls instctrl_set_filters with its result.

int instctrl_parse_statusfile  ) 
 

parses the statusfile of the instrument control program.

Returns:
void This function parses the statusfile of the instrument control program.

int instctrl_parse_statuslightfile  ) 
 

parses the statuslightfile of the instrument control program.

Returns:
void This function parses the statuslightfile of the instrument control program. This conatians it overall status. It must be in one of four states: ok idle busy fail.

int instctrl_pop_item struct instctrl_struct *  dummy  ) 
 

pops a command from the instctrl queue.

Parameters:
dummy a pointer to an instctrl_struct in which the poped item will be writen
Returns:
integer 0 on success, -1 on failure
This function pops a command from the instctrl queue.

void instctrl_push_item struct instctrl_struct  input  ) 
 

queues a new command into the instctrl queue.

Parameters:
input the command to be queued
Returns:
void
This function queues a new command into the instctrl queue.

int instctrl_send_commands  ) 
 

sends commands from the command queue to the instrument control program

Returns:
integer an error code
This function sends commands from the command queue to the instrument control program. It checks if the file if it wants to write its command to still exists and writes it only if this is the case. The instrument control program deletes the corresponding file after it read it, allows this function to write the next command. This function is called by a timer.

void instctrl_set_filenames struct instctrl_filename_struct  input  ) 
 

sets the names of the files to be used to communicate with the instrument control program

Parameters:
input a struct contraining the filename to be used
Returns:
void
This function sets the names of the files to be used to communicate with the instrument control program

void instctrl_set_filter char *  filter  ) 
 

queues the command to set a filter.

Parameters:
filter a string, the name of the filter to be set
Returns:
integer an error code
This function queues the command to set a filter

void instctrl_set_filters struct instctrl_filterlist_struct  input  ) 
 

updates the filterlist.

Parameters:
input the filterlist received from the instrument control program
Returns:
void This function parses and updates the filterlist. It checks if the filterlist actually changed and send respective information to the user interface if this is the case.

void instctrl_set_status struct instctrl_status_struct  input  ) 
 

sets the status of the instrument control.

Parameters:
input a instctrl_status_struct representing the status to be set.
Returns:
void This function sets the status of the instrument control.

void instctrl_set_status_async struct instctrl_status_struct  input  ) 
 

sets the status of the instrument control (for internal use by instctrl.c only).

Parameters:
input a instctrl_status_struct representing the status to be set.
Returns:
void This function sets the status of the instrument control without repecting instctrl_status_sem. This function for internal use by instctrl.c only. To set the instctrl status use instctrl_set_status.

void instctrl_set_telescopefocus long  focus  ) 
 

queues the command to set the telescope focus.

Parameters:
focus the new focus.
Returns:
integer an error code
This function queues the command to set the telescope focus

char* instctrl_status_message int  code  ) 
 

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

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

void intctrl_set_lockbusy double  time  ) 
 

a horrible patch to overcome a synchroniztion problem.

Parameters:
time the minimal time for which the instrument control program is assumed to be busy. This value should be bigger that the maximal replonse time of the instrument control program. 3 seconds works fine.
Returns:
void
This function a horrible patch to overcome a synchroniztion problem. Ok someone asks a filter to move and waits until the stratus property of the corresponding INDI vector has changed to OK. We are using file based communication, thus we can not find out if the filter control program is OK or not. Because we just read its file. The file says if it is OK or busy. But we don't know if our command is allready runnng in the filter control program. So there migth be an old OK. Yes you can overcomes this even in a filebased environment, but its somehow horrible. What we just wait for a certain amount of time and assume that the instrument control program to be busy. For after that we use the value in the file, during this time the instruemnt control program can update its file.


Variable Documentation

struct instctrl_filename_struct instctrl_filenames
 

a struct storing all filenames needed by instrument control

struct instctrl_filter_struct instctrl_filters[100]
 

an array of structs storing all information all about filters used by instrument control

sem_t instctrl_filters_sem
 

a semaphore procteting instctrl_status

GList* instctrl_list = NULL
 

a list of commands to be sent to the instument control programm

sem_t instctrl_sem
 

a semaphore protecting instctrl_list

struct instctrl_status_struct instctrl_status
 

a struct representing the current status of instrument control

sem_t instctrl_status_sem
 

a semaphore procteting instctrl_status


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