13#include "indi/indicommon.h"
20#include <QElapsedTimer>
24#include "guidestars.h"
25#include "calibration.h"
34#define SMART_THRESHOLD 0
35#define SEP_THRESHOLD 1
36#define CENTROID_THRESHOLD 2
37#define AUTO_THRESHOLD 3
39#define SEP_MULTISTAR 5
52 bool enabled[CHANNEL_CNT];
53 bool enabled_axis1[CHANNEL_CNT];
54 bool enabled_axis2[CHANNEL_CNT];
56 double proportional_gain[CHANNEL_CNT];
57 double integral_gain[CHANNEL_CNT];
58 int max_pulse_arcsec[CHANNEL_CNT];
59 double min_pulse_arcsec[CHANNEL_CNT];
70 GuideDirection pulse_dir[2];
78 double fov_wd, fov_ht;
79 double focal, aperture;
91 bool setVideoParameters(
int vid_wd,
int vid_ht,
int binX,
int binY);
92 bool setGuiderParameters(
double ccd_pix_wd,
double ccd_pix_ht,
double guider_aperture,
double guider_focal);
94 bool setTargetPosition(
double x,
double y);
95 bool getTargetPosition(
double *x,
double *y)
const;
97 int getAlgorithmIndex(
void)
const;
98 void setAlgorithmIndex(
int algorithmIndex);
99 bool usingSEPMultiStar()
const;
105 const cproc_out_params *getOutputParameters()
const
115 void suspend(
bool mode);
116 bool isSuspended()
const;
119 void getStarScreenPosition(
double *dx,
double *dy)
const;
122 bool isStarLost()
const;
123 void setLostStar(
bool is_lost);
126 void performProcessing(Ekos::GuideState state,
129 const std::pair<Seconds, Seconds> &timeStep,
130 GuideLog *logger =
nullptr);
132 void performDarkGuiding(Ekos::GuideState state,
const std::pair<Seconds, Seconds> &timeStep);
134 bool calibrate1D(
double start_x,
double start_y,
double end_x,
double end_y,
int RATotalPulse);
135 bool calibrate2D(
double start_ra_x,
double start_ra_y,
double end_ra_x,
double end_ra_y,
136 double start_dec_x,
double start_dec_y,
double end_dec_x,
double end_dec_y,
137 bool *swap_dec,
int RATotalPulse,
int DETotalPulse);
139 const Calibration &getCalibration()
143 Calibration *getMutableCalibration()
148 double getGuideStarSNR();
150 const GuideStars &getGuideStars()
156 void newAxisDelta(
double delta_ra,
double delta_dec);
160 void guideStats(
double raError,
double decError,
int raPulse,
int decPulse,
161 double snr,
double skyBg,
int numStars);
165 template <
typename T>
166 GuiderUtils::Vector findLocalStarPosition(
void)
const;
168 void updateCircularBuffers(
void);
169 GuiderUtils::Vector point2arcsec(
const GuiderUtils::Vector &p)
const;
170 void calculatePulses(Ekos::GuideState state,
const std::pair<Seconds, Seconds> &timeStep);
171 void calculateRmsError(
void);
174 void createGuideLog();
179 uint32_t iterationCounter { 0 };
182 int video_width { -1 };
184 int video_height { -1 };
185 double aperture { 0 };
186 bool suspended {
false };
187 bool lost_star {
false };
190 int algorithm { SMART_THRESHOLD };
194 GuiderUtils::Vector starPosition;
195 GuiderUtils::Vector targetPosition;
201 static constexpr int CIRCULAR_BUFFER_SIZE = 50;
203 uint32_t driftUpto[2];
205 double drift_integral[2];
208 cproc_in_params in_params;
209 cproc_out_params out_params;
212 bool do_statistics {
true };
217 GuideStars guideStars;
219 std::unique_ptr<GPG> gpg;
220 Calibration calibration;
221 bool configureInParams(Ekos::GuideState state);
222 void updateOutParams(
int k,
const double arcsecDrift,
int pulseLength, GuideDirection pulseDirection);
223 void outputGuideLog();
224 void processAxis(
const int k,
const bool dithering,
const bool darkGuiding,
const Seconds &timeStep,
const QString &label);