<% content_for :title, "#{@aircraft.tail_number} Loading setup" %> <%= render "shared/aircraft_header", aircraft: @aircraft %> <% stations = @setup.stations + Array.new([ 8 - @setup.stations.size, 2 ].max) { nil } %> <% points = @setup.entered_envelope + Array.new([ 10 - @setup.envelope.size, 2 ].max) { nil } %> <%= form_with url: aircraft_loading_setup_path(@aircraft), method: :patch, class: "card card-body max-w-3xl space-y-5" do %>

Loading setup

From the POH's weight and balance section. Arms are inches aft of the datum.

<% if @setup.errors.any? %> <% end %>
Stations
NameArm (in)Max (lb/gal)Fuel
<% stations.each_with_index do |st, i| %>
<%= text_field_tag "setup[stations][#{i}][name]", st&.name, class: "input", placeholder: ("Front seats" if i.zero?), "aria-label": "Station #{i + 1} name" %> <%= text_field_tag "setup[stations][#{i}][arm]", st&.arm&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Station #{i + 1} arm" %> <%= text_field_tag "setup[stations][#{i}][max]", st&.max&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Station #{i + 1} maximum" %> <%= check_box_tag "setup[stations][#{i}][fuel]", "1", st&.fuel, class: "mx-auto block h-4 w-4", "aria-label": "Station #{i + 1} is fuel" %>
<% end %>

Tick "Fuel" for fuel tanks: their quantity is entered in gallons and the max is the usable capacity in gallons. Other maximums are in pounds.

<%= label_tag "setup[fuel_lb_per_gal]", "Fuel weight (lb per gallon)", class: "label" %> <%= text_field_tag "setup[fuel_lb_per_gal]", @setup.fuel_lb_per_gal.to_s.sub(/\.0\z/, ""), class: "input", inputmode: "decimal" %>

6 for avgas, 6.7 for Jet-A.

CG envelope

The corners of the normal-category envelope, in order around it (e.g. forward limit at low weight, forward limit at gross, aft limit at gross, aft limit at low weight).

<%= label_tag "setup[envelope_unit]", "Envelope values are", class: "label" %> <%= select_tag "setup[envelope_unit]", options_for_select(LoadingSetup::ENVELOPE_UNITS.invert, @setup.envelope_unit), class: "input" %>

Use the same units as your source: a POH “moment envelope” chart or Garmin Pilot give moment in lb-in/1000 (e.g. 2300 lb at 104.5). Moments are converted to CG (moment × 1000 ÷ weight) when saved. Changing this and saving reads the numbers below in the new units, so it also fixes moments typed in as CG.

Weight (lb)<%= @setup.moment? ? "Moment (lb-in/1000)" : "CG (in)" %><%= "= CG (in)" if @setup.moment? %>
<% points.each_with_index do |pt, i| %>
<%= text_field_tag "setup[envelope][#{i}][weight]", pt&.first&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Envelope point #{i + 1} weight" %> <%= text_field_tag "setup[envelope][#{i}][cg]", pt&.last&.to_s&.sub(/\.0\z/, ""), class: "input", inputmode: "decimal", "aria-label": "Envelope point #{i + 1} #{@setup.moment? ? 'moment' : 'CG'}" %> <%= "#{@setup.envelope[i].last.round(2)} in" if @setup.moment? && @setup.envelope[i] %>
<% end %>
<%= submit_tag "Save", class: "btn-primary" %><%= link_to "Cancel", aircraft_weight_balance_records_path(@aircraft), class: "btn-secondary" %>
<% end %>