except Exception as error:
self.IDMessage(f"IUUpdate error: {error}")
raise
-
-
+
+ # ABS_FOCUS_POSITION - request a focuser move to
+ # FOCUS_ABSOLUTE_POSITION ticks
+
+ if name == "ABS_FOCUS_POSITION":
+ try:
+
+ # Update our idea of the request
+
+ focpos = self.IUUpdate(device, name, names, values)
+ focposval = focpos["FOCUS_ABSOLUTE_POSITION"].value
+
+ # Assuming 0 is the bottom of the focuser travel
+ # we move to the new position
+
+ curpos = self.motor.get_position()
+ self.motor.run_for_degrees(focposval-curpos, blocking=False)
+
+ # We now need to set the state to Busy until the motor
+ # stops running.
+
+ focpos.state='Busy'
+ self.IDSet(focpos)
+
+ # And set a callback to return to OK when the motor
+ # has finished
+
+ self.IEAddTimer(100, self.checkmotoridle)
+
+ except Exception as error:
+ self.IDMessage(f"IUUpdate error: {error}")
+ raise
+
if name == "FOCUS_TIMER":
try:
self.motor = Motor(portval)
conn.state = "Ok"
self._is_connected = True
-
+
self.IDSet(conn)
except Exception as error:
focpos = self.IUFind("REL_FOCUS_POSITION")
focpos.state = "Ok"
self.IDSet(focpos)
+ focpos = self.IUFind("ABS_FOCUS_POSITION")
+ focpos.state = "Ok"
+ self.IDSet(focpos)
else:
self.IEAddTimer(100, self.checkmotoridle)
+ def run_until_resistance(self):
+
+ # run motor until it appears it encounters resistance
+ # returns number of degrees travelled
+
+ # Initial absolute position of motor
+
+ ipos = self.motor.get_aposition()
+ pos = ipos
+ revs = 0
+
+ while abs(pos-ipos) < 15:
+ self.motor.run_for_degrees(360)
+ self.motor.run_to_position(ipos)
+ pos = self.motor.get_position()
+ revs += 1
+
+ return revs
+
def update_speed_direction(self):
# Absolute speed