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

Deformable mirrors have new members `cmin` and `cmax`

parent 6509e249
......@@ -2,6 +2,9 @@
## Version 0.8.2
* Deformable mirrors have new members `cmin` and `cmax` to indicate the minimum
and maximum values for an actuator command.
* Shell commands renamed with an `_` (underscore) separator instead of an `-`
(hyphen) as in Yorick and C code.
......
......@@ -247,7 +247,8 @@ int main(
}
// Allocate the remote mirror instance.
dm = tao_remote_mirror_create(ident, nbufs, inds, dims[0], dims[1], perms);
dm = tao_remote_mirror_create(
ident, nbufs, inds, dims[0], dims[1], -1.0, +1.0, perms);
if (dm == NULL) {
fprintf(stderr, "%s: failed to create remote mirror instance\n",
progname);
......
......@@ -438,6 +438,7 @@ const char* FUNC(
CASE(TAO_BAD_RESTORING_FORCE, "Invalid restoring force");
CASE(TAO_BAD_REFERENCE, "Invalid reference");
CASE(TAO_BAD_RANK, "Invalid number of dimensions");
CASE(TAO_BAD_RANGE, "Invalid interval of values");
CASE(TAO_BAD_PREPROCESSING, "Invalid pre-processing settings");
CASE(TAO_BAD_PIXELTYPE, "Invalid pixel type");
CASE(TAO_BAD_NUMBER, "Invalid number of values");
......
......@@ -10,6 +10,7 @@
// Copyright (C) 2019-2022, Éric Thiébaut.
#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdatomic.h>
......@@ -101,6 +102,8 @@ tao_remote_mirror* tao_remote_mirror_create(
const long* inds,
long dim1,
long dim2,
double cmin,
double cmax,
unsigned flags)
{
// Check arguments.
......@@ -133,6 +136,11 @@ tao_remote_mirror* tao_remote_mirror_create(
return NULL;
}
}
if (!isfinite(cmin) || !isfinite(cmax) || cmin >= cmax) {
tao_store_error(__func__, TAO_BAD_RANGE);
return NULL;
}
// Compute sizes and offsets of members.
size_t inds_size = ninds*sizeof(long);
......@@ -160,6 +168,8 @@ tao_remote_mirror* tao_remote_mirror_create(
tao_forced_store(&obj->dims[0], dim1);
tao_forced_store(&obj->dims[1], dim2);
tao_forced_store(&obj->refs_offset, refs_offset);
tao_forced_store(&obj->cmin, cmin);
tao_forced_store(&obj->cmax, cmax);
long* dest_inds = remote_mirror_get_inds(obj);
for (long i = 0; i < ninds; ++i) {
if (inds[i] >= 0) {
......@@ -211,6 +221,19 @@ const long* tao_remote_mirror_get_layout(
}
}
double tao_remote_mirror_get_cmin(
const tao_remote_mirror* obj)
{
return (obj == NULL) ? NAN : obj->cmin;
}
double tao_remote_mirror_get_cmax(
const tao_remote_mirror* obj)
{
return (obj == NULL) ? NAN : obj->cmax;
}
double* tao_remote_mirror_get_reference(
const tao_remote_mirror* obj)
{
......
......@@ -105,40 +105,41 @@ typedef enum tao_error_code_ {
TAO_BAD_NUMBER = -29,///< Invalid number of values
TAO_BAD_PIXELTYPE = -30,///< Bad pixel type
TAO_BAD_PREPROCESSING = -31,///< Bad pre-processing settings
TAO_BAD_RANK = -32,///< Invalid number of dimensions
TAO_BAD_REFERENCE = -33,///< Invalid reference
TAO_BAD_RESTORING_FORCE = -34,///< Invalid restoring force
TAO_BAD_ROI = -35,///< Invalid region of interest
TAO_BAD_SERIAL = -36,///< Invalid serial number
TAO_BAD_SIZE = -37,///< Invalid size
TAO_BAD_SPEED = -38,///< Invalid connection speed
TAO_BAD_STAGE = -39,///< Invalid or unexpected stage
TAO_BAD_TYPE = -40,///< Invalid type
TAO_BAD_VALUE = -41,///< Invalid parameter value
TAO_BROKEN_CYCLE = -42,///< Broken cycle or unordered operations
TAO_CANT_TRACK_ERROR = -43,///< Insufficient memory to track errors
TAO_CORRUPTED = -44,///< Corrupted structure
TAO_DESTROYED = -45,///< Resource has been destroyed
TAO_EXHAUSTED = -46,///< Resource exhausted
TAO_FORBIDDEN_CHANGE = -47,///< Forbidden change of parameter(s)
TAO_MISSING_SEPARATOR = -48,///< Separator missing
TAO_MUST_RESET = -49,///< Device must be reset
TAO_NOT_ACQUIRING = -50,///< Acquisition not started
TAO_NOT_FOUND = -51,///< Item not found
TAO_NOT_LOCKED = -52,///< Resource not locked by caller
TAO_NOT_READY = -53,///< Device not ready
TAO_NOT_RUNNING = -54,///< Server or thread is not running
TAO_NOT_YET_IMPLEMENTED = -55,///< Not yet implemented
TAO_NO_DATA = -56,///< No data available
TAO_NO_FITS_SUPPORT = -57,///< Compiled with no FITS support
TAO_OUT_OF_RANGE = -58,///< Out of range argument
TAO_OVERWRITTEN = -59,///< Contents has been overwritten
TAO_SYSTEM_ERROR = -60,///< Unknown system error
TAO_UNCLOSED_STRING = -61,///< Unclosed string
TAO_UNREADABLE = -62,///< Not readable
TAO_UNRECOVERABLE = -63,///< Unrecoverable error
TAO_UNSUPPORTED = -64,///< Unsupported feature
TAO_UNWRITABLE = -65,///< Not writable
TAO_BAD_RANGE = -32,///< Invalid interval of values
TAO_BAD_RANK = -33,///< Invalid number of dimensions
TAO_BAD_REFERENCE = -34,///< Invalid reference
TAO_BAD_RESTORING_FORCE = -35,///< Invalid restoring force
TAO_BAD_ROI = -36,///< Invalid region of interest
TAO_BAD_SERIAL = -37,///< Invalid serial number
TAO_BAD_SIZE = -38,///< Invalid size
TAO_BAD_SPEED = -39,///< Invalid connection speed
TAO_BAD_STAGE = -40,///< Invalid or unexpected stage
TAO_BAD_TYPE = -41,///< Invalid type
TAO_BAD_VALUE = -42,///< Invalid parameter value
TAO_BROKEN_CYCLE = -43,///< Broken cycle or unordered operations
TAO_CANT_TRACK_ERROR = -44,///< Insufficient memory to track errors
TAO_CORRUPTED = -45,///< Corrupted structure
TAO_DESTROYED = -46,///< Resource has been destroyed
TAO_EXHAUSTED = -47,///< Resource exhausted
TAO_FORBIDDEN_CHANGE = -48,///< Forbidden change of parameter(s)
TAO_MISSING_SEPARATOR = -49,///< Separator missing
TAO_MUST_RESET = -50,///< Device must be reset
TAO_NOT_ACQUIRING = -51,///< Acquisition not started
TAO_NOT_FOUND = -52,///< Item not found
TAO_NOT_LOCKED = -53,///< Resource not locked by caller
TAO_NOT_READY = -54,///< Device not ready
TAO_NOT_RUNNING = -55,///< Server or thread is not running
TAO_NOT_YET_IMPLEMENTED = -56,///< Not yet implemented
TAO_NO_DATA = -57,///< No data available
TAO_NO_FITS_SUPPORT = -58,///< Compiled with no FITS support
TAO_OUT_OF_RANGE = -59,///< Out of range argument
TAO_OVERWRITTEN = -60,///< Contents has been overwritten
TAO_SYSTEM_ERROR = -61,///< Unknown system error
TAO_UNCLOSED_STRING = -62,///< Unclosed string
TAO_UNREADABLE = -63,///< Not readable
TAO_UNRECOVERABLE = -64,///< Unrecoverable error
TAO_UNSUPPORTED = -65,///< Unsupported feature
TAO_UNWRITABLE = -66,///< Not writable
} tao_error_code;
/**
......
......@@ -246,7 +246,8 @@ int main(
}
// Allocate the remote mirror instance.
dm = tao_remote_mirror_create(ident, nbufs, inds, dim, dim, perms);
dm = tao_remote_mirror_create(
ident, nbufs, inds, dim, dim, -1.0, +1.0, perms);
if (dm == NULL) {
fprintf(stderr, "%s: failed to create remote mirror instance\n",
progname);
......
......@@ -22,6 +22,8 @@ struct tao_remote_mirror_ {
const long nacts;///< Number of actuators.
const long dims[2];///< Dimensions of actuator grid.
const long refs_offset;///< Offset to actuator reference (in bytes).
const double cmin;///< Minimal value for an actuator command.
const double cmax;///< Maximal value for an actuator command.
tao_serial mark;///< Serial number of last data-frame.
};
......
......@@ -87,6 +87,10 @@ typedef struct tao_remote_mirror_ tao_remote_mirror;
*
* @param dim2 The second dimension of the grid of actuators.
*
* @param cmin The minimal value for an actuator command.
*
* @param cmax The maximal value for an actuator command.
*
* @param flags Permissions for clients and options.
*
*
......@@ -99,6 +103,8 @@ tao_remote_mirror* tao_remote_mirror_create(
const long* inds,
long dim1,
long dim2,
double cmin,
double cmax,
unsigned flags);
/**
......@@ -588,6 +594,34 @@ extern const long* tao_remote_mirror_get_layout(
const tao_remote_mirror* obj,
long dims[2]);
/**
* Get the minimal value for an actuator commands.
*
* The minimal value is constant. It is not needed to lock the
* remote deformable mirror before calling this function.
*
* @param obj Address of remote deformable mirror instance (can be `NULL`).
*
* @return A minimal value, `NaN` if if `obj` is `NULL`. Whatever the result,
* this getter function leaves the caller's last error unchanged.
*/
extern double tao_remote_mirror_get_cmin(
const tao_remote_mirror* obj);
/**
* Get the maximal value for an actuator commands.
*
* The maximal value is constant. It is not needed to lock the
* remote deformable mirror before calling this function.
*
* @param obj Address of remote deformable mirror instance (can be `NULL`).
*
* @return A maximal value, `NaN` if if `obj` is `NULL`. Whatever the result,
* this getter function leaves the caller's last error unchanged.
*/
extern double tao_remote_mirror_get_cmax(
const tao_remote_mirror* obj);
/**
* Obtain requested actuators commands of a remote deformable mirror.
*
......
......@@ -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 0xdcd84c00
#define TAO_SHARED_MAGIC 0x6bc4e900
// Above magic number generated with Yorick command (6-th random number):
// Above magic number generated with Yorick command (7-th random number):
//
// write, format="0x%08x\n", lround(random()*(1<<24))<<8;
//
......
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