Instrument Neutral Distributed Interface INDI  1.9.2
manager.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017 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 #include "manager.h"
20 #include "indistandardproperty.h"
21 #include "indicom.h"
22 #include "indilogger.h"
23 #include "dsp.h"
24 
25 #include <dirent.h>
26 #include <cerrno>
27 #include <cstring>
28 #include <algorithm>
29 #include <thread>
30 #include <chrono>
31 
32 namespace DSP
33 {
35 {
36  convolution = new Convolution(dev);
37  dft = new FourierTransform(dev);
38  idft = new InverseFourierTransform(dev);
39  spectrum = new Spectrum(dev);
40  histogram = new Histogram(dev);
41  wavelets = new Wavelets(dev);
42 }
43 
45 {
46 }
47 
48 void Manager::ISGetProperties(const char *dev)
49 {
50  convolution->ISGetProperties(dev);
51  dft->ISGetProperties(dev);
52  idft->ISGetProperties(dev);
53  spectrum->ISGetProperties(dev);
54  histogram->ISGetProperties(dev);
55  wavelets->ISGetProperties(dev);
56 }
57 
59 {
60  bool r = false;
61  r |= convolution->updateProperties();
62  r |= dft->updateProperties();
63  r |= idft->updateProperties();
64  r |= spectrum->updateProperties();
65  r |= histogram->updateProperties();
66  r |= wavelets->updateProperties();
67  return r;
68 }
69 
70 bool Manager::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int num)
71 {
72  bool r = false;
73  r |= convolution->ISNewSwitch(dev, name, states, names, num);
74  r |= dft->ISNewSwitch(dev, name, states, names, num);
75  r |= idft->ISNewSwitch(dev, name, states, names, num);
76  r |= spectrum->ISNewSwitch(dev, name, states, names, num);
77  r |= histogram->ISNewSwitch(dev, name, states, names, num);
78  r |= wavelets->ISNewSwitch(dev, name, states, names, num);
79  return r;
80 }
81 
82 bool Manager::ISNewText(const char *dev, const char *name, char *texts[], char *names[], int num)
83 {
84  bool r = false;
85  r |= convolution->ISNewText(dev, name, texts, names, num);
86  r |= dft->ISNewText(dev, name, texts, names, num);
87  r |= idft->ISNewText(dev, name, texts, names, num);
88  r |= spectrum->ISNewText(dev, name, texts, names, num);
89  r |= histogram->ISNewText(dev, name, texts, names, num);
90  r |= wavelets->ISNewText(dev, name, texts, names, num);
91  return r;
92 }
93 
94 bool Manager::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int num)
95 {
96  bool r = false;
97  r |= convolution->ISNewNumber(dev, name, values, names, num);
98  r |= dft->ISNewNumber(dev, name, values, names, num);
99  r |= idft->ISNewNumber(dev, name, values, names, num);
100  r |= spectrum->ISNewNumber(dev, name, values, names, num);
101  r |= histogram->ISNewNumber(dev, name, values, names, num);
102  r |= wavelets->ISNewNumber(dev, name, values, names, num);
103  return r;
104 }
105 
106 bool Manager::ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
107  char *names[], int num)
108 {
109  bool r = false;
110  r |= convolution->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, num);
111  r |= dft->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, num);
112  r |= idft->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, num);
113  r |= spectrum->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, num);
114  r |= histogram->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, num);
115  r |= wavelets->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, num);
116  return r;
117 }
118 
119 bool Manager::saveConfigItems(FILE *fp)
120 {
121  bool r = false;
122  r |= convolution->saveConfigItems(fp);
123  r |= dft->saveConfigItems(fp);
124  r |= idft->saveConfigItems(fp);
125  r |= spectrum->saveConfigItems(fp);
126  r |= histogram->saveConfigItems(fp);
127  r |= wavelets->saveConfigItems(fp);
128  return r;
129 }
130 
131 bool Manager::processBLOB(uint8_t* buf, uint32_t ndims, int* dims, int bits_per_sample)
132 {
133  bool r = false;
134  r |= convolution->processBLOB(buf, ndims, dims, bits_per_sample);
135  r |= dft->processBLOB(buf, ndims, dims, bits_per_sample);
136  r |= idft->processBLOB(buf, ndims, dims, bits_per_sample);
137  r |= spectrum->processBLOB(buf, ndims, dims, bits_per_sample);
138  r |= histogram->processBLOB(buf, ndims, dims, bits_per_sample);
139  r |= wavelets->processBLOB(buf, ndims, dims, bits_per_sample);
140  return r;
141 }
142 
143 }
DSP::Manager::~Manager
virtual ~Manager()
Definition: manager.cpp:60
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
indistandardproperty.h
dsp.h
indicom.h
Implementations for common driver routines.
DSP::Manager::saveConfigItems
virtual bool saveConfigItems(FILE *fp)
Definition: manager.cpp:135
DSP::Interface::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Definition: dspinterface.cpp:148
DSP::Convolution::ISNewBLOB
bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
Definition: convolution.cpp:64
DSP::Manager::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Definition: manager.cpp:86
DSP::Manager::ISGetProperties
virtual void ISGetProperties(const char *dev)
Definition: manager.cpp:64
indilogger.h
DSP::Interface::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Definition: dspinterface.cpp:138
DSP::Manager::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Definition: manager.cpp:110
DSP::Manager::updateProperties
virtual bool updateProperties()
Definition: manager.cpp:74
DSP::Manager::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Definition: manager.cpp:98
DSP
The DSP Namespace adds signal processing to INDI drivers. Primarily written for sensors and detectors...
Definition: convolution.cpp:39
DSP::Manager::processBLOB
bool processBLOB(uint8_t *buf, uint32_t ndims, int *dims, int bits_per_sample)
Definition: manager.cpp:147
manager.h
DSP::Manager::ISNewBLOB
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Definition: manager.cpp:122
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::Wavelets::ISNewNumber
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Definition: convolution.cpp:125
DSP::Manager::Manager
Manager(INDI::DefaultDevice *dev)
Definition: manager.cpp:50
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::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