zkv1000 / Nasal / EIS / single-prop.nas /
cfe58f1 7 years ago
1 contributor
50 lines | 2.404kb
displayClass.showEIS = func (groups) {
    canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/EIS/single-prop.svg");
    append(groups.show, 'EIS', 'POWER-pointer');
    append(groups.text,
            'RPM-text', 'EGT-text', 'CHT-text', 'FUEL-USED-text',
            'FUEL-FLOW-text', 'MAN-Hg-text', 'POWER-PERCENT-text',
            'RPM-text', 'BUS-V-text', 'BATT-text', 'PSI-text',
            'OIL-TEMP-text'
        );
};

displayClass.updateEIS = func {
# displays Engine Informations System
    var power = getprop('/controls/engines/engine/throttle') * getprop('/engines/engine/running');
    me.screenElements['POWER-pointer']
        .setRotation(D2R * 140 * power);
    me.screenElements['POWER-PERCENT-text']
        .setText(sprintf('% 3u', power * 100));
    me.screenElements['RPM-text']
        .setText(sprintf(math.round(getprop('/engines/engine/rpm'), 50)));
    me.screenElements['MAN-Hg-text']
        .setText(sprintf('%.1d', getprop('/engines/engine/mp-inhg')));
    me.screenElements['FUEL-FLOW-text']
        .setText(sprintf('%.1f', getprop('/engines/engine/fuel-flow-gph')));
    if (math.mod(me._eis_count, 10) == 0) {
        var psi = getprop('/engines/engine/oil-pressure-psi');
        me.screenElements['PSI-text']
            .setText(psi == nil ? '--' : sprintf('%u', psi));
        me.screenElements['OIL-TEMP-text']
            .setText(sprintf('%i', getprop('/engines/engine/oil-temperature-degf')));
        var used_fuel = getprop('/instrumentation/zkv1000/eis/fuel-qty-at-start')
                      - getprop('/consumables/fuel/tank/level-gal_us')
                      - getprop('/consumables/fuel/tank[1]/level-gal_us');
        me.screenElements['FUEL-USED-text']
            .setText(sprintf('%.1d', used_fuel > 0 ? used_fuel : 0));
        me.screenElements['BUS-V-text']
            .setText(sprintf('%.1i', getprop('/systems/electrical/outputs/bus')));
        me.screenElements['BATT-text']
            .setText(sprintf('%+i', getprop('/systems/electrical/amps')));
        var cht = getprop('/engines/engine/cht-degf');
        me.screenElements['CHT-text']
            .setText(cht == nil ? '--' : sprintf('%i', cht));
        me.screenElements['EGT-text']
            .setText(sprintf('%i', getprop('/engines/engine/egt-degf')));
    }
    settimer(func me.updateEIS(), 1);
    me._eis_count += 1;
};

displayClass._eis_count = 0;