def update_disable_button_close_roof( self): # status: str, disabeld: str =''): """ Update disable button close roof""" Logger.getLogger().info( 'update_enable_disable_button_close_roof in gui') # self.win.FindElement('close-roof').Update(disabled=True) self.__toggle_button__(GuiKey.CLOSE_ROOF, disabled=True)
def update_status_sync(self, status, text_color: str = 'white', background_color: str = 'red') -> None: """ Update Sync Status """ Logger.getLogger().info('update_status_sync in gui') self.win.FindElement('status-sync').Update( status, text_color=text_color, background_color=background_color)
def update_status_tracking(self, status, text_color: str = 'white', background_color: str = 'red') -> None: """ Update Tracking Status """ Logger.getLogger().info('update_status_tracking in gui') self.win.FindElement('status-tracking').Update( status, text_color=text_color, background_color=background_color)
def update_status_roof(self, status: str, text_color: str = 'white', background_color: str = 'red') -> None: """ Update Roof Status """ Logger.getLogger().info('update_status_roof in gui') self.win.FindElement('status-roof').Update( status, text_color=text_color, background_color=background_color)
def update_status_curtain_west(self, status, text_color: str = 'white', background_color: str = 'red') -> None: """ Update Curtain West Status """ Logger.getLogger().info('update_status_curtain_west in gui') self.win.FindElement('status-curtain-west').Update( status, text_color=text_color, background_color=background_color)
def update_disable_panel_all(self): # status: str, disabeld: str =''): """ Update enable button on panel flat""" Logger.getLogger().info('update_disable_button_panel_flat_all') self.__toggle_button__( GuiKey.PANEL_ON, GuiKey.PANEL_OFF, disabled=True, button_color=["black", "red"]) #, tooltip="aridaje!! è già acceso!!")
def update_disable_panel_off(self): # status: str, disabeld: str =''): """ Update disable button off panel flat""" Logger.getLogger().info('update_disable_button_panel_flat_off') self.__toggle_button__(GuiKey.PANEL_ON, disabled=False, button_color=["black", "white"]) self.__toggle_button__(GuiKey.PANEL_OFF, disabled=True, button_color=["black", "red"])
def update_disable_button_power_off_ccd( self): # status: str, disabeld: str =''): """ Update enable button off auxiliary""" Logger.getLogger().info('update_disable_button_auxiliary_off') self.__toggle_button__(GuiKey.POWER_ON_CCD, disabled=False, button_color=["black", "white"]) self.__toggle_button__(GuiKey.POWER_OFF_CCD, disabled=True, button_color=["black", "red"])
def update_disable_button_light_off( self): # status: str, disabeld: str =''): """ Update enable button off light dome""" Logger.getLogger().info('update_disable_button_light_dome_off') self.__toggle_button__(GuiKey.LIGHT_ON, disabled=False, button_color=["black", "white"]) self.__toggle_button__(GuiKey.LIGHT_OFF, disabled=True, button_color=["black", "red"])
def update_disable_button_power_switch_off( self): # status: str, disabeld: str =''): """ Update disable button off power switch""" Logger.getLogger().info('update_disable_button_power_switch_off') self.__toggle_button__(GuiKey.POWER_ON_TELE, disabled=False, button_color=["black", "white"]) self.__toggle_button__(GuiKey.POWER_OFF_TELE, disabled=True, button_color=["black", "red"])
def update_enable_button_open_roof( self): # status: str, disabeld: str =''): """ Update enable button open roof""" Logger.getLogger().info( 'update_enable_disable_button_close_roof in gui') self.__toggle_button__(GuiKey.OPEN_ROOF, disabled=False) self.__toggle_button__(GuiKey.CLOSE_ROOF, GuiKey.ENABLED_CURTAINS, GuiKey.DISABLED_CURTAINS, GuiKey.CALIBRATE_CURTAINS, disabled=True)
def update_enable_disable_button( self ): # status: str, text_color: str = 'white', background_color: str = 'red') -> None: """ Update enable-disable button """ Logger.getLogger().info('update_enable_disable_button in gui') self.__toggle_button__(GuiKey.OPEN_ROOF, disabled=True) self.__toggle_button__(GuiKey.CLOSE_ROOF, GuiKey.ENABLED_CURTAINS, GuiKey.DISABLED_CURTAINS, GuiKey.CALIBRATE_CURTAINS, disabled=False)
def update_disable_panel_on(self): # status: str, disabeld: str =''): """ Update enable button on panel flat""" Logger.getLogger().info('update_disable_button_panel_flat_on') self.__toggle_button__(GuiKey.PANEL_ON, disabled=True, button_color=[ "white", "green" ]) #, tooltip="aridaje!! è già acceso!!") self.__toggle_button__( GuiKey.PANEL_OFF, disabled=False, button_color=[ "black", "white" ]) #, tooltip="premi per spegnere il pannello dei flat")
def update_button_sync(self, disabled): """ Disable Button Sync """ Logger.getLogger().info('update_disable_button_sync on gui') self.__toggle_button__(GuiKey.SYNC_TELE, disabled=disabled)
def update_disable_button_enabled_curtains(self): """ Update enable button curtains""" Logger.getLogger().info('update_enable_disable_button_curtains in gui') self.__toggle_button__(GuiKey.ENABLED_CURTAINS, disabled=True)
data = rcv.decode("UTF-8") LoggerClient.getLogger().debug("Data: %s", data) # # ROOF change_status(data[3], "Roof_open", win) change_status(data[4], "Roof_closed", win) # #CURTAINS W change_status(data[5], "Curtain_W_is_open", win) change_status(data[6], "Curtain_W_is_closed", win) # #CURTAINS W change_status(data[7], "Curtain_E_is_open", win) change_status(data[8], "Curtain_E_is_closed", win) change_encoder(data[9:12], "Count_W", win) change_encoder(data[12:], "Count_E", win) # The server's hostname or IP address HOST = config.Config.getValue("ip", "server") # The port used by the server PORT = config.Config.getInt("port", "server") while True: LoggerClient.getLogger().debug("connessione a: " + HOST + ":" + str(PORT)) key = connection() if key == "E": exit(0)
def connection() -> str: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) win = gui.create_win() while True: v, values = win.Read(timeout=5000) if not v: s.close() return GuiKey.EXIT roof = "S" curtain_west = "S" curtain_east = "S" panel = "S" power_tele = "S" light = "S" power_ccd = "S" for k, value in values.items(): if value: if k == "RO": roof = "O" elif k == "RC": roof = "C" elif k == GuiKey.PANEL_ON: panel = "A" elif k == GuiKey.PANEL_OFF: panel = "S" elif k is GuiKey.POWER_ON_TELE: power_tele = "A" elif k is GuiKey.POWER_OFF_TELE: power_tele = "S" elif k is GuiKey.LIGHT_ON: light = "A" elif k is GuiKey.LIGHT_OFF: light = "S" elif k is GuiKey.POWER_ON_CCD: power_ccd = "A" elif k is GuiKey.POWER_OFF_CCD: power_ccd = "S" elif k == "WO": curtain_west = "O" elif k == "WC": curtain_west = "C" elif k == "WS": curtain_west = "S" elif k == "EO": curtain_east = "O" elif k == "EC": curtain_east = "C" elif k == "ES": curtain_east = "S" code = roof + panel + power_tele + light + power_ccd + curtain_west + curtain_east LoggerClient.getLogger().debug("Code: %s", code) s.sendall(code.encode("UTF-8")) rcv = s.recv(15) data = rcv.decode("UTF-8") LoggerClient.getLogger().debug("Data: %s", data) # # ROOF change_status(data[3], "Roof_open", win) change_status(data[4], "Roof_closed", win) # #CURTAINS W change_status(data[5], "Curtain_W_is_open", win) change_status(data[6], "Curtain_W_is_closed", win) # #CURTAINS W change_status(data[7], "Curtain_E_is_open", win) change_status(data[8], "Curtain_E_is_closed", win) change_encoder(data[9:12], "Count_W", win) change_encoder(data[12:], "Count_E", win)
#!/usr/bin/env python # -*- coding: utf-8 -*- import time import sys from logger import LoggerClient if len(sys.argv) == 3: logger = LoggerClient(int(sys.argv[1]), int(sys.argv[2]), "lsetup.txt") logger.establish_connections() while True: time.sleep(30) print "making global backup at", \ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) logger.require_backups() else: print len(sys.argv) print "Execute o código da seguinte maneira:" print "python logger_cl.py M_KEY S_KEY"