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

Replace sub-pupil by sub-image

parent 9328cf41
......@@ -66,14 +66,11 @@ extern tao_remote_sensor* tao_remote_sensor_create(
return NULL;
}
size_t config_align = sizeof(double);
// Offsets and sizes of layout indices and definitions of sub-images in
// a `tao_remote_sensor_config` structure.
size_t inds_elsize = sizeof(long);
size_t subs_elsize = sizeof(tao_wavefront_sensor_subpupil);
size_t subs_align = sizeof(double);
// Offsets and sizes of layout indices and definitions of sub-pupils in
// `tao_remote_sensor_config` structure.
size_t subs_elsize = sizeof(tao_wavefront_sensor_subimage);
size_t subs_align = sizeof(double);
size_t config_inds_size = max_ninds*inds_elsize;
size_t config_subs_size = max_nsubs*subs_elsize;
size_t config_inds_offset = TAO_OFFSET_OF(tao_remote_sensor_config, inds);
......@@ -83,6 +80,7 @@ extern tao_remote_sensor* tao_remote_sensor_create(
// Offsets of primary and secondary configurations in `tao_remote_sensor`
// structure.
size_t config_align = sizeof(double);
size_t config1_offset = TAO_OFFSET_OF(tao_remote_sensor, config);
size_t config2_offset = round_size(
config1_offset + config_size, config_align);
......@@ -113,8 +111,17 @@ extern tao_remote_sensor* tao_remote_sensor_create(
tao_forced_store(&wfs->max_ninds, max_ninds);
tao_forced_store(&wfs->max_nsubs, max_nsubs);
tao_forced_store(&wfs->config2_offset, config2_offset);
tao_forced_store(&primary_config(wfs)->subs_offset, config_subs_offset);
tao_forced_store(&secondary_config(wfs)->subs_offset, config_subs_offset);
tao_remote_sensor_config* config1 = primary_config(wfs);
tao_forced_store(&config1->subs_offset, config_subs_offset);
tao_forced_store(&config1->max_ninds, max_ninds);
tao_forced_store(&config1->max_nsubs, max_nsubs);
tao_remote_sensor_config* config2 = secondary_config(wfs);
tao_forced_store(&config2->subs_offset, config_subs_offset);
tao_forced_store(&config2->max_ninds, max_ninds);
tao_forced_store(&config2->max_nsubs, max_nsubs);
return wfs;
}
......@@ -122,7 +129,7 @@ tao_status tao_remote_sensor_check_config(
const tao_remote_sensor* wfs,
const tao_remote_sensor_config* cfg,
const long* inds,
const tao_wavefront_sensor_subpupil* subs)
const tao_wavefront_sensor_subimage* subs)
{
if (wfs == NULL || cfg == NULL || inds == NULL || subs == NULL) {
tao_store_error(__func__, TAO_BAD_ADDRESS);
......@@ -171,6 +178,63 @@ const char* tao_remote_sensor_get_camera(
}
}
tao_status tao_remote_sensor_copy_config(
tao_remote_sensor_config* dst,
const tao_remote_sensor_config* src)
{
if (dst == NULL || src == NULL) {
tao_store_error(__func__, TAO_BAD_ADDRESS);
return TAO_ERROR;
}
if (dst != src) {
long ninds = src->base.dims[0]*src->base.dims[1];
long nsubs = src->base.nsubs;
if (dst->max_ninds < ninds || dst->max_nsubs < nsubs) {
tao_store_error(__func__, TAO_BAD_SIZE);
return TAO_ERROR;
}
dst->base = src->base;
dst->camera = src->camera;
memcpy(dst->inds, src->inds, ninds*sizeof(long));
memcpy(TAO_COMPUTED_ADDRESS(dst, dst->subs_offset),
TAO_COMPUTED_ADDRESS(src, src->subs_offset),
nsubs*sizeof(tao_wavefront_sensor_subimage));
}
return TAO_OK;
}
tao_serial tao_remote_sensor_configure(
tao_remote_sensor* wfs,
const tao_remote_sensor_config* cfg,
double secs)
{
tao_store_error(__func__, TAO_NOT_YET_IMPLEMENTED);
return -1;
}
tao_serial tao_remote_sensor_set_camera(
tao_remote_sensor* wfs,
tao_shmid shmid,
double secs)
{
if (wfs == NULL) {
tao_store_error(__func__, TAO_BAD_ADDRESS);
return TAO_ERROR;
}
if (shmid == TAO_BAD_SHMID) {
tao_store_error(__func__, TAO_BAD_SHMID);
return TAO_ERROR;
}
const tao_remote_sensor_config* src = secondary_config(wfs);
tao_remote_sensor_config* dst = secondary_config(wfs);
tao_remote_sensor_copy_config(dst, src);
dst->camera.shmid = shmid;
dst->camera.owner[0] = 0;
dst->camera.width = 0;
dst->camera.height = 0;
return tao_remote_sensor_configure(wfs, dst, secs);
}
static tao_serial send_simple_command(
const char* func,
tao_remote_sensor* wfs,
......
......@@ -28,24 +28,29 @@ typedef struct tao_remote_sensor_config_ {
tao_shmid shmid;
char owner[TAO_OWNER_SIZE];
} camera;
const size_t subs_offset;///< Offset to the sub-pupil definitions.
const long max_ninds;///< Maximum number of nodes in sub-image grid.
const long max_nsubs;///< Maximum number of sub-images.
const size_t subs_offset;///< Offset to the sub-image definitions.
// Last member, actual size large enough for `max_ninds` elements.
long inds[1];///< Layout indices.
} tao_remote_sensor_config;
// This structure has a fixed size part followed by two variable size parts:
// the layout of the sub-pupils grid and the list of sub-pupils definitions.
// the layout of the sub-images grid and the list of sub-images definitions.
// Since the structure is meant to be stored in shared memory, offsets relative
// to the address of the structure (and not absolute addresses in memory) of
// the variable size parts may be in the structure. If the first variable size
// part immediately (with some padding for correct alignment) follows the fixed
// size part, it can also be the last member of the structure.
//
// Having the offsets relative to the base structure make it possible to copy
// the structure without worries.
struct tao_remote_sensor_ {
tao_remote_object base;///< Common part for all shared objects.
const long max_ninds;///< Maximum number of nodes in sub-pupil
const long max_ninds;///< Maximum number of nodes in sub-image
/// grid.
const long max_nsubs;///< Maximum number of sub-pupils.
const long max_nsubs;///< Maximum number of sub-images.
const size_t config2_offset;///< Offset to the secondary configuration.
// Last member.
......@@ -54,7 +59,6 @@ struct tao_remote_sensor_ {
/**
* @brief Data-frame of remote wavefront sensor as stored in shared memory.
*
*/
typedef struct tao_remote_sensor_dataframe_ {
tao_dataframe_header base;
......@@ -62,6 +66,15 @@ typedef struct tao_remote_sensor_dataframe_ {
tao_wavefront_sensor_data data[1];
} tao_remote_sensor_dataframe;
extern tao_status tao_remote_sensor_copy_config(
tao_remote_sensor_config* dst,
const tao_remote_sensor_config* src);
extern tao_serial tao_remote_sensor_configure(
tao_remote_sensor* wfs,
const tao_remote_sensor_config* cfg,
double secs);
TAO_END_DECLS
#endif // TAO_REMOTE_SENSORS_PRIVATE__H_
......@@ -43,11 +43,11 @@ TAO_BEGIN_DECLS
* sensor. A remote wavefront sensor is a remote shared object with the
* following additional components:
*
* - A 2-dimensional array of indices describing the layout of the sub-pupils
* - A 2-dimensional array of indices describing the layout of the sub-images
* which can be retrieved by calling tao_remote_sensor_get_layout().
*
* - An internal configuration storing, among others, the bounding boxes and
* the reference position of the sub-pupils. These settings can be retrieved
* the reference position of the sub-images. These settings can be retrieved
* by calling tao_remote_sensor_get_configuration() and which is set by
* tao_remote_sensor_set_configuration().
*
......@@ -86,7 +86,7 @@ typedef struct tao_remote_sensor_ tao_remote_sensor;
* @param max_ninds The maximum number of nodes in of the 2-dimensional layout
* grid.
*
* @param max_nsubs The maximum number of the sub-pupils.
* @param max_nsubs The maximum number of the sub-images.
*
* @param flags Permissions for clients and options.
*
......
......@@ -64,12 +64,12 @@ typedef struct tao_measured_position_ {
} tao_measured_position;
/**
* Definition of a wavefront sensor sub-pupil.
* Definition of a wavefront sensor sub-image.
*/
typedef struct tao_wavefront_sensor_subpupil_ {
tao_bounding_box box;///< Bounding box of the sub-pupil.
tao_position ref;///< Reference position in the sub-pupil.
} tao_wavefront_sensor_subpupil;
typedef struct tao_wavefront_sensor_subimage_ {
tao_bounding_box box;///< Bounding box of the sub-image.
tao_position ref;///< Reference position in the sub-image.
} tao_wavefront_sensor_subimage;
/**
* Wavefront sensor elementary data.
......@@ -79,13 +79,13 @@ typedef struct tao_wavefront_sensor_subpupil_ {
*/
typedef struct tao_wavefront_sensor_data_ {
// The first members must be identical to those of the structure
// `tao_wavefront_sensor_subpupil`.
tao_bounding_box box;///< Bounding box of the sub-pupil.
tao_position ref;///< Reference position in the sub-pupil.
// `tao_wavefront_sensor_subimage`.
tao_bounding_box box;///< Bounding box of the sub-image.
tao_position ref;///< Reference position in the sub-image.
// Memebers not in `tao_wavefront_sensor_subpupil` structure.
tao_measured_position dat;///< Measured position in the sub-pupil (relative
/// to the reference).
// Memebers not in `tao_wavefront_sensor_subimage` structure.
tao_measured_position pos;///< Measured position (relative to the
/// reference).
double alpha;///< Intensity factor.
double epsilon;///< Quality factor.
} tao_wavefront_sensor_data;
......@@ -94,16 +94,16 @@ typedef struct tao_wavefront_sensor_data_ {
* Wavefront sensor configuration.
*
* This structure represents the fixed size part of a wavefront sensor
* configuration. The variable size parts (the layout of the sub-pupils grid
* and the list of sub-pupils definitions) are provided separately.
* configuration. The variable size parts (the layout of the sub-images grid
* and the list of sub-images definitions) are provided separately.
*/
typedef struct tao_wavefront_sensor_config_ {
double forgetting_factor;
double restoring_force;
double max_excursion;
tao_algorithm algo;
long nsubs;///< Number of sub-pupils.
long dims[2];///< Dimensions of sub-pupil grid.
long nsubs;///< Number of sub-images.
long dims[2];///< Dimensions of sub-image grid.
} tao_wavefront_sensor_config;
/**
......@@ -111,9 +111,9 @@ typedef struct tao_wavefront_sensor_config_ {
*
* @param cfg The fixed size part of the wavefront sensor configuration.
*
* @param inds The layout of the sub-pupils.
* @param inds The layout of the sub-images.
*
* @param subs The parameters of the sub-pupils.
* @param subs The parameters of the sub-images.
*
* @param width The width of the image.
*
......@@ -124,7 +124,7 @@ typedef struct tao_wavefront_sensor_config_ {
extern tao_status tao_wavefront_sensor_check_config(
const tao_wavefront_sensor_config* cfg,
const long* inds,
const tao_wavefront_sensor_subpupil* subs,
const tao_wavefront_sensor_subimage* subs,
long width,
long height);
......
......@@ -18,7 +18,7 @@
tao_status tao_wavefront_sensor_check_config(
const tao_wavefront_sensor_config* cfg,
const long* inds,
const tao_wavefront_sensor_subpupil* subs,
const tao_wavefront_sensor_subimage* subs,
long width,
long height)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment