The Ptable Test page (page ID ptbl, title "Ptable test") is a developer page. It evaluates and graphs any Ptable of any aircraft model and option. The same file registers the self-test Check aircraft data. It is defined in common/page/ptableTest.js. The aircraft apps (C172, C182, PA28, Baron, Bonanza, Kodiak, TBM) import it for its side effect:
import './common/page/ptableTest.js';
The page is optional. The developer card of the Settings page shows a "Ptables / Show..." button only when the page exists. It requires the Aircraft page (ac) with its setAc(), selectAcOption() and unselectAcOption() methods, the acType system, and Ptables in the aircraft data. Its help topic is empty.
Opening the page changes the app's aircraft, so the page protects the user's state. On open it saves the application state (storage.getState()) and disables saving for the page. It then builds a catalog of every Ptable for every model: for the model alone, for the model with each selectable option installed, and for the model with each applicable combination option, whose member options are installed together. On close it releases the catalog, restores the saved state with ctl.restoreValues(), re-enables saving, and saves.
The user selects the current aircraft model (ptbl_selModelId), an option (ptbl_selOptionId, shown only if the model has options with their own tables), and the table to evaluate (ptbl_selTblId). A table ID is the table's path in the aircraft data, for example tko.rollTbl. Selecting a model installs it with the Aircraft page, and selecting an option installs only that option. A combination option is never selectable itself, so selecting one installs the options it combines, which is what applies its data; it is listed under its own ID (conventionally the member IDs joined with +). The page then shows:
ptbl_title);ptbl_test), or "none", and any failure of the check (ptbl_testError);ptbl_label0 to ptbl_label4). A table input whose interpolation type is match gets a selector (ptbl_match1 to ptbl_match3) with the table's values. Any other input gets a numeric input (ptbl_num1 to ptbl_num4). The inputs are set to their defaults when the table changes;ptbl_value), or the error message and the input key that caused the error (ptbl_errorMsg, ptbl_errorKey).A table is displayable as a graph if it has at least one input and its last input is not a match input. The graph plots the last input on the X axis and the table value on the Y axis, with a curve for each value of the second-to-last input, the table's knots, and a dot at the evaluated input. A table with more than two inputs is split into one graph for each combination of the leading input values. The Prev and Next buttons step through all displayable graphs across all models and options. Two checkboxes change the list:
ptbl_unique) skips tables that are functionally identical to an earlier table with the same table ID (for example, the same table in two options).ptbl_byTableId) sorts by table ID, then model, then option, so all instances of a table ID are visited together. The default order is model, option, table ID.The grid spacing for each axis comes from the axis quantity's grid ladder in ptableTest.js: a list of major and minor spacings, such as 1000/250, 2000/500, 5000/1000 and 10000/2000 ft for pressure altitude. The graph uses the smallest spacing that gives at most 10 major divisions, so a takeoff chart to 10,000 ft gets 1000/250 and a climb chart to 31,000 ft gets 5000/1000. The X axis quantity is the table's last input key, and the Y axis quantity is its output key. A quantity with no ladder, or whose range no ladder spacing fits, gets a spacing computed from its range. A table's test spec can set the spacing with displayOpts (see below): majorX, minorX, majorY, minorY.
The page file registers the unit test Check aircraft data (see the unitTest Reference), which runs with the other self-tests. For every model, it:
Option data for <model>;Check <tableId> values in <model>; and for each applicable combination option, with its member options installed together: Check <tableId> values in <model> with <comboId>. A table is checked once, in the first model and option where it is found.A table's test spec is its test property (see the Ptable Reference). Shared specs are exported from common/aero/ptableTests.js, the way shared state variable infos are, and imported by the aircraft data files:
import {distancePtableTest} from '../common/aero/ptableTests.js';
rollTbl: new Ptable({
title: `Takeoff ground roll`,
test: distancePtableTest,
inputs: [...],
...
}),
A spec is an object with the constraints on each input key, and optionally the graph grid:
export const distancePtableTest = {
assertions: {
pressureAltitude:['monoIncr'], densityAltitude:['monoIncr'], oat:['monoIncr'],
isa:['monoIncr'], weight:['monoIncr'], headwind:['monoDecr'],
},
};
Each constraint on an input must hold along that input at every chart value of the other inputs: monoIncr (the value never decreases as the input increases), monoDecr, monoSlopeIncr (the slope never decreases), and monoSlopeDecr. Where the curves along an input are charted at different values of the later inputs, each is interpolated at the others' chart values, and a point off a curve's chart is skipped. Inputs the spec names that the table doesn't have are ignored, so one spec serves tables that chart different inputs. A spec that names none of the table's inputs, or names a match input, fails. An app can make a stricter spec by spreading a shared one:
test: {assertions: {...serviceCeilingPtableTest.assertions, oat:['monoDecr', 'monoSlopeDecr']}},
Where the POH itself is not monotonic along an input, the table's spec leaves that input out, with a comment citing the POH page. A table built from another (createExtendedPtable(), or new Ptable() passing test: table.test) keeps its test.
All the state variables have the prefix ptbl_. None of the inputs is saved.
| State variable | Type | Description |
|---|---|---|
ptbl_selModelId |
selectorInput |
The selected aircraft model. |
ptbl_selOptionId |
selectorInput |
The selected option, or '' for none. |
ptbl_selTblId |
selectorInput |
The selected table ID. |
ptbl_match1 ... ptbl_match3 |
selectorInput |
Inputs for the table's match inputs, in order. |
ptbl_num1 ... ptbl_num4 |
numericInput |
Inputs for the table's numeric inputs, in order. |
ptbl_unique |
booleanInput |
Step through functionally unique tables only. |
ptbl_byTableId |
booleanInput |
Order the graphs by table ID. |
ptbl_title, ptbl_label0 ... ptbl_label4 |
textOutput |
The table title and input labels. |
ptbl_value |
numericOutput |
The evaluated table value. |
ptbl_errorMsg, ptbl_errorKey |
textOutput |
The interpolation error and the input key that caused it. |
ptbl_test, ptbl_testError |
textOutput |
The constraints the table's test checks, and any failure of the check. |
ptbl_graph |
svg |
The graph. |
ptbl_inputs |
modelObject |
The input state variables currently in use. |
ptbl_displayGraph |
modelValue |
True if the selected table is graphable. |