Program Listing for File scTDC_types.h

Return to documentation for file (scTDC_types.h)

#pragma once

#ifndef ssize_t
#ifdef __linux__
  #include <sys/types.h>
#elif _WIN32
  #ifdef _MSC_VER
    #include <BaseTsd.h>
    typedef SSIZE_T ssize_t;
  #elif __MINGW32__
    #include <sys/types.h>
  #endif
#endif
#endif

#define SEPARATORS_TO_FLOW 0x01

#define STATISTICS_TO_FLOW 0x02

#define MILLISECONDS_TO_FLOW 0x04

#define FLIM_BOTH_WAY_SCAN 0x01

#define FLIM_XY_SWAP 0x02


struct sc3d_t
{
  int x;
  int y;
  long long time;
};

struct sc3du_t
{
  unsigned int x;
  unsigned int y;
  unsigned long long time;
};

struct roi_t
{
  struct sc3d_t offset;
  struct sc3du_t size;
};

struct statistics_t
{
  unsigned int counts_read[4][16];
  unsigned int counts_received[4][16];
  unsigned int events_found[4];
  unsigned int events_in_roi[4];
  unsigned int events_received[4];
  unsigned int counters[4][16];
  unsigned int reserved[52];
};

struct sc_tdc_channel_statistics_t
{
  unsigned long long counts_read;
  unsigned long long counts_received;
  unsigned long long counter;
  unsigned long long reserved[5];
};

struct sc_dld_device_statistics_t
{
  unsigned long long events_found;
  unsigned long long events_in_roi;
  unsigned long long events_received;
  unsigned long long reserved[5];
};

enum bitsize_t
{
  BS8 = 0,
  BS16 = 1,
  BS32 = 2,
  BS64 = 3,
  F32 = 4,
  F64 = 5
};

struct sc_tdc_format
{
  unsigned char total_bits_length;
  unsigned char channel_offset;
  unsigned char channel_length;
  unsigned char time_data_offset;
  unsigned char time_data_length;
  unsigned char time_tag_offset;
  unsigned char time_tag_length;
  unsigned char start_counter_offset;
  unsigned char start_counter_length;
  unsigned char dif1_offset;
  unsigned char dif1_length;
  unsigned char dif2_offset;
  unsigned char dif2_length;
  unsigned char sum_offset;
  unsigned char sum_length;
  unsigned char sign_counter_offset;
  unsigned char sign_counter_length;
  unsigned char reserved[14];
  unsigned char flow_control_flags;
};

enum sc_pipe_type_t
{
  TDC_HISTO = 0,
  DLD_IMAGE_XY = 1,
  DLD_IMAGE_XT = 2,
  DLD_IMAGE_YT = 3,
  DLD_IMAGE_3D = 4,
  DLD_SUM_HISTO = 5,
  STATISTICS = 6,
  TMSTAMP_TDC_HISTO = 7,
  TDC_STATISTICS = 8,
  DLD_STATISTICS = 9,
  USER_CALLBACKS = 10,
  DLD_IMAGE_XY_EXT = 11,
  BUFFERED_DATA_CALLBACKS = 12,
  PIPE_CAM_FRAMES = 13,
  PIPE_CAM_BLOBS = 14,
  USED_MEM_CALLBACKS = 100
};

