Instrument Neutral Distributed Interface INDI  1.9.2
guide_simulator.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017 Jasem Mutlaq. All rights reserved.
3  Copyright(c) 2010 Gerry Rozema. All rights reserved.
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7  .
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12  .
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "indiccd.h"
22 #include "indifilterinterface.h"
23 
40 class GuideSim : public INDI::CCD
41 {
42  public:
43 
44  GuideSim();
45  virtual ~GuideSim() override = default;
46 
47  const char *getDefaultName() override;
48 
49  bool initProperties() override;
50  bool updateProperties() override;
51 
52  void ISGetProperties(const char *dev) override;
53 
54  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
55  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
56  virtual bool ISSnoopDevice(XMLEle *root) override;
57 
58  static void *streamVideoHelper(void *context);
59  void *streamVideo();
60 
61  protected:
62 
63  bool Connect() override;
64  bool Disconnect() override;
65 
66  bool StartExposure(float duration) override;
67  bool StartGuideExposure(float) override;
68 
69  bool AbortExposure() override;
70  bool AbortGuideExposure() override;
71 
72  void TimerHit() override;
73 
74  int DrawCcdFrame(INDI::CCDChip *targetChip);
75 
76  int DrawImageStar(INDI::CCDChip *targetChip, float, float, float, float ExposureTime);
77  int AddToPixel(INDI::CCDChip *targetChip, int, int, int);
78 
79  virtual IPState GuideNorth(uint32_t) override;
80  virtual IPState GuideSouth(uint32_t) override;
81  virtual IPState GuideEast(uint32_t) override;
82  virtual IPState GuideWest(uint32_t) override;
83 
84  virtual bool saveConfigItems(FILE *fp) override;
85  virtual void addFITSKeywords(fitsfile *fptr, INDI::CCDChip *targetChip) override;
86  virtual void activeDevicesUpdated() override;
87  virtual int SetTemperature(double temperature) override;
88  virtual bool UpdateCCDFrame(int x, int y, int w, int h) override;
89  virtual bool UpdateCCDBin(int hor, int ver) override;
90 
91  virtual bool StartStreaming() override;
92  virtual bool StopStreaming() override;
93 
94  private:
95 
96  float CalcTimeLeft(timeval, float);
97  bool SetupParms();
98 
99  // Turns on/off Bayer RGB simulation.
100  void setRGB(bool onOff);
101 
102  double TemperatureRequest { 0 };
103 
104  float ExposureRequest { 0 };
105  struct timeval ExpStart
106  {
107  0, 0
108  };
109 
110  float GuideExposureRequest { 0 };
111  struct timeval GuideExpStart
112  {
113  0, 0
114  };
115 
116  int testvalue { 0 };
117  bool ShowStarField { true };
118  int bias { 1500 };
119  int maxnoise { 20 };
120  int maxval { 65000 };
121  int maxpix { 0 };
122  int minpix { 65000 };
123  float skyglow { 40 };
124  float limitingmag { 11.5 };
125  float saturationmag { 2 };
126  float seeing { 3.5 };
127  float ImageScalex { 1.0 };
128  float ImageScaley { 1.0 };
129  // An oag is offset this much from center of scope position (arcminutes)
130  float OAGoffset { 0 };
131  double rotationCW { 0 };
132  float TimeFactor { 1 };
133 
134  bool simulateRGB { false };
135 
136  // our zero point calcs used for drawing stars
137  float k { 0 };
138  float z { 0 };
139 
140  bool AbortGuideFrame { false };
141  bool AbortPrimaryFrame { false };
142 
144  float GuideRate { 7 };
145 
147  float PEPeriod { 8 * 60 };
148  float PEMax { 11 };
149 
150  double currentRA { 0 };
151  double currentDE { 0 };
152  bool usePE { false };
153  time_t RunStart;
154 
155  float guideNSOffset {0};
156  float guideWEOffset {0};
157 
158  float polarError { 0 };
159  float polarDrift { 0 };
160  float king_gamma = { 0 };
161  float king_theta = { 0 };
162 
163  int streamPredicate;
164  pthread_t primary_thread;
165  bool terminateThread;
166 
167  // And this lives in our simulator settings page
168 
169  INumberVectorProperty SimulatorSettingsNP;
170  INumber SimulatorSettingsN[17];
171 
172  ISwitchVectorProperty SimulateRgbSP;
173  ISwitch SimulateRgbS[2];
174 
175  // We are going to snoop these from focuser
176  INumberVectorProperty FWHMNP;
177  INumber FWHMN[1];
178 
179  INumberVectorProperty EqPENP;
180  INumber EqPEN[2];
181 
182  ISwitch CoolerS[2];
183  ISwitchVectorProperty CoolerSP;
184 
185  INumber GainN[1];
186  INumberVectorProperty GainNP;
187 };
GuideSim::streamVideoHelper
static void * streamVideoHelper(void *context)
Definition: guide_simulator.cpp:1331
GuideSim::AddToPixel
int AddToPixel(INDI::CCDChip *targetChip, int, int, int)
Definition: guide_simulator.cpp:1011
GuideSim::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: guide_simulator.cpp:1086
GuideSim::addFITSKeywords
virtual void addFITSKeywords(fitsfile *fptr, INDI::CCDChip *targetChip) override
Add FITS keywords to a fits file.
Definition: guide_simulator.cpp:1379
IPState
IPState
Property state.
Definition: indiapi.h:158
GuideSim::DrawCcdFrame
int DrawCcdFrame(INDI::CCDChip *targetChip)
Definition: guide_simulator.cpp:460
GuideSim::AbortGuideExposure
bool AbortGuideExposure() override
Abort ongoing exposure.
Definition: guide_simulator.cpp:321
ISwitch
One switch descriptor.
GuideSim::StartStreaming
virtual bool StartStreaming() override
StartStreaming Start live video streaming.
Definition: guide_simulator.cpp:1278
INumber
One number descriptor.
GuideSim::GuideNorth
virtual IPState GuideNorth(uint32_t) override
Guide northward for ms milliseconds.
Definition: guide_simulator.cpp:1052
GuideSim::Disconnect
bool Disconnect() override
Disconnect from device.
Definition: guide_simulator.cpp:98
GuideSim::GuideSouth
virtual IPState GuideSouth(uint32_t) override
Guide southward for ms milliseconds.
Definition: guide_simulator.cpp:1058
INDI::CCD
Class to provide general functionality of CCD cameras with a single CCD sensor, or a primary CCD sens...
Definition: indiccd.h:115
GuideSim::initProperties
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: guide_simulator.cpp:114
INDI::CCDChip
The CCDChip class provides functionality of a CCD Chip within a CCD.
Definition: indiccdchip.h:48
GuideSim::UpdateCCDBin
virtual bool UpdateCCDBin(int hor, int ver) override
CCD calls this function when CCD Binning needs to be updated in the hardware. Derived classes should ...
Definition: guide_simulator.cpp:1312
GuideSim::activeDevicesUpdated
virtual void activeDevicesUpdated() override
activeDevicesUpdated Inform children that ActiveDevices property was updated so they can snoop on the...
Definition: guide_simulator.cpp:1197
GuideSim::streamVideo
void * streamVideo()
Definition: guide_simulator.cpp:1336
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
GuideSim::DrawImageStar
int DrawImageStar(INDI::CCDChip *targetChip, float, float, float, float ExposureTime)
Definition: guide_simulator.cpp:942
GuideSim::updateProperties
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: guide_simulator.cpp:228
GuideSim::StartExposure
bool StartExposure(float duration) override
Start exposing primary CCD chip.
Definition: guide_simulator.cpp:275
INDI::CCD::ExposureTime
double ExposureTime
Definition: indiccd.h:550
GuideSim::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: guide_simulator.cpp:1146
xml_ele_
Definition: lilxml.c:105
GuideSim::ISSnoopDevice
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Definition: guide_simulator.cpp:1209
indifilterinterface.h
GuideSim::~GuideSim
virtual ~GuideSim() override=default
GuideSim::TimerHit
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: guide_simulator.cpp:347
GuideSim::GuideEast
virtual IPState GuideEast(uint32_t) override
Guide easward for ms milliseconds.
Definition: guide_simulator.cpp:1064
GuideSim::UpdateCCDFrame
virtual bool UpdateCCDFrame(int x, int y, int w, int h) override
CCD calls this function when CCD Frame dimension needs to be updated in the hardware....
Definition: guide_simulator.cpp:1299
GuideSim::getDefaultName
const char * getDefaultName() override
Definition: guide_simulator.cpp:109
GuideSim::GuideSim
GuideSim()
Definition: guide_simulator.cpp:37
indiccd.h
GuideSim::ISGetProperties
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition: guide_simulator.cpp:219
GuideSim::AbortExposure
bool AbortExposure() override
Abort ongoing exposure.
Definition: guide_simulator.cpp:311
ISState
ISState
Switch state.
Definition: indiapi.h:148
GuideSim::Connect
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: guide_simulator.cpp:89
GuideSim::GuideWest
virtual IPState GuideWest(uint32_t) override
Guide westward for ms milliseconds.
Definition: guide_simulator.cpp:1075
GuideSim::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save configuration items in XML file.
Definition: guide_simulator.cpp:1260
GuideSim::StartGuideExposure
bool StartGuideExposure(float) override
Start exposing guide CCD chip.
Definition: guide_simulator.cpp:300
GuideSim::StopStreaming
virtual bool StopStreaming() override
StopStreaming Stop live video streaming.
Definition: guide_simulator.cpp:1289
GuideSim::SetTemperature
virtual int SetTemperature(double temperature) override
Set CCD temperature.
Definition: guide_simulator.cpp:259
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
GuideSim
The GuideSim class provides an advanced simulator for a CCD that includes a dedicated on-board guide ...
Definition: guide_simulator.h:40