COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
sutra_rtc.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // This file is part of COMPASS <https://anr-compass.github.io/compass/>
3 //
4 // Copyright (C) 2011-2023 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 
7 // -----------------------------------------------------------------------------
8 
16 
17 #ifndef _SUTRA_RTC_H_
18 #define _SUTRA_RTC_H_
19 
20 #include <sutra_centroider_bpcog.h>
21 #include <sutra_centroider_cog.h>
22 #include <sutra_centroider_corr.h>
24 #include <sutra_centroider_pyr.h>
25 #include <sutra_centroider_tcog.h>
26 #include <sutra_centroider_wcog.h>
27 #include <sutra_controller_cured.h>
30 #include <sutra_controller_geo.h>
31 //#include <sutra_controller_kalman.h>
32 #include <sutra_controller_ls.h>
33 #include <sutra_controller_mv.h>
34 
35 template <typename Tin, typename T, typename Tout>
36 class SutraRtc {
37  public:
38  vector<SutraCentroider<Tin, T> *> d_centro;
39  vector<SutraController<T, Tout> *> d_control;
40 
41  public:
44  int add_centroider(CarmaContext *context, long nvalid, float offset,
45  float scale, bool filter_TT, long device,
46  std::string typec);
47 
48  int add_centroider(CarmaContext *context, long nvalid, float offset,
49  float scale, bool filter_TT, long device,
50  std::string typec, SutraWfs *wfs);
51 
52 
79  int add_controller(CarmaContext *context, std::string typec,long device, float delay, int nslope,
80  int nactu, int nslope_buffers = 0, int nstates = 0, int nstate_buffers = 0,
81  int nmodes = 0, int niir_in = 0, int niir_out = 0, bool polc = false,
82  bool is_modal = false, SutraDms *dms = nullptr, int *idx_dms = nullptr,
83  int ndm = 0, int *idx_centro = nullptr, int ncentro = 0, int Nphi = 0,
84  bool wfs_direction = false);
85 
86 
87 
88  int remove_centroider(int ncentro);
89  int remove_controller(int ncontrol);
90 
91  int do_imat(int ncntrl, SutraDms *ydms, int kernconv);
92 
93  int do_imat_basis(int ncntrl, SutraDms *ydm, int nModes, T *m2v,
94  T *pushAmpl, int kernconv);
95 
96  int do_imat_geom(int ncntrl, SutraDms *ydm, int type);
97 
98  int comp_images_imat(SutraDms *ydm, int kernconv);
99 
101  int do_calibrate_img(int ncntrl);
103  int do_centroids(int ncntrl);
104  int do_centroids(int ncntrl, bool noise);
105  int do_centroids_geom(int ncntrl, int type = 0);
106  int do_centroids_ref(int ncntrl);
107  int do_control(int ncntrl);
108  int do_clipping(int ncntrl);
109  int apply_control(int ncntrl, bool compVoltage = true);
110  int comp_voltage(int ncntrl);
111  int remove_ref(int ncntrl);
112  int set_centroids_ref(float *centroids_ref);
113 
114  private:
115  template <typename Q = T>
116  typename std::enable_if<std::is_same<Q, float>::value, int>::type
117  do_imat_impl(int ncntrl, SutraDms *ydm, int kernconv, std::true_type);
118  int do_imat_impl(int ncntrl, SutraDms *ydm, int kernconv, std::false_type);
119 
120  template <typename Q = T>
121  typename std::enable_if<std::is_same<Q, float>::value, int>::type
122  do_imat_basis_impl(int ncntrl, SutraDms *ydm, int nModes, T *m2v,
123  T *pushAmpl, int kernconv, std::true_type);
124  int do_imat_basis_impl(int ncntrl, SutraDms *ydm, int nModes, T *m2v,
125  T *pushAmpl, int kernconv, std::false_type);
126  template <typename Q = T>
127  typename std::enable_if<std::is_same<Q, float>::value, int>::type
128  do_imat_geom_impl(int ncntrl, SutraDms *ydm, int type, std::true_type);
129  int do_imat_geom_impl(int ncntrl, SutraDms *ydm, int type, std::false_type);
130 
131  template <typename Q = T>
132  typename std::enable_if<std::is_same<Q, float>::value, int>::type
133  do_centroids_geom_impl(int ncntrl, int type, std::true_type);
134  int do_centroids_geom_impl(int ncntrl, int type, std::false_type);
135 
136  template <typename Q = T>
137  typename std::enable_if<!std::is_same<Q, half>::value, int>::type
138  add_centroider_impl(CarmaContext *context, long nvalid, float offset,
139  float scale, bool filter_TT, long device,
140  std::string typec, SutraWfs *wfs, std::false_type);
141  int add_centroider_impl(CarmaContext *context, long nvalid, float offset,
142  float scale, bool filter_TT, long device,
143  std::string typec, SutraWfs *wfs, std::true_type);
144 
145  template <typename Q = T>
146  typename std::enable_if<!std::is_same<Q, half>::value, int>::type
147  add_controller_impl(CarmaContext *context,
149  std::string typec,long device, float delay, int nslope, int nactu,
150  int nslope_buffers, int nstates, int nstate_buffers, int nmodes,
151  int niir_in, int niir_out, bool polc,bool is_modal,
152  SutraDms *dms, int *idx_dms, int ndm, int *idx_centro, int ncentro,
153  int Nphi, bool wfs_direction,
154  std::false_type);
155 
156 
157 
158  int add_controller_impl(CarmaContext *context,
160  std::string typec,long device, float delay, int nslope, int nactu,
161  int nslope_buffers, int nstates, int nstate_buffers, int nmodes,
162  int niir_in, int niir_out, bool polc,bool is_modal,
163  SutraDms *dms, int *idx_dms, int ndm, int *idx_centro, int ncentro,
164  int Nphi, bool wfs_direction,
165  std::true_type);
166 };
167 
168 #endif // _SUTRA_RTC_H_
this class provides the context in which CarmaObj are created
Definition: carma_context.h:79
this class provides the rtc features to COMPASS
Definition: sutra_rtc.h:36
int comp_images_imat(SutraDms *ydm, int kernconv)
int add_centroider(CarmaContext *context, long nvalid, float offset, float scale, bool filter_TT, long device, std::string typec)
int do_imat(int ncntrl, SutraDms *ydms, int kernconv)
int do_clipping(int ncntrl)
vector< SutraController< T, Tout > * > d_control
Definition: sutra_rtc.h:39
int do_calibrate_img()
int do_centroids(int ncntrl, bool noise)
int do_centroids_geom(int ncntrl, int type=0)
int do_imat_geom(int ncntrl, SutraDms *ydm, int type)
int add_centroider(CarmaContext *context, long nvalid, float offset, float scale, bool filter_TT, long device, std::string typec, SutraWfs *wfs)
int comp_voltage(int ncntrl)
vector< SutraCentroider< Tin, T > * > d_centro
Definition: sutra_rtc.h:38
int add_controller(CarmaContext *context, std::string typec, long device, float delay, int nslope, int nactu, int nslope_buffers=0, int nstates=0, int nstate_buffers=0, int nmodes=0, int niir_in=0, int niir_out=0, bool polc=false, bool is_modal=false, SutraDms *dms=nullptr, int *idx_dms=nullptr, int ndm=0, int *idx_centro=nullptr, int ncentro=0, int Nphi=0, bool wfs_direction=false)
Add a SutraController object in the RTC.
int remove_centroider(int ncentro)
int do_centroids()
int remove_controller(int ncontrol)
int do_control(int ncntrl)
int do_calibrate_img(int ncntrl)
int apply_control(int ncntrl, bool compVoltage=true)
int remove_ref(int ncntrl)
int set_centroids_ref(float *centroids_ref)
int do_centroids(int ncntrl)
int do_imat_basis(int ncntrl, SutraDms *ydm, int nModes, T *m2v, T *pushAmpl, int kernconv)
int do_centroids_ref(int ncntrl)
this class provides the wfs features to COMPASS
Definition: sutra_wfs.h:35