diff --git a/Camera/IndiASICamera290MMMini.py b/Camera/IndiASICamera290MMMini.py new file mode 100644 index 0000000..5c16739 --- /dev/null +++ b/Camera/IndiASICamera290MMMini.py @@ -0,0 +1,19 @@ +# Basic stuff +import numpy as np + +# Local stuff +from Camera.IndiASICamera import IndiASICamera +from Camera.IndiASICameraNonCool import IndiASICameraNonCool + +class IndiASICamera290MMMini(IndiASICameraNonCool): + def __init__(self, serv_time, config=None, + connect_on_create=True): + + # Parent initialization + super().__init__( + serv_time=serv_time, + config=config, + connect_on_create=connect_on_create) + + def set_offset(self, value): + pass diff --git a/Camera/IndiAbstractCameraSimulator.py b/Camera/IndiAbstractCameraSimulator.py index c10ecbf..e3d898f 100644 --- a/Camera/IndiAbstractCameraSimulator.py +++ b/Camera/IndiAbstractCameraSimulator.py @@ -30,9 +30,4 @@ def initialize_simulation_setup(self): def unpark(self): IndiAbstractCamera.unpark(self) - self.initialize_simulation_setup() - - def set_cooling_on(self): - # This feels like a bug from the simulator ... - self.logger.warning(f"set_cooling_on working in async mode, as it seems to be a bug in simulator implementation") - self.set_switch('CCD_COOLER', ['COOLER_ON'], sync=False, timeout=self.defaultTimeout) + self.initialize_simulation_setup() \ No newline at end of file diff --git a/Camera/IndiCamera.py b/Camera/IndiCamera.py index bc1f999..00aab73 100644 --- a/Camera/IndiCamera.py +++ b/Camera/IndiCamera.py @@ -293,7 +293,8 @@ def set_temperature(self, temperature): sync=True, timeout=1200) def set_cooling_on(self): - self.set_switch('CCD_COOLER', ['COOLER_ON'], sync=True, timeout=self.defaultTimeout) + # No sync, because that's the way it works on indi for the CCD_COOLER property, it stays yellow in the interface + self.set_switch('CCD_COOLER', ['COOLER_ON'], sync=False) def set_cooling_off(self): self.set_switch('CCD_COOLER', ['COOLER_OFF'], sync=True, timeout=self.defaultTimeout) diff --git a/Mount/IndiAbstractMount.py b/Mount/IndiAbstractMount.py index 08a64e3..326aa27 100644 --- a/Mount/IndiAbstractMount.py +++ b/Mount/IndiAbstractMount.py @@ -89,10 +89,11 @@ def _setup_abstract_config(self): ############################################################################### # Mandatory overriden methods ############################################################################### - def initialize(self, *arg, **kwargs): # pragma: no cover - self.logger.debug(f"Initializing mount with args {arg}, {kwargs}") - self.connect() - self._is_initialized = True + + def initialize(self): + self.logger.debug("Initializing from IndiAbstractMount") + IndiMount.unpark(self) + self.logger.debug("Successfully initialized from IndiAbstractMount") def park(self): """ Slews to the park position and parks the mount. @@ -129,15 +130,10 @@ def unpark(self): self.start_indi_driver() self.connect(connect_device=True) self.initialize() - self._is_initialized = False + self._is_initialized = True self._is_parked = False self.logger.debug(f"Mount {self.device_name} successfully unparked") - def initialize(self): - self.logger.debug("Initializing from IndiAbstractMount") - IndiMount.unpark(self) - self.logger.debug("Successfully initialized from IndiAbstractMount") - def slew_to_coord(self, coord): self.slew_to_coord_and_track(coord) diff --git a/Mount/IndiG11.py b/Mount/IndiG11.py index 4f14132..7efb172 100644 --- a/Mount/IndiG11.py +++ b/Mount/IndiG11.py @@ -254,7 +254,7 @@ def initialize(self): #TODO TN URGENT as a temporary fix. we decided to park at startup but # the proper behaviour for the mount should be parked status by default # at startup, see https://indilib.org/forum/general/5497-indi-losmandy-driver-impossible-to-get-proper-park-status.html#41664 - IndiMount.park(self) + IndiMount.unpark(self) self.logger.debug("Successfully initialized from IndiG11") def set_time_config(self): @@ -308,4 +308,4 @@ def set_park_settings(self, mode='HOME'): def set_coord(self, coord): IndiMount.set_coord(self, coord) # Wait for the mount/tube to damper vibrations - time.sleep(5) \ No newline at end of file + time.sleep(10) \ No newline at end of file diff --git a/Observatory/AggregatedCustomScopeController.py b/Observatory/AggregatedCustomScopeController.py index 5dc4785..b0c7815 100644 --- a/Observatory/AggregatedCustomScopeController.py +++ b/Observatory/AggregatedCustomScopeController.py @@ -693,12 +693,13 @@ def park(self): self.logger.debug("Parking") # Power acquisition instruments: this is a very specific case, see https://github.com/indilib/indi-3rdparty/issues/822 - self.upbv2.power_off_acquisition_equipments() - time.sleep(1) - self.upbv2.switch_off_acquisition_equipments_usb() + if self.is_initialized: + self.upbv2.power_off_acquisition_equipments() + time.sleep(1) + self.upbv2.switch_off_acquisition_equipments_usb() - # Deinitialize arduino servo first (as it relies on upb power) - self.arduino_servo_controller.park() + # Deinitialize arduino servo first (as it relies on upb power) + self.arduino_servo_controller.park() # Deinitialize upbv2 self.upbv2.park() diff --git a/conf_files/config_backyard.yaml b/conf_files/config_backyard.yaml index fd55a1a..b75444f 100644 --- a/conf_files/config_backyard.yaml +++ b/conf_files/config_backyard.yaml @@ -153,7 +153,7 @@ mount: indi_port : 7625 cameras: - - module: IndiASICameraNonCool + module: IndiASICamera290MMMini camera_name : ZWO CCD ASI290MM Mini do_acquisition: false SCOPE_INFO: # 200/800 newtonian @@ -161,8 +161,8 @@ cameras: APERTURE: 200 sampling_arcsec: 0.88 do_guiding: true - do_pointing: true - pointing_seconds: 40 + do_pointing: false + pointing_seconds: 30 do_adjust_pointing: true adjust_center_x: 877 adjust_center_y: 637 @@ -174,14 +174,19 @@ cameras: autofocus_merit_function: half_flux_radius indi_client : indi_host : localhost - indi_port : 7625 + indi_port : 7627 #use_unique_client: True + indi_webmanager: + module: IndiWebManagerClient + host: localhost + port: 8627 + profile_name: zwo_guiding - module: IndiPlayerOneCamera camera_name : PlayerOne CCD Ares-M PRO indi_driver_name: PlayerOne CCD do_acquisition: true - working_temperature: -12 + working_temperature: 10 SCOPE_INFO: # 200/800 newtonian FOCAL_LENGTH: 800 APERTURE: 200 @@ -248,7 +253,7 @@ cameras: sampling_arcsec: 1.88 subsample_astrometry: 4 do_guiding: false - do_pointing: false + do_pointing: true pointing_seconds: 10 do_adjust_pointing: false adjust_center_x: 400 @@ -261,8 +266,12 @@ cameras: autofocus_merit_function: half_flux_radius #vollath_F4 indi_client: indi_host: localhost - indi_port: 7625 - + indi_port: 7628 + indi_webmanager: + module: IndiWebManagerClient + host: localhost + port: 8628 + profile_name: altair_pointing pointer: module: IterativeSync #DifferentialPointer #IterativeSync gen_hips: False @@ -270,7 +279,7 @@ pointer: max_iterations: 10 max_pointing_error_seconds: 10 offset_pointer: - module: StarOffsetPointer #StarOffsetPointer #NoOffsetPointer + module: StarOffsetPointer #StarOffsetPointer #NoOffsetPointer #InvisibleOffsetPointer timeout_seconds: 300 max_identification_error_seconds: 1 sync_mount_upon_solve: True @@ -282,7 +291,7 @@ guider: port : 4400 do_calibration : False profile_name : backyard - exposure_time_sec : 2 + exposure_time_sec : 8 settle : pixels : 3 time : 10 @@ -342,11 +351,6 @@ paws_publisher: mqtt_port: 1883 com_mode: publisher msg_port: 6500 -indi_webmanager: - module: IndiWebManagerClient - host: localhost - port: 8624 - profile_name: full_setup #independant_services: # - # module: NasaGCNService diff --git a/conf_files/spectral_targets.yaml b/conf_files/spectral_targets.yaml index 2c9d582..f75802e 100644 --- a/conf_files/spectral_targets.yaml +++ b/conf_files/spectral_targets.yaml @@ -3,41 +3,48 @@ constraints : maxairmass : 17 #for testing, normally use 2 minmoonseparationdeg : 2 # normally put 45 targets : -# "Altair" : #HD214680 #HD222404 + "Altair" : #HD214680 #HD222404 + priority : 0 + count : 1 + temperature : 10 + gain: 150 + offset: 30 + exp_time_sec : 20 + "Arcturus": + priority: 0 + count: 1 + temperature: 15 + gain: 150 + offset: 30 + exp_time_sec: 20 + "10 Lacertae": #HD214680 #HD222404 + priority: 0 + count: 1 + temperature: 15 + gain: 150 + offset: 30 + exp_time_sec: 20 + "Gamma Cassiopeiae" : + priority : 0 + count : 2 + temperature : 10 + gain: 150 + offset: 30 + exp_time_sec : 5 +# "T CrB" : # priority : 0 # count : 1 -# temperature : 15 +# temperature : 10 # gain: 150 # offset: 30 # exp_time_sec : 20 -# "Arcturus": -# priority: 0 -# count: 1 -# temperature: 15 -# gain: 150 -# offset: 30 -# exp_time_sec: 20 -# "10 Lacertae": #HD214680 #HD222404 -# priority: 0 -# count: 1 -# temperature: 15 -# gain: 150 -# offset: 30 -# exp_time_sec: 20 -# "T CrB" : +# "V375 Lac" : # priority : 0 -# count : 1 -# temperature : 15 +# count : 2 +# temperature : 10 # gain: 150 # offset: 30 -# exp_time_sec : 20 - "V375 Lac" : - priority : 0 - count : 2 - temperature : 15 - gain: 150 - offset: 30 - exp_time_sec : 5 +# exp_time_sec : 5 # "GK Per": # priority: 0 # count: 2 @@ -47,7 +54,7 @@ targets : # exp_time_sec: 5 reference_observation: count : 10 - temperature : 15 + temperature : 10 gain : 150 offset: 30 exp_time_sec : 20 diff --git a/helper/IndiClient.py b/helper/IndiClient.py index 7c2ba70..5a90a1b 100644 --- a/helper/IndiClient.py +++ b/helper/IndiClient.py @@ -79,7 +79,7 @@ def __init__(self, config): self.indi_webmanager_client = IndiWebManagerDummy() if "indi_webmanager" in config: - self.indi_webmanager_client = IndiWebManagerClient(config) + self.indi_webmanager_client = IndiWebManagerClient(config["indi_webmanager"]) # Start the main ioloop that will serve all async task in another (single) thread self.device_subscriptions = {} # dict of device_name: coroutines diff --git a/helper/IndiDevice.py b/helper/IndiDevice.py index 96e4e07..7dd81a8 100644 --- a/helper/IndiDevice.py +++ b/helper/IndiDevice.py @@ -6,6 +6,7 @@ # Indi stuff from helper.device import device, VectorHandler +from helper.IndiWebManagerClient import IndiWebManagerClient #Local from Base.Base import Base @@ -171,8 +172,10 @@ def _setup_indi_client(self): try: self.logger.debug(f"Setting up indi client") self.indi_client = IndiClient(config=self.indi_client_config) - except Exception: - raise RuntimeError('Problem setting up indi client') + except Exception as e: + msg = f"Problem setting up indi client for device {self.device_name}: {e}" + self.logger.error(msg) + raise RuntimeError(msg) def connect_client(self): """ @@ -231,8 +234,18 @@ def is_connected(self): return False def stop_indi_server(self): + # We could simply do like that: + # if self.indi_client is None: + # self._setup_indi_client() + # self.indi_client.indi_webmanager_client.start_server() + # But then in case of stopping, it could consume ressources for no reason if self.indi_client is not None: self.indi_client.indi_webmanager_client.stop_server() + else: + # Setup temporary webmanager client + if "indi_webmanager" in self.indi_client_config: + iwmc = IndiWebManagerClient(self.indi_client_config["indi_webmanager"]) + iwmc.stop_server() def start_indi_server(self): if self.indi_client is None: @@ -244,7 +257,6 @@ def start_indi_driver(self): driver_name=self.indi_driver_name, check_started=True) - def get_switch(self, name): return self.get_vector_dict(name) diff --git a/helper/IndiWebManagerClient.py b/helper/IndiWebManagerClient.py index 654cf03..6c537e0 100644 --- a/helper/IndiWebManagerClient.py +++ b/helper/IndiWebManagerClient.py @@ -92,7 +92,7 @@ def stop_server(self): req = f"{base_url}/api/server/stop" response = requests.post(req) self.logger.debug(f"stop_server - url {req} - code {response.status_code} - response:{response.text}") - assert response.status_code == 200 + assert response.status_code in [200, 500] # It's ok to stop an already stopped server except Exception as e: msg = f"Cannot start server: {e}" self.logger.error(msg) @@ -112,8 +112,8 @@ def get_running_driver(self): :return: """ try: - base_url = f"http://{self._indi_webserver_host}:" \ - f"{self._indi_webserver_port}" + base_url = f"http://{self.host}:" \ + f"{self.port}" req = f"{base_url}/api/server/drivers" response = requests.get(req) # self.logger.debug(f"get_running_driver - url {req} - code {response.status_code} - response :{response.text}") @@ -138,8 +138,8 @@ def restart_driver(self, driver_name): """ if self.is_driver_started(driver_name): try: - base_url = f"http://{self._indi_webserver_host}:" \ - f"{self._indi_webserver_port}" + base_url = f"http://{self.host}:" \ + f"{self.port}" req = f"{base_url}/api/drivers/restart/" \ f"{urllib.parse.quote(driver_name)}" response = requests.post(req) @@ -165,8 +165,8 @@ def start_driver(self, driver_name, check_started=True): if check_started and self.is_driver_started(driver_name): return try: - base_url = f"http://{self._indi_webserver_host}:" \ - f"{self._indi_webserver_port}" + base_url = f"http://{self.host}:" \ + f"{self.port}" req = f"{base_url}/api/drivers/start/" \ f"{urllib.parse.quote(driver_name)}" response = requests.post(req) @@ -191,8 +191,8 @@ def stop_driver(self, driver_name): try: # if driver_name not in ["ZWO CCD"]: #"Shelyak SPOX", "Arduino telescope controller", "ASI EAF", "Altair", "ZWO CCD" # return - base_url = f"http://{self._indi_webserver_host}:" \ - f"{self._indi_webserver_port}" + base_url = f"http://{self.host}:" \ + f"{self.port}" req = f"{base_url}/api/drivers/stop/" \ f"{urllib.parse.quote(driver_name)}" # self.logger.setLevel("DEBUG")