1
1
import asyncio
2
2
import logging
3
+ import time
3
4
from typing import Tuple , Optional , Any
4
5
5
6
from pyobs .events import RoofOpenedEvent , RoofClosingEvent
@@ -63,6 +64,14 @@ async def open(self) -> None:
63
64
# init status to IDLE
64
65
await self ._change_motion_status (MotionStatus .IDLE )
65
66
67
+ async def _send_open_dome (self ) -> None :
68
+ """Send command to open dome."""
69
+ try :
70
+ await self ._device .put ("OpenShutter" )
71
+ except ConnectionError :
72
+ await self ._change_motion_status (MotionStatus .UNKNOWN )
73
+ raise exc .InitError ("Could not open dome." )
74
+
66
75
@timeout (1200000 )
67
76
async def init (self , ** kwargs : Any ) -> None :
68
77
"""Open dome.
@@ -86,11 +95,8 @@ async def init(self, **kwargs: Any) -> None:
86
95
await self ._change_motion_status (MotionStatus .INITIALIZING )
87
96
88
97
# execute command
89
- try :
90
- await self ._device .put ("OpenShutter" )
91
- except ConnectionError :
92
- await self ._change_motion_status (MotionStatus .UNKNOWN )
93
- raise exc .InitError ("Could not open dome." )
98
+ await self ._send_open_dome ()
99
+ time_attempt = time .time ()
94
100
95
101
# wait for it
96
102
status = None
@@ -109,11 +115,25 @@ async def init(self, **kwargs: Any) -> None:
109
115
await self ._change_motion_status (MotionStatus .UNKNOWN )
110
116
raise exc .InitError ("Could not open dome." )
111
117
118
+ # waited >10s?
119
+ if time .time () - time_attempt > 10 :
120
+ await self ._send_open_dome ()
121
+ time_attempt = time .time ()
122
+
112
123
# set new status
113
124
log .info ("Dome opened." )
114
125
await self ._change_motion_status (MotionStatus .POSITIONED )
115
126
await self .comm .send_event (RoofOpenedEvent ())
116
127
128
+ async def _send_close_dome (self ) -> None :
129
+ """Send command to open dome."""
130
+ try :
131
+ await self ._device .put ("CloseShutter" )
132
+ await self ._device .put ("SlewToAzimuth" , Azimuth = 0 )
133
+ except ConnectionError :
134
+ await self ._change_motion_status (MotionStatus .UNKNOWN )
135
+ raise exc .ParkError ("Could not close dome." )
136
+
117
137
@timeout (1200000 )
118
138
async def park (self , ** kwargs : Any ) -> None :
119
139
"""Close dome.
@@ -134,12 +154,8 @@ async def park(self, **kwargs: Any) -> None:
134
154
await self .comm .send_event (RoofClosingEvent ())
135
155
136
156
# send command for closing shutter and rotate to South
137
- try :
138
- await self ._device .put ("CloseShutter" )
139
- await self ._device .put ("SlewToAzimuth" , Azimuth = 0 )
140
- except ConnectionError :
141
- await self ._change_motion_status (MotionStatus .UNKNOWN )
142
- raise exc .ParkError ("Could not close dome." )
157
+ await self ._send_close_dome ()
158
+ time_attempt = time .time ()
143
159
144
160
# wait for it
145
161
status = None
@@ -158,6 +174,11 @@ async def park(self, **kwargs: Any) -> None:
158
174
await self ._change_motion_status (MotionStatus .UNKNOWN )
159
175
raise exc .ParkError ("Could not close dome." )
160
176
177
+ # waited >10s?
178
+ if time .time () - time_attempt > 10 :
179
+ await self ._send_close_dome ()
180
+ time_attempt = time .time ()
181
+
161
182
# set new status
162
183
log .info ("Dome closed." )
163
184
await self ._change_motion_status (MotionStatus .PARKED )
0 commit comments