def __keyboard_movement_instruction(self, window, event): """ Sends movement instruction to facade Keyword arguments: window -- object the action occured on event -- contains information about the key press event """ direction_conversion = { ord("a"): (-1, 0, 0), ord("d"): (1, 0, 0), ord("w"): (0, 1, 0), ord("s"): (0, -1, 0), ord("W"): (0, 1, 0), ord("S"): (0, -1, 0), ord("A"): (-1, 0, 0), ord("D"): (1, 0, 0), ord("e"): (0, 0, 1), ord("q"): (0, 0, -1), } speed_change = {45: -1, 43: 113} key_pressed = event.keyval if key_pressed in direction_conversion and self.__keyboard_input: self.__activate_arrow(key_pressed) direction = direction_conversion[key_pressed] direction = [x for x in direction] facade.move(direction, self.__x_axis_inverted, self.__y_axis_inverted) elif key_pressed in speed_change and self.__keyboard_input: facade.change_speed(None, speed_change[key_pressed])
def __keyboard_movement_instruction(self, window, event): """ Sends movement instruction to facade Keyword arguments: window -- object the action occured on event -- contains information about the key press event """ direction_conversion = {97: (-1, 0, 0), 100: (1, 0, 0), 119: (0, 1, 0), 115: (0, -1, 0), 101: (0, 0, 1), 113: (0, 0, -1)} speed_change = {45 : -1, 43 : 1} key_pressed = event.keyval if key_pressed in direction_conversion and self.__keyboard_input: direction = direction_conversion[key_pressed] direction = [x for x in direction] facade.move(direction, self.__x_axis_inverted, self.__y_axis_inverted) elif key_pressed in speed_change and self.__keyboard_input: facade.change_speed(None, speed_change[key_pressed])
def __open_actuator_setup_window(self, menu_item): """ Opens the actuator setup window Keyword arguments: menu_item -- object the action occured on """ # set the combo box values com_port_combo = self.__builder.get_object("com_port_combo") available_com_ports = facade.get_available_com_ports() com_port_liststore = self.__builder.get_object("com_port_liststore") com_port_liststore.clear() for com_port_info in available_com_ports: com_port_combo.append_text(com_port_info[0]) com_port_combo.set_active(0) # set the current actuator step value in the textbox actuator_step_entry = self.__builder.get_object("actuator_step_entry") actuator_step_entry.set_text(str(facade.get_speed())) actuator_setup_window = self.__builder.get_object("actuator_setup_window") # do not listen for close events in order for the close button on the # window to work, as you are unable to add a signal to the close button actuator_setup_window.run() actuator_setup_window.hide() # sets the com-port for the actuators facade.set_com_port(com_port_combo.get_active_text()) # sets the actuator step actuator_step = actuator_step_entry.get_text() if actuator_step.isdigit(): facade.change_speed(int(actuator_step), None) else: log.log_error( "The magnitude of actuator step must be an integer," " '{0}' is not an integer.".format(magnitude) ) # switches the actuator axis if the box was checked switch_actuator_axis = self.__builder.get_object("switch_actuator_axis") if switch_actuator_axis.get_active(): facade.switch_actuator_axis() switch_actuator_axis.set_active(False)
def __open_actuator_setup_window(self, menu_item): """ Opens the actuator setup window Keyword arguments: menu_item -- object the action occured on """ #set the combo box values com_port_combo = self.__builder.get_object("com_port_combo") available_com_ports = facade.get_available_com_ports() com_port_liststore = self.__builder.get_object("com_port_liststore") com_port_liststore.clear() for com_port_info in available_com_ports: com_port_combo.append_text(com_port_info[0]) com_port_combo.set_active(0) #set the current actuator step value in the textbox actuator_step_entry = self.__builder.get_object("actuator_step_entry") actuator_step_entry.set_text(str(facade.get_speed())) actuator_setup_window = self.__builder.get_object("actuator_setup_window") # do not listen for close events in order for the close button on the # window to work, as you are unable to add a signal to the close button actuator_setup_window.run() actuator_setup_window.hide() #sets the com-port for the actuators facade.set_com_port(com_port_combo.get_active_text()) #sets the actuator step actuator_step = actuator_step_entry.get_text() if actuator_step.isdigit(): facade.change_speed(int(actuator_step), None) else: log.log_error("The magnitude of actuator step must be an integer,"\ " '{0}' is not an integer.".format(magnitude)) #switches the actuator axis if the box was checked switch_actuator_axis = self.__builder.get_object("switch_actuator_axis") if switch_actuator_axis.get_active(): facade.switch_actuator_axis() switch_actuator_axis.set_active(False)