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 and for the model with each selectable option installed. On close it releases the catalog, restores the saved state (ctl.resetAppValues() followed by ctl.setSavedState()), 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. The page then shows:
ptbl_title);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 comes from the displayOpts of the table's own info or of the matching ptableTests entry (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>;acData.ptableTests: Ptable tests for <model>. A model without it fails the test;ptableTests entries: Check <tableId> values in <model>.The ptableTests property of the aircraft data is an array of objects:
ptableTests: [
{
tables: ['tko.rollTbl', 'ldg.rollTbl'], // table IDs
assertions: {
weight: ['monoIncr', 'monoSlopeIncr'], // constraints on each input key
oat: ['monoIncr', 'monoSlopeIncr'],
pressureAltitude: ['monoIncr'],
},
displayOpts: {majorX:1000, minorX:250, majorY:500, minorY:100},
},
]
For each table, the first entry that lists its table ID applies. The assertions keyed by the table's last input key are checked on every array of knots of the table: monoIncr (the value never decreases as the input increases), monoDecr, monoSlopeIncr (the slope never decreases), and monoSlopeDecr. Tables with no assertion for their last input key are not checked. The displayOpts object sets the graph grid for the Ptable Test page.
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_graph |
svg |
The graph. |
ptbl_inputs |
modelObject |
The input state variables currently in use. |
ptbl_displayGraph |
modelValue |
True if the selected table is graphable. |