Kstars

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

KDE's Doxygen guidelines are available online.