Instrument Neutral Distributed Interface INDI  1.9.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 *dp) override;
49  virtual void newProperty(INDI::Property *property) override;
50  virtual void removeProperty(INDI::Property *property) override;
51  virtual void removeDevice(INDI::BaseDevice *dp) override;
52  virtual void newBLOB(IBLOB *bp) override;
53  virtual void newSwitch(ISwitchVectorProperty *svp) override;
54  virtual void newNumber(INumberVectorProperty *nvp) override;
55  virtual void newText(ITextVectorProperty *tvp) override;
56  virtual void newLight(ILightVectorProperty *lvp) override;
57  virtual void newMessage(INDI::BaseDevice *dp, int messageID) override;
58  virtual void serverConnected() override;
59  virtual void serverDisconnected(int exit_code) override;
60 
61  protected:
62  virtual const char *getDefaultName() override;
63  virtual bool Connect() override;
64  virtual bool Disconnect() override;
65 
66  private:
67  bool isRunning();
68  bool isCCDConnected();
69  bool isFilterConnected();
70  void defineProperties();
71  void deleteProperties();
72  void initiateNextFilter();
73  void initiateNextCapture();
74  void startBatch();
75  void abortBatch();
76  void batchDone();
77  void initiateDownload();
78 
79  char format[16];
80  int group { 0 };
81  int maxGroup { 0 };
82  int image { 0 };
83  int maxImage { 0 };
84  const char *controlledCCD { nullptr };
85  const char *controlledFilterWheel { nullptr };
86 
87  ITextVectorProperty ControlledDeviceTP;
88  IText ControlledDeviceT[2] {};
89  INumberVectorProperty GroupCountNP;
90  INumber GroupCountN[1];
91  INumberVectorProperty ProgressNP;
92  INumber ProgressN[3];
93  ISwitchVectorProperty BatchSP;
94  ISwitch BatchS[2];
95  ILightVectorProperty StatusLP;
96  ILight StatusL[2];
97  ITextVectorProperty ImageNameTP;
98  IText ImageNameT[2];
99  INumberVectorProperty DownloadNP;
100  INumber DownloadN[2];
101  IBLOBVectorProperty FitsBP;
102  IBLOB FitsB[1];
103 
104  INumberVectorProperty CCDImageExposureNP;
105  INumber CCDImageExposureN[1];
106  INumberVectorProperty CCDImageBinNP;
107  INumber CCDImageBinN[2];
108  ISwitch CCDUploadS[3];
109  ISwitchVectorProperty CCDUploadSP;
110  IText CCDUploadSettingsT[2] {};
111  ITextVectorProperty CCDUploadSettingsTP;
112 
113  INumberVectorProperty FilterSlotNP;
114  INumber FilterSlotN[1];
115 
116  std::vector<std::shared_ptr<Group>> groups;
117  std::shared_ptr<Group> currentGroup() const;
118  std::shared_ptr<Group> nextGroup() const;
119  std::shared_ptr<Group> getGroup(int index) const;
120 
121 };
Imager::getDefaultName
virtual const char * getDefaultName() override
Definition: agent_imager.cpp:213
Imager::ISSnoopDevice
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Definition: agent_imager.cpp:428
Imager::DEVICE_NAME
static const std::string DEVICE_NAME
Definition: agent_imager.h:30
_ILightVectorProperty
Light vector property descriptor.
Definition: indiapi.h:415
ISwitch
One switch descriptor.
Imager::removeProperty
virtual void removeProperty(INDI::Property *property) override
Emmited when a property is deleted for an INDI driver.
Definition: agent_imager.cpp:510
Imager::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: agent_imager.cpp:333
INumber
One number descriptor.
Imager::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: agent_imager.cpp:299
_IBLOBVectorProperty
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:469
Imager::removeDevice
virtual void removeDevice(INDI::BaseDevice *dp) override
Emmited when a device is deleted from INDI server.
Definition: agent_imager.cpp:515
Imager::newMessage
virtual void newMessage(INDI::BaseDevice *dp, int messageID) override
Emmited when a new message arrives from INDI server.
Definition: agent_imager.cpp:659
Imager
Definition: agent_imager.h:27
Imager::Connect
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: agent_imager.cpp:433
Imager::newBLOB
virtual void newBLOB(IBLOB *bp) override
Emmited when a new BLOB value arrives from INDI server.
Definition: agent_imager.cpp:520
Imager::newDevice
virtual void newDevice(INDI::BaseDevice *dp) override
Emmited when a new device is created from INDI server.
Definition: agent_imager.cpp:462
Imager::ISNewText
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: agent_imager.cpp:397
Imager::newLight
virtual void newLight(ILightVectorProperty *lvp) override
Emmited when a new light value arrives from INDI server.
Definition: agent_imager.cpp:654
INDI::Property
Provides generic container for INDI properties.
Definition: indiproperty.h:43
Imager::serverConnected
virtual void serverConnected() override
Emmited when the server is connected.
Definition: agent_imager.cpp:454
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
Imager::newText
virtual void newText(ITextVectorProperty *tvp) override
Emmited when a new text value arrives from INDI server.
Definition: agent_imager.cpp:614
Imager::Disconnect
virtual bool Disconnect() override
Disconnect from device.
Definition: agent_imager.cpp:444
ILight
One light descriptor.
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
IText
One text descriptor.
xml_ele_
Definition: lilxml.c:105
defaultdevice.h
Imager::newSwitch
virtual void newSwitch(ISwitchVectorProperty *svp) override
Emmited when a new switch value arrives from INDI server.
Definition: agent_imager.cpp:558
Imager::ISNewBLOB
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.
Definition: agent_imager.cpp:422
Group
Definition: group.h:28
INDI::BaseClient
Class to provide basic client functionality.
Definition: baseclient.h:54
Imager::~Imager
virtual ~Imager()=default
Imager::serverDisconnected
virtual void serverDisconnected(int exit_code) override
Emmited when the server gets disconnected.
Definition: agent_imager.cpp:665
Imager::ISGetProperties
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...
Definition: agent_imager.cpp:328
baseclient.h
Imager::Imager
Imager()
Definition: agent_imager.cpp:43
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
Imager::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: agent_imager.cpp:370
Imager::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: agent_imager.cpp:218
Imager::newNumber
virtual void newNumber(INumberVectorProperty *nvp) override
Emmited when a new number value arrives from INDI server.
Definition: agent_imager.cpp:591
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45
Imager::newProperty
virtual void newProperty(INDI::Property *property) override
Emmited when a new property is created for an INDI driver.
Definition: agent_imager.cpp:475
IBLOB
One Blob (Binary Large Object) descriptor.
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365