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

Bump magic number and add definitions for remote wavefront sensors

parent bc1cd315
......@@ -60,12 +60,14 @@ include_HEADERS = \
tao-macros.h \
tao-options.h \
tao-pixels.h \
tao-remote-mirrors.h \
tao-remote-cameras-private.h \
tao-remote-cameras.h \
tao-remote-mirrors.h \
tao-remote-mirrors-private.h \
tao-remote-objects.h \
tao-remote-objects-private.h \
tao-remote-sensors.h \
tao-remote-sensors-private.h \
tao-rwlocked-objects.h \
tao-rwlocked-objects-private.h \
tao-shared-arrays.h \
......@@ -96,6 +98,7 @@ libtao_la_SOURCES = \
remote-cameras.c \
remote-mirrors.c \
remote-objects.c \
remote-sensors.c \
rwlocked-objects.c \
semaphores.c \
shared-arrays.c \
......
// remote-sensors.c -
//
// Management of remote wavefront sensors.
//
//-----------------------------------------------------------------------------
//
// This file if part of TAO real-time software licensed under the MIT license
// (https://git-cral.univ-lyon1.fr/tao/tao-rt).
//
// Copyright (C) 2019-2022, Éric Thiébaut.
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdatomic.h>
#include "tao-basics.h"
#include "tao-config.h"
#include "tao-errors.h"
#include "tao-generic.h"
#include "tao-remote-sensors-private.h"
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)
{
if (wfs == NULL || cfg == NULL || inds == NULL || subs == NULL) {
tao_store_error(__func__, TAO_BAD_ADDRESS);
return TAO_ERROR;
}
long width = wfs->config.camera.width;
long height = wfs->config.camera.height;
if (tao_wavefront_sensor_check_config(
&cfg->base, inds, subs, width, height) != TAO_OK) {
return TAO_ERROR;
}
long dim1 = cfg->base.dims[0];
long dim2 = cfg->base.dims[1];
long ninds = dim1*dim2;
long nsubs = cfg->base.nsubs;
if (ninds > wfs->max_size || nsubs > wfs->max_nsubs) {
tao_store_error(__func__, TAO_OUT_OF_RANGE);
return TAO_ERROR;
}
return TAO_OK;
}
#define TYPE remote_sensor
#define MAGIC TAO_REMOTE_SENSOR
#define IS_REMOTE_OBJECT 1
#include "./shared-methods.c"
tao_serial tao_remote_sensor_get_mark(
const tao_remote_sensor* wfs)
{
return (wfs == NULL) ? 0 : wfs->mark;
}
......@@ -17,6 +17,7 @@
#include <tao-remote-cameras.h>
#include <tao-remote-mirrors.h>
#include <tao-remote-objects.h>
#include <tao-remote-sensors.h>
#include <tao-rwlocked-objects.h>
#include <tao-shared-objects.h>
......@@ -207,12 +208,14 @@ static inline bool tao_clamp_b(bool arg1_, bool arg2_, bool arg3_)
tao_remote_object *: (tao_shared_object*)(obj), \
tao_remote_camera *: (tao_shared_object*)(obj), \
tao_remote_mirror *: (tao_shared_object*)(obj), \
tao_remote_sensor *: (tao_shared_object*)(obj), \
tao_rwlocked_object *: (tao_shared_object*)(obj), \
tao_shared_array *: (tao_shared_object*)(obj), \
tao_shared_object const*: (obj), \
tao_remote_object const*: (tao_shared_object const*)(obj), \
tao_remote_camera const*: (tao_shared_object const*)(obj), \
tao_remote_mirror const*: (tao_shared_object const*)(obj), \
tao_remote_sensor const*: (tao_shared_object const*)(obj), \
tao_rwlocked_object const*: (tao_shared_object const*)(obj), \
tao_shared_array const*: (tao_shared_object const*)(obj))
#endif /* TAO_DOXYGEN_ */
......@@ -250,9 +253,11 @@ static inline bool tao_clamp_b(bool arg1_, bool arg2_, bool arg3_)
tao_remote_object *: (obj), \
tao_remote_camera *: (tao_remote_object*)(obj), \
tao_remote_mirror *: (tao_remote_object*)(obj), \
tao_remote_sensor *: (tao_remote_object*)(obj), \
tao_remote_object const*: (obj), \
tao_remote_camera const*: (tao_remote_object const*)(obj), \
tao_remote_mirror const*: (tao_remote_object const*)(obj))
tao_remote_mirror const*: (tao_remote_object const*)(obj), \
tao_remote_sensor const*: (tao_remote_object const*)(obj))
#endif /* TAO_DOXYGEN_ */
//-----------------------------------------------------------------------------
......@@ -261,12 +266,20 @@ static inline bool tao_clamp_b(bool arg1_, bool arg2_, bool arg3_)
#define TAO_ANY_OBJECT_METHOD(verb, obj) \
_Generic( \
(obj), \
tao_remote_camera *: tao_remote_camera_##verb, \
tao_remote_mirror *: tao_remote_mirror_##verb, \
tao_remote_object *: tao_remote_object_##verb, \
tao_rwlocked_object*: tao_rwlocked_object_##verb, \
tao_shared_array *: tao_remote_object_##verb, \
tao_shared_object *: tao_shared_object_##verb)
tao_remote_camera *: tao_remote_camera_##verb, \
tao_remote_camera const*: tao_remote_camera_##verb, \
tao_remote_mirror *: tao_remote_mirror_##verb, \
tao_remote_mirror const*: tao_remote_mirror_##verb, \
tao_remote_object *: tao_remote_object_##verb, \
tao_remote_object const*: tao_remote_object_##verb, \
tao_remote_sensor *: tao_remote_sensor_##verb, \
tao_remote_sensor const*: tao_remote_sensor_##verb, \
tao_rwlocked_object *: tao_rwlocked_object_##verb, \
tao_rwlocked_object const*: tao_rwlocked_object_##verb, \
tao_shared_array *: tao_remote_object_##verb, \
tao_shared_array const*: tao_remote_object_##verb, \
tao_shared_object *: tao_shared_object_##verb, \
tao_shared_object const*: tao_shared_object_##verb)
/**
* @def tao_attach(T,shmid,...)
......@@ -323,7 +336,8 @@ static inline bool tao_clamp_b(bool arg1_, bool arg2_, bool arg3_)
tao_shared_object*: tao_shared_object_##verb, \
tao_remote_object*: tao_remote_object_##verb, \
tao_remote_camera*: tao_remote_camera_##verb, \
tao_remote_mirror*: tao_remote_mirror_##verb)
tao_remote_mirror*: tao_remote_mirror_##verb, \
tao_remote_sensor*: tao_remote_sensor_##verb)
/**
* @def tao_lock(obj)
......@@ -496,6 +510,7 @@ static inline bool tao_clamp_b(bool arg1_, bool arg2_, bool arg3_)
tao_remote_object *: tao_remote_object_##verb, \
tao_remote_camera *: tao_remote_camera_##verb, \
tao_remote_mirror *: tao_remote_mirror_##verb, \
tao_remote_snesor *: tao_remote_sensor_##verb, \
tao_rwlocked_object*: tao_rwlocked_object_##verb, \
tao_shared_array *: tao_remote_object_##verb)
......
// tao-remote-sensors-private.h -
//
// Private definitions for remote wavefront sensors in TAO library.
//
//-----------------------------------------------------------------------------
//
// This file if part of TAO real-time software licensed under the MIT license
// (https://git-cral.univ-lyon1.fr/tao/tao-rt).
//
// Copyright (C) 2019-2022, Éric Thiébaut.
#ifndef TAO_REMOTE_SENSORS_PRIVATE_H_
#define TAO_REMOTE_SENSORS_PRIVATE_H_ 1
#include <tao-remote-objects-private.h>
#include <tao-remote-sensors.h>
TAO_BEGIN_DECLS
/**
* Structure describing the complete configuration of a wavefront sensor.
*
*/
typedef struct tao_remote_sensor_config_ {
tao_wavefront_sensor_config base;
struct {
char owner[TAO_OWNER_SIZE];
long width;
long height;
} camera;
// 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. 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.
size_t subs_offset;///< Offset to the sub-pupil definitions.
// To save one offset The layout must be the last member, its reserved size is `max_size`, its actual size is `dims[0]*dims[1]` and it is followed by `max_nsubs` dims[0]*dims[1]`.
long layout[1];///< Layout of sub-pupils grid.
} tao_remote_sensor_config;
struct tao_remote_sensor_ {
tao_remote_object base;///< Common part for all shared objects.
const long max_nsubs;///< Maximum number of sub-pupils.
const long max_size;///< Maximum size of sub-pupil grid.
const long refs_offset;///< Offset to sub-pupil reference (in bytes).
tao_serial mark;///< Serial number of last data-frame.
tao_remote_sensor_config config;///< Current configuration.
};
TAO_END_DECLS
#endif // TAO_REMOTE_SENSORS_PRIVATE__H_
This diff is collapsed.
......@@ -71,9 +71,9 @@ typedef struct tao_shared_object_ tao_shared_object;
* To avoid confusion, object types bitwise or'ed with @ref TAO_SHARED_MASK
* shall be equal to @ref TAO_SHARED_MAGIC.
*/
#define TAO_SHARED_MAGIC 0x59d42800
#define TAO_SHARED_MAGIC 0xdcd84c00
// Above magic number generated with Yorick command (5-th random number):
// Above magic number generated with Yorick command (6-th random number):
//
// write, format="0x%08x\n", lround(random()*(1<<24))<<8;
//
......@@ -106,7 +106,7 @@ typedef enum tao_object_type_ {
TAO_SHARED_ARRAY = (TAO_RWLOCKED_OBJECT| 1),///< Shared multi-dimensional array.
TAO_REMOTE_CAMERA = (TAO_REMOTE_OBJECT | 2),///< Remote camera.
TAO_REMOTE_MIRROR = (TAO_REMOTE_OBJECT | 3),///< Remote deformable mirror.
//TAO_REMOTE_SENSOR = (TAO_REMOTE_OBJECT | 4),///< Remote wavefront sensor.
TAO_REMOTE_SENSOR = (TAO_REMOTE_OBJECT | 4),///< Remote wavefront sensor.
} tao_object_type;
/**
......
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