Kstars

indiguider.cpp
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5
6 INDI Guide Interface
7*/
8
9#include "indiguider.h"
10
11namespace ISD
12{
13
14Guider::Guider(GenericDevice *parent) : ConcreteDevice(parent)
15{
16}
17
18void Guider::setDECSwap(bool enable)
19{
20 swapDEC = enable;
21}
22
23bool Guider::doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs)
24{
25 bool raOK = doPulse(ra_dir, ra_msecs);
26 bool decOK = doPulse(dec_dir, dec_msecs);
27 return (raOK && decOK);
28}
29
30bool Guider::doPulse(GuideDirection dir, int msecs)
31{
32 auto raPulse = getNumber("TELESCOPE_TIMED_GUIDE_WE");
33 auto decPulse = getNumber("TELESCOPE_TIMED_GUIDE_NS");
34 INDI::PropertyView<INumber> *npulse = nullptr;
35 INDI::WidgetView<INumber> *dirPulse = nullptr;
36
37 if (!raPulse || !decPulse)
38 return false;
39
40 if (dir == RA_INC_DIR || dir == RA_DEC_DIR)
41 {
42 raPulse->at(0)->setValue(0);
43 raPulse->at(1)->setValue(0);
44 }
45 else
46 {
47 decPulse->at(0)->setValue(0);
48 decPulse->at(1)->setValue(0);
49 }
50
51 switch (dir)
52 {
53 case RA_INC_DIR:
55 dirPulse = npulse->findWidgetByName("TIMED_GUIDE_W");
56 break;
57
58 case RA_DEC_DIR:
60 dirPulse = npulse->findWidgetByName("TIMED_GUIDE_E");
61 break;
62
63 case DEC_INC_DIR:
65 dirPulse = npulse->findWidgetByName(swapDEC ? "TIMED_GUIDE_S" : "TIMED_GUIDE_N");
66 break;
67
68 case DEC_DEC_DIR:
70 dirPulse = npulse->findWidgetByName(swapDEC ? "TIMED_GUIDE_N" : "TIMED_GUIDE_S");
71 break;
72
73 default:
74 return false;
75 }
76
77 if (!dirPulse)
78 return false;
79
80 dirPulse->setValue(msecs);
81
82 sendNewProperty(npulse);
83
84 return true;
85}
86}
ISD is a collection of INDI Standard Devices.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.