Skip to content

Commit

Permalink
change code in guide_on
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjeon committed Mar 22, 2022
1 parent 14d4325 commit b66ea90
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
19 changes: 12 additions & 7 deletions python/lvmagp/actor/commands/test.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
from lvmagp.actor.commfunc import LVMTelescopeUnit

sci = LVMTelescopeUnit("sci")

sci.fine_autofocus()
sci.goto_eq(8, -38)
sci.guide_on()

import time
def my_exposure(exptime):
print("my_exposure Start")
time.sleep(exptime)
print("my_exposure Done")
return True

res = my_exposure(60)
sci = LVMTelescopeUnit("sci")

# autofocus
sci.fine_autofocus()

# slew
sci.goto_eq(11, -25)

# autoguide
sci.guide_on()

# kill autoguide loop
res = my_exposure(10)
if (res):
sci.guide_off()
22 changes: 7 additions & 15 deletions python/lvmagp/actor/commfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,11 +1065,7 @@ def dither(self, delta_x=None, delta_y=None, delta_pa=None):

pass


def handler(self, signum, frame):
self.guide_off()

def guide_on(self, timeout=None, useteldata=False, guide_parameters=None):
def guide_on(self, useteldata=False, guide_parameters=None):
'''
Start guiding, or modify parameters of running guide loop. <--- modify????
guide_parameters is a dictionary containing additional parameters for
Expand All @@ -1093,23 +1089,14 @@ def guide_on(self, timeout=None, useteldata=False, guide_parameters=None):
f"{datetime.datetime.now()} | (lvmagp) Autoguide Start"
)

signal.signal(signal.SIGINT, self.handler)
if timeout is not None:
signal.signal(signal.SIGALRM, self.handler)
signal.alarm(timeout)

try:
t = Thread(target=self.autoguide_supervisor, args=(useteldata, ))
t.setDaemon(True)
t.start()

except Exception as e:
self.amqpc.log.error(f"{datetime.datetime.now()} | {e}")
raise
# if self.ag_break:
# self.amqpc.log.debug(
# f"{datetime.datetime.now()} | (lvmagp) Autoguide Done"
# )

# finally:
# self.ag_task = None

Expand All @@ -1122,6 +1109,7 @@ def guide_off(self):
'''
if self.ag_task is not None:
self.ag_break = True
self.ag_task = None
else:
return self.amqpc.log.error(
f"There is no autoguiding loop for telescope {self.name}"
Expand Down Expand Up @@ -1238,12 +1226,16 @@ def autoguide_supervisor(self, useteldata):
"""
initposition, initflux = self.find_guide_stars()

# counter = 0
while 1:
print("autoguiding loop Start")
self.autoguiding(
initposition,
initflux,
useteldata,
)
print("autoguiding loop Done")
# counter = counter + 1

if self.ag_break:
self.ag_break = False
Expand Down
2 changes: 1 addition & 1 deletion python/lvmagp/actor/user_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class usrpars:
park_az_d = -999

# autofocus parameters
af_incremental = 10000 # step size for each movement
af_incremental = 100 # step size for each movement
af_repeat = 5 # the number of steps
af_exptime = 3 # in seconds

Expand Down

0 comments on commit b66ea90

Please sign in to comment.