Instrument Neutral Distributed Interface INDI 2.2.5
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"
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
32namespace 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
47
48void 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
70bool 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
82bool 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
94bool 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
106bool 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
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
131bool 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}
143{
144 convolution->setCaptureFileExtension(ext);
145 dft->setCaptureFileExtension(ext);
146 idft->setCaptureFileExtension(ext);
147 spectrum->setCaptureFileExtension(ext);
148 histogram->setCaptureFileExtension(ext);
149 wavelets->setCaptureFileExtension(ext);
150}
151}
bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
virtual bool processBLOB(uint8_t *out, uint32_t dims, int *sizes, int bits_per_sample) override
processBLOB Propagate to Callback and generate BLOBs for parent device.
virtual bool processBLOB(uint8_t *out, uint32_t dims, int *sizes, int bits_per_sample) override
processBLOB Propagate to Callback and generate BLOBs for parent device.
virtual bool processBLOB(uint8_t *out, uint32_t dims, int *sizes, int bits_per_sample) override
processBLOB Propagate to Callback and generate BLOBs for parent device.
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)
virtual void ISGetProperties(const char *dev)
void setCaptureFileExtension(const char *ext)
setIntegrationFileExtension Set the returned file extension.
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
virtual bool updateProperties()
virtual bool saveConfigItems(FILE *fp)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
virtual bool processBLOB(uint8_t *out, uint32_t dims, int *sizes, int bits_per_sample) override
processBLOB Propagate to Callback and generate BLOBs for parent device.
bool processBLOB(uint8_t *buf, uint32_t ndims, int *dims, int bits_per_sample)
Definition manager.cpp:131
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
Definition manager.cpp:106
virtual void ISGetProperties(const char *dev)
Definition manager.cpp:48
virtual bool saveConfigItems(FILE *fp)
Definition manager.cpp:119
virtual ~Manager()
Definition manager.cpp:44
virtual bool updateProperties()
Definition manager.cpp:58
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Definition manager.cpp:94
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Definition manager.cpp:70
Manager(INDI::DefaultDevice *dev)
Definition manager.cpp:34
void setCaptureFileExtension(const char *ext)
Definition manager.cpp:142
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Definition manager.cpp:82
virtual bool processBLOB(uint8_t *out, uint32_t dims, int *sizes, int bits_per_sample) override
processBLOB Propagate to Callback and generate BLOBs for parent device.
virtual bool processBLOB(uint8_t *out, uint32_t dims, int *sizes, int bits_per_sample) override
processBLOB Propagate to Callback and generate BLOBs for parent device.
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
ISState
Switch state.
Definition indiapi.h:148
Implementations for common driver routines.
The DSP Namespace adds signal processing to INDI drivers. Primarily written for sensors and detectors...