def __init__(self, comm): get_client_socket( ) # this is not used for Bluetooth, but to force a connection to the simulator (startup # sequence) self.port = int( get_simulation_settings()['exec_settings']['bluetooth_port']) self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def test_serialize_deserialize(self): server_thread = threading.Thread(target=self.run_fake_server) server_thread.start() msg_length = get_simulation_settings()['exec_settings']['message_size'] from ev3dev2simulator.connection.client_socket import get_client_socket sock = get_client_socket() command = RotateCommand('test_port', 500.0, 100.0, 'hold') sock.send_command(command) ser = sock.serialize(command) unpadded = ( b'{"type": "RotateCommand", "address": "test_port", "speed": 500.0, "distance": 100.0, ' b'"stop_action": "hold"}') expected = unpadded.ljust(msg_length, b'#') self.assertEqual(ser, expected) ser = b'{"value": 15}' deser = sock.deserialize(ser) self.assertEqual(deser, 15) sock.client.send(str.encode('close_test_server')) sock.client.close() server_thread.join()
def __init__(self, address: str, max_speed: int): self.address = address self.max_speed = max_speed self.duty_cycle = None self.speed = None self.distance = None self.time = None self.stop_action = None self.client_socket = get_client_socket()
def __init__(self, address: str): self.address = address if address is None: raise RuntimeError('created connector with None as address') self.client_socket = get_client_socket() self.wait_time = 0.008 self.frame_time = 1 / int( get_simulation_settings()['exec_settings']['frames_per_second']) self.last_request_time = 0 self.value_cache = None self.delta_sum = 0
def __init__(self, play_actual_sound=True): self.client_socket = get_client_socket() self.play_actual_sound = play_actual_sound
def __init__(self, address): self.address = address self.client_socket = get_client_socket()
def __init__(self, address, class_name): self.address = address self.class_name = class_name self.client_socket = get_client_socket()