• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • indi
inditelescope.cpp
Go to the documentation of this file.
1 /* INDI CCD
2  Copyright (C) 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3 
4  This application is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8  */
9 
10 #include <indi/indidevice.h>
11 
12 #include "inditelescope.h"
13 #include "kstars.h"
14 #include "skymap.h"
15 #include "clientmanager.h"
16 
17 namespace ISD
18 {
19 
20 Telescope::Telescope(GDInterface *iPtr) : DeviceDecorator(iPtr)
21 {
22  dType = KSTARS_TELESCOPE;
23 }
24 
25 Telescope::~Telescope()
26 {
27 }
28 
29 void Telescope::processNumber(INumberVectorProperty *nvp)
30 {
31 
32  if (!strcmp(nvp->name, "EQUATORIAL_EOD_COORD"))
33  {
34  INumber *RA = IUFindNumber(nvp, "RA");
35  INumber *DEC = IUFindNumber(nvp, "DEC");
36  if (RA == NULL || DEC == NULL)
37  return;
38 
39  currentCoord.setRA(RA->value);
40  currentCoord.setDec(DEC->value);
41 
42  KStars::Instance()->map()->update();
43 
44  emit numberUpdated(nvp);
45 
46  return;
47  }
48 
49  if (!strcmp(nvp->name, "HORIZONTAL_COORD"))
50  {
51  INumber *Az = IUFindNumber(nvp, "AZ");
52  INumber *Alt = IUFindNumber(nvp, "ALT");
53  if (Az == NULL || Alt == NULL)
54  return;
55 
56  currentCoord.setAz(Az->value);
57  currentCoord.setAlt(Alt->value);
58 
59  KStars::Instance()->map()->update();
60 
61  emit numberUpdated(nvp);
62 
63  return;
64  }
65 
66  DeviceDecorator::processNumber(nvp);
67 
68 }
69 
70 void Telescope::processSwitch(ISwitchVectorProperty *svp)
71 {
72 
73  DeviceDecorator::processSwitch(svp);
74 }
75 
76 void Telescope::processText(ITextVectorProperty *tvp)
77 {
78 
79  DeviceDecorator::processText(tvp);
80 }
81 
82 bool Telescope::canGuide()
83 {
84  INumberVectorProperty *raPulse = baseDevice->getNumber("TELESCOPE_TIMED_GUIDE_WE");
85  INumberVectorProperty *decPulse = baseDevice->getNumber("TELESCOPE_TIMED_GUIDE_NS");
86 
87  if (raPulse && decPulse)
88  return true;
89  else
90  return false;
91 }
92 
93 bool Telescope::canSync()
94 {
95  ISwitchVectorProperty *motionSP = baseDevice->getSwitch("ON_COORD_SET");
96  if (motionSP == NULL)
97  return false;
98 
99  ISwitch *syncSW = IUFindSwitch(motionSP, "SYNC");
100 
101  return (syncSW != NULL);
102 }
103 
104 bool Telescope::canPark()
105 {
106  ISwitchVectorProperty *parkSP = baseDevice->getSwitch("TELESCOPE_PARK");
107  if (parkSP == NULL)
108  return false;
109 
110  ISwitch *parkSW = IUFindSwitch(parkSP, "PARK");
111 
112  return (parkSW != NULL);
113 }
114 
115 bool Telescope::isSlewing()
116 {
117  INumberVectorProperty *EqProp(NULL);
118 
119  EqProp = baseDevice->getNumber("EQUATORIAL_EOD_COORD");
120  if (EqProp == NULL)
121  return false;
122 
123  return (EqProp->s == IPS_BUSY);
124 }
125 
126 bool Telescope::doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs )
127 {
128  if (canGuide() == false)
129  return false;
130 
131  bool raOK=false, decOK=false;
132  raOK = doPulse(ra_dir, ra_msecs);
133  decOK = doPulse(dec_dir, dec_msecs);
134 
135  if (raOK && decOK)
136  return true;
137  else
138  return false;
139 }
140 
141 bool Telescope::doPulse(GuideDirection dir, int msecs )
142 {
143  INumberVectorProperty *raPulse = baseDevice->getNumber("TELESCOPE_TIMED_GUIDE_WE");
144  INumberVectorProperty *decPulse = baseDevice->getNumber("TELESCOPE_TIMED_GUIDE_NS");
145  INumberVectorProperty *npulse = NULL;
146  INumber *dirPulse=NULL;
147 
148  if (raPulse == NULL || decPulse == NULL)
149  return false;
150 
151  switch(dir)
152  {
153  case RA_INC_DIR:
154  dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_W");
155  if (dirPulse == NULL)
156  return false;
157 
158  npulse = raPulse;
159  break;
160 
161  case RA_DEC_DIR:
162  dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_E");
163  if (dirPulse == NULL)
164  return false;
165 
166  npulse = raPulse;
167  break;
168 
169  case DEC_INC_DIR:
170  dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_N");
171  if (dirPulse == NULL)
172  return false;
173 
174  npulse = decPulse;
175  break;
176 
177  case DEC_DEC_DIR:
178  dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_S");
179  if (dirPulse == NULL)
180  return false;
181 
182  npulse = decPulse;
183  break;
184 
185  default:
186  return false;
187 
188  }
189 
190  if (dirPulse == NULL || npulse == NULL)
191  return false;
192 
193  dirPulse->value = msecs;
194 
195  clientManager->sendNewNumber(npulse);
196 
197  //qDebug() << "Sending pulse for " << npulse->name << " in direction " << dirPulse->name << " for " << msecs << " ms " << endl;
198 
199  return true;
200 
201 
202 }
203 
204 bool Telescope::runCommand(int command, void *ptr)
205 {
206  //qDebug() << "Telescope run command is called!!!" << endl;
207 
208  switch (command)
209  {
210  case INDI_SEND_COORDS:
211  if (ptr == NULL)
212  sendCoords(KStars::Instance()->map()->clickedPoint());
213  else
214  sendCoords(static_cast<SkyPoint *> (ptr));
215 
216  break;
217 
218 
219  case INDI_ENGAGE_TRACKING:
220  KStars::Instance()->map()->setClickedPoint(&currentCoord);
221  KStars::Instance()->map()->slotCenter();
222  break;
223 
224  default:
225  return DeviceDecorator::runCommand(command, ptr);
226  break;
227 
228  }
229 
230  return true;
231 
232 }
233 
234 bool Telescope::sendCoords(SkyPoint *ScopeTarget)
235 {
236 
237  INumber *RAEle(NULL), *DecEle(NULL), *AzEle(NULL), *AltEle(NULL);
238  INumberVectorProperty *EqProp(NULL), *HorProp(NULL);
239  double currentRA=0, currentDEC=0, currentAlt=0, currentAz=0;
240  bool useJ2000 (false);
241 
242  EqProp = baseDevice->getNumber("EQUATORIAL_EOD_COORD");
243  if (EqProp == NULL)
244  {
245  // J2000 Property
246  EqProp = baseDevice->getNumber("EQUATORIAL_COORD");
247  if (EqProp)
248  useJ2000 = true;
249 
250  }
251 
252  HorProp = baseDevice->getNumber("HORIZONTAL_COORD");
253 
254  if (EqProp && EqProp->p == IP_RO)
255  EqProp = NULL;
256 
257  if (HorProp && HorProp->p == IP_RO)
258  HorProp = NULL;
259 
260  //kDebug() << "Skymap click - RA: " << scope_target->ra().toHMSString() << " DEC: " << scope_target->dec().toDMSString();
261 
262  if (EqProp)
263  {
264  RAEle = IUFindNumber(EqProp, "RA");
265  if (!RAEle) return false;
266  DecEle = IUFindNumber(EqProp, "DEC");
267  if (!DecEle) return false;
268 
269  if (useJ2000)
270  ScopeTarget->apparentCoord(KStars::Instance()->data()->ut().djd(), (long double) J2000);
271 
272  currentRA = RAEle->value;
273  currentDEC = DecEle->value;
274  RAEle->value = ScopeTarget->ra().Hours();
275  DecEle->value = ScopeTarget->dec().Degrees();
276  }
277 
278  if (HorProp)
279  {
280  AzEle = IUFindNumber(HorProp, "AZ");
281  if (!AzEle) return false;
282  AltEle = IUFindNumber(HorProp,"ALT");
283  if (!AltEle) return false;
284 
285  currentAz = AzEle->value;
286  currentAlt = AltEle->value;
287  AzEle->value = ScopeTarget->az().Degrees();
288  AltEle->value = ScopeTarget->alt().Degrees();
289  }
290 
291  /* Could not find either properties! */
292  if (EqProp == NULL && HorProp == NULL)
293  return false;
294 
295  if (EqProp)
296  {
297  clientManager->sendNewNumber(EqProp);
298  RAEle->value = currentRA;
299  DecEle->value = currentDEC;
300  }
301  if (HorProp)
302  {
303  clientManager->sendNewNumber(HorProp);
304  AzEle->value = currentAz;
305  AltEle->value = currentAlt;
306  }
307 
308  return true;
309 
310 }
311 
312 bool Telescope::Slew(double ra, double dec)
313 {
314  SkyPoint target;
315 
316  target.setRA(ra);
317  target.setDec(dec);
318 
319  return Slew(&target);
320 }
321 
322 bool Telescope::Slew(SkyPoint *ScopeTarget)
323 {
324  ISwitchVectorProperty *motionSP = baseDevice->getSwitch("ON_COORD_SET");
325  if (motionSP == NULL)
326  return false;
327 
328  ISwitch *slewSW = IUFindSwitch(motionSP, "SLEW");
329  if (slewSW == NULL)
330  slewSW = IUFindSwitch(motionSP, "TRACK");
331 
332  if (slewSW == NULL)
333  return NULL;
334 
335  if (slewSW->s != ISS_ON)
336  {
337  IUResetSwitch(motionSP);
338  slewSW->s = ISS_ON;
339  clientManager->sendNewSwitch(motionSP);
340  }
341 
342  return sendCoords(ScopeTarget);
343 
344 }
345 
346 bool Telescope::Sync(double ra, double dec)
347 {
348  SkyPoint target;
349 
350  target.setRA(ra);
351  target.setDec(dec);
352 
353  return Sync(&target);
354 }
355 
356 bool Telescope::Sync(SkyPoint *ScopeTarget)
357 {
358  ISwitchVectorProperty *motionSP = baseDevice->getSwitch("ON_COORD_SET");
359  if (motionSP == NULL)
360  return false;
361 
362  ISwitch *syncSW = IUFindSwitch(motionSP, "SYNC");
363  if (syncSW == NULL)
364  return NULL;
365 
366  if (syncSW->s != ISS_ON)
367  {
368  IUResetSwitch(motionSP);
369  syncSW->s = ISS_ON;
370  clientManager->sendNewSwitch(motionSP);
371  }
372 
373  return sendCoords(ScopeTarget);
374 }
375 
376 bool Telescope::Abort()
377 {
378  ISwitchVectorProperty *motionSP = baseDevice->getSwitch("TELESCOPE_ABORT_MOTION");
379  if (motionSP == NULL)
380  return false;
381 
382  ISwitch *abortSW = IUFindSwitch(motionSP, "ABORT");
383  if (abortSW == NULL)
384  return NULL;
385 
386  abortSW->s = ISS_ON;
387  clientManager->sendNewSwitch(motionSP);
388 
389  return true;
390 }
391 
392 
393 bool Telescope::Park()
394 {
395  ISwitchVectorProperty *motionSP = baseDevice->getSwitch("TELESCOPE_PARK");
396  if (motionSP == NULL)
397  return false;
398 
399  ISwitch *parkSW = IUFindSwitch(motionSP, "PARK");
400  if (parkSW == NULL)
401  return NULL;
402 
403  parkSW->s = ISS_ON;
404  clientManager->sendNewSwitch(motionSP);
405 
406  return true;
407 
408 }
409 
410 bool Telescope::getEqCoords(double *ra, double *dec)
411 {
412  INumberVectorProperty *EqProp(NULL);
413  INumber *RAEle(NULL), *DecEle(NULL);
414 
415  EqProp = baseDevice->getNumber("EQUATORIAL_EOD_COORD");
416  if (EqProp == NULL)
417  return false;
418 
419  RAEle = IUFindNumber(EqProp, "RA");
420  if (!RAEle)
421  return false;
422  DecEle = IUFindNumber(EqProp, "DEC");
423  if (!DecEle)
424  return false;
425 
426  *ra = RAEle->value;
427  *dec = DecEle->value;
428 
429  return true;
430 
431 }
432 
433 
434 }
ISD::DeviceDecorator
Definition: indistd.h:152
ISD::DeviceDecorator::baseDevice
INDI::BaseDevice * baseDevice
Definition: indistd.h:189
SkyPoint::ra
const dms & ra() const
Definition: skypoint.h:171
ISD::DeviceDecorator::runCommand
virtual bool runCommand(int command, void *ptr=NULL)
Definition: indistd.cpp:629
ISD::Telescope::~Telescope
~Telescope()
Definition: inditelescope.cpp:25
SkyPoint::apparentCoord
void apparentCoord(long double jd0, long double jdf)
Computes the apparent coordinates for this SkyPoint for any epoch, accounting for the effects of prec...
Definition: skypoint.cpp:433
INDI_ENGAGE_TRACKING
Definition: indicommon.h:72
SkyPoint::az
const dms & az() const
Definition: skypoint.h:177
KStars::map
SkyMap * map() const
Definition: kstars.h:134
ISD::Telescope::canGuide
bool canGuide()
Definition: inditelescope.cpp:82
DEC_INC_DIR
Definition: indicommon.h:28
SkyMap::slotCenter
void slotCenter()
Center the display at the point ClickedPoint.
Definition: skymap.cpp:373
ISD::Telescope::processSwitch
void processSwitch(ISwitchVectorProperty *svp)
Definition: inditelescope.cpp:70
ISD::Telescope::Telescope
Telescope(GDInterface *iPtr)
Definition: inditelescope.cpp:20
ISD::Telescope::isSlewing
bool isSlewing()
Definition: inditelescope.cpp:115
SkyPoint::setAz
void setAz(dms az)
Sets Az, the Azimuth.
Definition: skypoint.h:152
ISD::DeviceDecorator::processNumber
virtual void processNumber(INumberVectorProperty *nvp)
Definition: indistd.cpp:653
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
ISD::Telescope::canSync
bool canSync()
Definition: inditelescope.cpp:93
KStars::Instance
static KStars * Instance()
Definition: kstars.h:125
GuideDirection
GuideDirection
Definition: indicommon.h:23
indidevice.h
clientmanager.h
ISD::DeviceDecorator::processSwitch
virtual void processSwitch(ISwitchVectorProperty *svp)
Definition: indistd.cpp:659
ISD::Telescope::canPark
bool canPark()
Definition: inditelescope.cpp:104
ISD::GDInterface::numberUpdated
void numberUpdated(INumberVectorProperty *nvp)
ISD::Telescope::Park
bool Park()
Definition: inditelescope.cpp:393
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
ISD::Telescope::sendCoords
bool sendCoords(SkyPoint *ScopeTarget)
Definition: inditelescope.cpp:234
ISD::Telescope::processText
void processText(ITextVectorProperty *tvp)
Definition: inditelescope.cpp:76
DEC_DEC_DIR
Definition: indicommon.h:29
ISD::Telescope::Sync
bool Sync(SkyPoint *ScopeTarget)
Definition: inditelescope.cpp:356
skymap.h
ISD::DeviceDecorator::processText
virtual void processText(ITextVectorProperty *tvp)
Definition: indistd.cpp:665
inditelescope.h
RA_INC_DIR
Definition: indicommon.h:26
ISD::Telescope::Abort
bool Abort()
Definition: inditelescope.cpp:376
ISD::Telescope::doPulse
bool doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs)
Definition: inditelescope.cpp:126
SkyPoint::dec
const dms & dec() const
Definition: skypoint.h:174
dms::Hours
double Hours() const
Definition: dms.h:125
ISD::DeviceDecorator::clientManager
ClientManager * clientManager
Definition: indistd.h:190
ISD::Telescope::Slew
bool Slew(SkyPoint *ScopeTarget)
Definition: inditelescope.cpp:322
SkyMap::setClickedPoint
void setClickedPoint(SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition: skymap.cpp:829
J2000
#define J2000
Definition: kstarsdatetime.h:21
ISD::GDInterface::dType
DeviceFamily dType
Definition: indistd.h:78
ISD::Telescope::processNumber
void processNumber(INumberVectorProperty *nvp)
Definition: inditelescope.cpp:29
RA_DEC_DIR
Definition: indicommon.h:27
ISD::Telescope::runCommand
virtual bool runCommand(int command, void *ptr=NULL)
Definition: inditelescope.cpp:204
SkyPoint::setAlt
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition: skypoint.h:141
SkyPoint::setRA
void setRA(dms r)
Sets RA, the current Right Ascension.
Definition: skypoint.h:119
SkyPoint::setDec
void setDec(dms d)
Sets Dec, the current Declination.
Definition: skypoint.h:130
SkyPoint::alt
const dms & alt() const
Definition: skypoint.h:180
KSTARS_TELESCOPE
Definition: indicommon.h:66
INDI_SEND_COORDS
Definition: indicommon.h:72
ISD::Telescope::getEqCoords
bool getEqCoords(double *ra, double *dec)
Definition: inditelescope.cpp:410
kstars.h
ISD::GDInterface
Definition: indistd.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal