def set_reset_area(self, command=None): if command is None: command = self.__computer.RESET_ALL_LIGHTS_ON if command == self.__computer.RESET_ALL_LIGHTS_ON: legend = "reset, command=RESET_ALL_LIGHTS_ON\n" elif command == self.__computer.RESET_ALL_LIGHTS_OFF: legend = "reset, command=RESET_ALL_LIGHTS_OFF\n" elif command == self.__computer.RESET_TOUCH_CONTROLS: legend = "reset, command=RESET_TOUCH_CONTROLS\n" else: legend = "reset, command=UNKNOWN COMMAND !!\n" print_error("Wrong command={}".format(command)) self.__save_line() cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_RESET cmd[2] = command self.__commands.append(Command(legend, cmd))
def set_get_status(self): legend = "set_get_status" cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_GET_STATUS self.__commands.append(Command(legend, cmd))
def __save_block(self): if self.__save: legend = "__save_block" cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_SAVE self.__commands.append(Command(legend, cmd))
def set_end_block_line(self): self.__save_block() legend = "end_block_line\n\n" cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_TRANSMIT_EXECUTE self.__commands.append(Command(legend, cmd))
def __save_line(self): if self.__save: legend = "__save_block, block={}".format(self.__block) cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_SAVE_NEXT cmd[2] = self.__block self.__commands.append(Command(legend, cmd))
def set_end_colors_line(self): self.__save_line() legend = "end_colors_line\n" cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_LOOP_BLOCK_END self.__hex_id += 1 self.__commands.append(Command(legend, cmd))
def on_button_send_custom_command_clicked(self, button, data=None): command_value = self.entry_custom_command.get_text() try: values = (int(val) for val in command_value.split(":")) except: gtk_append_text_to_buffer(self.textbuffer_block_testing, '\n' + "WRONG FORMAT" + '\n') constructor = (Command("Custom", values), ) try: self._testing_driver.write_constructor(constructor) except Exception: gtk_append_text_to_buffer(self.textbuffer_pyusb, '\n' + format_exc() + '\n') gtk_append_text_to_buffer(self.textbuffer_pyusb, command_value + "\n")
def add_light_zone(self, area_hex_id, color): self.__save_line() legend = '''add_light_zone: left_color={}, hex_id={}'''.format( color, area_hex_id) parsed_area_hex_id = self.__adapt_area_hex_id(area_hex_id) adapted_left_color = self.__adapt_left_color(color) cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_SET_COLOR cmd[2] = self.__hex_id cmd[3] = parsed_area_hex_id[0] cmd[4] = parsed_area_hex_id[1] cmd[5] = parsed_area_hex_id[2] cmd[6] = adapted_left_color[0] cmd[7] = adapted_left_color[1] self.__commands.append(Command(legend, cmd))
def set_speed(self, speed): speed = int(speed) if speed > 255: speed = 255 print_warning( "the speed can not be > 255, it will be set equal to 255.") elif speed < 0: speed = 0 print_warning( "The speed can not be < 0, it will be set equal to 0.") self.__save_line() legend = "set_speed, speed={}\n".format(speed) cmd = self.__get_cmd() cmd[0] = self.__computer.START_BYTE cmd[1] = self.__computer.COMMAND_SET_SPEED cmd[3] = int(speed) self.__commands.append(Command(legend, cmd))