def commit_settings(self, param): if param.name() in custom_tree.iter_children( self.settings.child(('infos')), []): actuator_socket = [ client['socket'] for client in self.connected_clients if client['type'] == 'ACTUATOR' ][0] send_string(actuator_socket, 'set_info') path = custom_tree.get_param_path( param )[2:] #get the path of this param as a list starting at parent 'infos' send_list(actuator_socket, path) #send value data = custom_tree.parameter_to_xml_string(param) send_string(actuator_socket, data)
def queue_command(self, command=ThreadCommand()): """ """ if command.command == "ini_connection": status = self.init_connection() elif command.command == "quit": try: self.socket.close() except Exception as e: pass finally: self.cmd_signal.emit(ThreadCommand('disconnected')) elif command.command == 'update_connection': self.ipaddress = command.attributes['ipaddress'] self.port = command.attributes['port'] elif command.command == 'data_ready': self.data_ready(command.attributes) elif command.command == 'send_info': path = command.attributes['path'] param = command.attributes['param'] param_xml = custom_tree.parameter_to_xml_string(param) send_string(self.socket, 'Info_xml') send_list(self.socket, path) # send value data = custom_tree.parameter_to_xml_string(param) send_string(self.socket, data) elif command.command == 'position_is': send_string(self.socket, 'position_is') send_scalar(self.socket, command.attributes[0]) elif command.command == 'move_done': send_string(self.socket, 'move_done') send_scalar(self.socket, command.attributes[0]) elif command.command == 'x_axis': send_string(self.socket, 'x_axis') x_axis = dict(label='', units='') if isinstance(command.attributes[0], np.ndarray): x_axis['data'] = command.attributes[0] elif isinstance(command.attributes[0], dict): x_axis.update(command.attributes[0].copy()) send_array(self.socket, x_axis['data']) send_string(self.socket, x_axis['label']) send_string(self.socket, x_axis['units']) elif command.command == 'y_axis': send_string(self.socket, 'y_axis') y_axis = dict(label='', units='') if isinstance(command.attributes[0], np.ndarray): y_axis['data'] = command.attributes[0] elif isinstance(command.attributes[0], dict): y_axis.update(command.attributes[0].copy()) send_array(self.socket, y_axis['data']) send_string(self.socket, y_axis['label']) send_string(self.socket, y_axis['units'])
def send_data(self, data_list): # first send 'Done' and then send the length of the list send_string(self.socket, 'Done') send_list(self.socket, data_list)