Instrument Neutral Distributed Interface INDI  1.9.2
indicorrelator.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2010, 2017 Ilia Platone, Jasem Mutlaq. All rights reserved.
3 
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 "indisensorinterface.h"
22 #include "dsp.h"
23 #include <fitsio.h>
24 
25 #ifdef HAVE_WEBSOCKET
26 #include "indiwsserver.h"
27 #endif
28 
29 #include <fitsio.h>
30 
31 #include <memory>
32 #include <cstring>
33 #include <chrono>
34 #include <stdint.h>
35 #include <mutex>
36 #include <thread>
37 
38 //JM 2019-01-17: Disabled until further notice
39 //#define WITH_EXPOSURE_LOOPING
40 
41 
58 namespace INDI
59 {
60 class StreamManager;
61 
63 {
64  public:
69  typedef union {
70  struct {
71  double x;
72  double y;
73  double z;
74  };
75  double values[3];
76  } Baseline;
77 
82  typedef union {
83  struct {
84  double u;
85  double v;
86  };
87  double values[2];
88  } UVCoordinate;
89 
94  typedef struct {
97  double coefficient;
98  } Correlation;
99 
100  enum
101  {
104 
105  Correlator();
106  virtual ~Correlator();
107 
108  bool initProperties() override;
109  bool updateProperties() override;
110  void ISGetProperties(const char *dev) override;
111  bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
112  bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
113  bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
114  bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override;
115  bool ISSnoopDevice(XMLEle *root) override;
116 
117  virtual bool StartIntegration(double duration) override;
118 
123  virtual inline double getCorrelationDegree() { return 0.0; }
124 
129  inline Correlation getCorrelation() { Correlation ret; ret.coordinate = getUVCoordinates(); ret.baseline = baseline; ret.coefficient = getCorrelationDegree(); return ret; }
130 
135  void setBaseline(Baseline bl);
136 
141  void setWavelength(double wl);
142 
147  void setBandwidth(double bw);
148 
154  {
155  return baseline;
156  }
157 
162  inline double getWavelength()
163  {
164  return wavelength;
165  }
166 
171  UVCoordinate getUVCoordinates();
172 
178  UVCoordinate getUVCoordinates(double lst);
179 
186  UVCoordinate getUVCoordinates(double alt, double az);
187 
192  double getDelay();
193 
199  double getDelay(double lst);
200 
207  double getDelay(double alt, double az);
208 
213  inline double setBandwidth()
214  {
215  return bandwidth;
216  }
217 
222  {
223  return &CorrelatorSettingsNP;
224  }
225 
229  uint32_t GetCorrelatorCapability() const
230  {
231  return capability;
232  }
233 
238  void SetCorrelatorCapability(uint32_t cap);
239 
250  void setMinMaxStep(const char *property, const char *element, double min, double max, double step, bool sendToClient);
251 
252  typedef enum
253  {
261 
262  private:
263  Baseline baseline;
264  double wavelength;
265  double bandwidth;
266  INumber CorrelatorSettingsN[5];
267 };
268 }
INDI::Correlator::ISNewNumber
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: indicorrelator.cpp:119
INDI::Correlator::getDelay
double getDelay()
getDelay Get current baseline delay with reference to the current sidereal time.
Definition: indicorrelator.cpp:197
dsp.h
INDI::Correlator::Baseline::z
double z
Definition: indicorrelator.h:73
INDI::Correlator::initProperties
bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: indicorrelator.cpp:70
INDI::Correlator::CORRELATOR_BASELINE_Y
@ CORRELATOR_BASELINE_Y
Definition: indicorrelator.h:255
INDI::Correlator::ISSnoopDevice
bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Definition: indicorrelator.cpp:109
min
double min(void)
INDI::Correlator::ISNewSwitch
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: indicorrelator.cpp:127
INumber
One number descriptor.
INDI::Correlator::~Correlator
virtual ~Correlator()
Definition: indicorrelator.cpp:66
INDI::Correlator::Correlator
Correlator()
Definition: indicorrelator.cpp:61
INDI::SensorInterface
The SensorDevice class provides functionality of a Sensor Device within a Sensor.
Definition: indisensorinterface.h:70
INDI::Correlator::Correlation::coordinate
UVCoordinate coordinate
Definition: indicorrelator.h:96
INDI::Correlator::ISNewBLOB
bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
Process the client newBLOB command.
Definition: indicorrelator.cpp:132
INDI::Correlator::Baseline
the baseline (position of the telescopes) of this correlator.
Definition: indicorrelator.h:69
INDI::Correlator::Baseline::y
double y
Definition: indicorrelator.h:72
StreamManager
Class to provide video streaming and recording functionality.
INDI::Correlator::UVCoordinate::u
double u
Definition: indicorrelator.h:84
INDI::Correlator::UVCoordinate
Definition: indicorrelator.h:82
max
double max(void)
INDI::Correlator::StartIntegration
virtual bool StartIntegration(double duration) override
Start integration from the Sensor device.
Definition: indicorrelator.cpp:215
INDI::Correlator::GetCorrelatorCapability
uint32_t GetCorrelatorCapability() const
GetCorrelatorCapability returns the Sensor capabilities.
Definition: indicorrelator.h:229
INDI::Correlator::CORRELATOR_BASELINE_X
@ CORRELATOR_BASELINE_X
Definition: indicorrelator.h:254
INDI::Correlator::updateProperties
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: indicorrelator.cpp:90
INDI::Correlator::setBaseline
void setBaseline(Baseline bl)
setBaseline Set the baseline size in meters.
Definition: indicorrelator.cpp:138
INDI::SensorInterface::capability
uint32_t capability
Definition: indisensorinterface.h:418
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::SensorInterface::SENSOR_MAX_CAPABILITY
@ SENSOR_MAX_CAPABILITY
Definition: indisensorinterface.h:81
INDI::Correlator::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: indicorrelator.cpp:85
INDI::Correlator::Correlation
Definition: indicorrelator.h:94
INDI::Correlator::Baseline::x
double x
Definition: indicorrelator.h:71
INDI::Correlator::CorrelatorCapability
enum INDI::Correlator::@169 CorrelatorCapability
INDI::Correlator::ISNewText
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: indicorrelator.cpp:114
INDI::Correlator::CORRELATOR_INFO_INDEX
CORRELATOR_INFO_INDEX
Definition: indicorrelator.h:252
INDI::Correlator::getWavelength
double getWavelength()
setWavelength Get the observed wavelength.
Definition: indicorrelator.h:162
INDI::Correlator::Correlation::baseline
Baseline baseline
Definition: indicorrelator.h:95
xml_ele_
Definition: lilxml.c:105
INDI::Correlator::CORRELATOR_WAVELENGTH
@ CORRELATOR_WAVELENGTH
Definition: indicorrelator.h:257
INDI::Correlator::CORRELATOR_MAX_CAPABILITY
@ CORRELATOR_MAX_CAPABILITY
Definition: indicorrelator.h:102
INDI::Correlator
Class to provide general functionality of Monodimensional Correlator.
Definition: indicorrelator.h:62
INDI::Correlator::getCorrelationDegree
virtual double getCorrelationDegree()
getCorrelationDegree Get current correlation degree.
Definition: indicorrelator.h:123
indiwsserver.h
INDI::Correlator::Correlation::coefficient
double coefficient
Definition: indicorrelator.h:97
INDI::Correlator::getCorrelation
Correlation getCorrelation()
getCorrelation Get current correlation degree plus UV and baseline information.
Definition: indicorrelator.h:129
INDI::Correlator::CORRELATOR_BASELINE_Z
@ CORRELATOR_BASELINE_Z
Definition: indicorrelator.h:256
INDI::Correlator::UVCoordinate::v
double v
Definition: indicorrelator.h:85
indisensorinterface.h
INDI::Correlator::getCorrelatorSettings
INumberVectorProperty * getCorrelatorSettings()
Return Vector Info Property.
Definition: indicorrelator.h:221
INDI::Correlator::getBaseline
Baseline getBaseline()
setBaseline Get the baseline size in meters.
Definition: indicorrelator.h:153
INDI::Correlator::getUVCoordinates
UVCoordinate getUVCoordinates()
getUVCoordinates Get current UV projected coordinates with reference to the current sidereal time.
Definition: indicorrelator.cpp:173
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::Correlator::CorrelatorSettingsNP
INumberVectorProperty CorrelatorSettingsNP
Definition: indicorrelator.h:260
INDI::Correlator::CORRELATOR_BANDWIDTH
@ CORRELATOR_BANDWIDTH
Definition: indicorrelator.h:258
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::Correlator::setMinMaxStep
void setMinMaxStep(const char *property, const char *element, double min, double max, double step, bool sendToClient)
setMinMaxStep for a number property element
Definition: indicorrelator.cpp:222
INDI::Correlator::SetCorrelatorCapability
void SetCorrelatorCapability(uint32_t cap)
SetCorrelatorCapability Set the Correlator capabilities. Al fields must be initilized.
Definition: indicorrelator.cpp:167
INDI::Correlator::setWavelength
void setWavelength(double wl)
setWavelength Set the observed wavelength.
Definition: indicorrelator.cpp:149
INDI::Correlator::setBandwidth
double setBandwidth()
setBandwidth Get the bandwidth of the correlator.
Definition: indicorrelator.h:213