Instrument Neutral Distributed Interface INDI  1.5.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 
68 {
69  public:
71  {
77  };
79  {
82  };
84  {
89  };
91  {
96  };
98  {
102  };
104  {
110  };
112  {
116  };
118  {
122  };
123 
125  {
127  PEC_OFF = 0,
128  PEC_ON = 1
129  };
130 
135  enum
136  {
137  CONNECTION_NONE = 1 << 0,
138  CONNECTION_SERIAL = 1 << 1,
139  CONNECTION_TCP = 1 << 2
141 
146  enum
147  {
155  TELESCOPE_HAS_PEC = 1 << 7,
160 
161  Telescope();
162  virtual ~Telescope();
163 
164  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
165  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
166  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
167  virtual void ISGetProperties(const char *dev);
168  virtual bool ISSnoopDevice(XMLEle *root);
169 
173  uint32_t GetTelescopeCapability() const { return capability; }
174 
183  void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount = 0);
184 
188  bool CanGOTO() { return capability & TELESCOPE_CAN_GOTO; }
189 
193  bool CanSync() { return capability & TELESCOPE_CAN_SYNC; }
194 
199 
203  bool CanPark() { return capability & TELESCOPE_CAN_PARK; }
204 
209 
213  bool HasTime() { return capability & TELESCOPE_HAS_TIME; }
214 
219 
224 
229 
234 
239 
241  virtual bool initProperties();
243  virtual bool updateProperties();
244 
246  virtual bool Handshake();
247 
249  virtual void TimerHit();
250 
258 
267  bool InitPark();
268 
273  bool isParked();
274 
280  void SetParked(bool isparked);
281 
285  double GetAxis1Park();
286 
290  double GetAxis1ParkDefault();
291 
295  double GetAxis2Park();
296 
300  double GetAxis2ParkDefault();
301 
308  void SetAxis1Park(double value);
309 
315  void SetAxis1ParkDefault(double steps);
316 
323  void SetAxis2Park(double steps);
324 
330  void SetAxis2ParkDefault(double steps);
331 
337  bool isLocked();
338 
339  // Joystick helpers
340  static void joystickHelper(const char *joystick_n, double mag, double angle, void *context);
341  static void buttonHelper(const char *button_n, ISState state, void *context);
342 
348  void setTelescopeConnection(const uint8_t &value);
349 
353  uint8_t getTelescopeConnection() const;
354 
355  void setPierSide(TelescopePierSide side);
357 
358  void setPECState(TelescopePECState state);
360 
361  protected:
362  virtual bool saveConfigItems(FILE *fp);
363 
365  void NewRaDec(double ra, double dec);
366 
380  virtual bool ReadScopeStatus() = 0;
381 
388  virtual bool Goto(double ra, double dec);
389 
396  virtual bool Sync(double ra, double dec);
397 
406  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command);
407 
416  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command);
417 
424  virtual bool Park();
425 
432  virtual bool UnPark();
433 
440  virtual bool Abort();
441 
449  virtual bool SetTrackMode(uint8_t mode);
450 
459  virtual bool SetTrackRate(double raRate, double deRate);
460 
469  virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false);
470 
479  virtual bool SetTrackEnabled(bool enabled);
480 
489  virtual bool updateTime(ln_date *utc, double utc_offset);
490 
500  virtual bool updateLocation(double latitude, double longitude, double elevation);
501 
511  virtual bool SetParkPosition(double Axis1Value, double Axis2Value);
512 
519  virtual bool SetCurrentPark();
520 
527  virtual bool SetDefaultPark();
528 
538  virtual bool SetSlewRate(int index);
539 
545  bool callHandshake();
546 
547  // Joystick
548  void processNSWE(double mag, double angle);
549  void processJoystick(const char *joystick_n, double mag, double angle);
550  void processSlewPresets(double mag, double angle);
551  void processButton(const char *button_n, ISState state);
552 
557  bool LoadScopeConfig();
558 
562  bool UpdateScopeConfig();
563 
569  std::string GetHomeDirectory() const;
570 
575  int GetScopeConfigIndex() const;
576 
583  bool CheckFile(const std::string &file_name, bool writable) const;
584 
591 
596 
597  // All telescopes should produce equatorial co-ordinates
600 
601  // When a goto is issued, domes will snoop the target property
602  // to start moving the dome when a telescope moves
605 
606  // Abort motion
609 
610  // On a coord_set message, sync, or slew
613 
614  // A number vector that stores lattitude and longitude
617 
618  // A Switch in the client interface to park the scope
621 
622  // Custom parking position
625 
626  // Custom parking options
629 
630  // A switch for North/South motion
633 
634  // A switch for West/East motion
637 
638  // Slew Rate
641 
642  // Telescope & guider aperture and focal length
645 
646  // UTC and UTC Offset
649 
650  // Active GPS/Dome device to snoop
653 
654  // Switch to lock if dome is closed, and or force parking if dome parks
657 
658  // Lock Joystick Axis to one direciton only
661 
662  // Pier Side
665 
666  // Pier Side
668 
669  // PEC State
672 
673  // Track Mode
675  ISwitch *TrackModeS { nullptr };
676 
677  // Track State
680 
681  // Track Rate
684 
685  // PEC State
687 
688 
689  uint32_t capability;
691 
692  //Park
693  char *LoadParkData();
694  bool WriteParkData();
695 
696  int PortFD = -1;
699 
700  private:
701  bool processTimeInfo(const char *utc, const char *offset);
702  bool processLocationInfo(double latitude, double longitude, double elevation);
703 
704  void triggerSnoop(const char *driverName, const char *propertyName);
705 
706  TelescopeParkData parkDataType;
707  bool IsLocked;
708  bool IsParked;
709  const char *ParkDeviceName;
710  const std::string ParkDataFileName;
711  XMLEle *ParkdataXmlRoot, *ParkdeviceXml, *ParkstatusXml, *ParkpositionXml, *ParkpositionAxis1Xml,
712  *ParkpositionAxis2Xml;
713 
714  double Axis1ParkPosition;
715  double Axis1DefaultParkPosition;
716  double Axis2ParkPosition;
717  double Axis2DefaultParkPosition;
718 
719  uint8_t nSlewRate;
720 
721  IPState lastEqState;
722 
723  uint8_t telescopeConnection = CONNECTION_SERIAL | CONNECTION_TCP;
724  INDI::Controller *controller;
725 
726  // A switch to apply custom aperture/focal length config
727  enum
728  {
729  SCOPE_CONFIG1,
730  SCOPE_CONFIG2,
731  SCOPE_CONFIG3,
732  SCOPE_CONFIG4,
733  SCOPE_CONFIG5,
734  SCOPE_CONFIG6
735  };
736  ISwitch ScopeConfigs[6];
737  ISwitchVectorProperty ScopeConfigsSP;
738 
739  // Scope config name
740  ITextVectorProperty ScopeConfigNameTP;
741  IText ScopeConfigNameT[1];
742 
744  const std::string ScopeConfigFileName;
745 };
int GetScopeConfigIndex() const
Get the scope config index.
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount=0)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
ISwitch LockAxisS[2]
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
Move the telescope in the direction dir.
ISwitch * TrackModeS
TelescopePECState lastPECState
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool Abort()
Abort any telescope motion including tracking if possible.
Connection::TCP * tcpConnection
ISwitch PECStateS[2]
static void joystickHelper(const char *joystick_n, double mag, double angle, void *context)
virtual bool SetTrackEnabled(bool enabled)
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available...
INumberVectorProperty ParkPositionNP
ITextVectorProperty TimeTP
TelescopeStatus TrackState
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
virtual ~Telescope()
IPState
Property state.
Definition: indiapi.h:133
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user...
virtual bool SetCurrentPark()
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
ISwitchVectorProperty ParkSP
void processSlewPresets(double mag, double angle)
INumber TrackRateN[2]
ISwitchVectorProperty AbortSP
virtual bool SetParkPosition(double Axis1Value, double Axis2Value)
SetParkPosition Set desired parking position to the supplied value. This ONLY sets the desired park p...
Class to provide general functionality of a telescope device.
Definition: inditelescope.h:67
One number descriptor.
Definition: indiapi.h:246
ITextVectorProperty ActiveDeviceTP
virtual void TimerHit()
Called when setTimer() time is up.
The Controller class provides functionality to access a controller (e.g. joystick) input and send it ...
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
INDI_DIR_WE
Definition: indibasetypes.h:50
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
bool callHandshake()
callHandshake Helper function that sets the port file descriptor before calling the actual Handshake ...
virtual bool SetSlewRate(int index)
SetSlewRate Set desired slew rate index.
INumberVectorProperty TargetNP
INDI_DIR_NS
Definition: indibasetypes.h:44
virtual bool updateTime(ln_date *utc, double utc_offset)
Update telescope time, date, and UTC offset.
virtual bool ISSnoopDevice(XMLEle *root)
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
IText ActiveDeviceT[2]
double GetAxis2ParkDefault()
virtual bool Goto(double ra, double dec)
Move the scope to the supplied RA and DEC coordinates.
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...
virtual bool Sync(double ra, double dec)
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
const char * name
Definition: indiserver.c:112
ISwitchVectorProperty DomeClosedLockTP
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
ISwitch MovementNSS[2]
void setPierSide(TelescopePierSide side)
Switch vector property descriptor.
Definition: indiapi.h:337
ISwitchVectorProperty MovementWESP
ISwitchVectorProperty MovementNSSP
bool isParked()
isParked is mount currently parked?
ISwitch MovementWES[2]
void processNSWE(double mag, double angle)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
INumberVectorProperty EqNP
ISwitchVectorProperty LockAxisSP
void processButton(const char *button_n, ISState state)
ISwitch PierSideS[2]
ISwitchVectorProperty TrackStateSP
One switch descriptor.
Definition: indiapi.h:319
INumberVectorProperty LocationNP
TelescopePierSide lastPierSide
ISwitchVectorProperty PECStateSP
uint8_t getTelescopeConnection() const
INumber TargetN[2]
virtual bool Handshake()
perform handshake with device to check communication
virtual bool updateProperties()
Called when connected state changes, to add/remove properties.
bool UpdateScopeConfig()
Save scope settings to XML files.
TelescopeStatus RememberTrackState
RememberTrackState Remember last state of Track State to fall back to in case of errors or aborts...
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.
double dec
double GetAxis1ParkDefault()
ISwitchVectorProperty SlewRateSP
INumber ParkPositionN[2]
ISwitch ParkS[2]
virtual bool initProperties()
Called to initialize basic properties required all the time.
Number vector property descriptor.
Definition: indiapi.h:289
bool CheckFile(const std::string &file_name, bool writable) const
Check if a file exists and it is readable.
static void buttonHelper(const char *button_n, ISState state, void *context)
One text descriptor.
Definition: indiapi.h:196
The TCP class manages connection with devices over the network via TCP/IP. Upon successfull connectio...
Definition: connectiontcp.h:37
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
Start or Stop the telescope motion in the direction dir.
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.
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
void processJoystick(const char *joystick_n, double mag, double angle)
ISwitch DomeClosedLockT[4]
ISwitch AbortS[1]
ISwitchVectorProperty TrackModeSP
TelescopePierSide currentPierSide
virtual bool Park()
Park the telescope to its home position.
bool LoadScopeConfig()
Load scope settings from XML files.
ISState
Switch state.
Definition: indiapi.h:124
bool CanControlTrack()
virtual bool SetDefaultPark()
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
TelescopePECState getPECState()
virtual bool SetTrackRate(double raRate, double deRate)
SetTrackRate Set custom tracking rates.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
INumberVectorProperty TrackRateNP
ISwitch TrackStateS[2]
std::string GetHomeDirectory() const
Validate a file name.
INumber EqN[2]
virtual bool ReadScopeStatus()=0
Read telescope status.
INumber ScopeParametersN[4]
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 ParkOptionSP
virtual bool UnPark()
Unpark the telescope if already parked.
INumber LocationN[3]
virtual bool updateLocation(double latitude, double longitude, double elevation)
Update telescope location settings.
ISwitch CoordS[3]
TelescopePECState currentPECState
Text vector property descriptor.
Definition: indiapi.h:216
INumberVectorProperty ScopeParametersNP
bool isLocked()
isLocked is mount currently locked?
virtual bool SetTrackMode(uint8_t mode)
SetTrackMode Set active tracking mode. Do not change track state.
__le16 type
Definition: pwc-ioctl.h:65
void setPECState(TelescopePECState state)
ISwitch * SlewRateS
uint32_t capability
Connection::Serial * serialConnection
TelescopePierSide getPierSide()
enum INDI::Telescope::@58 TelescopeCapability
void setTelescopeConnection(const uint8_t &value)
setTelescopeConnection Set telescope connection mode. Child class should call this in the constructor...
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
double ra
ISwitchVectorProperty PierSideSP
enum INDI::Telescope::@57 TelescopeConnection
ISwitchVectorProperty CoordSP
ISwitch ParkOptionS[3]