Instrument Neutral Distributed Interface INDI 2.2.5
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#include "libastro.h"
23#include "indipropertyswitch.h"
24#include <libnova/julian_day.h>
25
26#include <string>
27
75namespace INDI
76{
77
79{
80 public:
136
143
145 {
148 PEC_ON = 1
149 };
150
157
162 enum
163 {
166 CONNECTION_TCP = 1 << 2
168
173 enum
174 {
193
194 Telescope();
195 virtual ~Telescope();
196
197 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
198 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
199 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
200 virtual void ISGetProperties(const char *dev) override;
201 virtual bool ISSnoopDevice(XMLEle *root) override;
202
206 uint32_t GetTelescopeCapability() const
207 {
208 return capability;
209 }
210
219 void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount);
220
224 bool CanGOTO()
225 {
227 }
228
232 bool CanSync()
233 {
235 }
236
240 bool CanFlip()
241 {
243 }
244
248 bool CanAbort()
249 {
251 }
252
256 bool CanPark()
257 {
259 }
260
268
272 bool HasTime()
273 {
275 }
276
281 {
283 }
284
289 {
291 }
292
311 {
313 }
314
319 {
321 }
322
327 {
329 }
330
335 {
337 }
338
343 {
345 }
346
351 {
353 }
354
356 virtual bool initProperties() override;
358 virtual bool updateProperties() override;
359
361 virtual bool Handshake();
362
364 virtual void TimerHit() override;
365
373
382 bool InitPark();
383
388 bool isParked();
389
395 virtual void SetParked(bool isparked);
396
400 double GetAxis1Park() const;
401
405 double GetAxis1ParkDefault() const;
406
410 double GetAxis2Park() const;
411
415 double GetAxis2ParkDefault() const;
416
423 void SetAxis1Park(double value);
424
430 void SetAxis1ParkDefault(double steps);
431
438 void SetAxis2Park(double steps);
439
445 void SetAxis2ParkDefault(double steps);
446
451 bool isLocked() const;
452
453 // Joystick helpers
454 static void joystickHelper(const char *joystick_n, double mag, double angle, void *context);
455 static void axisHelper(const char *axis_n, double value, void *context);
456 static void buttonHelper(const char *button_n, ISState state, void *context);
457
463 void setTelescopeConnection(const uint8_t &value);
464
468 uint8_t getTelescopeConnection() const;
469
475
476 void setPECState(TelescopePECState state);
481
482 protected:
483 virtual bool saveConfigItems(FILE *fp) override;
484
486 void NewRaDec(double ra, double dec);
487
501 virtual bool ReadScopeStatus() = 0;
502
509 virtual bool Flip(double ra, double dec);
510
517 virtual bool Goto(double ra, double dec);
518
525 virtual bool Sync(double ra, double dec);
526
535 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command);
536
545 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command);
546
553 virtual bool Park();
554
561 virtual bool UnPark();
562
569 virtual bool Abort();
570
578 virtual bool SetTrackMode(uint8_t mode);
579
588 virtual bool SetTrackRate(double raRate, double deRate);
589
598 virtual int AddTrackMode(const char *name, const char *label, bool isDefault = false);
599
608 virtual bool SetTrackEnabled(bool enabled);
609
618 virtual bool updateTime(ln_date *utc, double utc_offset);
619
629 virtual bool updateLocation(double latitude, double longitude, double elevation);
630
640 void updateObserverLocation(double latitude, double longitude, double elevation);
641
651 virtual bool SetParkPosition(double Axis1Value, double Axis2Value);
652
660
667 virtual bool SetCurrentPark();
668
675 virtual bool SetDefaultPark();
676
677
682 virtual void SyncParkStatus(bool isparked);
683
693 virtual bool SetSlewRate(int index);
694
700 bool callHandshake();
701
702 // Joystick
703 void processNSWE(double mag, double angle);
704 void processJoystick(const char *joystick_n, double mag, double angle);
705 void processAxis(const char *axis_n, double value);
706 void processSlewPresets(double mag, double angle);
707 void processButton(const char *button_n, ISState state);
708
714
715 // Geographic Location
717
723 std::string GetHomeDirectory() const;
724
730
737 bool CheckFile(const std::string &file_name, bool writable) const;
738
745
750
756 // All telescopes should produce equatorial co-ordinates
758
759 // When a goto is issued, domes will snoop the target property
760 // to start moving the dome when a telescope moves
762
763 // Abort motion
765
766 // On a coord_set message, sync, or slew
768
769 // A number vector that stores latitude and longitude
771
772 // A Switch in the client interface to park the scope
774 enum
775 {
777 UNPARK
778 };
779
780 // Custom parking position
782
795 enum
796 {
801 };
802
803 // A switch for North/South motion
805
806 // A switch for West/East motion
808
809 // Reverse NS or WE
811 enum
812 {
815 };
816
817 // Slew Rate
819
820 // UTC and UTC Offset
822 enum
823 {
825 OFFSET
826 };
827 void sendTimeFromSystem();
828
829 // Active GPS/Dome device to snoop
831 enum
832 {
835 };
836
837 // Switch to lock if dome is closed.
839
840 // Switch for choosing between motion control by 4-way joystick or two separate axes
842 enum
843 {
846 };
847
848 // Lock Joystick Axis to one direction only
850 enum
851 {
854 };
855
856 // Joystick reverse motion and swapping (joystick only, does not affect MoveNS/MoveWE)
858 enum
859 {
863 };
864
865 // Pier Side
867
868 // Pier Side Simulation
870 enum
871 {
874 };
875 bool getSimulatePierSide() const;
876 void setSimulatePierSide(bool value);
877
878 // Pier Side
880
881 const char * getPierSideStr(TelescopePierSide ps);
882
883 // Satellite tracking
894
899 enum
900 {
904
914 enum
915 {
919
920 // PEC State
922
923 // Mount Type
925 enum
926 {
930 };
931
932 // Track Mode
934
935 // Track State
937 // ISwitch TrackStateS[2];
938
939 // Track Rate
941
942 // Home Position
944
947 // PEC State
949
950 uint32_t capability {0};
952
953 //Park
954 const char *LoadParkData();
955 bool WriteParkData();
956 bool PurgeParkData();
957
958 int PortFD = -1;
961
962 bool IsParked {false};
964
965 private:
966 bool processTimeInfo(const char *utc, const char *offset);
967 bool processLocationInfo(double latitude, double longitude, double elevation);
968 void triggerSnoop(const char *driverName, const char *propertyName);
969 void generateCoordSet();
970
975 const char *LoadParkXML();
976
977 bool IsLocked {true};
978 const char *ParkDeviceName {nullptr};
979 const std::string ParkDataFileName;
980 XMLEle *ParkdataXmlRoot {nullptr}, *ParkdeviceXml {nullptr}, *ParkstatusXml {nullptr}, *ParkpositionXml {nullptr},
981 *ParkpositionAxis1Xml {nullptr}, *ParkpositionAxis2Xml {nullptr};
982
983 double Axis1ParkPosition {0};
984 double Axis1DefaultParkPosition {0};
985 double Axis2ParkPosition {0};
986 double Axis2DefaultParkPosition {0};
987
988 uint8_t nSlewRate {0};
989 IPState lastEqState { IPS_IDLE };
990
991 uint8_t telescopeConnection = (CONNECTION_SERIAL | CONNECTION_TCP);
992
993 Controller *controller {nullptr};
994
995 float motionDirNSValue {0};
996 float motionDirWEValue {0};
997
1001 bool m_slewPresetArmed {true};
1002
1003 bool m_simulatePierSide; // use setSimulatePierSide and getSimulatePierSide for public access
1004
1005 // 100 millisecond of arc or time.
1006 static constexpr double EQ_NOTIFY_THRESHOLD {1.0 / (60 * 60 * 10)};
1007};
1008
1009}
int SetSlewRate(void)
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
The TCP class manages connection with devices over the network via TCP/IP. Upon successful connection...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
TelescopeStatus TrackState
bool isLocked() const
isLocked is mount currently locked?
virtual bool SetTrackMode(uint8_t mode)
SetTrackMode Set active tracking mode. Do not change track state.
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
bool HasPierSideSimulation()
virtual bool Goto(double ra, double dec)
Move the scope to the supplied RA and DEC coordinates.
int GetScopeConfigIndex() const
Get the scope config index.
void processButton(const char *button_n, ISState state)
static void axisHelper(const char *axis_n, double value, void *context)
void processAxis(const char *axis_n, double value)
bool CheckFile(const std::string &file_name, bool writable) const
Check if a file exists and it is readable.
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
virtual bool ReadScopeStatus()=0
Read telescope status.
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
virtual bool Park()
Park the telescope to its home position.
virtual bool SetCurrentPark()
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
TelescopeParkData parkDataType
std::string GetHomeDirectory() const
Validate a file name.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual void TimerHit() override
Called when setTimer() time is up.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool SetTrackRate(double raRate, double deRate)
SetTrackRate Set custom tracking rates.
double GetAxis1Park() const
virtual bool UnPark()
Unpark the telescope if already parked.
virtual bool SetDefaultPark()
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
void setTelescopeConnection(const uint8_t &value)
setTelescopeConnection Set telescope connection mode. Child class should call this in the constructor...
double GetAxis2Park() const
bool isParked()
isParked is mount currently parked?
void processNSWE(double mag, double angle)
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
Connection::Serial * serialConnection
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
static void joystickHelper(const char *joystick_n, double mag, double angle, void *context)
void updateObserverLocation(double latitude, double longitude, double elevation)
Update location settings of the observer.
double GetAxis1ParkDefault() const
virtual bool Handshake()
perform handshake with device to check communication
virtual bool SetTrackEnabled(bool enabled)
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
virtual bool updateTime(ln_date *utc, double utc_offset)
Update telescope time, date, and UTC offset.
Connection::TCP * tcpConnection
static void buttonHelper(const char *button_n, ISState state, void *context)
uint8_t getTelescopeConnection() const
const char * LoadParkData()
void setPECState(TelescopePECState state)
TelescopePierSide getPierSide()
virtual IPState ExecuteHomeAction(TelescopeHomeAction action)
Execute a homing action.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateLocation(double latitude, double longitude, double elevation)
Update telescope location settings.
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual bool SetParkPosition(double Axis1Value, double Axis2Value)
SetParkPosition Set desired parking position to the supplied value. This ONLY sets the desired park p...
IGeographicCoordinates m_Location
@ TELESCOPE_HAS_PIER_SIDE_SIMULATION
void processJoystick(const char *joystick_n, double mag, double angle)
bool callHandshake()
callHandshake Helper function that sets the port file descriptor before calling the actual Handshake ...
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
enum INDI::Telescope::@473 TelescopeConnection
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
virtual void SyncParkStatus(bool isparked)
SyncParkStatus Update the state and switches for parking.
void setPierSide(TelescopePierSide side)
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
TelescopePECState getPECState()
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
Move the telescope in the direction dir.
TelescopeStatus RememberTrackState
RememberTrackState Remember last state of Track State to fall back to in case of errors or aborts.
virtual bool Abort()
Abort any telescope motion including tracking if possible.
double GetAxis2ParkDefault() const
TelescopePECState currentPECState
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData....
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
Start or Stop the telescope motion in the direction dir.
virtual bool Flip(double ra, double dec)
Move and flip the scope to the supplied RA and DEC coordinates.
enum INDI::Telescope::@474 TelescopeCapability
void processSlewPresets(double mag, double angle)
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
TelescopePECState lastPECState
TelescopePierSide expectedPierSide(double ra)
Calculate the expected pier side for scopes that do not report this property themselves.
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
virtual bool Sync(double ra, double dec)
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
INDI::PropertySwitch ParkSP
INDI::PropertySwitch SimulatePierSideSP
TelescopePierSide currentPierSide
INDI::PropertySwitch AbortSP
INDI::PropertySwitch DomePolicySP
INDI::PropertyText ActiveDeviceTP
INDI::PropertyText TLEtoTrackTP
Text Vector property defining the orbital elements of an artificial satellite (TLE)....
INDI::PropertyNumber TrackRateNP
INDI::PropertySwitch MovementNSSP
INDI::PropertyText SatPassWindowTP
Text Vector property defining the start and end of a satellite pass (window contains pass)....
TelescopePierSide lastPierSide
INDI::PropertyNumber EqNP
INDI::PropertySwitch TrackStateSP
bool getSimulatePierSide() const
INDI::PropertySwitch PECStateSP
enum INDI::Telescope::@484 SatelliteWindow
INDI::PropertySwitch HomeSP
INDI::PropertySwitch MotionControlModeTP
INDI::PropertySwitch TrackSatSP
Switch Vector property defining the state of the satellite tracking of the mount. Example implementat...
INDI::PropertySwitch SlewRateSP
enum INDI::Telescope::@485 SatelliteTracking
INDI::PropertySwitch TrackModeSP
INDI::PropertyText TimeTP
INDI::PropertySwitch MountTypeSP
INDI::PropertySwitch PierSideSP
INDI::PropertySwitch LockAxisSP
INDI::PropertySwitch ReverseMovementSP
INDI::PropertySwitch MovementWESP
INDI::PropertySwitch JoystickReverseSP
INDI::PropertySwitch ParkOptionSP
INDI::PropertySwitch CoordSP
void setSimulatePierSide(bool value)
INDI::PropertyNumber LocationNP
INDI::PropertyNumber ParkPositionNP
const char * getPierSideStr(TelescopePierSide ps)
INDI::PropertyNumber TargetNP
@ SAT_PASS_WINDOW_END
Index for end of the window.
@ SAT_PASS_WINDOW_START
Index for start of the window.
@ SAT_TRACK
Track signal.
@ SAT_HALT
Halt signal (abort)
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
@ IPS_IDLE
Definition indiapi.h:159
INDI_DIR_WE
INDI_DIR_NS
Namespace to encapsulate INDI client, drivers, and mediator classes.
uint16_t type
Definition pwc-ioctl.h:0