Instrument Neutral Distributed Interface INDI  1.9.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 
30 namespace INDI
31 {
32 class DefaultDevice;
33 }
34 
35 namespace DSP
36 {
42 extern const char *DSP_TAB;
43 class Interface
44 {
66  public:
71  typedef enum {
72  DSP_NONE = 0,
77  } Type;
78 
79  virtual void ISGetProperties(const char *dev);
80  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
81  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
82  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
83  virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n);
84  virtual bool saveConfigItems(FILE *fp);
85  virtual bool updateProperties();
86 
95  bool processBLOB(uint8_t* buf, uint32_t ndims, int* dims, int bits_per_sample);
96 
102  void setSizes(uint32_t num, int* sizes) { BufferSizes = sizes; BufferSizesQty = num; }
103 
109  void getSizes(uint32_t *num, int** sizes) { *sizes = BufferSizes; *num = BufferSizesQty; }
110 
115  void setBPS(int bps) { BPS = bps; }
116 
121  int getBPS() { return BPS; }
122 
123  protected:
124 
128  virtual void Activated();
129 
133  virtual void Deactivated();
134 
143  virtual uint8_t* Callback(uint8_t* buf, uint32_t ndims, int* dims, int bits_per_sample);
144 
151  dsp_stream_p loadFITS(char* buf, int len);
152 
154 
157 
160 
161  // We are going to snoop these from a telescope
164 
167 
168  Interface(INDI::DefaultDevice *dev, Type type = DSP_NONE, const char *name = "DSP_PLUGIN", const char *label = "DSP Plugin");
169  virtual ~Interface();
170 
171  const char *getDeviceName();
173  const char *m_Name { nullptr };
174  const char *m_Label { nullptr };
176  void setStream(void *buf, uint32_t dims, int *sizes, int bits_per_sample);
177  uint8_t *getStream();
179 
180  private:
181  uint32_t BufferSizesQty;
182  int *BufferSizes;
183  int BPS;
184 
185  char processedFileName[MAXINDINAME];
186  void fits_update_key_s(fitsfile *fptr, int type, std::string name, void *p, std::string explanation, int *status);
187  void addFITSKeywords(fitsfile *fptr);
188  bool sendFITS(uint8_t *buf, bool sendCapture, bool saveCapture);
189  bool uploadFile(const void *fitsData, size_t totalBytes, bool sendIntegration, bool saveIntegration, const char* format);
190  int getFileIndex(const char *dir, const char *prefix, const char *ext);
191 };
192 }
DSP::Interface::loadFITS
dsp_stream_p loadFITS(char *buf, int len)
loadFITS Converts FITS data into a dsp_stream structure pointer.
Definition: dspinterface.cpp:333
DSP::Interface::setBPS
void setBPS(int bps)
setBPS Set the returned file bit depth/sample size.
Definition: dspinterface.h:115
DSP::Interface
Definition: dspinterface.h:43
DSP::Interface::ISNewBLOB
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Definition: dspinterface.cpp:158
DSP::Interface::m_Name
const char * m_Name
Definition: dspinterface.h:173
dsp.h
DSP::Interface::Callback
virtual uint8_t * Callback(uint8_t *buf, uint32_t ndims, int *dims, int bits_per_sample)
Callback Called by processBLOB.
Definition: dspinterface.cpp:172
ISwitch
One switch descriptor.
DSP::Interface::getStream
uint8_t * getStream()
Definition: dspinterface.cpp:699
DSP::Interface::ActivateSP
ISwitchVectorProperty ActivateSP
Definition: dspinterface.h:158
INumber
One number descriptor.
MAXINDINAME
#define MAXINDINAME
Definition: indiapi.h:190
_IBLOBVectorProperty
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:469
DSP::Interface::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Definition: dspinterface.cpp:148
DSP::Interface::DSP_DFT
@ DSP_DFT
Definition: dspinterface.h:73
DSP::Interface::setStream
void setStream(void *buf, uint32_t dims, int *sizes, int bits_per_sample)
Definition: dspinterface.cpp:665
DSP::Interface::Deactivated
virtual void Deactivated()
Deactivated Called after deactivation from client application.
Definition: dspinterface.cpp:226
DSP::Interface::ActivateS
ISwitch ActivateS[2]
Definition: dspinterface.h:159
DSP::Interface::ActiveDeviceT
IText ActiveDeviceT[4]
Definition: dspinterface.h:166
DSP::Interface::FitsB
IBLOB FitsB
Definition: dspinterface.h:156
DSP::Interface::getBPS
int getBPS()
getBPS Get the returned file bit depth/sample size.
Definition: dspinterface.h:121
dsp_stream_t
Contains a set of informations and data relative to a buffer and how to use it.
Definition: dsp.h:175
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
type
__le16 type
Definition: pwc-ioctl.h:2
DSP::Interface::PluginActive
bool PluginActive
Definition: dspinterface.h:153
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
IText
One text descriptor.
DSP::Interface::Interface
Interface(INDI::DefaultDevice *dev, Type type=DSP_NONE, const char *name="DSP_PLUGIN", const char *label="DSP Plugin")
Definition: dspinterface.cpp:60
DSP::Interface::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Definition: dspinterface.cpp:138
indidevapi.h
Interface to the reference INDI C API device implementation on the Device Driver side.
DSP::Interface::Type
Type
Definition: dspinterface.h:71
DSP::Interface::stream
dsp_stream_p stream
Definition: dspinterface.h:178
DSP::Interface::EqNP
INumberVectorProperty EqNP
Definition: dspinterface.h:162
DSP::Interface::m_Type
Type m_Type
Definition: dspinterface.h:175
DSP::Interface::m_Label
const char * m_Label
Definition: dspinterface.h:174
DSP::DSP_TAB
const char * DSP_TAB
Definition: dspinterface.cpp:58
DSP::Interface::Activated
virtual void Activated()
Activated Called after activation from client application.
Definition: dspinterface.cpp:221
DSP
The DSP Namespace adds signal processing to INDI drivers. Primarily written for sensors and detectors...
Definition: convolution.cpp:39
DSP::Interface::DSP_SPECTRUM
@ DSP_SPECTRUM
Definition: dspinterface.h:76
DSP::Interface::DSP_CONVOLUTION
@ DSP_CONVOLUTION
Definition: dspinterface.h:75
Type
Holds the connection type.
DSP::Interface::setSizes
void setSizes(uint32_t num, int *sizes)
setSizes Set the returned file dimensions and corresponding sizes.
Definition: dspinterface.h:102
DSP::Interface::FitsBP
IBLOBVectorProperty FitsBP
Definition: dspinterface.h:155
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
DSP::Interface::ActiveDeviceTP
ITextVectorProperty ActiveDeviceTP
Definition: dspinterface.h:165
DSP::Interface::DSP_NONE
@ DSP_NONE
Definition: dspinterface.h:72
DSP::Interface::saveConfigItems
virtual bool saveConfigItems(FILE *fp)
Definition: dspinterface.cpp:231
DSP::Interface::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Definition: dspinterface.cpp:118
DSP::Interface::updateProperties
virtual bool updateProperties()
Definition: dspinterface.cpp:103
ISState
ISState
Switch state.
Definition: indiapi.h:148
DSP::Interface::DSP_IDFT
@ DSP_IDFT
Definition: dspinterface.h:74
DSP::Interface::getSizes
void getSizes(uint32_t *num, int **sizes)
getSizes Get the returned file dimensions and corresponding sizes.
Definition: dspinterface.h:109
DSP::Interface::ISGetProperties
virtual void ISGetProperties(const char *dev)
Definition: dspinterface.cpp:88
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
DSP::Interface::~Interface
virtual ~Interface()
Definition: dspinterface.cpp:79
DSP::Interface::processBLOB
bool processBLOB(uint8_t *buf, uint32_t ndims, int *dims, int bits_per_sample)
processBLOB Propagate to Callback and generate BLOBs for parent device.
Definition: dspinterface.cpp:182
IBLOB
One Blob (Binary Large Object) descriptor.
DSP::Interface::m_Device
INDI::DefaultDevice * m_Device
Definition: dspinterface.h:172
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
DSP::Interface::getDeviceName
const char * getDeviceName()
Definition: dspinterface.cpp:83
DSP::Interface::EqN
INumber EqN[2]
Definition: dspinterface.h:163