def setup_ui(self): self.ui.setupUi(self) self.ui.id_read_only.setText("디바이스 아이디 : " + self.device_setting.id) set_control_setting_style(self.ui.auto_control_button, self.device_setting.auto_control) set_control_setting_style(self.ui.remote_control_button, self.device_setting.remote_control) self.ui.notice_wrong_label.setText("") self.ui.notice_wrong_label_2.setText("")
def setup_ui(self): self.ui.setupUi(self) self.ui.id_read_only.setText( "ID & PW : '" + self.device_setting.id + "' & '" + self.device_setting.password + "'") self.ui.notice_wrong_label.setText("") self.ui.notice_wrong_label_2.setText("") self.ui.change_setting_button.setText("설정 변경하기") self.ui.initial_button.setText("에너지 지킴이 초기화") set_control_setting_style(self.ui.auto_control_button, self.device_setting.auto_control) set_control_setting_style(self.ui.remote_control_button, self.device_setting.remote_control)
def init(self): self.page = 0 self.password = "" self.re_password = "" self.password_wrong = False self.device_setting.device_setting_init() self.ui.id_read_only.setText( "디바이스 그룹&아이디 : '" + self.device_setting.group + "' & '" + self.device_setting.id + "'") set_control_setting_style(self.ui.auto_control_button, self.device_setting.auto_control) set_control_setting_style(self.ui.remote_control_button, self.device_setting.remote_control)
def toggle_remote_control(self): self.remote_control = not self.remote_control if self.exist_message: self.exist_message = False self.ui.change_setting_button.setText("설정 변경하기") self.ui.notice_wrong_label.setText("") self.ui.notice_wrong_label_2.setText("") if self.is_initial: self.is_initial = False self.ui.initial_button.setText("에너지 지킴이 초기화") set_control_setting_style(self.ui.remote_control_button, self.remote_control)
def change_setting(self): is_pw = False password_is_change = False remote_control_is_change = False auto_control_is_change = False if self.is_initial: self.is_initial = False self.ui.initial_button.setText("에너지 지킴이 초기화") if self.remote_control is not self.device_setting.remote_control: self.device_setting.remote_control = self.remote_control remote_control_is_change = True if self.auto_control is not self.device_setting.auto_control: self.device_setting.auto_control = self.auto_control auto_control_is_change = True if len(self.password) > 0: is_pw = True if finish_set_password(self, self.ui.change_setting_button): if self.password is not self.device_setting.password: self.device_setting.password = self.password password_is_change = True else: self.exist_message = True else: if len(self.re_password) > 0: self.ui.password_re_edit.setText("") else: self.ui.notice_wrong_label.setText("") self.ui.notice_wrong_label_2.setText("") if password_is_change and not remote_control_is_change and not auto_control_is_change: self.ui.change_setting_button.setText("비밀번호가 변경되었습니다.") self.exist_message = True elif remote_control_is_change and not password_is_change and not auto_control_is_change: self.ui.change_setting_button.setText("원격 제어 설정이 변경되었습니다.") self.exist_message = True elif auto_control_is_change and not password_is_change and not remote_control_is_change: self.ui.change_setting_button.setText("자동 OFF 설정이 변경되었습니다.") self.exist_message = True elif remote_control_is_change and auto_control_is_change and not password_is_change: self.ui.change_setting_button.setText("원격 제어/자동 OFF 설정이 변경되었습니다.") self.exist_message = True elif password_is_change and remote_control_is_change and not auto_control_is_change: self.ui.change_setting_button.setText("원격제어 설정/비밀번호가 변경되었습니다.") self.exist_message = True elif password_is_change and auto_control_is_change and not remote_control_is_change: self.ui.change_setting_button.setText("자동 OFF 설정/비밀번호가 변경되었습니다.") self.exist_message = True elif password_is_change and auto_control_is_change and remote_control_is_change: self.ui.change_setting_button.setText("비밀번호/원격 제어/자동 OFF 설정이 변경되었습니다.") self.exist_message = True else: if not is_pw: self.ui.change_setting_button.setText("설정이 변경되지 않았습니다.") self.exist_message = True self.password = "" self.re_password = "" ## 라즈베리파이 설정 반영 if not password_is_change and not remote_control_is_change and auto_control_is_change: self.device_setting.write() return is_change = password_is_change or remote_control_is_change if is_change: if get_token(self.server, self.apis) is None: request_failed('GET_TOKEN') self.ui.change_setting_button.setText("오류가 발생했습니다. 설정 변경에 실패하였습니다.") self.exist_message = True self.device_setting.load_conf() set_control_setting_style(self.ui.auto_control_button, self.device_setting.auto_control) set_control_setting_style(self.ui.remote_control_button, self.device_setting.remote_control) else: res = self.apis.raspberry.put(self.server.token.access) if not res[0]: request_failed('RASPBERRY.PUT') self.ui.change_setting_button.setText("오류가 발생했습니다. 설정 변경에 실패하였습니다.") self.exist_message = True self.device_setting.load_conf() set_control_setting_style(self.ui.auto_control_button, self.device_setting.auto_control) set_control_setting_style(self.ui.remote_control_button, self.device_setting.remote_control) else: self.device_setting.write() self.ui.id_read_only.setText( "ID & PW : '" + self.device_setting.id + "' & '" + self.device_setting.password + "'") self.auto_control = self.device_setting.auto_control self.remote_control = self.device_setting.remote_control
def toggle_remote_control(self): self.device_setting.remote_control = not self.device_setting.remote_control set_control_setting_style(self.ui.remote_control_button, self.device_setting.remote_control)
def toggle_auto_control(self): self.device_setting.auto_control = not self.device_setting.auto_control set_control_setting_style(self.ui.auto_control_button, self.device_setting.auto_control)