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

Fix functions so that code do compile

parent c285c165
// fli-core.h -
//
// Implementation of the interface to FLI (Finger Lakes Instrumentation)
// Implementation of the interface to Finger Lakes Instrumentation (FLI)
// cameras in TAO (a Toolkit for Adaptive Optics).
//
//-----------------------------------------------------------------------------
......@@ -8,12 +8,13 @@
// This file if part of TAO real-time software licensed under the MIT license
// (https://git-cral.univ-lyon1.fr/tao/tao-rt).
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include "libfipro.h"
#include "libflipro.h"
#include "tao-fli-cameras.h" // for the prototype of tao_foo_camera_open
#include "tao-fli-cameras.h" // for the prototype of tao_fli_camera_open
#include "tao-threads.h" // for mutexes
#include "tao-errors.h" // for error management
#include "tao-cameras-private.h" // for the definition of tao_camera
......@@ -22,7 +23,7 @@
#define MAX_CONNECTED_CAMERAS 8
// List of available cameras and mutex to protect access to this list.
FPRODEVICEINFO device_list[MAX_CONNECTED_CAMERA];
FPRODEVICEINFO device_list[MAX_CONNECTED_CAMERAS];
long ndevices = 0;
tao_mutex mutex = TAO_MUTEX_INITIALIZER;
......@@ -30,7 +31,7 @@ tao_mutex mutex = TAO_MUTEX_INITIALIZER;
static tao_status update_device_list();
// A handle fo a camera (see <libfipro.h>).
typedef int32 fli_handle;
typedef int32_t fli_handle;
typedef struct fli_camera_ {
tao_camera base; // A FLI camera is also a TAO camera.
......@@ -58,8 +59,22 @@ static void fli_error(const char* func, int code);
// second).
static tao_status set_exposure(
fli_camera* dev,
double exposure,
double fps);
double exposuretime,
double framerate);
// Set the pixel binning.
static tao_status set_binning(
fli_camera* dev,
long xbin,
long ybin);
// Set the ROI.
static tao_status set_region(
fli_camera* dev,
long xoff,
long yoff,
long width,
long height);
//-----------------------------------------------------------------------------
// Declaration of private methods and of the table grouping these methods for
......@@ -98,22 +113,23 @@ static tao_status on_wait_buffer(
int drop);
static tao_camera_ops ops = {
.name = "FLICamera",
.initialize = on_initialize,
.finalize = on_finalize,
.reset = on_reset,
.name = "FLICamera",
.initialize = on_initialize,
.finalize = on_finalize,
.reset = on_reset,
.update_config = on_update_config,
.check_config = on_check_config,
.set_config = on_set_config,
.start = on_start,
.stop = on_stop,
.wait_buffer: on_wait_buffer
.check_config = on_check_config,
.set_config = on_set_config,
.start = on_start,
.stop = on_stop,
.wait_buffer = on_wait_buffer
};
//-----------------------------------------------------------------------------
// Definition of the public function to connect to a Foo camera.
// Definition of the public function to connect to a Finger Lakes
// Instrumentation (FLI) camera.
tao_camera* tao_foo_camera_open(
tao_camera* tao_fli_camera_open(
int num)
{
// First lock global resources.
......@@ -160,7 +176,7 @@ static tao_status on_initialize(
tao_camera* cam)
{
// The camera is a FLI camera.
fli_camera* dev = (tao_fli_camera*)cam;
fli_camera* dev = (fli_camera*)cam;
// The contextual data is the device information.
FPRODEVICEINFO* devinfo = cam->ctx;
......@@ -188,11 +204,11 @@ static tao_status on_finalize(
tao_camera* cam)
{
// The camera is a FLI camera.
fli_camera* dev = (tao_fli_camera*)cam;
fli_camera* dev = (fli_camera*)cam;
// Close the device.
if (dev->handle >= 0) {
fli_handle = handle = dev->handle;
fli_handle handle = dev->handle;
dev->handle = -1; // never close more than once
FLI_CALL(FPROCam_Close,(handle), return TAO_ERROR);
}
......@@ -225,6 +241,47 @@ static tao_status on_set_config(
tao_camera* cam,
const tao_camera_config* cfg)
{
// The camera is a FLI camera.
fli_camera* dev = (fli_camera*)cam;
// Do we need to change the frame rate?
bool reduce_fps = (cfg->framerate < cam->info.config.framerate);
bool augment_fps = (cfg->framerate > cam->info.config.framerate);
bool change_expoure = (cfg->exposuretime != cam->info.config.exposuretime);
// Reduce frame rate if possible before changing ROI.
if (reduce_fps) {
if (set_exposure(dev, cfg->exposuretime, cfg->framerate) != TAO_OK) {
return TAO_ERROR;
}
change_expoure = false;
}
// Set binning.
if (cfg->roi.xbin != cam->info.config.roi.xbin ||
cfg->roi.ybin != cam->info.config.roi.ybin) {
if (set_binning(dev, cfg->roi.xbin, cfg->roi.ybin) != TAO_OK) {
return TAO_ERROR;
}
}
// Set image region.
if (cfg->roi.xoff != cam->info.config.roi.xoff ||
cfg->roi.yoff != cam->info.config.roi.yoff ||
cfg->roi.width != cam->info.config.roi.width ||
cfg->roi.height != cam->info.config.roi.height) {
if (set_region(dev, cfg->roi.xoff, cfg->roi.yoff,
cfg->roi.width, cfg->roi.height) != TAO_OK) {
return TAO_ERROR;
}
}
// Augment frame rate after changing ROI.
if (augment_fps || change_expoure) {
if (set_exposure(dev, cfg->exposuretime, cfg->framerate) != TAO_OK) {
return TAO_ERROR;
}
}
tao_store_error(__func__, TAO_NOT_YET_IMPLEMENTED);
return TAO_ERROR;
}
......@@ -266,11 +323,11 @@ static tao_status update_device_list()
uint32_t num = MAX_CONNECTED_CAMERAS;
FLI_CALL(FPROCam_GetCameraList, (device_list, &num), return TAO_ERROR);
if (num >= MAX_CONNECTED_CAMERAS) {
fprint(stderr,
"Warning: There may be more than %d connected cameras. You "
"should change\n the value of macro "
"`MAX_CONNECTED_CAMERAS` in file `%s`\n",
MAX_CONNECTED_CAMERAS, __FILE__);
fprintf(stderr,
"Warning: There may be more than %d connected cameras. You "
"should change\n the value of macro "
"`MAX_CONNECTED_CAMERAS` in file `%s`\n",
MAX_CONNECTED_CAMERAS, __FILE__);
}
ndevices = num;
return TAO_OK;
......@@ -282,18 +339,19 @@ static tao_status update_device_list()
// second).
static tao_status set_exposure(
fli_camera* dev,
double exposure,
double fps)
double exposuretime,
double framerate)
{
// In the SDK, the exposure time and the frame delay are in nanoseconds.
uint64_t exposure_ns = lround(exposure*NANOSECONDS_PER_SECOND);
uint64_t exposuretime_ns = lround(exposuretime*NANOSECONDS_PER_SECOND);
uint64_t framedelay_ns = lround(NANOSECONDS_PER_SECOND/framerate)
- exposuretime_ns;
uint64_t actual_exposure_ns;
uint64_t actual_exposuretime_ns;
uint64_t actual_framedelay_ns;
FLI_CALL(Ctrl_SetExposureEx,
(dev->handle, exposure_ns, framedelay_ns, false,
&actual_exposure_ns, &actual_framedelay_ns), return TAO_ERROR);
FLI_CALL(FPROCtrl_SetExposureEx,
(dev->handle, exposuretime_ns, framedelay_ns, false,
&actual_exposuretime_ns, &actual_framedelay_ns),
return TAO_ERROR);
dev->base.info.config.exposuretime =
actual_exposuretime_ns/NANOSECONDS_PER_SECOND;
dev->base.info.config.framerate =
......@@ -302,6 +360,28 @@ static tao_status set_exposure(
return TAO_OK;
}
// Set the pixel binning.
static tao_status set_binning(
fli_camera* dev,
long xbin,
long ybin)
{
tao_store_error(__func__, TAO_NOT_YET_IMPLEMENTED);
return TAO_ERROR;
}
// Set the ROI.
static tao_status set_region(
fli_camera* dev,
long xoff,
long yoff,
long width,
long height)
{
tao_store_error(__func__, TAO_NOT_YET_IMPLEMENTED);
return TAO_ERROR;
}
//-----------------------------------------------------------------------------
// ERROR MANAGEMENT.
......
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