struct sc_pipe_dld_image_xy_params_t
{
  enum bitsize_t depth;
  int channel;
  unsigned long long modulo;
  struct sc3du_t binning;
  struct roi_t roi;
  unsigned int accumulation_ms;
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_dld_image_xt_params_t
{
  enum bitsize_t depth;
  int channel;
  unsigned long long modulo;
  struct sc3du_t binning;
  struct roi_t roi;
  unsigned int accumulation_ms;
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_dld_image_yt_params_t
{
  enum bitsize_t depth;
  int channel;
  unsigned long long modulo;
  struct sc3du_t binning;
  struct roi_t roi;
  unsigned int accumulation_ms;
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_dld_image_3d_params_t
{
  enum bitsize_t depth;
  int channel;
  unsigned long long modulo;
  struct sc3du_t binning;
  struct roi_t roi;
  unsigned int accumulation_ms;
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_dld_sum_histo_params_t
{
  enum bitsize_t depth;
  int channel;
  unsigned long long modulo;
  struct sc3du_t binning;
  struct roi_t roi;
  unsigned int accumulation_ms;
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_tdc_histo_params_t
{
  enum bitsize_t depth;
  unsigned int channel;
  unsigned long long modulo;
  unsigned int binning;
  unsigned long long offset;
  unsigned int size;
  unsigned int accumulation_ms;
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_statistics_params_t
{
  void *allocator_owner;
  int (*allocator_cb)(void *, void **);
};

struct sc_pipe_tdc_stat_params_t
{
  void *allocator_owner;
  int (*allocator_cb) (void *, void **);
  int channel_number;
};

struct sc_pipe_dld_stat_params_t
{
  void *allocator_owner;
  int (*allocator_cb) (void *, void **);
  int device_number;
};

enum sc_pipe_param_extension_type
{
  SC_PIPE_PARAM_EXTENSION_TYPE_IMAGE_SOURCE
};

struct sc_pipe_image_source
{
  enum sc_pipe_param_extension_type type;
  void *extension;
  enum sc_ImageSource {
    EVENTS,
    RAMDATA,
    BOTH
  } source;
};

struct sc_pipe_dld_image_xy_ext_params_t
{
  struct sc_pipe_dld_image_xy_params_t base;
  void *extension;
};

struct sc_TdcEvent
{
  unsigned subdevice;
  unsigned channel;
  unsigned long long start_counter;
  unsigned long long time_tag;
  unsigned long long time_data;
  unsigned long long sign_counter;
};

struct sc_DldEvent
{
  unsigned long long start_counter;
  unsigned long long time_tag;
  unsigned subdevice;
  unsigned channel;
  unsigned long long sum;
  unsigned short dif1;
  unsigned short dif2;
  unsigned master_rst_counter;
  unsigned short adc;
  unsigned short signal1bit;
};

//----- struct sc_pipe_callbacks -----------------------------------------------
struct sc_pipe_callbacks
{
  void *priv;
  void (*start_of_measure) (void *priv);
  void (*end_of_measure) (void *priv);
  void (*millisecond_countup) (void *priv);
  void (*statistics) (void *priv, const struct statistics_t *stat);
  void (*tdc_event)
    (void *priv, const struct sc_TdcEvent *const event_array, size_t event_array_len);
  void (*dld_event)
    (void *priv, const struct sc_DldEvent *const event_array, size_t event_array_len);
};


struct sc_pipe_callback_params_t
{
  struct sc_pipe_callbacks *callbacks;
};

struct sc_pipe_buf_callback_args
{
  /* any of the pointer members may be null, indicating
   * that no data is available */
  unsigned long long event_index;
  unsigned long long* som_indices;
  unsigned long long* ms_indices;
  unsigned* subdevice;
  unsigned* channel;
  unsigned long long* start_counter;
  unsigned* time_tag;
  unsigned* dif1;
  unsigned* dif2;
  unsigned long long* time;
  unsigned* master_rst_counter;
  int* adc;
  unsigned short* signal1bit;
  unsigned som_indices_len;
  unsigned ms_indices_len;
  unsigned data_len;
  unsigned char reserved[12];
};

enum sc_data_field_t
{
  SC_DATA_FIELD_SUBDEVICE          = 0x0001u,
  SC_DATA_FIELD_CHANNEL            = 0x0002u,
  SC_DATA_FIELD_START_COUNTER      = 0x0004u,
  SC_DATA_FIELD_TIME_TAG           = 0x0008u,
  SC_DATA_FIELD_DIF1               = 0x0010u,
  SC_DATA_FIELD_DIF2               = 0x0020u,
  SC_DATA_FIELD_TIME               = 0x0040u,
  SC_DATA_FIELD_MASTER_RST_COUNTER = 0x0080u,
  SC_DATA_FIELD_ADC                = 0x0100u,
  SC_DATA_FIELD_SIGNAL1BIT         = 0x0200u,
};

struct sc_pipe_buf_callbacks_params_t
{
  void *priv;
  void (*data)(void *priv, const sc_pipe_buf_callback_args* const);
  bool (*end_of_measurement)(void *priv);
  unsigned data_field_selection;
  unsigned max_buffered_data_len;
  int dld_events;
  int version;
  unsigned char reserved[24];
};

struct sc_pipe_used_mem_callbacks_params_t
{
  void *priv;
  void (*used_mem)(void *priv, const unsigned used_mem_kb_value);
};

const unsigned long long sc_mask64[] = {
  0x0000000000000000ULL,
  0x0000000000000001ULL,
  0x0000000000000003ULL,
  0x0000000000000007ULL,
  0x000000000000000FULL,
  0x000000000000001FULL,
  0x000000000000003FULL,
  0x000000000000007FULL,
  0x00000000000000FFULL,
  0x00000000000001FFULL,
  0x00000000000003FFULL,
  0x00000000000007FFULL,
  0x0000000000000FFFULL,
  0x0000000000001FFFULL,
  0x0000000000003FFFULL,
  0x0000000000007FFFULL,
  0x000000000000FFFFULL,
  0x000000000001FFFFULL,
  0x000000000003FFFFULL,
  0x000000000007FFFFULL,
  0x00000000000FFFFFULL,
  0x00000000001FFFFFULL,
  0x00000000003FFFFFULL,
  0x00000000007FFFFFULL,
  0x0000000000FFFFFFULL,
  0x0000000001FFFFFFULL,
  0x0000000003FFFFFFULL,
  0x0000000007FFFFFFULL,
  0x000000000FFFFFFFULL,
  0x000000001FFFFFFFULL,
  0x000000003FFFFFFFULL,
  0x000000007FFFFFFFULL,
  0x00000000FFFFFFFFULL,
  0x00000001FFFFFFFFULL,
  0x00000003FFFFFFFFULL,
  0x00000007FFFFFFFFULL,
  0x0000000FFFFFFFFFULL,
  0x0000001FFFFFFFFFULL,
  0x0000003FFFFFFFFFULL,
  0x0000007FFFFFFFFFULL,
  0x000000FFFFFFFFFFULL,
  0x000001FFFFFFFFFFULL,
  0x000003FFFFFFFFFFULL,
  0x000007FFFFFFFFFFULL,
  0x00000FFFFFFFFFFFULL,
  0x00001FFFFFFFFFFFULL,
  0x00003FFFFFFFFFFFULL,
  0x00007FFFFFFFFFFFULL,
  0x0000FFFFFFFFFFFFULL,
  0x0001FFFFFFFFFFFFULL,
  0x0003FFFFFFFFFFFFULL,
  0x0007FFFFFFFFFFFFULL,
  0x000FFFFFFFFFFFFFULL,
  0x001FFFFFFFFFFFFFULL,
  0x003FFFFFFFFFFFFFULL,
  0x007FFFFFFFFFFFFFULL,
  0x00FFFFFFFFFFFFFFULL,
  0x01FFFFFFFFFFFFFFULL,
  0x03FFFFFFFFFFFFFFULL,
  0x07FFFFFFFFFFFFFFULL,
  0x0FFFFFFFFFFFFFFFULL,
  0x1FFFFFFFFFFFFFFFULL,
  0x3FFFFFFFFFFFFFFFULL,
  0x7FFFFFFFFFFFFFFFULL,
  0xFFFFFFFFFFFFFFFFULL,
};

const unsigned int sc_mask32[] = {
  0x00000000,
  0x00000001,
  0x00000003,
  0x00000007,
  0x0000000F,
  0x0000001F,
  0x0000003F,
  0x0000007F,
  0x000000FF,
  0x000001FF,
  0x000003FF,
  0x000007FF,
  0x00000FFF,
  0x00001FFF,
  0x00003FFF,
  0x00007FFF,
  0x0000FFFF,
  0x0001FFFF,
  0x0003FFFF,
  0x0007FFFF,
  0x000FFFFF,
  0x001FFFFF,
  0x003FFFFF,
  0x007FFFFF,
  0x00FFFFFF,
  0x01FFFFFF,
  0x03FFFFFF,
  0x07FFFFFF,
  0x0FFFFFFF,
  0x1FFFFFFF,
  0x3FFFFFFF,
  0x7FFFFFFF,
  0xFFFFFFFF,
};


enum sc_event_type_index {
  SC_TDC_SIGN_START = 0,
  SC_TDC_SIGN_MILLISEC = 1,
  SC_TDC_SIGN_STAT = 2
};

enum sc_LoggerFacility {UNUSED}; //TODO: Remove

struct sc_Logger
{
  void *private_data;
  void (*do_log)(void *pd, const char *sender, const char *msg);
};

struct sc_PipeCbf
{
  void (*cb)(void *);
  void *private_data;
};

struct sc_ConfigLine
{
  const char *section;
  const char *key;
  const char *value;
};

struct sc_DeviceProperties1
{
  struct sc3du_t detector_size;
  double pixel_size_x;
  double pixel_size_y;
  double pixel_size_t;
};

struct sc_DeviceProperties2
{
  int tdc_channel_number;
};

struct sc_DeviceProperties3
{
  size_t dld_event_size;
  size_t tdc_event_size;
  size_t user_callback_size;
};

struct sc_DeviceProperties4
{
  unsigned auto_start_period;
  unsigned auto_modulo;
};

struct sc_DeviceProperties5
{
  unsigned tag_period;
};

struct sc_CmosSmootherParameters
{
  enum sc_ShutterMode {
    FULLY_EXTERNAL,
    IMMEDIATE_START_INTERNAL_TIMER,
    IMMEDIATE_START_INTERNAL_TIMER_MULTIPLE_SLOPES,
    EXTERNAL_START_INTERNAL_TIMER,
    EXTERNAL_START_INTERNAL_TIMER_MULTIPLE_SLOPES,
    IMMEDIATE_START_EXTERNAL_FINISH
  } shutter_mode;
  unsigned int single_slope_us;
  unsigned int dual_slope_us;
  unsigned int triple_slope_us;
  unsigned int frame_count;
  unsigned int analog_gain;
  double digital_gain;
  unsigned int black_offset;
  int black_cal_offset;
  unsigned int smoother_shift1;
  unsigned char smoother_pixel_mask1 [8][8];
  unsigned int smoother_shift2;
  unsigned char smoother_pixel_mask2 [8][8];
  unsigned char white_pixel_min;
};

struct sc_BlobParameters
{
  unsigned int unbinning;
  unsigned int dif_min_top;
  unsigned int dif_min_bottom;
  double z_scale_factor;
};

struct sc_flimTriggersCounters {
  unsigned long long pixelTriggerCounter;
  unsigned long long lineTriggerCounter;
  unsigned long long frameTriggerCounter;
};