def __init__(self, telescope_plugin: str, mock: bool = False): self.mock = mock if not mock: from components.roof_control import RoofControl from components.button_control import ButtonControl else: from mock.roof_control import RoofControl # type: ignore from mock.button_control import ButtonControl # type: ignore telescopio = importlib.import_module(f"components.telescope.{telescope_plugin}.telescope") self.telescope = telescopio.Telescope() # type: ignore self.roof_control = RoofControl() self.n_step_corsa = config.Config.getInt('n_step_corsa', "encoder_step") self.curtain_east = FactoryCurtain.curtain(orientation=Orientation.EAST, mock=self.mock) self.curtain_west = FactoryCurtain.curtain(orientation=Orientation.WEST, mock=self.mock) self.panel_control = ButtonControl(GPIOPin.SWITCH_PANEL) self.power_tele_control = ButtonControl(GPIOPin.SWITCH_POWER_TELE) self.light_control = ButtonControl(GPIOPin.SWITCH_LIGHT) self.power_ccd_control = ButtonControl(GPIOPin.SWITCH_POWER_CCD) self.started = False self.alt_max_tend_e = config.Config.getInt("max_est", "tende") self.alt_max_tend_w = config.Config.getInt("max_west", "tende") self.alt_min_tend_e = config.Config.getInt("park_est", "tende") self.alt_min_tend_w = config.Config.getInt("park_west", "tende") self.prevSteps = {'east': self.alt_min_tend_e, 'west': self.alt_min_tend_w} # stabilisco il valore di increm per ogni tenda, increm corrisponde al # valore dell'angolo della tenda coperto da 1 step) self.increm_e = (self.alt_max_tend_e-self.alt_min_tend_e)/self.n_step_corsa self.increm_w = (self.alt_max_tend_w-self.alt_min_tend_w)/self.n_step_corsa self.crac_status = CracStatus()
def test_is_in_anomaly(self): cs = CracStatus() cs.curtain_east_status = CurtainsStatus.STOPPED self.assertTrue(cs.is_in_anomaly())
def test_create_crac_status_2(self): code = "OSS-036100992C000C000TSASSN" cs = CracStatus(code) self.assertEqual(cs.telescope_coords, {"alt": -3.61, "az": 9.92}) self.assertEqual(repr(cs), code)
def test_create_crac_status(self): code = "CPP0802012534A250S090SSSAAS" cs = CracStatus(code) self.assertEqual(cs.telescope_coords, {"alt": 80.20, "az": 125.34}) self.assertEqual(repr(cs), code)
def test_telescope_in_secure_and_roof_is_closing(self): cs = CracStatus() cs.telescope_status = TelescopeStatus.SECURE cs.roof_status = Status.CLOSING self.assertTrue(cs.telescope_in_secure_and_roof_is_closing)
def test_are_closed(self): cs = CracStatus() cs.curtain_east_status = CurtainsStatus.DISABLED cs.curtain_west_status = CurtainsStatus.DISABLED self.assertTrue(cs.are_curtains_disabled())
def test_are_in_danger(self): cs = CracStatus() cs.curtain_east_status = CurtainsStatus.DANGER self.assertTrue(cs.are_curtains_in_danger())