add WIP definitions of data structures

parent 51d6cb1d
/*
* Copyright CERN 2021
* Author: Juan David Gonzalez Cobas <dcobas _at_ cern.ch>
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef FSI_LIB_H_
#define FSI_LIB_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdlib.h>
#include <sys/time.h>
enum fsi_peak_type {
FSI_PEAK_LORENTZ = 1, /**< Cauchy-Lorentz 1/(1+xˆ2) distribution */
FSI_PEAK_GAUSS, /**< Gaussian (normal) distribution */
FSI_PEAK_SINC, /**< Sinc (sin(x)/x)) distribution */
FSI_PEAK_MOFFAT, /**< Moffat (power of Cauchy pdf) distribution */
FSI_PEAK_BRAGG, /**< Bragg-type peak */
/* FIXME:should Bragg type be set apart? */
};
/* biggest number of model parameters among different peak types */
#define FSI_MAX_MODEL_PARAMS 4
/* max number of peaks to find in a channel sample */
#define FSI_MAX_PEAKS 5
/* length of return peak data */
#define FSI_PEAK_LENGTH 200
/* library error codes */
#define __FSI_ERR_START 1024
struct fsi_peak_request {
double frequency; /**< estimated frequency where peak fits */
double search_range; /**< estimated interval of peak range */
double channel_gain; /**< FIXME: should be per-channel, not per-peak? */
enum fsi_peak_type type; /**< shape of peak to fit */
};
struct fsi_peak_result {
double frequency; /**< center of peak fitted to data */
double amplitude; /**< peak width derived from parameters */
double snr; /**< peak signal-to-noise ratio (?) */
enum fsi_peak_type
type; /**< shape of peak fit to data */
double fit_params[FSI_MAX_MODEL_PARAMS];
/**< goodness-of-fit params, model-dependent */
uint16_t samples[FSI_PEAK_LENGTH]; /**< actual peak samples */
};
struct fsi_channel_request {
unsigned int channel_id; /**< channel to be configured */
double channel_gain; /**< channel gain FIXME: see fsi_peak_request */
int npeaks; /**< number of valid peaks in peaks array */
struct fsi_peak_request
peaks[FSI_MAX_PEAKS]; /**< peak requests */
};
struct fsi_channel_measurement {
unsigned int channel_id; /**< channel measured here */
int npeaks; /**< number of valid entries in peaks array */
struct fsi_peak_result
peaks[FSI_MAX_PEAKS]; /**< peam measured values */
};
#ifdef __cplusplus
}
#endif
#endif /* FSI_LIB_H_ */
Markdown is supported
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