Commit f6804b8e authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Standardization of names

Standard C imposes that names prefixed by `_` and types suffixed by `_t`
are reserved).  Hence:

- Public symbols and macros are prefixed by `tao_` and `TAO_`.

- Private/helper symbols and macros are prefixed by `tao__` and `TAO__`.

- Types are no longer suffixed by `_t`.

- `struct`/`enum`/`union` have the same name as their `typedef`
  counterpart.

- Headers define a macro `TAO_..._H_` to avoid being included more than
  once.
parent 718c7ef1
* Standardization of naming conventions (standard C imposes that names prefixed
by `_` are reserved):
- Public symbols and macros are prefixed by `tao_` and `TAO_`.
- Private/helper symbols and macros are prefixed by `tao__` and `TAO__`.
- Types are no longer suffixed by `_t` (which is reserved for the C).
- `struct`/`enum`/`union` have the same name as their `typedef` counterpart.
- Headers define a macro `TAO_..._H_` to avoid being included more than once.
* Provide thread-pools.
* Image server for cameras connected to a Phoenix frame-grabber.
......@@ -23,17 +36,17 @@
* Interface to r/w locks.
* Timed operations now return a `tao_timed_t` value. Function
`tao_get_absolute_timeout()` returns a `tao_timeout_t` value which reflects
the different possible cases: errors, timeout alread expired, timeout is
occuring now, in the future or never. Function
* Timed operations now return a `tao_status` value which may be `TAO_TIMEOUT`.
Function `tao_get_absolute_timeout()` returns a `tao_timeout` value which
reflects the different possible cases: errors, timeout alread expired,
timeout is occuring now, in the future or never. Function
`tao_is_finite_absolute_time()` has been suppressed as the value returned by
`tao_get_absolute_timeout()` is sufficient to figure out the kind of timeout.
* Allow for process shared mutexes and condition variables.
* Use `struct timespec` for storing the time (instead of `tao_time_t` which was
completely similar).
* Use `tao_time` for storing the time with fields of known type (unlike `struct timespec`
whose field types depend on the implementation).
* Manage to have '-Wall -Werror -O2' the default compilation flags.
......
......@@ -265,7 +265,7 @@ alpao_mirror_t* alpao_open_mirror(
{
// Local variables.
char* serial;
tao_eltype_t eltype;
tao_eltype eltype;
alpao_mirror_t* dm = NULL;
asdkDM* handle = NULL;
long number;
......@@ -351,14 +351,14 @@ void alpao_close_mirror(
// return tao_try_lock_mutex(&MUTEX(dm));
// }
//
// tao_status_t
// tao_status
// alpao_abstimed_lock_mirror(alpao_mirror_t* dm,
// const struct timespec* abstime)
// {
// return tao_abstimed_lock_mutex(&MUTEX(dm), abstime);
// }
//
// tao_status_t
// tao_status
// alpao_timed_lock_mirror(alpao_mirror_t* dm, double secs)
// {
// return tao_timed_lock_mutex(&MUTEX(dm), secs);
......@@ -382,7 +382,7 @@ void alpao_close_mirror(
// return tao_wait_condition(&CONDVAR(dm), &MUTEX(dm));
// }
//
// tao_status_t
// tao_status
// alpao_abstimed_wait_mirror(alpao_mirror_t* dm,
// const struct timespec* abstime)
// {
......@@ -390,14 +390,14 @@ void alpao_close_mirror(
// &MUTEX(dm), abstime);
// }
//
// tao_status_t
// tao_status
// alpao_timed_wait_mirror(alpao_mirror_t* dm, double secs)
// {
// return tao_timed_wait_condition(&CONDVAR(dm),
// &MUTEX(dm), secs);
// }
tao_status_t alpao_apply_scheduled_commands(
tao_status alpao_apply_scheduled_commands(
alpao_mirror_t* dm)
{
const Scalar vmin = -1;
......@@ -419,7 +419,7 @@ tao_status_t alpao_apply_scheduled_commands(
}
// caller must have locked the associated shared mirror
tao_status_t alpao_reset_mirror(
tao_status alpao_reset_mirror(
alpao_mirror_t* dm)
{
if (asdkReset((asdkDM*)dm->handle) != SUCCESS) {
......@@ -431,7 +431,7 @@ tao_status_t alpao_reset_mirror(
return TAO_OK;
}
tao_status_t alpao_stop_mirror(
tao_status alpao_stop_mirror(
alpao_mirror_t* dm)
{
// FIXME: reflect changes to others?
......@@ -529,7 +529,7 @@ static int find_attribute(
return -1;
}
tao_status_t alpao_get_boolean_attribute(
tao_status alpao_get_boolean_attribute(
alpao_mirror_t* dm,
const char* key,
bool* ptr)
......@@ -555,7 +555,7 @@ tao_status_t alpao_get_boolean_attribute(
return TAO_OK;
}
tao_status_t alpao_get_integer_attribute(
tao_status alpao_get_integer_attribute(
alpao_mirror_t* dm,
const char* key,
long* ptr)
......@@ -581,7 +581,7 @@ tao_status_t alpao_get_integer_attribute(
return TAO_OK;
}
tao_status_t alpao_get_real_attribute(
tao_status alpao_get_real_attribute(
alpao_mirror_t* dm,
const char* key,
double* ptr)
......@@ -607,7 +607,7 @@ tao_status_t alpao_get_real_attribute(
return TAO_OK;
}
tao_status_t alpao_set_boolean_attribute(
tao_status alpao_set_boolean_attribute(
alpao_mirror_t* dm,
const char* key,
bool val)
......@@ -631,7 +631,7 @@ tao_status_t alpao_set_boolean_attribute(
return TAO_OK;
}
tao_status_t alpao_set_integer_attribute(
tao_status alpao_set_integer_attribute(
alpao_mirror_t* dm,
const char* key,
long val)
......@@ -655,7 +655,7 @@ tao_status_t alpao_set_integer_attribute(
return TAO_OK;
}
tao_status_t alpao_set_real_attribute(
tao_status alpao_set_real_attribute(
alpao_mirror_t* dm,
const char* key,
double val)
......@@ -679,7 +679,7 @@ tao_status_t alpao_set_real_attribute(
return TAO_OK;
}
tao_status_t alpao_set_string_attribute(
tao_status alpao_set_string_attribute(
alpao_mirror_t* dm,
const char* key,
const char* str)
......
......@@ -11,8 +11,10 @@
#include <tao-mirrors.h>
#ifndef _TAO_ALPAO_H_
#define _TAO_ALPAO_H_ 1
#ifndef TAO_ALPAO_H_
#define TAO_ALPAO_H_ 1
TAO_BEGIN_DECLS
// ---------------------------------------------------------------------------
// REMOTE CAMERAS
......@@ -41,14 +43,14 @@ typedef struct alpao_mirror_ alpao_mirror_t;
* and is used to prepare the command to send.
*/
struct alpao_mirror_ {
void* handle;///< Handle to device.
tao_shared_mirror_t* shared;///< Attached shared mirror.
void* current;///< Pointer to current commands.
void* scheduled;///< Pointer to scheduled commands.
void* temporary;///< Buffer for temporary commands.
const char* serial;///< Name of device.
long number;///< Number of actuators.
int debuglevel;///< Level of verbosity of debug messages.
void* handle;///< Handle to device.
tao_shared_mirror* shared;///< Attached shared mirror.
void* current;///< Pointer to current commands.
void* scheduled;///< Pointer to scheduled commands.
void* temporary;///< Buffer for temporary commands.
const char* serial;///< Name of device.
long number;///< Number of actuators.
int debuglevel;///< Level of verbosity of debug messages.
};
/**
......@@ -67,34 +69,34 @@ extern alpao_mirror_t* alpao_open_mirror(
extern void alpao_close_mirror(
alpao_mirror_t* dm);
extern tao_status_t alpao_lock_mirror(
extern tao_status alpao_lock_mirror(
alpao_mirror_t* dm);
extern tao_status_t alpao_try_lock_mirror(
extern tao_status alpao_try_lock_mirror(
alpao_mirror_t* dm);
extern tao_status_t alpao_abstimed_lock_mirror(
extern tao_status alpao_abstimed_lock_mirror(
alpao_mirror_t* dm,
const struct timespec* abstime);
extern tao_status_t alpao_timed_lock_mirror(
extern tao_status alpao_timed_lock_mirror(
alpao_mirror_t* dm,
double secs);
extern tao_status_t alpao_unlock_mirror(
extern tao_status alpao_unlock_mirror(
alpao_mirror_t* dm);
extern tao_status_t alpao_signal_mirror(
extern tao_status alpao_signal_mirror(
alpao_mirror_t* dm);
extern tao_status_t alpao_wait_mirror(
extern tao_status alpao_wait_mirror(
alpao_mirror_t* dm);
extern tao_status_t alpao_abstimed_wait_mirror(
extern tao_status alpao_abstimed_wait_mirror(
alpao_mirror_t* dm,
const struct timespec* abstime);
extern tao_status_t alpao_timed_wait_mirror(
extern tao_status alpao_timed_wait_mirror(
alpao_mirror_t* dm,
double secs);
......@@ -104,7 +106,7 @@ extern tao_status_t alpao_timed_wait_mirror(
* To maintain the consistency of the shared information, the caller shall have
* locked the mirror.
*/
extern tao_status_t alpao_apply_scheduled_commands(
extern tao_status alpao_apply_scheduled_commands(
alpao_mirror_t* dm);
/**
......@@ -113,7 +115,7 @@ extern tao_status_t alpao_apply_scheduled_commands(
* To maintain the consistency of the shared information, the caller shall have
* locked the mirror.
*/
extern tao_status_t alpao_stop_mirror(
extern tao_status alpao_stop_mirror(
alpao_mirror_t* dm);
/**
......@@ -122,13 +124,13 @@ extern tao_status_t alpao_stop_mirror(
* To maintain the consistency of the shared information, the caller shall have
* locked the mirror.
*/
extern tao_status_t alpao_reset_mirror(
extern tao_status alpao_reset_mirror(
alpao_mirror_t* dm);
/**
* Get the value of a boolean attribute of an Alpao mirror.
*/
extern tao_status_t alpao_get_boolean_attribute(
extern tao_status alpao_get_boolean_attribute(
alpao_mirror_t* dm,
const char* key,
bool* ptr);
......@@ -136,7 +138,7 @@ extern tao_status_t alpao_get_boolean_attribute(
/**
* Get the value of an integer attribute of an Alpao mirror.
*/
extern tao_status_t alpao_get_integer_attribute(
extern tao_status alpao_get_integer_attribute(
alpao_mirror_t* dm,
const char* key,
long* ptr);
......@@ -144,7 +146,7 @@ extern tao_status_t alpao_get_integer_attribute(
/**
* Get the value of a floating-point attribute of an Alpao mirror.
*/
extern tao_status_t alpao_get_real_attribute(
extern tao_status alpao_get_real_attribute(
alpao_mirror_t* dm,
const char* key,
double* ptr);
......@@ -152,7 +154,7 @@ extern tao_status_t alpao_get_real_attribute(
/**
* Set the value of a boolean attribute of an Alpao mirror.
*/
extern tao_status_t alpao_set_boolean_attribute(
extern tao_status alpao_set_boolean_attribute(
alpao_mirror_t* dm,
const char* key,
bool val);
......@@ -160,7 +162,7 @@ extern tao_status_t alpao_set_boolean_attribute(
/**
* Set the value of an integer attribute of an Alpao mirror.
*/
extern tao_status_t alpao_set_integer_attribute(
extern tao_status alpao_set_integer_attribute(
alpao_mirror_t* dm,
const char* key,
long val);
......@@ -168,7 +170,7 @@ extern tao_status_t alpao_set_integer_attribute(
/**
* Set the value of a floating-point attribute of an Alpao mirror.
*/
extern tao_status_t alpao_set_real_attribute(
extern tao_status alpao_set_real_attribute(
alpao_mirror_t* dm,
const char* key,
double val);
......@@ -176,7 +178,7 @@ extern tao_status_t alpao_set_real_attribute(
/**
* Set the value of a textual attribute of an Alpao mirror.
*/
extern tao_status_t alpao_set_string_attribute(
extern tao_status alpao_set_string_attribute(
alpao_mirror_t* dm,
const char* key,
const char* str);
......@@ -188,6 +190,7 @@ extern void alpao_push_error(
const char* func);
// * @}
_TAO_END_DECLS
#endif // _TAO_ALPAO_H_
TAO_END_DECLS
#endif // TAO_ALPAO_H_
......@@ -87,11 +87,11 @@
# include __FILE__
#undef TMP_TYPE
tao_status_t andor_convert_buffer(
tao_status andor_convert_buffer(
void* restrict dst,
tao_encoding_t dst_enc,
tao_encoding dst_enc,
const void* restrict src,
tao_encoding_t src_enc,
tao_encoding src_enc,
long width,
long height,
long stride)
......
......@@ -27,7 +27,7 @@
static struct {
const char* name;
const wchar_t* wname;
tao_encoding_t value;
tao_encoding value;
} encoding_definitions[] = {
#define ENCDEF(val, str) { str, L##str, val }
ENCDEF(ANDOR_ENCODING_MONO8, "Mono8"),
......@@ -128,7 +128,7 @@ static void finalize(
(void)chmod(xmlfile, logmode);
}
tao_status_t andor_initialize(
tao_status andor_initialize(
void)
{
AT_64 ival;
......@@ -182,42 +182,42 @@ tao_status_t andor_initialize(
// Early declarations of all virtual methods in to initialize table of
// operations.
static tao_status_t on_initialize(
tao_camera_t* cam);
static tao_status on_initialize(
tao_camera* cam);
static void on_finalize(
tao_camera_t* cam);
tao_camera* cam);
static tao_status_t on_reset(
tao_camera_t* cam);
static tao_status on_reset(
tao_camera* cam);
static tao_status_t on_update_config(
tao_camera_t* cam);
static tao_status on_update_config(
tao_camera* cam);
static tao_status_t on_check_config(
tao_camera_t* cam,
const tao_camera_config_t* cfg);
static tao_status on_check_config(
tao_camera* cam,
const tao_camera_config* cfg);
static tao_status_t on_set_config(
tao_camera_t* cam,
const tao_camera_config_t* cfg);
static tao_status on_set_config(
tao_camera* cam,
const tao_camera_config* cfg);
static tao_status_t on_start(
tao_camera_t* cam);
static tao_status on_start(
tao_camera* cam);
static tao_status_t on_stop(
tao_camera_t* cam);
static tao_status on_stop(
tao_camera* cam);
static tao_status_t on_release_buffer(
tao_camera_t* cam);
static tao_status on_release_buffer(
tao_camera* cam);
static tao_status_t on_wait_buffer(
tao_camera_t* cam,
static tao_status on_wait_buffer(
tao_camera* cam,
double secs);
// Table of operations of all Andor cameras. Its address can be used to
// assert that a given TAO camera belongs to this family.
static const tao_camera_ops_t ops = {
static const tao_camera_ops ops = {
.name = "Andor",
.initialize = on_initialize,
.finalize = on_finalize,
......@@ -232,7 +232,7 @@ static const tao_camera_ops_t ops = {
};
andor_device_t* andor_get_device(
tao_camera_t* cam)
tao_camera* cam)
{
if (cam == NULL) {
return NULL;
......@@ -249,55 +249,55 @@ andor_device_t* andor_get_device(
// Getters get_width() and get_height() must be called after setting
// sensorwidth and sensorheight in the device.
static tao_status_t get_sensorwidth(
static tao_status get_sensorwidth(
andor_device_t* dev,
long* valptr);
static tao_status_t get_sensorheight(
static tao_status get_sensorheight(
andor_device_t* dev,
long* valptr);
static tao_status_t get_xbin(
static tao_status get_xbin(
andor_device_t* dev,
long* valptr);
static tao_status_t get_ybin(
static tao_status get_ybin(
andor_device_t* dev,
long* valptr);
static tao_status_t get_xoff(
static tao_status get_xoff(
andor_device_t* dev,
long* valptr);
static tao_status_t get_yoff(
static tao_status get_yoff(
andor_device_t* dev,
long* valptr);
static tao_status_t get_width(
static tao_status get_width(
andor_device_t* dev,
long* valptr);
static tao_status_t get_height(
static tao_status get_height(
andor_device_t* dev,
long* valptr);
static tao_status_t get_exposuretime(
static tao_status get_exposuretime(
andor_device_t* dev,
double* valptr);
static tao_status_t get_framerate(
static tao_status get_framerate(
andor_device_t* dev,
double* valptr);
static tao_status_t get_pixelencoding(
static tao_status get_pixelencoding(
andor_device_t* dev,
tao_encoding_t* valptr);
tao_encoding* valptr);
static tao_status_t get_temperature(
static tao_status get_temperature(
andor_device_t* dev,
double* valptr);
static tao_status_t alloc_buffers(
static tao_status alloc_buffers(
andor_device_t* dev,
int nbufs,
int size);
......@@ -305,19 +305,19 @@ static tao_status_t alloc_buffers(
static void free_buffers(
andor_device_t* dev);
static tao_status_t update_pixel_encodings(
static tao_status update_pixel_encodings(
andor_device_t* dev);
static tao_status_t update_configuration(
static tao_status update_configuration(
andor_device_t* dev,
bool all);
static tao_status_t check_configuration(
static tao_status check_configuration(
andor_device_t* dev,
const tao_camera_config_t* cfg,
const tao_camera_config* cfg,
const char* func);
tao_camera_t* andor_open_camera(
tao_camera* andor_open_camera(
long dev)
{
// Check device number after initializing the library if needed.
......@@ -338,8 +338,8 @@ tao_camera_t* andor_open_camera(
// In case of errors during initialization, we simply call the `on_finalize`
// virtual method.
static tao_status_t on_initialize(
tao_camera_t* cam)
static tao_status on_initialize(
tao_camera* cam)
{
// Fetch Andor device structure and device number.
assert(cam->ops == &ops);
......@@ -385,7 +385,7 @@ static tao_status_t on_initialize(
// with no damages. Acquisitions buffers are destroyed by the caller after
// calling this virtual method.
static void on_finalize(
tao_camera_t* cam)
tao_camera* cam)
{
assert(cam != NULL);
assert(cam->ops == &ops);
......@@ -397,8 +397,8 @@ static void on_finalize(
}
}
static tao_status_t on_reset(
tao_camera_t* cam)
static tao_status on_reset(
tao_camera* cam)
{
assert(cam->ops == &ops);
assert(cam->runlevel == 3);
......@@ -409,23 +409,23 @@ static tao_status_t on_reset(
return TAO_ERROR;
}
static tao_status_t on_update_config(
tao_camera_t* cam)
static tao_status on_update_config(
tao_camera* cam)
{
return update_configuration((andor_device_t*)cam, true);
}
static tao_status_t on_check_config(
tao_camera_t* cam,
const tao_camera_config_t* cfg)
static tao_status on_check_config(
tao_camera* cam,
const tao_camera_config* cfg)
{
return check_configuration((andor_device_t*)cam, cfg,
"tao_check_camera_configuration");
}
static tao_status_t on_set_config(
tao_camera_t* cam,
const tao_camera_config_t* cfg)
static tao_status on_set_config(
tao_camera* cam,
const tao_camera_config* cfg)
{
const char* func = "tao_set_camera_configuration";
int status;
......@@ -444,8 +444,8 @@ static tao_status_t on_set_config(
// order recommended in the Andor SDK doc. We only set the parameters
// which have changed.
{
tao_camera_roi_t* dst = &dev->base.info.config.roi;
const tao_camera_roi_t* src = &cfg->roi;
tao_camera_roi* dst = &dev->base.info.config.roi;
const tao_camera_roi* src = &cfg->roi;
if (src->xbin != dst->xbin || src->ybin != dst->ybin ||
src->xoff != dst->xoff || src->yoff != dst->yoff ||
src->width != dst->width || src->height != dst->height) {
......@@ -509,8 +509,8 @@ static tao_status_t on_set_config(
// Change pixel encoding, pixel type and number of acquisition buffers
// if requested so.
{
tao_camera_config_t* dst = &dev->base.info.config;
const tao_camera_config_t* src = cfg;
tao_camera_config* dst = &dev->base.info.config;
const tao_camera_config* src = cfg;
if (src->pixeltype != dst->pixeltype) {
dst->pixeltype = src->pixeltype;
changes = true;
......@@ -520,7 +520,7 @@ static tao_status_t on_set_config(
changes = true;
}
if (src->bufferencoding != dst->bufferencoding) {
tao_encoding_t enc = src->bufferencoding;
tao_encoding enc = src->bufferencoding;
int idx = -1;
for (int k = 0; k < dev->nencodings; ++k) {
if (dev->encodings[k] == enc) {
......@@ -547,8 +547,8 @@ static tao_status_t on_set_config(
// requested, then change the exposure time if requested, finally augment
// the frame rate if requested.
for (int pass = 1; pass <= 2; ++pass) {
tao_camera_config_t* dst = &dev->base.info.config;
const tao_camera_config_t* src = cfg;
tao_camera_config* dst = &dev->base.info.config;
const tao_camera_config* src = cfg;
if ((pass == 1 && src->framerate < dst->framerate) ||
(pass == 2 && src->framerate > dst->framerate)) {
status = AT_SetFloat(dev->handle, L"FrameRate", src->framerate);
......@@ -581,8 +581,8 @@ static tao_status_t on_set_config(
return TAO_OK;