From fc092b385c8abdae5c69a68953c9fa3adc6ba6b9 Mon Sep 17 00:00:00 2001 From: Alain Klotz Date: Thu, 17 Dec 2020 18:32:08 +0100 Subject: [PATCH] Mise à jour de TNC Raspberry. --- mount_tnc/raspberry/mountastro.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- mount_tnc/raspberry/universalpad.py | 60 ++++++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 88 insertions(+), 23 deletions(-) diff --git a/mount_tnc/raspberry/mountastro.py b/mount_tnc/raspberry/mountastro.py index eb5775c..e657345 100644 --- a/mount_tnc/raspberry/mountastro.py +++ b/mount_tnc/raspberry/mountastro.py @@ -843,7 +843,7 @@ class Mountastro(Mounttools): axisb.simu_motion_start("CONTINUOUS", frame='ang', drift=ha_drift_deg_per_sec) axisp.simu_motion_start("CONTINUOUS", frame='ang', drift=dec_drift_deg_per_sec) # === Real hardware - err, res = self._my_hadec_move_stop(ha_drift_deg_per_sec, dec_drift_deg_per_sec) + err, res = self._my_hadec_move_stop() return err, res def _my_hadec_stop(self): @@ -1326,6 +1326,55 @@ class Mountastro(Mounttools): self.radec_init(self._lx200_setra_deg, self._lx200_setdec_deg) elif command.startswith(":MS")==True: self.radec_goto(self._lx200_setra_deg, self._lx200_setdec_deg) + if self._remote_command_protocol=="astromecca": + if command.startswith(chr(6))==True: + res = "P" + elif command.startswith(":Gg")==True: + deg = self.site.longitude + res = celme.Angle(deg).sexagesimal("d +0180") + res = res[0:4] + "*" + res[5:7] + """ + while True: + # --- read the ASCOM commands + lignes = "" + try: + err, lignes = ascom_chan.read_chan() + #print("lignes = {}".format(lignes)) + lignes = str(lignes[0]) + except: + pass + if err==ascom_chan.NO_ERROR and lignes != "": + mount_scx11.log.print("===\nlignes recu ={}".format(lignes)) + mots = lignes.split() + mount_scx11.log.print("mots recus ={}".format(mots)) + msg = "" + # --- traiter la ligne recue de ASCOM + if lignes.startswith("READ_RA")==True: + # --- on traite un goto + ra, dec, side = mount_scx11.radec_coord(UNIT_RA="deg") + mount_scx11.log.print("{} ra={}".format(mots[0],ra)) + msg = str( float(ra)/15.) + if lignes.startswith("READ_DEC")==True: + # --- on traite un goto + ra, dec, side = mount_scx11.radec_coord(UNIT_DEC="deg") + mount_scx11.log.print("{} dec={}".format(mots[0],dec)) + msg = str(dec) + # --- traiter la ligne recue de ASCOM + if lignes.startswith("GOTO_RA_DEC")==True: + ra = float(mots[1])*15. + dec = float(mots[2]) + mount_scx11.log.print("{} ra={} dec={}".format(mots[0],ra,dec)) + mount_scx11.radec_goto(ra, dec, EQUINOX="NOW") + if lignes.startswith("PARK")==True: + ha = 270.0 + dec = 90.0 + side = 1 + mount_scx11.log.print("{} ha={} dec={} side={}".format(mots[0],ra,dec,side)) + mount_scx11.hadec_goto(ha, dec, side=side) + # --- send the EQMOD answer to ASCOM + mount_scx11.log.print("msg renvoyé ={}".format(msg)) + ascom_chan.put_chan(msg) + """ else: pass if res=="": diff --git a/mount_tnc/raspberry/universalpad.py b/mount_tnc/raspberry/universalpad.py index cd8ec8c..221f954 100644 --- a/mount_tnc/raspberry/universalpad.py +++ b/mount_tnc/raspberry/universalpad.py @@ -220,7 +220,9 @@ class UniversalPadRepeat(Thread): try: self._myself.pad_cbk_compute_lst() self._myself.pad_cbk_compute_coord() + #print("ok 1001") except: + #print("pb 1001") pass time.sleep(0.5) msg = "The thread UniversalPadRepeat termined properly" @@ -250,7 +252,7 @@ class UniversalPad(): # --- configuration depending the computer if hostname == "titanium": print("Configuration = {}".format(hostname)) - port_serial_scx11='//./com6' ; # '//./com4' + port_serial_scx11='//./com12' ; # '//./com4' port_serial_aux='//./com1' elif hostname == "rapido2": print("Configuration = {}".format(hostname)) @@ -275,12 +277,18 @@ class UniversalPad(): # --- shortcuts self._themount_axisb = self._themount.axis[Mountaxis.BASE] self._themount_axisp = self._themount.axis[Mountaxis.POLAR] - # --- simulation or not - self._themount_axisb.real = False + # --- simulation or not + mount_mode = self.padconfig['mount_mode'] + if mount_mode=="simulation": + mount_mode_real = False + else: + mount_mode_real = True + print("mount_mode={}".format(mount_mode)) + self._themount_axisb.real = mount_mode_real self._themount_axisb.ratio_wheel_puley = 6.32721 self._themount_axisb.inc_per_motor_rev = 1540 # DPR for -490000 to +490000 self._themount_axisb.senseinc = 1 - self._themount_axisp.real = False + self._themount_axisp.real = mount_mode_real self._themount_axisp.ratio_wheel_puley = 6.8262 self._themount_axisp.inc_per_motor_rev = 1421 self._themount_axisp.senseinc = -1 @@ -336,8 +344,8 @@ class UniversalPad(): self._themount.hadec_goto(ha, dec, side=theside, blocking=False) def pad_cbk_name2coord(self): - name =self.pad_var_object_name.get() with lock: + name =self.pad_var_object_name.get() tools = Mounttools() found, ra, dec= tools.name2coord(name) if found==1: @@ -363,26 +371,29 @@ class UniversalPad(): self._themount.radec_goto(ra, dec, side=theside, blocking=False) def pad_cbk_compute_coord(self): + # --- do not lock this function !!! err = self.NO_ERROR - with lock: - try: - if self._themount!=None: + try: + if self._themount!=None: + with lock: ha, dec, side = self._themount.hadec_coord() - else: - ha, dec, side = (0, 0, 0) - coord = "H.A.="+str(ha)+" Dec="+str(dec)+" "+str(side) - self.pad_var_coord.set(coord) - # - if self._themount!=None: + else: + ha, dec, side = (0, 0, 0) + coord = "H.A.="+str(ha)+" Dec="+str(dec)+" "+str(side) + self.pad_var_coord.set(coord) + # + if self._themount!=None: + with lock: ra2000, dec2000, side_radec = self._themount.radec_coord(EQUINOX="J2000") - else: - ra2000, dec2000, side_radec = (0, 0, 0) - coord = "R.A.="+str(ra2000)+" Dec="+str(dec2000)+" "+str(side_radec) - self.pad_var_radec_coord.set(coord) - except: - print("pb coord") - ha, dec, side = (0,0,0) - err= self.ERR_UNKNOWN + else: + ra2000, dec2000, side_radec = (0, 0, 0) + coord = "R.A.="+str(ra2000)+" Dec="+str(dec2000)+" "+str(side_radec) + self.pad_var_radec_coord.set(coord) + print("pad_cbk_compute_coord={}".format(coord)) + except: + print("pb coord") + ha, dec, side = (0,0,0) + err= self.ERR_UNKNOWN return err, ha, dec, side def pad_cbk_coord_detailed(self): @@ -450,6 +461,10 @@ class UniversalPad(): self._themount.goto_park() def pad_cbk_quit(self): + try: + self._themount.close_chan() + except: + pass self.pad_gui_delete() def pad_cbk_console(self, event): @@ -518,6 +533,7 @@ class UniversalPad(): lst_hms = ang.sexagesimal("H0.0") self.pad_var_date.set("UTC {}".format(dateiso)) self.pad_var_lst.set("Local Sideral Time {}".format(lst_hms)) + lock.release() def pad_gui_delete(self): # --- kill the threads -- libgit2 0.21.2