Instrument Neutral Distributed Interface INDI  1.6.0
inditelescope.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2011 Gerry Rozema, Jasem Mutlaq. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "defaultdevice.h"
22 
23 #include <libnova/julian_day.h>
24 
25 #include <string>
26 
67 namespace INDI
68 {
69 
70 class Telescope : public DefaultDevice
71 {
72  public:
74  {
80  };
82  {
85  };
87  {
92  };
94  {
99  };
101  {
105  };
107  {
114  };
116  {
120  };
122  {
126  };
127 
129  {
131  PEC_OFF = 0,
132  PEC_ON = 1
133  };
134 
139  enum
140  {
141  CONNECTION_NONE = 1 << 0,
142  CONNECTION_SERIAL = 1 << 1,
143  CONNECTION_TCP = 1 << 2
145 
150  enum
151  {
159  TELESCOPE_HAS_PEC = 1 << 7,
164 
165  Telescope();
166  virtual ~Telescope();
167 
168  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
169  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
170  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
171  virtual void ISGetProperties(const char *dev);
172  virtual bool ISSnoopDevice(XMLEle *root);
173 
177  uint32_t GetTelescopeCapability() const { return capability; }
178 
187  void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount = 0);
188 
192  bool CanGOTO() { return capability & TELESCOPE_CAN_GOTO; }
193 
197  bool CanSync() { return capability & TELESCOPE_CAN_SYNC; }
198 
203 
207  bool CanPark() { return capability & TELESCOPE_CAN_PARK; }
208 
213 
217  bool HasTime() { return capability & TELESCOPE_HAS_TIME; }
218 
223 
228 
233 
238 
243 
245  virtual bool initProperties();
247  virtual bool updateProperties();
248 
250  virtual bool Handshake();
251 
253  virtual void TimerHit();
254 
262 
271  bool InitPark();
272 
277  bool isParked();
278 
284  void SetParked(bool isparked);
285 
289  double GetAxis1Park();
290 
294  double GetAxis1ParkDefault();
295 
299  double GetAxis2Park();
300 
304  double GetAxis2ParkDefault();
305 
312  void SetAxis1Park(double value);
313 
319  void SetAxis1ParkDefault(double steps);
320 
327  void SetAxis2Park(double steps);
328 
334  void SetAxis2ParkDefault(double steps);
335 
341  bool isLocked();
342 
343  // Joystick helpers
344  static void joystickHelper(const char *joystick_n, double mag, double angle, void *context);
345  static void buttonHelper(const char *button_n, ISState state, void *context);
346 
352  void setTelescopeConnection(const uint8_t &value);
353 
357  uint8_t getTelescopeConnection() const;
358 
359  void setPierSide(TelescopePierSide side);
361 
362  void setPECState(TelescopePECState state);
364 
365  protected:
366  virtual bool saveConfigItems(FILE *fp);
367 
369  void NewRaDec(double ra, double dec);
370 
384  virtual bool ReadScopeStatus() = 0;
385 
392  virtual bool Goto(double ra, double dec);
393 
400  virtual bool Sync(double ra, double dec);
401 
410  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command);
411 
420  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command);
421 
428  virtual bool Park();
429 
436  virtual bool UnPark();
437 
444  virtual bool Abort();
445 
453  virtual bool SetTrackMode(uint8_t mode);
454 
463  virtual bool SetTrackRate(double raRate, double deRate);
464 
473  virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false);
474 
483  virtual bool SetTrackEnabled(bool enabled);
484 
493  virtual bool updateTime(ln_date *utc, double utc_offset);
494 
504  virtual bool updateLocation(double latitude, double longitude, double elevation);
505 
515  virtual bool SetParkPosition(double Axis1Value, double Axis2Value);
516 
523  virtual bool SetCurrentPark();
524 
531  virtual bool SetDefaultPark();
532 
542  virtual bool SetSlewRate(int index);
543 
549  bool callHandshake();
550 
551  // Joystick
552  void processNSWE(double mag, double angle);
553  void processJoystick(const char *joystick_n, double mag, double angle);
554  void processSlewPresets(double mag, double angle);
555  void processButton(const char *button_n, ISState state);
556 
561  bool LoadScopeConfig();
562 
567  bool HasDefaultScopeConfig();
568 
572  bool UpdateScopeConfig();
573 
579  std::string GetHomeDirectory() const;
580 
585  int GetScopeConfigIndex() const;
586 
593  bool CheckFile(const std::string &file_name, bool writable) const;
594 
601 
606 
607  // All telescopes should produce equatorial co-ordinates
610 
611  // When a goto is issued, domes will snoop the target property
612  // to start moving the dome when a telescope moves
615 
616  // Abort motion
619 
620  // On a coord_set message, sync, or slew
623 
624  // A number vector that stores lattitude and longitude
627 
628  // A Switch in the client interface to park the scope
631 
632  // Custom parking position
635 
636  // Custom parking options
639 
640  // A switch for North/South motion
643 
644  // A switch for West/East motion
647 
648  // Slew Rate
651 
652  // Telescope & guider aperture and focal length
655 
656  // UTC and UTC Offset
659 
660  // Active GPS/Dome device to snoop
663 
664  // Switch to lock if dome is closed, and or force parking if dome parks
667 
668  // Lock Joystick Axis to one direciton only
671 
672  // Pier Side
675 
676  // Pier Side
678 
679  // PEC State
682 
683  // Track Mode
685  ISwitch *TrackModeS { nullptr };
686 
687  // Track State
690 
691  // Track Rate
694 
695  // PEC State
697 
698 
699  uint32_t capability;
701 
702  //Park
703  char *LoadParkData();
704  bool WriteParkData();
705 
706  int PortFD = -1;
709 
710  // XML node names for scope config
711  const std::string ScopeConfigRootXmlNode { "scopeconfig" };
712  const std::string ScopeConfigDeviceXmlNode { "device" };
713  const std::string ScopeConfigNameXmlNode { "name" };
714  const std::string ScopeConfigScopeFocXmlNode { "scopefoc" };
715  const std::string ScopeConfigScopeApXmlNode { "scopeap" };
716  const std::string ScopeConfigGScopeFocXmlNode { "gscopefoc" };
717  const std::string ScopeConfigGScopeApXmlNode { "gscopeap" };
718  const std::string ScopeConfigLabelApXmlNode { "label" };
719 
720  // A switch to apply custom aperture/focal length config
721  enum
722  {
729  };
732 
733  // Scope config name
736 
738  const std::string ScopeConfigFileName;
739 
740 private:
741  bool processTimeInfo(const char *utc, const char *offset);
742  bool processLocationInfo(double latitude, double longitude, double elevation);
743 
744  void triggerSnoop(const char *driverName, const char *propertyName);
745 
746  TelescopeParkData parkDataType;
747  bool IsLocked;
748  bool IsParked;
749  const char *ParkDeviceName;
750  const std::string ParkDataFileName;
751  XMLEle *ParkdataXmlRoot, *ParkdeviceXml, *ParkstatusXml, *ParkpositionXml, *ParkpositionAxis1Xml,
752  *ParkpositionAxis2Xml;
753 
754  double Axis1ParkPosition;
755  double Axis1DefaultParkPosition;
756  double Axis2ParkPosition;
757  double Axis2DefaultParkPosition;
758 
759  uint8_t nSlewRate;
760 
761  IPState lastEqState;
762 
763  uint8_t telescopeConnection = CONNECTION_SERIAL | CONNECTION_TCP;
764  Controller *controller;
765 };
766 
767 }
virtual bool SetParkPosition(double Axis1Value, double Axis2Value)
SetParkPosition Set desired parking position to the supplied value. This ONLY sets the desired park p...
ISwitch LockAxisS[2]
ISwitch * TrackModeS
TelescopePECState lastPECState
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
const std::string ScopeConfigScopeFocXmlNode
Connection::TCP * tcpConnection
void processSlewPresets(double mag, double angle)
ISwitch PECStateS[2]
ITextVectorProperty ScopeConfigNameTP
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData.xml) is updated in the process.
enum INDI::Telescope::@74 TelescopeCapability
INumberVectorProperty ParkPositionNP
bool HasDefaultScopeConfig()
Load scope settings from XML files.
bool isParked()
isParked is mount currently parked?
ITextVectorProperty TimeTP
TelescopeStatus TrackState
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
ISwitchVectorProperty ScopeConfigsSP
IPState
Property state.
Definition: indiapi.h:143
static void joystickHelper(const char *joystick_n, double mag, double angle, void *context)
const std::string ScopeConfigLabelApXmlNode
ISwitchVectorProperty ParkSP
INumber TrackRateN[2]
ISwitchVectorProperty AbortSP
virtual bool Abort()
Abort any telescope motion including tracking if possible.
virtual bool ISSnoopDevice(XMLEle *root)
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
One number descriptor.
Definition: indiapi.h:256
ITextVectorProperty ActiveDeviceTP
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
virtual bool updateLocation(double latitude, double longitude, double elevation)
Update telescope location settings.
bool isLocked()
isLocked is mount currently locked?
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
INDI_DIR_WE
Definition: indibasetypes.h:50
INumberVectorProperty TargetNP
INDI_DIR_NS
Definition: indibasetypes.h:44
IText ActiveDeviceT[2]
double GetAxis1ParkDefault()
void processButton(const char *button_n, ISState state)
IText ScopeConfigNameT[1]
virtual bool Handshake()
perform handshake with device to check communication
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
virtual ~Telescope()
const char * name
Definition: indiserver.c:113
ISwitchVectorProperty DomeClosedLockTP
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
virtual bool SetCurrentPark()
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
const std::string ScopeConfigGScopeApXmlNode
ISwitch MovementNSS[2]
Switch vector property descriptor.
Definition: indiapi.h:347
ISwitchVectorProperty MovementWESP
Namespace to encapsulate INDI client, drivers, and mediator classes. Developers can subclass the base...
virtual bool Goto(double ra, double dec)
Move the scope to the supplied RA and DEC coordinates.
static void buttonHelper(const char *button_n, ISState state, void *context)
ISwitchVectorProperty MovementNSSP
virtual bool updateProperties()
Called when connected state changes, to add/remove properties.
ISwitch MovementWES[2]
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user...
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
INumberVectorProperty EqNP
ISwitchVectorProperty LockAxisSP
ISwitch PierSideS[2]
double ra
ISwitchVectorProperty TrackStateSP
One switch descriptor.
Definition: indiapi.h:329
INumberVectorProperty LocationNP
virtual bool SetSlewRate(int index)
SetSlewRate Set desired slew rate index.
virtual bool SetTrackEnabled(bool enabled)
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available...
const std::string ScopeConfigGScopeFocXmlNode
virtual bool updateTime(ln_date *utc, double utc_offset)
Update telescope time, date, and UTC offset.
TelescopePierSide lastPierSide
ISwitchVectorProperty PECStateSP
void processNSWE(double mag, double angle)
void setTelescopeConnection(const uint8_t &value)
setTelescopeConnection Set telescope connection mode. Child class should call this in the constructor...
INumber TargetN[2]
ISwitch ScopeConfigs[6]
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
Start or Stop the telescope motion in the direction dir.
void processJoystick(const char *joystick_n, double mag, double angle)
const std::string ScopeConfigNameXmlNode
TelescopeStatus RememberTrackState
RememberTrackState Remember last state of Track State to fall back to in case of errors or aborts...
virtual bool SetTrackMode(uint8_t mode)
SetTrackMode Set active tracking mode. Do not change track state.
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData.xml) is updated in the process.
ISwitchVectorProperty SlewRateSP
double dec
INumber ParkPositionN[2]
ISwitch ParkS[2]
std::string GetHomeDirectory() const
Validate a file name.
const std::string ScopeConfigScopeApXmlNode
const std::string ScopeConfigFileName
The telescope/guide scope configuration file name.
Number vector property descriptor.
Definition: indiapi.h:299
One text descriptor.
Definition: indiapi.h:206
The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connectio...
Definition: connectiontcp.h:37
virtual bool Park()
Park the telescope to its home position.
virtual bool Sync(double ra, double dec)
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
bool callHandshake()
callHandshake Helper function that sets the port file descriptor before calling the actual Handshake ...
ISwitch DomeClosedLockT[4]
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData.xml) is updated in the process.
ISwitch AbortS[1]
ISwitchVectorProperty TrackModeSP
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount=0)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
const std::string ScopeConfigDeviceXmlNode
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
TelescopePierSide currentPierSide
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
ISState
Switch state.
Definition: indiapi.h:134
bool CanControlTrack()
TelescopePECState getPECState()
virtual bool SetDefaultPark()
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
INumberVectorProperty TrackRateNP
bool UpdateScopeConfig()
Save scope settings to XML files.
ISwitch TrackStateS[2]
bool CheckFile(const std::string &file_name, bool writable) const
Check if a file exists and it is readable.
INumber EqN[2]
double GetAxis2ParkDefault()
virtual bool ReadScopeStatus()=0
Read telescope status.
virtual bool SetTrackRate(double raRate, double deRate)
SetTrackRate Set custom tracking rates.
INumber ScopeParametersN[4]
ISwitchVectorProperty ParkOptionSP
virtual bool UnPark()
Unpark the telescope if already parked.
INumber LocationN[3]
bool LoadScopeConfig()
Load scope settings from XML files.
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
ISwitch CoordS[3]
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
Move the telescope in the direction dir.
virtual bool initProperties()
Called to initialize basic properties required all the time.
TelescopePECState currentPECState
Text vector property descriptor.
Definition: indiapi.h:226
INumberVectorProperty ScopeParametersNP
__le16 type
Definition: pwc-ioctl.h:53
ISwitch * SlewRateS
void setPECState(TelescopePECState state)
int GetScopeConfigIndex() const
Get the scope config index.
uint32_t capability
Connection::Serial * serialConnection
TelescopePierSide getPierSide()
virtual void TimerHit()
Called when setTimer() time is up.
const std::string ScopeConfigRootXmlNode
ISwitchVectorProperty PierSideSP
uint8_t getTelescopeConnection() const
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
virtual void ISGetProperties(const char *dev)
define the driver&#39;s properties to the client. Usually, only a minimum set of properties are defined t...
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
enum INDI::Telescope::@73 TelescopeConnection
ISwitchVectorProperty CoordSP
void setPierSide(TelescopePierSide side)
ISwitch ParkOptionS[3]