| 1 | /* |
| 2 | Driver type: GPhoto Camera INDI Driver |
| 3 | |
| 4 | Copyright (C) 2009 Geoffrey Hausheer |
| 5 | Copyright (C) 2013 Jasem Mutlaq (mutlaqja AT ikarustech DOT com) |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU Lesser General Public License as published |
| 9 | by the Free Software Foundation; either version 2.1 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 | License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public License |
| 18 | along with this library; if not, write to the Free Software Foundation, |
| 19 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #include "gphoto_driver.h"cxx . . $ `<file>/gphoto_driver.h`/ |
| 26 | |
| 27 | #include <indiccd.h> |
| 28 | #include <indifocuserinterface.h> |
| 29 | |
| 30 | #include <map> |
| 31 | #include <future> |
| 32 | #include <string> |
| 33 | |
| 34 | #define MAXEXPERRcxx . . $ `gphoto_ccd.h:34:9`! 10 /* max err in exp time we allow, secs */ |
| 35 | #define OPENDTcxx . . $ `gphoto_ccd.h:35:9`! 5 /* open retry delay, secs */ |
| 36 | |
| 37 | typedef struct _Cameracxx . . $ _Camera# Cameracxx . . $ Camera#; |
| 38 | |
| 39 | enumcxx . . $ $anonymous_type_da3c9b8439ad58cf_0# |
| 40 | { |
| 41 | ON_Scxx . . $ ON_S., |
| 42 | OFF_Scxx . . $ OFF_S. |
| 43 | }; |
| 44 | |
| 45 | typedef structcxx . . $ $anonymous_type_da3c9b8439ad58cf_1# |
| 46 | { |
| 47 | gphoto_widgetcxx . . $ gphoto_widget# * widgetcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#widget.; |
| 48 | unioncxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_2# |
| 49 | { |
| 50 | INumbercxx . . $ INumber# numcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_2#num.; |
| 51 | ISwitchcxx . . $ ISwitch# * swcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_2#sw.; |
| 52 | ITextcxx . . $ IText# textcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_2#text.; |
| 53 | } itemcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#item.; |
| 54 | unioncxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_3# |
| 55 | { |
| 56 | INumberVectorPropertycxx . . $ INumberVectorProperty# numcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_3#num.; |
| 57 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# swcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_3#sw.; |
| 58 | ITextVectorPropertycxx . . $ ITextVectorProperty# textcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#$anonymous_type_3#text.; |
| 59 | } propcxx . . $ $anonymous_type_da3c9b8439ad58cf_1#prop.; |
| 60 | } cam_optcxx . . $ cam_opt#; |
| 61 | |
| 62 | class GPhotoCCDcxx . . $ GPhotoCCD# : public INDIcxx . . $ INDI/::CCDcxx . . $ INDI/CCD#, public INDIcxx . . $ INDI/::FocuserInterfacecxx . . $ INDI/FocuserInterface# |
| 63 | { |
| 64 | public: |
| 65 | explicit GPhotoCCDcxx . . $ GPhotoCCD#GPhotoCCD(49f6e7a06ebc5aa8).(); |
| 66 | explicit GPhotoCCDcxx . . $ GPhotoCCD#GPhotoCCD(2fa786934fe80e24).(const char * model, const char * port); |
| 67 | virtual ~cxx . . $ GPhotoCCD#`~GPhotoCCD`(49f6e7a06ebc5aa8).GPhotoCCDcxx . . $ GPhotoCCD#() override; |
| 68 | |
| 69 | const char * getDefaultNamecxx . . $ GPhotoCCD#getDefaultName(33a1f659e94feb42).() override; |
| 70 | |
| 71 | bool initPropertiescxx . . $ GPhotoCCD#initProperties(c9857a73d68e59ba).() override; |
| 72 | void ISGetPropertiescxx . . $ GPhotoCCD#ISGetProperties(85c52e162fed56f9).(const char * dev) override; |
| 73 | bool updatePropertiescxx . . $ GPhotoCCD#updateProperties(c9857a73d68e59ba).() override; |
| 74 | |
| 75 | bool Connectcxx . . $ GPhotoCCD#Connect(c9857a73d68e59ba).() override; |
| 76 | bool Disconnectcxx . . $ GPhotoCCD#Disconnect(c9857a73d68e59ba).() override; |
| 77 | |
| 78 | bool StartExposurecxx . . $ GPhotoCCD#StartExposure(4e2b510d3867ab27).(float duration) override; |
| 79 | bool AbortExposurecxx . . $ GPhotoCCD#AbortExposure(c9857a73d68e59ba).() override; |
| 80 | bool UpdateCCDFramecxx . . $ GPhotoCCD#UpdateCCDFrame(a1642a0ee405ca20).(int x, int y, int w, int h) override; |
| 81 | |
| 82 | // enable binning |
| 83 | bool UpdateCCDBincxx . . $ GPhotoCCD#UpdateCCDBin(cf9ef193275fa6d8).(int hor, int ver) override; |
| 84 | |
| 85 | virtual bool ISNewNumbercxx . . $ GPhotoCCD#ISNewNumber(b910d3521abb33fb).(const char * dev, const char * name, double values[], char * names[], int n) override; |
| 86 | virtual bool ISNewSwitchcxx . . $ GPhotoCCD#ISNewSwitch(e439c05866add404).(const char * dev, const char * name, ISStatecxx . . $ ISState# * states, char * names[], int n) override; |
| 87 | virtual bool ISNewTextcxx . . $ GPhotoCCD#ISNewText(1f3dbebc116ed926).(const char * dev, const char * name, char * texts[], char * names[], int n) override; |
| 88 | |
| 89 | static void ExposureUpdatecxx . . $ GPhotoCCD#ExposureUpdate(5d22bdacc48458e8).(void * vp); |
| 90 | void ExposureUpdatecxx . . $ GPhotoCCD#ExposureUpdate(49f6e7a06ebc5aa8).(); |
| 91 | |
| 92 | static void UpdateExtendedOptionscxx . . $ GPhotoCCD#UpdateExtendedOptions(5d22bdacc48458e8).(void * vp); |
| 93 | void UpdateExtendedOptionscxx . . $ GPhotoCCD#UpdateExtendedOptions(b45ddcbc8423892c).(bool force = false); |
| 94 | |
| 95 | static void UpdateFocusMotionHelpercxx . . $ GPhotoCCD#UpdateFocusMotionHelper(5d22bdacc48458e8).(void *context); |
| 96 | void UpdateFocusMotionCallbackcxx . . $ GPhotoCCD#UpdateFocusMotionCallback(49f6e7a06ebc5aa8).(); |
| 97 | |
| 98 | protected: |
| 99 | // Misc. |
| 100 | bool saveConfigItemscxx . . $ GPhotoCCD#saveConfigItems(dc9e5a301483124c).(FILE * fp) override; |
| 101 | void addFITSKeywordscxx . . $ GPhotoCCD#addFITSKeywords(4418322fd1af6dda).(INDIcxx . . $ INDI/::CCDChipcxx . . $ INDI/CCDChip# * targetChip) override; |
| 102 | void TimerHitcxx . . $ GPhotoCCD#TimerHit(49f6e7a06ebc5aa8).() override; |
| 103 | |
| 104 | // Capture format |
| 105 | bool SetCaptureFormatcxx . . $ GPhotoCCD#SetCaptureFormat(cef82f9be00a201a).(uint8_t index) override; |
| 106 | |
| 107 | // Simulation Triggered |
| 108 | void simulationTriggeredcxx . . $ GPhotoCCD#simulationTriggered(b45ddcbc8423892c).(bool enabled) override; |
| 109 | |
| 110 | // Upload Mode |
| 111 | bool UpdateCCDUploadModecxx . . $ GPhotoCCD#UpdateCCDUploadMode(349c755248ea41ba).(CCD_UPLOAD_MODEcxx . . $ INDI/CCD#CCD_UPLOAD_MODE# mode) override; |
| 112 | |
| 113 | // Focusing |
| 114 | #if 0 |
| 115 | bool SetFocuserSpeed(int speed) override; |
| 116 | IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override; |
| 117 | #endif |
| 118 | /** |
| 119 | * \brief MoveFocuser the focuser to an relative position. |
| 120 | * \param dir Direction of focuser, either FOCUS_INWARD or FOCUS_OUTWARD. |
| 121 | * \param ticks The relative ticks to move. |
| 122 | * \return Return IPS_OK if motion is completed and focuser reached requested position. Return |
| 123 | * IPS_BUSY if focuser started motion to requested position and is in progress. |
| 124 | * Return IPS_ALERT if there is an error. |
| 125 | */ |
| 126 | virtual IPStatecxx . . $ IPState# MoveRelFocusercxx . . $ GPhotoCCD#MoveRelFocuser(7f9c1e68e57c0ac9).(FocusDirectioncxx . . $ INDI/FocuserInterface#FocusDirection# dir, uint32_t ticks) override; |
| 127 | |
| 128 | // Streaming |
| 129 | bool StartStreamingcxx . . $ GPhotoCCD#StartStreaming(c9857a73d68e59ba).() override; |
| 130 | bool StopStreamingcxx . . $ GPhotoCCD#StopStreaming(c9857a73d68e59ba).() override; |
| 131 | void streamLiveViewcxx . . $ GPhotoCCD#streamLiveView(49f6e7a06ebc5aa8).(); |
| 132 | |
| 133 | stdcxx . . $ std/::mutexcxx . . $ std/mutex# liveStreamMutexcxx . . $ GPhotoCCD#liveStreamMutex.; |
| 134 | bool m_RunLiveStreamcxx . . $ GPhotoCCD#m_RunLiveStream.; |
| 135 | //bool stopLiveVideo(); |
| 136 | |
| 137 | // Preview |
| 138 | //bool startLivePreview(); |
| 139 | |
| 140 | |
| 141 | private: |
| 142 | ISwitchcxx . . $ ISwitch# * create_switchcxx . . $ GPhotoCCD#create_switch(39f9a8dab6e76520).(const char * basestr, char ** options, int max_opts, int setidx); |
| 143 | void AddWidgetcxx . . $ GPhotoCCD#AddWidget(47a5eb50ab18737f).(gphoto_widgetcxx . . $ gphoto_widget# * widget); |
| 144 | void UpdateWidgetcxx . . $ GPhotoCCD#UpdateWidget(a2cae4171d5f6cfb).(cam_optcxx . . $ cam_opt# * opt); |
| 145 | void ShowExtendedOptionscxx . . $ GPhotoCCD#ShowExtendedOptions(49f6e7a06ebc5aa8).(void); |
| 146 | void HideExtendedOptionscxx . . $ GPhotoCCD#HideExtendedOptions(49f6e7a06ebc5aa8).(void); |
| 147 | |
| 148 | double CalcTimeLeftcxx . . $ GPhotoCCD#CalcTimeLeft(31fa7155c10fdd13).(); |
| 149 | bool grabImagecxx . . $ GPhotoCCD#grabImage(c9857a73d68e59ba).(); |
| 150 | |
| 151 | char namecxx . . $ GPhotoCCD#name.[MAXINDIDEVICEcxx . . $ `<external>/17384864463803044886/indiapi.h:193:9`!]; |
| 152 | char modelcxx . . $ GPhotoCCD#model.[MAXINDINAMEcxx . . $ `<external>/17384864463803044886/indiapi.h:191:9`!]; |
| 153 | char portcxx . . $ GPhotoCCD#port.[MAXINDINAMEcxx . . $ `<external>/17384864463803044886/indiapi.h:191:9`!]; |
| 154 | |
| 155 | struct timeval ExpStartcxx . . $ GPhotoCCD#ExpStart.; |
| 156 | double ExposureRequestcxx . . $ GPhotoCCD#ExposureRequest.; |
| 157 | |
| 158 | gphoto_drivercxx . . $ gphoto_driver# * gphotodrvcxx . . $ GPhotoCCD#gphotodrv.; |
| 159 | stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, cam_optcxx . . $ cam_opt# *> CamOptionscxx . . $ GPhotoCCD#CamOptions.; |
| 160 | int expTIDcxx . . $ GPhotoCCD#expTID.; /* exposure callback timer id, if any */ |
| 161 | int optTIDcxx . . $ GPhotoCCD#optTID.; /* callback for exposure timer id */ |
| 162 | int focusSpeedcxx . . $ GPhotoCCD#focusSpeed. {0}; |
| 163 | |
| 164 | char * on_offcxx . . $ GPhotoCCD#on_off.[2]; |
| 165 | int timerIDcxx . . $ GPhotoCCD#timerID.; |
| 166 | bool frameInitializedcxx . . $ GPhotoCCD#frameInitialized.; |
| 167 | bool isTemperatureSupportedcxx . . $ GPhotoCCD#isTemperatureSupported. { false }; |
| 168 | |
| 169 | // Focus |
| 170 | bool m_CanFocuscxx . . $ GPhotoCCD#m_CanFocus. { false }; |
| 171 | int32_t m_TargetLargeStepcxx . . $ GPhotoCCD#m_TargetLargeStep. {0}, m_TargetMedStepcxx . . $ GPhotoCCD#m_TargetMedStep. {0}, m_TargetLowStepcxx . . $ GPhotoCCD#m_TargetLowStep. {0}, m_FocusTimerIDcxx . . $ GPhotoCCD#m_FocusTimerID. {-1}; |
| 172 | |
| 173 | int liveVideoWidthcxx . . $ GPhotoCCD#liveVideoWidth. {-1}; |
| 174 | int liveVideoHeightcxx . . $ GPhotoCCD#liveVideoHeight. {-1}; |
| 175 | |
| 176 | // binning ? |
| 177 | bool binningcxx . . $ GPhotoCCD#binning. { false }; |
| 178 | |
| 179 | ISwitchcxx . . $ ISwitch# mConnectScxx . . $ GPhotoCCD#mConnectS.[2]; |
| 180 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# mConnectSPcxx . . $ GPhotoCCD#mConnectSP.; |
| 181 | ITextcxx . . $ IText# mPortTcxx . . $ GPhotoCCD#mPortT.[1] {}; |
| 182 | ITextVectorPropertycxx . . $ ITextVectorProperty# PortTPcxx . . $ GPhotoCCD#PortTP.; |
| 183 | |
| 184 | INumbercxx . . $ INumber# mMirrorLockNcxx . . $ GPhotoCCD#mMirrorLockN.[1]; |
| 185 | INumberVectorPropertycxx . . $ INumberVectorProperty# mMirrorLockNPcxx . . $ GPhotoCCD#mMirrorLockNP.; |
| 186 | |
| 187 | INumbercxx . . $ INumber# mExposureNcxx . . $ GPhotoCCD#mExposureN.[1]; |
| 188 | INumberVectorPropertycxx . . $ INumberVectorProperty# mExposureNPcxx . . $ GPhotoCCD#mExposureNP.; |
| 189 | |
| 190 | ISwitchcxx . . $ ISwitch# * mIsoScxx . . $ GPhotoCCD#mIsoS. = nullptr; |
| 191 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# mIsoSPcxx . . $ GPhotoCCD#mIsoSP.; |
| 192 | |
| 193 | ISwitchcxx . . $ ISwitch# captureTargetScxx . . $ GPhotoCCD#captureTargetS.[2]; |
| 194 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# captureTargetSPcxx . . $ GPhotoCCD#captureTargetSP.; |
| 195 | enumcxx . . $ GPhotoCCD#$anonymous_type_4# |
| 196 | { |
| 197 | CAPTURE_INTERNAL_RAMcxx . . $ GPhotoCCD#CAPTURE_INTERNAL_RAM., |
| 198 | CAPTURE_SD_CARDcxx . . $ GPhotoCCD#CAPTURE_SD_CARD. |
| 199 | }; |
| 200 | |
| 201 | ISwitchcxx . . $ ISwitch# SDCardImageScxx . . $ GPhotoCCD#SDCardImageS.[3]; |
| 202 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# SDCardImageSPcxx . . $ GPhotoCCD#SDCardImageSP.; |
| 203 | enumcxx . . $ GPhotoCCD#$anonymous_type_5# |
| 204 | { |
| 205 | SD_CARD_SAVE_IMAGEcxx . . $ GPhotoCCD#SD_CARD_SAVE_IMAGE., |
| 206 | SD_CARD_DELETE_IMAGEcxx . . $ GPhotoCCD#SD_CARD_DELETE_IMAGE., |
| 207 | SD_CARD_IGNORE_IMAGEcxx . . $ GPhotoCCD#SD_CARD_IGNORE_IMAGE., |
| 208 | |
| 209 | }; |
| 210 | |
| 211 | ISwitchcxx . . $ ISwitch# autoFocusScxx . . $ GPhotoCCD#autoFocusS.[1]; |
| 212 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# autoFocusSPcxx . . $ GPhotoCCD#autoFocusSP.; |
| 213 | |
| 214 | ISwitchcxx . . $ ISwitch# livePreviewScxx . . $ GPhotoCCD#livePreviewS.[2]; |
| 215 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# livePreviewSPcxx . . $ GPhotoCCD#livePreviewSP.; |
| 216 | |
| 217 | ISwitchcxx . . $ ISwitch# * mExposurePresetScxx . . $ GPhotoCCD#mExposurePresetS. = nullptr; |
| 218 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# mExposurePresetSPcxx . . $ GPhotoCCD#mExposurePresetSP.; |
| 219 | |
| 220 | ISwitchcxx . . $ ISwitch# forceBULBScxx . . $ GPhotoCCD#forceBULBS.[2]; |
| 221 | ISwitchVectorPropertycxx . . $ ISwitchVectorProperty# forceBULBSPcxx . . $ GPhotoCCD#forceBULBSP.; |
| 222 | enumcxx . . $ GPhotoCCD#$anonymous_type_6# |
| 223 | { |
| 224 | FORCE_BULB_ONcxx . . $ GPhotoCCD#FORCE_BULB_ON., |
| 225 | FORCE_BULB_OFFcxx . . $ GPhotoCCD#FORCE_BULB_OFF. |
| 226 | }; |
| 227 | |
| 228 | // Upload file, used for testing purposes under simulation under native mode |
| 229 | ITextVectorPropertycxx . . $ ITextVectorProperty# UploadFileTPcxx . . $ GPhotoCCD#UploadFileTP.; |
| 230 | ITextcxx . . $ IText# UploadFileTcxx . . $ GPhotoCCD#UploadFileT.[1] {}; |
| 231 | |
| 232 | IBLOBVectorPropertycxx . . $ IBLOBVectorProperty# * imageBPcxx . . $ GPhotoCCD#imageBP. = nullptr; |
| 233 | IBLOBcxx . . $ IBLOB# * imageBcxx . . $ GPhotoCCD#imageB. = nullptr; |
| 234 | |
| 235 | Cameracxx . . $ Camera# * cameracxx . . $ GPhotoCCD#camera. = nullptr; |
| 236 | |
| 237 | // Threading |
| 238 | stdcxx . . $ std/::threadcxx . . $ std/thread# liveViewThreadcxx . . $ GPhotoCCD#liveViewThread.; |
| 239 | |
| 240 | stdcxx . . $ std/::mapcxx . . $ std/map# <uint8_t, uint8_t> m_CaptureFormatMapcxx . . $ GPhotoCCD#m_CaptureFormatMap.; |
| 241 | |
| 242 | static constexpr double MINUMUM_CAMERA_TEMPERATUREcxx . . $ GPhotoCCD#MINUMUM_CAMERA_TEMPERATURE. = -60.0; |
| 243 | |
| 244 | // Ratio from far 3 to far 2 |
| 245 | static constexpr double FOCUS_HIGH_MED_RATIOcxx . . $ GPhotoCCD#FOCUS_HIGH_MED_RATIO. = 7.33; |
| 246 | // Ratio from far 2 to far 1 |
| 247 | static constexpr double FOCUS_MED_LOW_RATIOcxx . . $ GPhotoCCD#FOCUS_MED_LOW_RATIO. = 6.36; |
| 248 | |
| 249 | friend void ::ISSnoopDevicecxx . . $ ISSnoopDevice(dc1c2aa52e0f1fe7).(XMLEle * root); |
| 250 | friend void ::ISGetPropertiescxx . . $ ISGetProperties(85c52e162fed56f9).(const char * dev); |
| 251 | friend void ::ISNewSwitchcxx . . $ ISNewSwitch(61a6b63729612065).(const char * dev, const char * name, ISStatecxx . . $ ISState# * states, char * names[], int num); |
| 252 | friend void ::ISNewTextcxx . . $ ISNewText(305f560580b7f0f5).(const char * dev, const char * name, char * texts[], char * names[], int num); |
| 253 | friend void ::ISNewNumbercxx . . $ ISNewNumber(4e61198878ed5c81).(const char * dev, const char * name, double values[], char * names[], int num); |
| 254 | friend void ::ISNewBLOBcxx . . $ ISNewBLOB(8f9c2f8f6f10ed41).(const char * dev, const char * name, int sizes[], int blobsizes[], char * blobs[], |
| 255 | char * formats[], char * names[], int n); |
| 256 | }; |