# blueboat_runtime_calculator.py

# Battery configuration
battery_voltage = 14.8        # volts

# For 8x smaller batteries:
battery_capacity_ah = 10      # amp-hours per battery
battery_count = 8             # number of batteries in parallel

# For 2x larger white batteries:
# battery_capacity_ah = 15.6      # amp-hours per battery
# battery_count = 2               # number of batteries in parallel

# Calculate total energy available (Wh)
total_capacity_ah = battery_capacity_ah * battery_count
total_energy_wh = battery_voltage * total_capacity_ah

# Device power draws (in watts)
thrusters_min_power = 80
thrusters_max_power = 120

raspberry_pi = 8
ins_rug3 = 3.5
mikrotik_radio = 6
norbit_wbms = 40
ethernet_switch = 1

# Comms systems
starlink = 35
rv55 = 3

# Travel speeds in m/s
thrusters_min_speed = 0.8
thrusters_max_speed = 1.0

# Calculate runtimes for both Starlink and RV55
def calculate_runtime(comms_power):
    total_power_min = thrusters_min_power + raspberry_pi + ins_rug3 + mikrotik_radio + comms_power + norbit_wbms + ethernet_switch
    total_power_max = thrusters_max_power + raspberry_pi + ins_rug3 + mikrotik_radio + comms_power + norbit_wbms + ethernet_switch
    runtime_min = total_energy_wh / total_power_max
    runtime_max = total_energy_wh / total_power_min
    return runtime_min, runtime_max

starlink_runtime = calculate_runtime(starlink)
rv55_runtime = calculate_runtime(rv55)

# Calculate max distances for RV55
rv55_runtime_min, rv55_runtime_max = rv55_runtime
distance_min_m_rv55 = thrusters_min_speed * rv55_runtime_min * 3600
distance_max_m_rv55 = thrusters_max_speed * rv55_runtime_max * 3600

# Calculate max distances for Starlink
starlink_runtime_min, starlink_runtime_max = starlink_runtime
distance_min_m_starlink = thrusters_min_speed * starlink_runtime_min * 3600
distance_max_m_starlink = thrusters_max_speed * starlink_runtime_max * 3600

# Output results
print(f"Battery configuration: {battery_count}x {battery_voltage}V {battery_capacity_ah}Ah (Total = {total_energy_wh:.1f} Wh)")
print()
print("Estimated runtimes:")
print(f"  Using Starlink (draws {starlink}W): {starlink_runtime[0]:.2f} – {starlink_runtime[1]:.2f} hours")
print(f"  Using RV55     (draws {rv55}W): {rv55_runtime_min:.2f} – {rv55_runtime_max:.2f} hours")
print()
print("Estimated max travel distance:")
print(f"  Using Starlink:")
print(f"    At 0.8 m/s (1.56 knots): {distance_min_m_starlink:.0f} meters")
print(f"    At 1.0 m/s (1.94 knots): {distance_max_m_starlink:.0f} meters")
print(f"  Using RV55:")
print(f"    At 0.8 m/s (1.56 knots): {distance_min_m_rv55:.0f} meters")
print(f"    At 1.0 m/s (1.94 knots): {distance_max_m_rv55:.0f} meters")
