Kstars

observatorydomemodel.cpp
1 /* Ekos Observatory Module
2  SPDX-FileCopyrightText: Wolfgang Reissenberger <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "observatorydomemodel.h"
8 #include <KLocalizedString>
9 
10 namespace Ekos
11 {
12 
13 void ObservatoryDomeModel::initModel(Dome *dome)
14 {
15  domeInterface = dome;
16 
17  connect(domeInterface, &Dome::ready, this, [&]() {initialized = true; emit ready();});
18  connect(domeInterface, &Dome::disconnected, this, [&]() {emit disconnected(); initialized = false;});
19  connect(domeInterface, &Dome::newStatus, this, &ObservatoryDomeModel::newStatus);
20  connect(domeInterface, &Dome::newParkStatus, this, &ObservatoryDomeModel::newParkStatus);
21  connect(domeInterface, &Dome::newShutterStatus, this, &ObservatoryDomeModel::newShutterStatus);
22  connect(domeInterface, &Dome::azimuthPositionChanged, this, &ObservatoryDomeModel::azimuthPositionChanged);
23  connect(domeInterface, &Dome::newAutoSyncStatus, this, &ObservatoryDomeModel::newAutoSyncStatus);
24 
25  initialized = true;
26 }
27 
28 ISD::Dome::Status ObservatoryDomeModel::status()
29 {
30  if (domeInterface == nullptr)
31  return ISD::Dome::DOME_IDLE;
32 
33  return domeInterface->status();
34 }
35 
36 ISD::Dome::ShutterStatus ObservatoryDomeModel::shutterStatus()
37 {
38  if (domeInterface == nullptr)
39  return ISD::Dome::SHUTTER_UNKNOWN;
40 
41  return domeInterface->shutterStatus();
42 }
43 
44 void ObservatoryDomeModel::park()
45 {
46  if (domeInterface == nullptr)
47  return;
48 
49  emit newLog(i18n("Parking %1...", isRolloffRoof() ? i18n("rolloff roof") : i18n("dome")));
50  domeInterface->park();
51 }
52 
53 
54 void ObservatoryDomeModel::unpark()
55 {
56  if (domeInterface == nullptr)
57  return;
58 
59  emit newLog(i18n("Unparking %1...", isRolloffRoof() ? i18n("rolloff roof") : i18n("dome")));
60  domeInterface->unpark();
61 }
62 
63 ISD::ParkStatus ObservatoryDomeModel::parkStatus()
64 {
65  if (domeInterface == nullptr)
66  return ISD::PARK_UNKNOWN;
67  else if (isRolloffRoof())
68  {
69  // we need to override the parking status of the dome interface for opening and closing rolloff roofs
70  if (domeInterface->status() == ISD::Dome::DOME_MOVING_CW)
71  return ISD::PARK_UNPARKING;
72  else if (domeInterface->status() == ISD::Dome::DOME_MOVING_CCW)
73  return ISD::PARK_PARKING;
74  }
75 
76  // in all other cases use the underlying park status
77  return domeInterface->parkStatus();
78 }
79 
80 void ObservatoryDomeModel::setAutoSync(bool activate)
81 {
82  if (domeInterface == nullptr)
83  return;
84 
85  if (domeInterface->setAutoSync(activate))
86  emit newLog(activate ? i18n("Slaving activated.") : i18n("Slaving deactivated."));
87 
88 }
89 
90 void ObservatoryDomeModel::abort()
91 {
92  if (domeInterface == nullptr)
93  return;
94 
95  emit newLog(i18n("Aborting..."));
96  domeInterface->abort();
97 }
98 
99 void ObservatoryDomeModel::openShutter()
100 {
101  if (domeInterface == nullptr)
102  return;
103 
104  emit newLog(i18n("Opening shutter..."));
105  domeInterface->controlShutter(true);
106 }
107 
108 void ObservatoryDomeModel::closeShutter()
109 {
110  if (domeInterface == nullptr)
111  return;
112 
113  emit newLog(i18n("Closing shutter..."));
114  domeInterface->controlShutter(false);
115 }
116 
117 bool ObservatoryDomeModel::moveDome(bool moveCW, bool start)
118 {
119  if (domeInterface == nullptr)
120  return false;
121 
122  if (isRolloffRoof())
123  emit newLog(i18nc("%2 dome or rolloff roof motion %1...", "%2 rolloff roof %1...", moveCW ? i18n("opening") : i18n("closing"), start ? i18n("Start") : i18n("Stop")));
124  else
125  emit newLog(i18nc("%2 dome or rolloff roof motion %1...", "%2 dome motion %1...", moveCW ? i18n("clockwise") : i18n("counter clockwise"), start ? i18n("Start") : i18n("Stop")));
126  return domeInterface->moveDome(moveCW, start);
127 }
128 
129 void ObservatoryDomeModel::execute(WeatherActions actions)
130 {
131  if (hasShutter() && actions.closeShutter)
132  closeShutter();
133  if (actions.parkDome)
134  park();
135 }
136 
137 }
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
QString i18n(const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 8 2022 04:13:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.