import time
import robot_movement as rm

robot = rm.RobotMovement()
good = 0
i = 1
duration = 30
start_time = time.time()
end_time = start_time + duration
while time.time() < end_time:
    data = robot.get_sensor_data()
    print(f"{i}. {data}")
    if data.count(0) <= 4 and data.count(999.0) == 0:
        good += 1
    elif data.count(0) > 4 or data.count(999.0) != 0:
        print(f"Pokazilo sa to na {i} meraní. Data: {data}")
        print(good)
        break
    i += 1

print(f"Good: {good}/{i-1}")
print(f"Average score: {good/(i-1):.2%}")
print(f"Total time: {time.time() - start_time:.2f} seconds")
print(f"Average measurements per second: {(i-1)/(time.time() - start_time):.2f}")
robot.close()