Instrument Neutral Distributed Interface INDI  2.0.2
dspinterface.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017 Ilia Platone, Jasem Mutlaq. All rights reserved.
3 
4  DSP plugin Interface
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 *******************************************************************************/
20 
21 #pragma once
22 
23 #include "indidevapi.h"
24 #include "dsp.h"
25 
26 #include <fitsio.h>
27 #include <functional>
28 #include <string>
29 #include <cstdint>
30 
31 namespace INDI
32 {
33 class DefaultDevice;
34 }
35 
36 namespace DSP
37 {
43 extern const char *DSP_TAB;
44 class Interface
45 {
67  public:
72  typedef enum
73  {
74  DSP_NONE = 0,
81  } Type;
82 
83  virtual void ISGetProperties(const char *dev);
84  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
85  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
86  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
87  virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
88  char *names[], int n);
89  virtual bool saveConfigItems(FILE *fp);
90  virtual bool updateProperties();
91 
100  virtual bool processBLOB(uint8_t* buf, uint32_t ndims, int* dims, int bits_per_sample);
101 
107  void setSizes(uint32_t num, int* sizes)
108  {
109  BufferSizes = sizes;
110  BufferSizesQty = num;
111  }
112 
118  void getSizes(uint32_t *num, int** sizes)
119  {
120  *sizes = BufferSizes;
121  *num = BufferSizesQty;
122  }
123 
128  void setBPS(int bps)
129  {
130  BPS = bps;
131  }
132 
137  int getBPS()
138  {
139  return BPS;
140  }
141 
146  void setCaptureFileExtension(const char *ext);
147 
148  protected:
149 
153  virtual void Activated();
154 
158  virtual void Deactivated();
159 
168  virtual uint8_t* Callback(uint8_t* buf, uint32_t ndims, int* dims, int bits_per_sample);
169 
176  dsp_stream_p loadFITS(char* buf, int len);
177 
179 
182 
185 
186  // We are going to snoop these from a telescope
189 
192 
193  Interface(INDI::DefaultDevice *dev, Type type = DSP_NONE, const char *name = "DSP_PLUGIN",
194  const char *label = "DSP Plugin");
195  virtual ~Interface();
196 
197  const char *getDeviceName();
199  const char *m_Name { nullptr };
200  const char *m_Label { nullptr };
202  bool setStream(void *buf, uint32_t dims, int *sizes, int bits_per_sample);
203  bool setMagnitude(void *buf, uint32_t dims, int *sizes, int bits_per_sample);
204  bool setPhase(void *buf, uint32_t dims, int *sizes, int bits_per_sample);
205  bool setReal(void *buf, uint32_t dims, int *sizes, int bits_per_sample);
206  bool setImaginary(void *buf, uint32_t dims, int *sizes, int bits_per_sample);
207  uint8_t *getStream();
208  uint8_t *getMagnitude();
209  uint8_t *getPhase();
210  uint8_t *getReal();
211  uint8_t *getImaginary();
212  uint8_t* getBuffer(dsp_stream_p in, uint32_t *dims, int **sizes);
214 
215  private:
216  char captureExtention[MAXINDIBLOBFMT] { "fits" };
217  void *buffer { nullptr };
218  uint32_t BufferSizesQty {0 };
219  int *BufferSizes { nullptr };
220  int BPS { 16 };
221 
222  void fits_update_key_s(fitsfile *fptr, int type, std::string name, void *p, std::string explanation, int *status);
223  void addFITSKeywords(fitsfile *fptr);
224  bool sendFITS(uint8_t *buf, bool sendCapture, bool saveCapture);
225  bool uploadFile(const void *fitsData, size_t totalBytes, bool sendIntegration, bool saveIntegration, const char* format);
226  int getFileIndex(const char *dir, const char *prefix, const char *ext);
227 };
228 }
bool setImaginary(void *buf, uint32_t dims, int *sizes, int bits_per_sample)
void getSizes(uint32_t *num, int **sizes)
getSizes Get the returned file dimensions and corresponding sizes.
Definition: dspinterface.h:118
Interface(INDI::DefaultDevice *dev, Type type=DSP_NONE, const char *name="DSP_PLUGIN", const char *label="DSP Plugin")
ITextVectorProperty ActiveDeviceTP
Definition: dspinterface.h:190
const char * getDeviceName()
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
uint8_t * getStream()
virtual void ISGetProperties(const char *dev)
virtual void Activated()
Activated Called after activation from client application.
ISwitchVectorProperty ActivateSP
Definition: dspinterface.h:183
INumber EqN[2]
Definition: dspinterface.h:188
virtual ~Interface()
void setCaptureFileExtension(const char *ext)
setIntegrationFileExtension Set the returned file extension.
uint8_t * getMagnitude()
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
int getBPS()
getBPS Get the returned file bit depth/sample size.
Definition: dspinterface.h:137
uint8_t * getPhase()
virtual bool updateProperties()
virtual bool saveConfigItems(FILE *fp)
virtual bool processBLOB(uint8_t *buf, uint32_t ndims, int *dims, int bits_per_sample)
processBLOB Propagate to Callback and generate BLOBs for parent device.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
bool setReal(void *buf, uint32_t dims, int *sizes, int bits_per_sample)
uint8_t * getImaginary()
void setSizes(uint32_t num, int *sizes)
setSizes Set the returned file dimensions and corresponding sizes.
Definition: dspinterface.h:107
dsp_stream_p stream
Definition: dspinterface.h:213
IBLOBVectorProperty FitsBP
Definition: dspinterface.h:180
ISwitch ActivateS[2]
Definition: dspinterface.h:184
const char * m_Label
Definition: dspinterface.h:200
bool setStream(void *buf, uint32_t dims, int *sizes, int bits_per_sample)
uint8_t * getReal()
INDI::DefaultDevice * m_Device
Definition: dspinterface.h:198
const char * m_Name
Definition: dspinterface.h:199
dsp_stream_p loadFITS(char *buf, int len)
loadFITS Converts FITS data into a dsp_stream structure pointer.
void setBPS(int bps)
setBPS Set the returned file bit depth/sample size.
Definition: dspinterface.h:128
bool setMagnitude(void *buf, uint32_t dims, int *sizes, int bits_per_sample)
INumberVectorProperty EqNP
Definition: dspinterface.h:187
virtual uint8_t * Callback(uint8_t *buf, uint32_t ndims, int *dims, int bits_per_sample)
Callback Called by processBLOB.
uint8_t * getBuffer(dsp_stream_p in, uint32_t *dims, int **sizes)
bool setPhase(void *buf, uint32_t dims, int *sizes, int bits_per_sample)
IText ActiveDeviceT[4]
Definition: dspinterface.h:191
virtual void Deactivated()
Deactivated Called after deactivation from client application.
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
ISState
Switch state.
Definition: indiapi.h:150
#define MAXINDIBLOBFMT
Definition: indiapi.h:196
Interface to the reference INDI C API device implementation on the Device Driver side.
The DSP Namespace adds signal processing to INDI drivers. Primarily written for sensors and detectors...
Definition: convolution.cpp:40
const char * DSP_TAB
Namespace to encapsulate INDI client, drivers, and mediator classes.
__le16 type
Definition: pwc-ioctl.h:0
One Blob (Binary Large Object) descriptor.
One number descriptor.
One switch descriptor.
One text descriptor.
Holds the connection type.
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:471
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246
Contains a set of informations and data relative to a buffer and how to use it.
Definition: dsp.h:363