Kstars

indidustcap.h
1 /*
2  SPDX-FileCopyrightText: 2015 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <memory>
10 #include <QTimer>
11 
12 #include "indiconcretedevice.h"
13 
14 namespace ISD
15 {
16 /**
17  * @class DustCap
18  * Handles operation of a remotely controlled dust cover cap.
19  *
20  * @author Jasem Mutlaq
21  */
22 class DustCap : public ConcreteDevice
23 {
24  Q_OBJECT
25  Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.INDI.DustCap")
26  Q_PROPERTY(ISD::DustCap::Status status READ status NOTIFY newStatus)
27  Q_PROPERTY(ISD::ParkStatus parkStatus READ parkStatus NOTIFY newParkStatus)
28  Q_PROPERTY(bool canPark READ canPark)
29 
30  public:
31  explicit DustCap(GenericDevice *parent);
32  virtual ~DustCap() override = default;
33  typedef enum
34  {
35  CAP_IDLE,
36  CAP_PARKING,
37  CAP_UNPARKING,
38  CAP_PARKED,
39  CAP_ERROR
40  } Status;
41 
42  virtual void processSwitch(ISwitchVectorProperty *svp) override;
43 
44  Q_SCRIPTABLE virtual bool canPark();
45  // Check if cap is fully parked.
46  Q_SCRIPTABLE virtual bool isParked();
47  // Check if cap is fully unparked. We need this because we have parking and unparking in progress
48  Q_SCRIPTABLE virtual bool isUnParked();
49 
50  static const QString getStatusString(Status status, bool translated = true);
51 
52  public slots:
53  /**
54  * @brief Park Close dust cap
55  * @return True if operation is successful, false otherwise.
56  */
57  Q_SCRIPTABLE bool park();
58 
59  /**
60  * @brief UnPark Open dust cap
61  * @return True if operation is successful, false otherwise.
62  */
63  Q_SCRIPTABLE bool unpark();
64 
65  Q_SCRIPTABLE Status status()
66  {
67  return m_Status;
68  }
69  ISD::ParkStatus parkStatus() const
70  {
71  return m_ParkStatus;
72  }
73 
74  signals:
75  void newStatus(ISD::DustCap::Status status);
76  void newParkStatus(ISD::ParkStatus status);
77 
78  private:
79  Status m_Status { CAP_IDLE };
80  ParkStatus m_ParkStatus { PARK_UNKNOWN };
81  static const QList<const char *> capStates;
82 };
83 
84 }
85 
86 Q_DECLARE_METATYPE(ISD::DustCap::Status)
87 QDBusArgument &operator<<(QDBusArgument &argument, const ISD::DustCap::Status &source);
88 const QDBusArgument &operator>>(const QDBusArgument &argument, ISD::DustCap::Status &dest);
Q_OBJECTQ_OBJECT
Q_SCRIPTABLE bool park()
Park Close dust cap.
Q_PROPERTY(...)
Q_CLASSINFO(Name, Value)
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Q_SCRIPTABLE bool unpark()
UnPark Open dust cap.
The ConcreteDevice class.
QDebug operator<<(QDebug d, const QCPVector2D &vec)
Definition: qcustomplot.h:450
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:15:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.