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

Add tao_remote_sensor_fetch_data (untested)

parent 5c7dcf42
......@@ -419,7 +419,7 @@ tao_status tao_remote_mirror_fetch_data(
// FIXME: check whether serial is too high, server is running, etc.
double* src_refs;
double* src_cmds;
tao_dataframe_header* header = fetch_frame(
const tao_dataframe_header* header = fetch_frame(
obj, serial, &src_refs, &src_cmds);
if (atomic_load(&header->serial) != serial) {
if (info != NULL) {
......
......@@ -190,6 +190,16 @@ long tao_remote_sensor_get_ninds(
}
}
const long* tao_remote_sensor_get_dims(
const tao_remote_sensor* wfs)
{
if (wfs == NULL) {
return NULL;
} else {
return wfs->config.base.dims;
}
}
const long* tao_remote_sensor_get_inds(
const tao_remote_sensor* wfs,
long* dims)
......@@ -453,6 +463,90 @@ tao_serial tao_remote_sensor_kill(
return send_simple_command(__func__, wfs, TAO_COMMAND_KILL, secs);
}
static inline void* remote_object_get_buffer(
const tao_remote_object* obj,
tao_serial serial)
{
size_t offset = obj->offset + ((serial - 1)%obj->nbufs)*obj->stride;
return TAO_COMPUTED_ADDRESS(obj, offset);
}
// Offset of the reference values in a data-frame.
#define DATA_OFFSET_IN_DATAFRAME \
TAO_ROUND_UP(sizeof(tao_dataframe_header), sizeof(double))
static inline tao_dataframe_header* fetch_frame(
const tao_remote_sensor* obj,
tao_serial serial,
tao_shackhartmann_data** data)
{
tao_dataframe_header* header = remote_object_get_buffer(
tao_remote_object_cast(obj), serial);
*data = TAO_COMPUTED_ADDRESS(header, DATA_OFFSET_IN_DATAFRAME);
return header;
}
tao_status tao_remote_sensor_fetch_data(
const tao_remote_sensor* obj,
tao_serial serial,
tao_shackhartmann_data* data,
long ndata,
tao_dataframe_info* info)
{
// Check arguments, then copy and check that data did not get overwritten
// in the mean time.
if (obj == NULL) {
tao_store_error(__func__, TAO_BAD_ADDRESS);
return TAO_ERROR;
}
if (obj->config.base.nsubs < 1 || obj->base.nbufs < 2) {
tao_store_error(__func__, TAO_CORRUPTED);
return TAO_ERROR;
}
if (ndata != obj->config.base.nsubs) {
tao_store_error(__func__, TAO_BAD_SIZE);
return TAO_ERROR;
}
size_t nbytes = ndata*sizeof(data[0]);
if (serial < 1) {
if (serial != 0) {
tao_store_error(__func__, TAO_BAD_SERIAL);
return TAO_ERROR;
}
if (info != NULL) {
memset(info, 0, sizeof(*info));
}
if (data != NULL) {
memset(data, 0, nbytes);
}
} else {
// FIXME: check whether serial is too high, server is running, etc.
tao_shackhartmann_data* src_data;
const tao_dataframe_header* header = fetch_frame(
obj, serial, &src_data);
if (atomic_load(&header->serial) != serial) {
if (info != NULL) {
info->serial = 0;
info->mark = 0;
info->time = TAO_TIME(0, 0);
}
return TAO_TIMEOUT;
}
if (info != NULL) {
info->serial = serial;
info->mark = header->mark;
info->time = header->time;
}
if (data != NULL) {
memcpy(data, src_data, nbytes);
}
if (atomic_load(&header->serial) != serial) {
return TAO_TIMEOUT;
}
}
return TAO_OK;
}
#define TYPE remote_sensor
#define MAGIC TAO_REMOTE_SENSOR
#define REMOTE_OBJECT 2 // sub-type of remote object type
......
......@@ -528,9 +528,13 @@ extern int tao_remote_sensor_is_alive(
const tao_remote_sensor* wfs);
// Getters.
extern long tao_remote_sensor_get_ninds(
const tao_remote_sensor* wfs);
const long* tao_remote_sensor_get_dims(
const tao_remote_sensor* wfs);
extern long tao_remote_sensor_get_nsubs(
const tao_remote_sensor* wfs);
......@@ -559,6 +563,13 @@ extern const long* tao_remote_sensor_get_inds(
extern const tao_subimage* tao_remote_sensor_get_subs(
const tao_remote_sensor* wfs, long* nsubs);
extern tao_status tao_remote_sensor_fetch_data(
const tao_remote_sensor* obj,
tao_serial serial,
tao_shackhartmann_data* data,
long ndata,
tao_dataframe_info* info);
/**
* Get the camera of a remote wavefront sensor.
*
......
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