File indexing completed on 2024-05-05 15:54:55
0001 /* Ekos commands for the capture module 0002 SPDX-FileCopyrightText: Wolfgang Reissenberger <sterne-jaeger@openfuture.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 0008 #pragma once 0009 0010 #include "ekos/ekos.h" 0011 #include "indi/indicommon.h" 0012 #include "indiapi.h" 0013 0014 #include "indi/indidome.h" 0015 #include "indi/indicamerachip.h" 0016 #include "indi/indidustcap.h" 0017 #include "indi/indimount.h" 0018 0019 #include "ekos/auxiliary/filtermanager.h" 0020 0021 namespace { 0022 class Camera; 0023 class LightBox; 0024 class Rotator; 0025 } 0026 0027 namespace Ekos 0028 { 0029 0030 class SequenceJobState; 0031 0032 class CaptureDeviceAdaptor: public QObject 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 CaptureDeviceAdaptor() {} 0038 0039 ////////////////////////////////////////////////////////////////////// 0040 // current sequence job's state machine 0041 ////////////////////////////////////////////////////////////////////// 0042 /** 0043 * @brief Set the state machine for the current sequence job and attach 0044 * all active devices to it. 0045 */ 0046 void setCurrentSequenceJobState(QSharedPointer<SequenceJobState> jobState); 0047 0048 0049 ////////////////////////////////////////////////////////////////////// 0050 // Devices 0051 ////////////////////////////////////////////////////////////////////// 0052 void setLightBox(ISD::LightBox *device) 0053 { 0054 m_ActiveLightBox = device; 0055 } 0056 ISD::LightBox *lightBox() 0057 { 0058 return m_ActiveLightBox; 0059 } 0060 0061 void setDustCap(ISD::DustCap *device); 0062 ISD::DustCap *dustCap() 0063 { 0064 return m_ActiveDustCap; 0065 } 0066 0067 void setMount(ISD::Mount *device); 0068 ISD::Mount *mount() 0069 { 0070 return m_ActiveMount; 0071 } 0072 0073 void setDome(ISD::Dome *device); 0074 ISD::Dome *dome() 0075 { 0076 return m_ActiveDome; 0077 } 0078 0079 void setRotator(ISD::Rotator *device); 0080 ISD::Rotator *rotator() 0081 { 0082 return m_ActiveRotator; 0083 } 0084 0085 void setActiveCamera(ISD::Camera *device); 0086 ISD::Camera *getActiveCamera() 0087 { 0088 return m_ActiveCamera; 0089 } 0090 0091 void setActiveChip(ISD::CameraChip *device) 0092 { 0093 m_ActiveChip = device; 0094 } 0095 ISD::CameraChip *getActiveChip() 0096 { 0097 return m_ActiveChip; 0098 } 0099 0100 // FIXME add support for guide head, not implemented yet 0101 void addGuideHead(ISD::Camera *device) 0102 { 0103 Q_UNUSED(device) 0104 } 0105 0106 void setFilterWheel(ISD::FilterWheel *device); 0107 ISD::FilterWheel *filterWheel() 0108 { 0109 return m_ActiveFilterWheel; 0110 } 0111 0112 void setFilterManager(QSharedPointer<FilterManager> device); 0113 QSharedPointer<FilterManager> getFilterManager() 0114 { 0115 return m_FilterManager; 0116 } 0117 0118 /** 0119 * @brief disconnectDevices Connect all current devices to the job's 0120 * state machine 0121 */ 0122 void disconnectDevices(SequenceJobState *state); 0123 0124 ////////////////////////////////////////////////////////////////////// 0125 // Rotator commands 0126 ////////////////////////////////////////////////////////////////////// 0127 /** 0128 * @brief Set the rotator's angle 0129 */ 0130 void setRotatorAngle(double rawAngle); 0131 0132 /** 0133 * @brief Get the rotator's angle 0134 */ 0135 double getRotatorAngle(); 0136 0137 /** 0138 * @brief Get the rotator's angle state 0139 */ 0140 IPState getRotatorAngleState(); 0141 0142 /** 0143 * @brief reverseRotator Toggle rotation reverse 0144 * @param toggled If true, reverse rotator normal direction. If false, use rotator normal direction. 0145 */ 0146 void reverseRotator(bool toggled); 0147 0148 /** 0149 * @brief Read the current rotator's angle from the rotator device 0150 * and emit it as {@see newRotatorAngle()} 0151 */ 0152 void readRotatorAngle(); 0153 0154 ////////////////////////////////////////////////////////////////////// 0155 // Camera commands 0156 ////////////////////////////////////////////////////////////////////// 0157 0158 /** 0159 * @brief Set the CCD target temperature 0160 * @param temp 0161 */ 0162 void setCCDTemperature(double temp); 0163 0164 /** 0165 * @brief Set CCD to batch mode 0166 * @param enable true iff batch mode 0167 */ 0168 void enableCCDBatchMode(bool enable); 0169 0170 /** 0171 * @brief Abort exposure if fast exposure is enabled 0172 */ 0173 void abortFastExposure(); 0174 0175 /** 0176 * @brief getGain Retrieve the gain value from the custom property value. Depending 0177 * on the camera, it is either stored as GAIN property value of CCD_GAIN or as 0178 * Gain property value from CCD_CONTROLS. 0179 */ 0180 double cameraGain(QMap<QString, QMap<QString, QVariant> > propertyMap); 0181 0182 /** 0183 * @brief cameraGain Retrieve the gain value from the active camera 0184 */ 0185 double cameraGain(); 0186 0187 /** 0188 * @brief getOffset Retrieve the offset value from the custom property value. Depending 0189 * on the camera, it is either stored as OFFSET property value of CCD_OFFSET or as 0190 * Offset property value from CCD_CONTROLS. 0191 */ 0192 double cameraOffset(QMap<QString, QMap<QString, QVariant> > propertyMap); 0193 /** 0194 * @brief cameraOffset Retrieve the offset value from the active camera 0195 */ 0196 double cameraOffset(); 0197 0198 /** 0199 * @brief cameraTemperature Retrieve the current chip temperature from the active camera 0200 */ 0201 double cameraTemperature(); 0202 0203 ////////////////////////////////////////////////////////////////////// 0204 // Filter wheel commands 0205 ////////////////////////////////////////////////////////////////////// 0206 0207 /** 0208 * @brief Select the filter at the given position 0209 */ 0210 void setFilterPosition(int targetFilterPosition, FilterManager::FilterPolicy policy = FilterManager::ALL_POLICIES); 0211 /** 0212 * @brief updateFilterPosition Inform the sequence job state machine about the current filter position 0213 */ 0214 void updateFilterPosition(); 0215 0216 ////////////////////////////////////////////////////////////////////// 0217 // Flat capturing commands 0218 ////////////////////////////////////////////////////////////////////// 0219 0220 /** 0221 * @brief Ask for covering the scope manually with a flats light source or dark cover 0222 */ 0223 void askManualScopeCover(QString question, QString title, bool light); 0224 /** 0225 * @brief Ask for opening the scope cover manually 0226 */ 0227 void askManualScopeOpen(bool light); 0228 /** 0229 * @brief Turn light on in the light box 0230 */ 0231 void setLightBoxLight(bool on); 0232 /** 0233 * @brief park the dust cap 0234 */ 0235 void parkDustCap(bool park); 0236 /** 0237 * @brief Slew the telescope to a target 0238 */ 0239 void slewTelescope(SkyPoint &target); 0240 /** 0241 * @brief Turn scope tracking on and off 0242 */ 0243 void setScopeTracking(bool on); 0244 /** 0245 * @brief Park / unpark telescope 0246 */ 0247 void setScopeParked(bool parked); 0248 /** 0249 * @brief Park / unpark dome 0250 */ 0251 void setDomeParked(bool parked); 0252 /** 0253 * @brief Check if the focuser needs to be moved to the focus position. 0254 */ 0255 void flatSyncFocus(int targetFilterID); 0256 0257 ////////////////////////////////////////////////////////////////////// 0258 // Dark capturing commands 0259 ////////////////////////////////////////////////////////////////////// 0260 0261 /** 0262 * @brief Check whether the CCD has a shutter 0263 */ 0264 void queryHasShutter(); 0265 0266 signals: 0267 /** 0268 * @brief filterIdChanged Update of the currently selected filter ID 0269 */ 0270 void filterIdChanged(int id); 0271 /** 0272 * @brief newCamera A new camera has been set 0273 * @param name device name (empty if none) 0274 */ 0275 void newCamera(QString name); 0276 /** 0277 * @brief CameraConnected signal if the camera got connected 0278 * @param connected is it connected? 0279 */ 0280 void CameraConnected(bool connected); 0281 /** 0282 * @brief Update for the CCD temperature 0283 */ 0284 void newCCDTemperatureValue(double value); 0285 /** 0286 * @brief newRotator A new rotator has been set 0287 * @param name device name (empty if none) 0288 */ 0289 void newRotator(QString name); 0290 /** 0291 * @brief Update for the rotator's angle 0292 */ 0293 void newRotatorAngle(double value, IPState state); 0294 /** 0295 * @brief Update for the rotator reverse status 0296 */ 0297 void rotatorReverseToggled(bool enabled); 0298 /** 0299 * @brief newFilterWheel A new filter wheel has been set 0300 * @param name device name (empty if none) 0301 */ 0302 void newFilterWheel(QString name); 0303 /** 0304 * @brief FilterWheelConnected signal if the filter wheel got connected 0305 * @param connected is it connected? 0306 */ 0307 void FilterWheelConnected(bool connected); 0308 /** 0309 * @brief Cover for the scope with a flats light source (light is true) or dark (light is false) 0310 */ 0311 void manualScopeCoverUpdated(bool closed, bool success, bool light); 0312 /** 0313 * @brief Light box light is on. 0314 */ 0315 void lightBoxLight(bool on); 0316 /** 0317 * @brief dust cap status change 0318 */ 0319 void dustCapStatusChanged(ISD::DustCap::Status status); 0320 /** 0321 * @brief telescope status change 0322 */ 0323 void scopeStatusChanged(ISD::Mount::Status status); 0324 /** 0325 * @brief telescope pier side change 0326 */ 0327 void pierSideChanged(ISD::Mount::PierSide pierside); 0328 /** 0329 * @brief telescope park status change 0330 */ 0331 void scopeParkStatusChanged(ISD::ParkStatus status); 0332 /** 0333 * @brief dome status change 0334 */ 0335 void domeStatusChanged(ISD::Dome::Status status); 0336 /** 0337 * @brief flat sync focus status change 0338 */ 0339 void flatSyncFocusChanged(bool completed); 0340 /** 0341 * @brief CCD has a shutter 0342 */ 0343 void hasShutter(bool present); 0344 0345 public slots: 0346 /** 0347 * @brief Slot that reads the requested device state and publishes the corresponding event 0348 * @param state device state that needs to be read directly 0349 */ 0350 void readCurrentState(CaptureState state); 0351 0352 private: 0353 // the state machine for the current sequence job 0354 QSharedPointer<SequenceJobState> currentSequenceJobState; 0355 // the light box device 0356 ISD::LightBox *m_ActiveLightBox { nullptr }; 0357 // the dust cap 0358 ISD::DustCap *m_ActiveDustCap { nullptr }; 0359 // the current mount 0360 ISD::Mount *m_ActiveMount { nullptr }; 0361 // the current dome 0362 ISD::Dome *m_ActiveDome { nullptr }; 0363 // active rotator device 0364 ISD::Rotator * m_ActiveRotator { nullptr }; 0365 // active camera device 0366 ISD::Camera * m_ActiveCamera { nullptr }; 0367 // active CCD chip 0368 ISD::CameraChip * m_ActiveChip { nullptr }; 0369 // currently active filter wheel device 0370 ISD::FilterWheel * m_ActiveFilterWheel { nullptr }; 0371 // currently active filter manager 0372 QSharedPointer<FilterManager> m_FilterManager; 0373 0374 // flag if light manual cover has been asked 0375 bool m_ManualLightCoveringAsked { false }; 0376 bool m_ManualLightOpeningAsked { false }; 0377 0378 // flag if dark manual cover has been asked 0379 bool m_ManualDarkCoveringAsked { false }; 0380 bool m_ManualDarkOpeningAsked { false }; 0381 0382 ////////////////////////////////////////////////////////////////////// 0383 // Device Connections 0384 ////////////////////////////////////////////////////////////////////// 0385 void connectDustCap(SequenceJobState *state); 0386 void disconnectDustCap(SequenceJobState *state); 0387 void connectMount(SequenceJobState *state); 0388 void disconnectMount(SequenceJobState *state); 0389 void connectDome(SequenceJobState *state); 0390 void disconnectDome(SequenceJobState *state); 0391 void connectRotator(SequenceJobState *state); 0392 void disconnectRotator(SequenceJobState *state); 0393 void connectActiveCamera(SequenceJobState *state); 0394 void disconnectActiveCamera(SequenceJobState *state); 0395 void connectFilterManager(SequenceJobState *state); 0396 void disconnectFilterManager(SequenceJobState *state); 0397 }; 0398 }; // namespace