SOCKET_PATH = "/tmp/compLib"


# def send(data, size):
#     with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
#         sock.connect(SOCKET_PATH)
#         sock.sendall(size.to_bytes(1, byteorder='big'))
#         sock.sendall(data)
#
#         response_size_bytes = sock.recv(1)
#         response_size = int.from_bytes(response_size_bytes, byteorder="big")
#         # print(f"Response size: {response_size}")
#
#         response_bytes = sock.recv(response_size)
#         generic_response = CompLib_pb2.GenericResponse()
#
#         generic_response.ParseFromString(response_bytes)
#         # print(f"Response: {generic_response}")
#
#         # reponseBytes =


def main():
    # encoder_read_positions_request = CompLib_pb2.EncoderReadPositionsRequest()
    # # readSensorsRequest.header = CompLib_pb2.Header()
    # encoder_read_positions_request.header.message_type = encoder_read_positions_request.DESCRIPTOR.full_name
    #
    # start_time = time.time()
    # for i in range(100000):
    #     send(encoder_read_positions_request.SerializeToString(), encoder_read_positions_request.ByteSize())
    # print("--- %s seconds ---" % (time.time() - start_time))

    # from compLib.IRSensor import IRSensor
    # IRSensor.read_all()
    #
    # from compLib.Encoder import Encoder
    # print(Encoder.read_all_positions())
    # print(Encoder.read_all_velocities())

    # from compLib.Motor import Motor
    # Motor.speed(0, 50)
    # Motor.speed(3, -50)
    #
    # import time
    # time.sleep(2)
    #
    # Motor.speed(0, 0)
    # Motor.speed(3, -0)

    # Motor.power(0, 0)
    # Motor.power(3, 0)

    # import math
    # from compLib.Movement import Movement
    # Movement.turn_degrees(90, math.pi * 2)
    # Movement.turn_degrees(-90, math.pi * 2)
    #
    # Movement.turn_degrees(90, math.pi * 2)
    # Movement.turn_degrees(90, -math.pi * 2)
    #
    # Movement.turn_degrees(90, math.pi * 2)
    # Movement.turn_degrees(-90, -math.pi * 2)

    # from compLib.Movement import Movement
    # Movement.drive_distance(0.1, 0.5)
    # Movement.drive_distance(-0.1, 0.5)
    #
    # Movement.drive_distance(0.1, 0.5)
    # Movement.drive_distance(0.1, -0.5)
    #
    # Movement.drive_distance(0.1, 0.5)
    # Movement.drive_distance(-0.1, -0.5)

    from compLib.Movement import Movement
    import math
    Movement.drive_distance(0.5, 0.5)
    Movement.turn_degrees(90, math.pi * 2)

    Movement.drive_distance(0.5, 0.5)
    Movement.turn_degrees(90, math.pi * 2)

    Movement.drive_distance(0.5, 0.5)
    Movement.turn_degrees(90, math.pi * 2)

    Movement.drive_distance(0.5, 0.5)
    Movement.turn_degrees(90, math.pi * 2)


if __name__ == '__main__':
    main()
