forked from AstronomyLiveYt/SatTraker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMount.py
More file actions
60 lines (49 loc) · 1.76 KB
/
Copy pathMount.py
File metadata and controls
60 lines (49 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from abc import ABC, abstractmethod
import win32com.client
import math
class Mount(ABC):
@abstractmethod
def connect(self) -> None:
pass
@abstractmethod
def disconnect(self) -> None:
pass
@abstractmethod
def slewToRadCoordinates(self, coords) -> None:
pass
@abstractmethod
def abortSlew(self) -> None:
pass
class AscomEQ(Mount):
def __init__(self) -> None:
super().__init__()
self.tel = None
self.axis_ra_rate = 0.0
self.axis_dec_rate = 0.0
def connect(self) -> bool:
driver = win32com.client.Dispatch("ASCOM.Utilities.Chooser")
driver.DeviceType = 'Telescope'
driverName = driver.Choose("None")
self.tel = win32com.client.Dispatch(driverName)
if not self.tel.Connected:
self.tel.Connected = True
axis = self.tel.CanMoveAxis(0)
axis2 = self.tel.CanMoveAxis(1)
if axis is False or axis2 is False:
print('This scope cannot use the MoveAxis method, aborting. DriverName=' + driverName)
return False
else:
self.tel.Connected = True
self.axis_ra_rate = float(self.tel.AxisRates(0).Item(1).Maximum)
self.axis_dec_rate = float(self.tel.AxisRates(1).Item(1).Maximum)
return True
def disconnect(self) -> None:
if self.tel and self.tel.Connected:
self.tel.AbortSlew()
self.tel.Connected = False
# coords are a tuple of (ra, dec)
def slewToRadCoordinates(self, coords) -> None:
self.tel.SlewToCoordinates((math.degrees(coords[0]) / 15), math.degrees(coords[1]))
def abortSlew(self) -> None:
if self.tel:
self.tel.AbortSlew()