Instrument Neutral Distributed Interface INDI  2.0.2
agent_imager.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2013-2016 CloudMakers, s. r. o. All rights reserved.
3  Copyright(c) 2017 Marco Gulino <marco.gulino@gmai.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18  *******************************************************************************/
19 
20 #pragma once
21 
22 #include "baseclient.h"
23 #include "defaultdevice.h"
24 #define MAX_GROUP_COUNT 16
25 
26 class Group;
27 class Imager : public virtual INDI::DefaultDevice, public virtual INDI::BaseClient
28 {
29  public:
30  static const std::string DEVICE_NAME;
31  Imager();
32  virtual ~Imager() = default;
33 
34  // DefaultDevice
35 
36  virtual bool initProperties() override;
37  virtual bool updateProperties() override;
38  virtual void ISGetProperties(const char *dev) override;
39  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
40  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
41  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
42  virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[],
43  char *formats[], char *names[], int n) override;
44  virtual bool ISSnoopDevice(XMLEle *root) override;
45 
46  // BaseClient
47 
48  virtual void newDevice(INDI::BaseDevice baseDevice) override;
49  virtual void newProperty(INDI::Property property) override;
50  virtual void updateProperty(INDI::Property property) override;
51 
52  virtual void serverConnected() override;
53  virtual void serverDisconnected(int exit_code) override;
54 
55  protected:
56  virtual const char *getDefaultName() override;
57  virtual bool Connect() override;
58  virtual bool Disconnect() override;
59 
60  private:
61  bool isRunning();
62  bool isCCDConnected();
63  bool isFilterConnected();
64  void defineProperties();
65  void deleteProperties();
66  void initiateNextFilter();
67  void initiateNextCapture();
68  void startBatch();
69  void abortBatch();
70  void batchDone();
71  void initiateDownload();
72 
73  char format[16];
74  int group { 0 };
75  int maxGroup { 0 };
76  int image { 0 };
77  int maxImage { 0 };
78  const char *controlledCCD { nullptr };
79  const char *controlledFilterWheel { nullptr };
80 
81  ITextVectorProperty ControlledDeviceTP;
82  IText ControlledDeviceT[2] {};
83  INumberVectorProperty GroupCountNP;
84  INumber GroupCountN[1];
85  INumberVectorProperty ProgressNP;
86  INumber ProgressN[3];
87  ISwitchVectorProperty BatchSP;
88  ISwitch BatchS[2];
89  ILightVectorProperty StatusLP;
90  ILight StatusL[2];
91  ITextVectorProperty ImageNameTP;
92  IText ImageNameT[2];
93  INumberVectorProperty DownloadNP;
94  INumber DownloadN[2];
95  IBLOBVectorProperty FitsBP;
96  IBLOB FitsB[1];
97 
98  INumberVectorProperty CCDImageExposureNP;
99  INumber CCDImageExposureN[1];
100  INumberVectorProperty CCDImageBinNP;
101  INumber CCDImageBinN[2];
102  ISwitch CCDUploadS[3];
103  ISwitchVectorProperty CCDUploadSP;
104  IText CCDUploadSettingsT[2] {};
105  ITextVectorProperty CCDUploadSettingsTP;
106 
107  INumberVectorProperty FilterSlotNP;
108  INumber FilterSlotN[1];
109 
110  std::vector<std::shared_ptr<Group>> groups;
111  std::shared_ptr<Group> currentGroup() const;
112  std::shared_ptr<Group> nextGroup() const;
113  std::shared_ptr<Group> getGroup(int index) const;
114 
115 };
Definition: group.h:29
Class to provide basic client functionality.
Definition: baseclient.h:52
Class to provide basic INDI device functionality.
Definition: basedevice.h:52
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides generic container for INDI properties.
Definition: indiproperty.h:48
virtual void updateProperty(INDI::Property property) override
Emmited when a new property value arrives from INDI server.
static const std::string DEVICE_NAME
Definition: agent_imager.h:30
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual const char * getDefaultName() override
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual void serverConnected() override
Emmited when the server is connected.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual void newDevice(INDI::BaseDevice baseDevice) override
Emmited when a new device is created from INDI server.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool Disconnect() override
Disconnect from device.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual void serverDisconnected(int exit_code) override
Emmited when the server gets disconnected.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual void newProperty(INDI::Property property) override
Emmited when a new property is created for an INDI driver.
virtual ~Imager()=default
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual 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.
ISState
Switch state.
Definition: indiapi.h:150
One Blob (Binary Large Object) descriptor.
One light descriptor.
One number descriptor.
One switch descriptor.
One text descriptor.
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:471
Light vector property descriptor.
Definition: indiapi.h:417
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246