| 1 | /******************************************************************************* |
| 2 | Copyright(c) 2017 Jasem Mutlaq. All rights reserved. |
| 3 | |
| 4 | INDI Astrometry.net Driver |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the Free |
| 8 | Software Foundation; either version 2 of the License, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | more details. |
| 15 | |
| 16 | You should have received a copy of the GNU Library General Public License |
| 17 | along with this library; see the file COPYING.LIB. If not, write to |
| 18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | Boston, MA 02110-1301, USA. |
| 20 | |
| 21 | The full GNU General Public License is included in this distribution in the |
| 22 | file called LICENSE. |
| 23 | *******************************************************************************/ |
| 24 | |
| 25 | #pragma once |
| 26 | |
| 27 | #include "defaultdevice.h"cxx . . $ `<file>/libs/indibase/defaultdevice.h`/ |
| 28 | |
| 29 | #include <pthread.h> |
| 30 | |
| 31 | /** |
| 32 | * @brief The AstrometryDriver class is an INDI driver frontend for astrometry.net |
| 33 | * |
| 34 | * There are two supported methods to solve an image: |
| 35 | * |
| 36 | * 1. Upload an image using the BLOB property. |
| 37 | * 2. Listen to uploaded BLOBs as emitted from a CCD driver. Set the CCD driver name to listen to in Options. |
| 38 | * |
| 39 | * The solver settings should be set before running the solver in order to ensure correct and timely response from astrometry.net |
| 40 | * It is assumed that astrometry.net is property set-up in the same machine the driver is running along with the appropiate index files. |
| 41 | * |
| 42 | * If the solver is successfull, the driver sets the solver results which include: |
| 43 | * + Pixel Scale (arcsec/pixel). |
| 44 | * + Orientation (E or W) degrees. |
| 45 | * + Center RA (J2000) Hours. |
| 46 | * + Center DE (J2000) Degrees. |
| 47 | * + Parity |
| 48 | * |
| 49 | * @author Jasem Mutlaq |
| 50 | */ |
| 51 | class AstrometryDrivercxx . . $ AstrometryDriver# : public INDIcxx . . $ INDI/::DefaultDevicecxx . . $ INDI/DefaultDevice# |
| 52 | { |
| 53 | public: |
| 54 | enumcxx . . $ AstrometryDriver#$anonymous_type_0# |
| 55 | { |
| 56 | ASTROMETRY_SETTINGS_BINARYcxx . . $ AstrometryDriver#ASTROMETRY_SETTINGS_BINARY., |
| 57 | ASTROMETRY_SETTINGS_OPTIONScxx . . $ AstrometryDriver#ASTROMETRY_SETTINGS_OPTIONS. |
| 58 | }; |
| 59 | |
| 60 | enumcxx . . $ AstrometryDriver#$anonymous_type_1# |
| 61 | { |
| 62 | ASTROMETRY_RESULTS_PIXSCALEcxx . . $ AstrometryDriver#ASTROMETRY_RESULTS_PIXSCALE., |
| 63 | ASTROMETRY_RESULTS_ORIENTATIONcxx . . $ AstrometryDriver#ASTROMETRY_RESULTS_ORIENTATION., |
| 64 | ASTROMETRY_RESULTS_RAcxx . . $ AstrometryDriver#ASTROMETRY_RESULTS_RA., |
| 65 | ASTROMETRY_RESULTS_DEcxx . . $ AstrometryDriver#ASTROMETRY_RESULTS_DE., |
| 66 | ASTROMETRY_RESULTS_PARITYcxx . . $ AstrometryDriver#ASTROMETRY_RESULTS_PARITY. |
| 67 | }; |
| 68 | |
| 69 | AstrometryDrivercxx . . $ AstrometryDriver#AstrometryDriver(49f6e7a06ebc5aa8).(); |
| 70 | ~cxx . . $ AstrometryDriver#`~AstrometryDriver`(49f6e7a06ebc5aa8).AstrometryDrivercxx . . $ AstrometryDriver#() = default; |
| 71 | |
| 72 | virtual void ISGetPropertiescxx . . $ AstrometryDriver#ISGetProperties(85c52e162fed56f9).(const char *dev) override; |
| 73 | virtual bool initPropertiescxx . . $ AstrometryDriver#initProperties(c9857a73d68e59ba).() override; |
| 74 | virtual bool updatePropertiescxx . . $ AstrometryDriver#updateProperties(c9857a73d68e59ba).() override; |
| 75 | |
| 76 | virtual bool ISNewTextcxx . . $ AstrometryDriver#ISNewText(1f3dbebc116ed926).(const char *dev, const char *name, char *texts[], char *names[], int n) override; |
| 77 | virtual bool ISNewSwitchcxx . . $ AstrometryDriver#ISNewSwitch(e439c05866add404).(const char *dev, const char *name, ISStatecxx . . $ ISState# *states, char *names[], int n) override; |
| 78 | virtual bool ISNewNumbercxx . . $ AstrometryDriver#ISNewNumber(b910d3521abb33fb).(const char *dev, const char *name, double values[], char *names[], int n) override; |
| 79 | virtual bool ISNewBLOBcxx . . $ AstrometryDriver#ISNewBLOB(1c8c4505943e50f6).(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], |
| 80 | char *formats[], char *names[], int n) override; |
| 81 | virtual bool ISSnoopDevicecxx . . $ AstrometryDriver#ISSnoopDevice(4c5c830808cba56b).(XMLEle *root) override; |
| 82 | |
| 83 | static void *runSolverHelpercxx . . $ AstrometryDriver#runSolverHelper(9f162e79bfc6c74).(void *context); |
| 84 | |
| 85 | protected: |
| 86 | // Generic indi device entries |
| 87 | bool Connectcxx . . $ AstrometryDriver#Connect(c9857a73d68e59ba).() override; |
| 88 | bool Disconnectcxx . . $ AstrometryDriver#Disconnect(c9857a73d68e59ba).() override; |
| 89 | const char *getDefaultNamecxx . . $ AstrometryDriver#getDefaultName(33a1f659e94feb42).() override; |
| 90 | |
| 91 | virtual bool saveConfigItemscxx . . $ AstrometryDriver#saveConfigItems(dc9e5a301483124c).(FILE *fp) override; |
| 92 | |
| 93 | // Astrometry |
| 94 | |
| 95 | // Enable/Disable solver |
| 96 | ISwitchcxx . . $ ISwitch# SolverScxx . . $ AstrometryDriver#SolverS.[2]; |
| 97 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# SolverSPcxx . . $ AstrometryDriver#SolverSP.; |
| 98 | enumcxx . . $ AstrometryDriver#$anonymous_type_2# { SOLVER_ENABLEcxx . . $ AstrometryDriver#SOLVER_ENABLE., SOLVER_DISABLEcxx . . $ AstrometryDriver#SOLVER_DISABLE.}; |
| 99 | |
| 100 | // Solver Settings |
| 101 | ITextcxx . . $ IText# SolverSettingsTcxx . . $ AstrometryDriver#SolverSettingsT.[2] {}; |
| 102 | ITextVectorPropertycxx . . $ ITextVectorProperty# SolverSettingsTPcxx . . $ AstrometryDriver#SolverSettingsTP.; |
| 103 | |
| 104 | // Solver Results |
| 105 | INumbercxx . . $ INumber# SolverResultNcxx . . $ AstrometryDriver#SolverResultN.[5]; |
| 106 | INumberVectorPropertycxx . . $ INumberVectorProperty# SolverResultNPcxx . . $ AstrometryDriver#SolverResultNP.; |
| 107 | |
| 108 | ITextVectorPropertycxx . . $ ITextVectorProperty# ActiveDeviceTPcxx . . $ AstrometryDriver#ActiveDeviceTP.; |
| 109 | ITextcxx . . $ IText# ActiveDeviceTcxx . . $ AstrometryDriver#ActiveDeviceT.[1] {}; |
| 110 | |
| 111 | IBLOBVectorPropertycxx . . $ IBLOBVectorProperty# SolverDataBPcxx . . $ AstrometryDriver#SolverDataBP.; |
| 112 | IBLOBcxx . . $ IBLOB# SolverDataBcxx . . $ AstrometryDriver#SolverDataB.[1]; |
| 113 | |
| 114 | IBLOBcxx . . $ IBLOB# CCDDataBcxx . . $ AstrometryDriver#CCDDataB.[1]; |
| 115 | IBLOBVectorPropertycxx . . $ IBLOBVectorProperty# CCDDataBPcxx . . $ AstrometryDriver#CCDDataBP.; |
| 116 | |
| 117 | private: |
| 118 | // Run solver thread |
| 119 | void runSolvercxx . . $ AstrometryDriver#runSolver(49f6e7a06ebc5aa8).(); |
| 120 | |
| 121 | /** |
| 122 | * @brief processBLOB Read blob FITS. Uncompress if necessary, write to temporary file, and run |
| 123 | * solver against it. |
| 124 | * @param data raw data FITS buffer |
| 125 | * @param size size of FITS data |
| 126 | * @param len size of raw data. If no compression is used then len = size. If compression is used, |
| 127 | * then len is the compressed buffer size and size is the uncompressed final valid data size. |
| 128 | * @return True if blob buffer was processed correctly and solver started, false otherwise. |
| 129 | */ |
| 130 | bool processBLOBcxx . . $ AstrometryDriver#processBLOB(86eb03e0b3dad722).(uint8_tcxx . . $ uint8_t# *data, uint32_tcxx . . $ uint32_t# size, uint32_tcxx . . $ uint32_t# len); |
| 131 | |
| 132 | // Thread for listenINDI() |
| 133 | pthread_t solverThreadcxx . . $ AstrometryDriver#solverThread.; |
| 134 | pthread_mutex_t lockcxx . . $ AstrometryDriver#lock.; |
| 135 | }; |