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 {
149 };
150
161
168
173 enum
174 {
179
184 enum
185 {
205
206 Telescope();
207 virtual ~Telescope();
208
209 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
210 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
211 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
212 virtual void ISGetProperties(const char *dev) override;
213 virtual bool ISSnoopDevice(XMLEle *root) override;
214
218 uint32_t GetTelescopeCapability() const
219 {
220 return capability;
221 }
222
231 void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount);
232
236 bool CanGOTO()
237 {
239 }
240
244 bool CanSync()
245 {
247 }
248
252 bool CanFlip()
253 {
255 }
256
260 bool CanAbort()
261 {
263 }
264
268 bool CanPark()
269 {
271 }
272
280
284 bool HasTime()
285 {
287 }
288
293 {
295 }
296
301 {
303 }
304
312
319
323 {
325 }
326
331 {
333 }
334
339 {
341 }
342
347 {
349 }
350
355 {
357 }
358
363 {
365 }
366
376
378 virtual bool initProperties() override;
380 virtual bool updateProperties() override;
381
383 virtual bool Handshake();
384
386 virtual void TimerHit() override;
387
395
404 bool InitPark();
405
410 bool isParked();
411
417 virtual void SetParked(bool isparked);
418
422 double GetAxis1Park() const;
423
427 double GetAxis1ParkDefault() const;
428
432 double GetAxis2Park() const;
433
437 double GetAxis2ParkDefault() const;
438
445 void SetAxis1Park(double value);
446
452 void SetAxis1ParkDefault(double steps);
453
460 void SetAxis2Park(double steps);
461
467 void SetAxis2ParkDefault(double steps);
468
473 bool isLocked() const;
474
475 // Joystick helpers
476 static void joystickHelper(const char *joystick_n, double mag, double angle, void *context);
477 static void axisHelper(const char *axis_n, double value, void *context);
478 static void buttonHelper(const char *button_n, ISState state, void *context);
479
485 void setTelescopeConnection(const uint8_t &value);
486
490 uint8_t getTelescopeConnection() const;
491
497
498 void setPECState(TelescopePECState state);
503
511
516
517 protected:
518 virtual bool saveConfigItems(FILE *fp) override;
519
521 void NewRaDec(double ra, double dec);
522
536 virtual bool ReadScopeStatus() = 0;
537
544 virtual bool Flip(double ra, double dec);
545
552 virtual bool Goto(double ra, double dec);
553
560 virtual bool Sync(double ra, double dec);
561
570 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command);
571
580 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command);
581
588 virtual bool Park();
589
596 virtual bool UnPark();
597
604 virtual bool Abort();
605
613 virtual bool SetTrackMode(uint8_t mode);
614
623 virtual bool SetTrackRate(double raRate, double deRate);
624
633 virtual int AddTrackMode(const char *name, const char *label, bool isDefault = false);
634
643 virtual bool SetTrackEnabled(bool enabled);
644
653 virtual bool updateTime(ln_date *utc, double utc_offset);
654
664 virtual bool updateLocation(double latitude, double longitude, double elevation);
665
675 void updateObserverLocation(double latitude, double longitude, double elevation);
676
686 virtual bool SetParkPosition(double Axis1Value, double Axis2Value);
687
695
702 virtual bool SetCurrentPark();
703
710 virtual bool SetDefaultPark();
711
712
717 virtual void SyncParkStatus(bool isparked);
718
728 virtual bool SetSlewRate(int index);
729
742
748 bool callHandshake();
749
750 // Joystick
751 void processNSWE(double mag, double angle);
752 void processJoystick(const char *joystick_n, double mag, double angle);
753 void processAxis(const char *axis_n, double value);
754 void processSlewPresets(double mag, double angle);
755 void processButton(const char *button_n, ISState state);
756
762
763 // Geographic Location
765
771 std::string GetHomeDirectory() const;
772
778
785 bool CheckFile(const std::string &file_name, bool writable) const;
786
793
798
803
804 // All telescopes should produce equatorial co-ordinates
806
807 // When a goto is issued, domes will snoop the target property
808 // to start moving the dome when a telescope moves
810
811 // Abort motion
813
814 // On a coord_set message, sync, or slew
816
817 // A number vector that stores latitude and longitude
819
820 // A Switch in the client interface to park the scope
822 enum
823 {
826 };
827
828 // Custom parking position
830
843 enum
844 {
849 };
850
851 // A switch for North/South motion
853
854 // A switch for West/East motion
856
857 // Reverse NS or WE
859 enum
860 {
863 };
864
865 // Slew Rate
867
868 // UTC and UTC Offset
870 enum
871 {
874 };
875 void sendTimeFromSystem();
876
877 // Active GPS/Dome device to snoop
879 enum
880 {
883 };
884
885 // Switch to lock if dome is closed.
887
888 // Switch for choosing between motion control by 4-way joystick or two separate axes
890 enum
891 {
894 };
895
896 // Lock Joystick Axis to one direction only
898 enum
899 {
902 };
903
904 // Joystick reverse motion and swapping (joystick only, does not affect MoveNS/MoveWE)
906 enum
907 {
911 };
912
913 // Pier Side
915
916 // Pier Side Simulation
918 enum
919 {
922 };
923 bool getSimulatePierSide() const;
924 void setSimulatePierSide(bool value);
925
926 // Pier Side
928
929 const char * getPierSideStr(TelescopePierSide ps);
930
931 // Satellite tracking
942
947 enum
948 {
952
962 enum
963 {
967
968 // PEC State
970
977
978 // Track Mode
980
981 // Track State
983 // ISwitch TrackStateS[2];
984
985 // Track Rate
987
988 // Home Position
990
992
993 // PEC State
995
996 uint32_t capability {0};
998
999 //Park
1000 const char *LoadParkData();
1001 bool WriteParkData();
1002 bool PurgeParkData();
1003
1004 int PortFD = -1;
1007
1008 bool IsParked {false};
1010
1011 private:
1012 bool processTimeInfo(const char *utc, const char *offset);
1013 bool processLocationInfo(double latitude, double longitude, double elevation);
1014 void triggerSnoop(const char *driverName, const char *propertyName);
1015 void generateCoordSet();
1016
1021 const char *LoadParkXML();
1022
1023 bool IsLocked {true};
1024 const char *ParkDeviceName {nullptr};
1025 const std::string ParkDataFileName;
1026 XMLEle *ParkdataXmlRoot {nullptr}, *ParkdeviceXml {nullptr}, *ParkstatusXml {nullptr}, *ParkpositionXml {nullptr},
1027 *ParkpositionAxis1Xml {nullptr}, *ParkpositionAxis2Xml {nullptr};
1028
1029 double Axis1ParkPosition {0};
1030 double Axis1DefaultParkPosition {0};
1031 double Axis2ParkPosition {0};
1032 double Axis2DefaultParkPosition {0};
1033
1034 uint8_t nSlewRate {0};
1035 IPState lastEqState { IPS_IDLE };
1036
1037 uint8_t telescopeConnection = (CONNECTION_SERIAL | CONNECTION_TCP);
1038
1039 Controller *controller {nullptr};
1040
1041 float motionDirNSValue {0};
1042 float motionDirWEValue {0};
1043
1047 bool m_slewPresetArmed {true};
1048
1049 bool m_simulatePierSide; // use setSimulatePierSide and getSimulatePierSide for public access
1050
1051 // 100 millisecond of arc or time.
1052 static constexpr double EQ_NOTIFY_THRESHOLD {1.0 / (60 * 60 * 10)};
1053};
1054
1055}
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...
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.
TelescopeMountType getMountType() const
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 SetMountType(TelescopeMountType type)
SetMountType Called when the user selects a different mount type in TELESCOPE_MOUNT_TYPE....
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.
TelescopeMountType
Mount geometry reported in the standard TELESCOPE_MOUNT_TYPE property. The values are the indices of ...
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
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.
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....
void setMountType(TelescopeMountType type)
setMountType Report the mount type in TELESCOPE_MOUNT_TYPE. Drivers call it when the type is fixed by...
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.
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
@ TELESCOPE_HAS_PIER_SIDE_SIMULATION
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
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
INDI::PropertySwitch TrackModeSP
INDI::PropertyText TimeTP
INDI::PropertySwitch MountTypeSP
Standard TELESCOPE_MOUNT_TYPE property, indexed by TelescopeMountType. Writable if the driver sets TE...
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_TRACK
Track signal.
@ SAT_HALT
Halt signal (abort).
@ SAT_PASS_WINDOW_END
Index for end of the window.
@ SAT_PASS_WINDOW_START
Index for start of the window.
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
*brief user defined string literal for JSON values *sa std::size_t n
struct xml_ele_ XMLEle
Definition lilxml.h:81
Namespace to encapsulate INDI client, drivers, and mediator classes.
uint16_t type
Definition pwc-ioctl.h:0
Possible states for the satellite tracking.
Satellite pass: window start and end.
Holds the capabilities of a telescope.
Holds the connection mode of the telescope.