Powered by AppSignal & Oban Pro

Lesson 03 Livebook: Payload Bay

livebooks/03_payload_bay.livemd

Lesson 03 Livebook: Payload Bay

The hull is still one hull. The internals stop pretending to be one module.

Mix.install([
  {:helios_fleet, path: "../03_payload_bay"}
])

Application.ensure_all_started(:helios_fleet)

Helpers

defmodule Lesson03Helpers do
  alias HeliosFleet.Runtime

  def unique_agent_id(prefix) do
    "#{prefix}-#{System.unique_integer([:positive])}"
  end

  def safe_stop(agent_id) do
    case Runtime.whereis(agent_id) do
      nil -> :ok
      _pid -> Runtime.stop_agent(agent_id)
    end
  end
end

Push Work Through The Subsystems

alias HeliosFleet
alias Jido.AgentServer
alias Jido.Signal

probe_id = Lesson03Helpers.unique_agent_id("khepri")
{:ok, pid} = HeliosFleet.start_probe(probe_id)

{:ok, _probe} =
  AgentServer.call(
    pid,
    Signal.new!(
      "navigation.approach_solution_plotted",
      %{
        target: "ice fragment 6R",
        delta_v_mps: 18,
        burn_window_s: 240
      },
      source: "/nav/core"
    )
  )

{:ok, _probe} =
  AgentServer.call(
    pid,
    Signal.new!(
      "navigation.burn_authorized",
      %{
        source_window: "sol-echo-window-2"
      },
      source: "/orpheus/mission"
    )
  )

{:ok, _probe} =
  AgentServer.call(
    pid,
    Signal.new!(
      "sensors.contact_classified",
      %{
        target: "ice fragment 6R",
        classification: "volatile_ice",
        confidence: "medium"
      },
      source: "/sensor/mast"
    )
  )

{:ok, _probe} =
  AgentServer.call(
    pid,
    Signal.new!(
      "thermal.radiator_repositioned",
      %{
        posture: "shadow_spread",
        heat_load_kw: 6
      },
      source: "/thermal/loop"
    )
  )

payload_state = HeliosFleet.runtime_payload_snapshot(pid)

Lesson03Helpers.safe_stop(probe_id)

payload_state