1
0
Fork 0

IESI - revise power so that it also uses Emesary

This commit is contained in:
Jonathan Redpath 2022-04-30 13:14:13 +01:00
parent 2b27c7d483
commit cf9a657195
5 changed files with 203 additions and 141 deletions

View file

@ -1758,7 +1758,11 @@
</groundradar>
<iesi>
<att-reset type="double">false</att-reset>
<att-reset-cmd type="bool">false</att-reset-cmd>
<display>
<show-mach type="bool">false</show-mach>
</display>
</iesi>
<marker-beacon n="0">

View file

@ -4,7 +4,6 @@
# props.nas nodes
var iesi_init = props.globals.initNode("/instrumentation/iesi/iesi-init", 0, "BOOL");
var iesi_reset = props.globals.initNode("/instrumentation/iesi/att-reset", 0, "DOUBLE");
var pinPrograms = {
metricAltitude: 1,
@ -29,6 +28,7 @@ var canvas_IESI = {
};
canvas.parsesvg(obj.group, svg, {"font-mapper": obj.font_mapper} );
foreach(var key; obj.getKeys()) {
obj[key] = obj.group.getElementById(key);
@ -46,20 +46,28 @@ var canvas_IESI = {
obj[key].set("clip-frame", canvas.Element.PARENT);
}
};
obj.AI_horizon_trans = obj["AI_horizon"].createTransform();
obj.AI_horizon_rot = obj["AI_horizon"].createTransform();
obj._aiCenter = obj["AI_center"].getCenter();
obj._cachedInhg = -999;
obj._cachedMetric = pinPrograms.metricAltitude;
obj._cachedMode = nil;
obj._cachedShowInhg = pinPrograms.showInHg;
obj._canReset = 0;
obj._excessMotionInInit = 0;
obj._fastInit = 0;
obj._IESITime = 0;
obj._isNegativeAlt = 0;
obj._middleAltOffset = nil;
obj._powerResult = 0;
obj._roll = 0;
obj.iesiInAlign = 0;
obj["IESI"].hide();
obj["IESI_Init"].show();
obj["ATTflag"].hide();
obj.update_items = [
props.UpdateManager.FromHashValue("airspeed", 0.1, func(val) {
@ -78,6 +86,7 @@ var canvas_IESI = {
obj.altOffset = (val / 500) - int(val / 500);
obj.middleAltText = roundaboutAlt(val / 100);
if (obj.altOffset > 0.5) {
obj._middleAltOffset = -(obj.altOffset - 1) * 258.5528;
} else {
@ -86,6 +95,7 @@ var canvas_IESI = {
obj["ALT_scale"].setTranslation(0, -obj._middleAltOffset);
obj["ALT_scale"].update();
obj["ALT_five"].setText(sprintf("%03d", abs(obj.middleAltText + 10)));
obj["ALT_four"].setText(sprintf("%03d", abs(obj.middleAltText + 5)));
obj["ALT_three"].setText(sprintf("%03d", abs(obj.middleAltText)));
@ -93,8 +103,8 @@ var canvas_IESI = {
obj["ALT_one"].setText(sprintf("%03d", abs(obj.middleAltText - 10)));
obj["ALT_meters"].setText(sprintf("%5.0f", math.round(val * 0.3048, 10)));
obj.altTens = num(right(sprintf("%02d", val), 2));
obj["ALT_tens"].setTranslation(0, obj.altTens * 3.16);
obj["ALT_tens"].setTranslation(0, num(right(sprintf("%02d", val), 2)) * 3.16);
}),
props.UpdateManager.FromHashValue("altitude_ind", 0.5, func(val) {
obj["ALT_digits"].setText(sprintf("%s", math.clamp(val, -20, 500)));
@ -111,16 +121,15 @@ var canvas_IESI = {
props.UpdateManager.FromHashValue("mach", 0.001, func(val) {
obj["ASI_mach"].setText(sprintf("%2.0f", math.clamp(val * 100, 0, 99)));
}),
props.UpdateManager.FromHashValue("pitch", 0.025, func(val) {
props.UpdateManager.FromHashValue("iesiPitch", 0.025, func(val) {
obj.AI_horizon_trans.setTranslation(0, val * 16.74);
}),
props.UpdateManager.FromHashValue("roll", 0.025, func(val) {
obj._roll = -val * D2R;
obj.AI_horizon_rot.setRotation(obj._roll, obj._aiCenter);
obj["AI_bank"].setRotation(obj._roll);
obj.AI_horizon_rot.setRotation(-val * D2R, obj._aiCenter);
obj["AI_bank"].setRotation(-val * D2R);
}),
props.UpdateManager.FromHashValue("skid", 0.1, func(val) {
if (abs(val) >= 84.99) {
if (abs(val) >= 85) {
obj["AI_slipskid"].hide();
} else {
obj["AI_slipskid"].setTranslation(-val, 0);
@ -128,112 +137,172 @@ var canvas_IESI = {
}
}),
];
obj.update_items_init = [
props.UpdateManager.FromHashList(["iesiAlignTime","elapsedTime"], 0.5, func(val) {
if (val.iesiAlignTime + 90 >= val.elapsedTime) {
obj.iesiInAlign = 1;
} else {
obj.iesiInAlign = 0;
}
}),
props.UpdateManager.FromHashList(["iesiInAlign","iesiFastInit","irAlignFault"], 1, func(val) {
if (val.iesiInAlign) {
if (!val.iesiFastInit and val.irAlignFault) {
obj._excessMotionInInit = 1;
}
}
}),
props.UpdateManager.FromHashList(["iesiExcessMotion","iesiFastInit","iesiInAlign"], 1, func(val) {
if (val.iesiInAlign) {
if (val.iesiFastInit) {
obj["IESI"].show();
obj["IESI_Init"].hide();
obj["AI_bank"].hide();
obj["AI_bank_center"].hide();
obj["AI_bank_scale"].hide();
obj["AI_horizon"].hide();
obj["AI_sky_bank"].hide();
obj["ATTflag_text"].setText("ATT 10s");
obj["ATTflag_text"].setColor(0,0,0);
obj["ATTflag_rect"].setScale(1.5,1);
obj["ATTflag_rect"].setTranslation(-250,0);
obj["ATTflag_rect"].setColorFill(1,1,0);
obj["ATTflag_rect"].setColor(1,1,0);
obj["ATTflag"].show();
obj["attRst"].hide();
obj["attRstRect"].hide();
} else {
obj["IESI"].hide();
obj["IESI_Init"].show();
obj["ATTflag"].hide();
}
} else {
if (!val.iesiExcessMotion) {
obj["IESI_Init"].hide();
obj["IESI"].show();
obj["AI_bank"].show();
obj["AI_bank_center"].show();
obj["AI_bank_scale"].show();
obj["AI_index"].show();
obj["AI_horizon"].show();
obj["AI_sky_bank"].show();
obj["ATTflag"].hide();
} else {
obj["IESI_Init"].hide();
obj["IESI"].show();
obj["AI_bank"].hide();
obj["AI_bank_center"].hide();
obj["AI_bank_scale"].hide();
obj["AI_horizon"].hide();
obj["AI_sky_bank"].hide();
obj["ATTflag_text"].setText("ATT");
obj["ATTflag_text"].setColor(1,0,0);
obj["ATTflag_rect"].setScale(1,1);
obj["ATTflag_rect"].setTranslation(0,0);
obj["ATTflag_rect"].setColorFill(0,0,0);
obj["ATTflag_rect"].setColor(0,0,0);
obj["ATTflag"].show();
obj["attRst"].show();
obj["attRstRect"].show();
}
}
}),
];
obj.update_items_power = [
props.UpdateManager.FromHashList(["iesiPowered","iesiBrt"], 0.005, func(val) {
if (val.iesiPowered and val.iesiBrt > 0.01) {
obj.group.setVisible(1);
} else {
obj.group.setVisible(0);
}
}),
props.UpdateManager.FromHashList(["iesiPowered","acconfig","iesiInit"], 1, func(val) {
if (val.iesiPowered) {
if (val.iesiInit) return;
obj.initIESI(val.acconfig);
} elsif (val.iesiInit) {
obj._canReset = 0;
obj._excessMotionInInit = 0;
obj._fastInit = 0;
iesi_init.setBoolValue(0);
}
}),
];
return obj;
},
},
getKeys: func() {
return ["IESI","IESI_Init","attRst","attRstRect","att90s","ATTflag","ATTflag_rect","ATTflag_text","ALTwarn","SPDwarn","ASI_scale","ASI_mach","ASI_mach_decimal","AI_center","AI_index","AI_horizon","AI_sky_bank","AI_bank","AI_bank_center","AI_slipskid","ALT_scale","ALT_one","ALT_two","ALT_three","ALT_four","ALT_five","ALT_digits","ALT_tens","ALT_meters","QNH_setting","QNH_std","negText","negText2","AI_bank_scale","metricM","metricBox"];
},
alignFault: props.globals.getNode("/systems/navigation/align-fault"),
update: func(notification) {
me._powerResult = me.updatePower(notification);
if (me._powerResult == 0) { return; }
me.updatePower(notification);
if (math.abs(notification.qnh_inhg - me._cachedInhg) > 0.005 or notification.altimeter_mode != me._cachedMode) {
me._cachedInhg = notification.qnh_inhg;
me._cachedMode = notification.altimeter_mode;
foreach(var update_item; me.update_items_power)
{
update_item.update(notification);
}
if (!me.group.getVisible()) { return; }
notification.iesiAlignTime = me._IESITime;
notification.iesiExcessMotion = me._excessMotionInInit;
notification.iesiFastInit = me._fastInit;
notification.iesiInAlign = me.iesiInAlign;
foreach(var update_item; me.update_items_init)
{
update_item.update(notification);
}
if (math.abs(notification.qnh_inhg_iesi - me._cachedInhg) > 0.005 or notification.altimeter_mode_iesi != me._cachedMode or pinPrograms.showInHg != me._cachedShowInhg) {
me._cachedInhg = notification.qnh_inhg_iesi;
me._cachedMode = notification.altimeter_mode_iesi;
me._cachedShowInhg = pinPrograms.showInHg;
me.updateQNH(notification);
}
if (me._IESITime + 90 >= notification.elapsedTime) {
if (!me._fastInit and me.alignFault.getBoolValue()) {
me._excessMotionInInit = 1;
}
if (me._fastInit) {
me["IESI"].show();
me["IESI_Init"].hide();
me["AI_bank"].hide();
me["AI_bank_center"].hide();
me["AI_bank_scale"].hide();
me["AI_horizon"].hide();
me["AI_sky_bank"].hide();
me["ATTflag_text"].setText("ATT 10s");
me["ATTflag_text"].setColor(0,0,0);
me["ATTflag_rect"].setScale(1.5,1);
me["ATTflag_rect"].setTranslation(-250,0);
me["ATTflag_rect"].setColorFill(1,1,0);
me["ATTflag_rect"].setColor(1,1,0);
me["ATTflag"].show();
me["attRst"].hide();
me["attRstRect"].hide();
} else {
me["IESI"].hide();
me["IESI_Init"].show();
me["ATTflag"].hide();
return;
}
} else {
if (pinPrograms.metricAltitude) {
me["ALT_meters"].show();
me["metricM"].show();
me["metricBox"].show();
if (me._isNegativeAlt) {
me["negText2"].show();
} else {
me["negText2"].hide();
}
} else {
me["ALT_meters"].hide();
me["metricM"].hide();
me["metricBox"].hide();
me["negText2"].hide();
}
if (!me._excessMotionInInit) {
me["IESI_Init"].hide();
me["IESI"].show();
me["AI_bank"].show();
me["AI_bank_center"].show();
me["AI_bank_scale"].show();
me["AI_index"].show();
me["AI_horizon"].show();
me["AI_sky_bank"].show();
me["ATTflag"].hide();
} else {
me["IESI_Init"].hide();
me["IESI"].show();
me["AI_bank"].hide();
me["AI_bank_center"].hide();
me["AI_bank_scale"].hide();
me["AI_horizon"].hide();
me["AI_sky_bank"].hide();
me["ATTflag_text"].setText("ATT");
me["ATTflag_text"].setColor(1,0,0);
me["ATTflag_rect"].setScale(1,1);
me["ATTflag_rect"].setTranslation(0,0);
me["ATTflag_rect"].setColorFill(0,0,0);
me["ATTflag_rect"].setColor(0,0,0);
me["ATTflag"].show();
me["attRst"].show();
me["attRstRect"].show();
}
}
if (me.iesiInAlign and !me._fastInit) return;
foreach(var update_item; me.update_items)
{
update_item.update(notification);
}
if (!me.iesiInAlign and pinPrograms.metricAltitude != me._cachedMetric) {
me._cachedMetric = pinPrograms.metricAltitude;
me.updateMetric(pinPrograms.metricAltitude);
}
if (pinPrograms.metricAltitude) {
if (me._isNegativeAlt) {
me["negText2"].show();
} else {
me["negText2"].hide();
}
}
},
updateMetric: func(val) {
if (val) {
me["ALT_meters"].show();
me["metricM"].show();
me["metricBox"].show();
} else {
me["ALT_meters"].hide();
me["metricM"].hide();
me["metricBox"].hide();
me["negText2"].hide();
}
},
updateQNH: func(notification) {
if (notification.altimeter_mode) {
if (notification.altimeter_mode_iesi) {
me["QNH_setting"].hide();
me["QNH_std"].show();
} else {
if (pinPrograms.showInHg) {
me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa) ~ "/" ~ sprintf("%2.2f", notification.qnh_inhg));
me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa_iesi) ~ "/" ~ sprintf("%2.2f", notification.qnh_inhg_iesi));
} else {
me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa));
me["QNH_setting"].setText(sprintf("%4.0f", notification.qnh_hpa_iesi));
}
me["QNH_std"].hide();
me["QNH_setting"].show();
@ -248,28 +317,13 @@ var canvas_IESI = {
} else if (me._IESITime + 90 < notification.elapsedTime and notification.iesiInit and !me._canReset) {
me._canReset = 1;
}
if (notification.iesiPowered) {
if (notification.acconfig != 1 and notification.iesiInit != 1) {
iesi_init.setBoolValue(1);
me._IESITime = notification.elapsedTime - (me._fastInit ? 80 : 0);
} else if (notification.acconfig == 1 and notification.iesiInit != 1) {
iesi_init.setBoolValue(1);
me._IESITime = notification.elapsedTime - 87;
}
} elsif (notification.iesiInit) {
me._canReset = 0;
me._excessMotionInInit = 0;
me._fastInit = 0;
iesi_init.setBoolValue(0);
}
if (notification.iesiPowered and notification.iesiBrt > 0.01) {
me.group.setVisible(1);
return 1;
},
initIESI: func(acconfig) {
iesi_init.setBoolValue(1);
if (!acconfig) {
me._IESITime = pts.Sim.Time.elapsedSec.getValue() - (me._fastInit ? 80 : 0);
} else {
me.group.setVisible(0);
return 0;
me._IESITime = pts.Sim.Time.elapsedSec.getValue() - 87;
}
},
};
@ -302,40 +356,41 @@ var IESIRecipient =
var A320IESI = IESIRecipient.new("A320 IESI");
emesary.GlobalTransmitter.Register(A320IESI);
# Emesary Frame Notifiaction Properties
var input = {
"acconfig": "/systems/acconfig/autoconfig-running",
"airspeed": "/instrumentation/airspeed-indicator[0]/indicated-speed-kt",
"altitude": "/instrumentation/altimeter[6]/indicated-altitude-ft",
"altitude_ind": "/instrumentation/altimeter[6]/indicated-altitude-ft-pfd",
"altimeter_mode": "/instrumentation/altimeter[6]/std",
"altimeter_mode_iesi": "/instrumentation/altimeter[6]/std",
"attReset": "/instrumentation/iesi/att-reset",
"iesiBrt": "/controls/lighting/DU/iesi",
"iesiInit": "/instrumentation/iesi/iesi-init",
"iesiPitch": "/instrumentation/iesi/pitch-deg",
"iesiPowered": "/instrumentation/iesi/power/power-on",
"irAlignFault": "/systems/navigation/align-fault",
"mach": "/instrumentation/airspeed-indicator/indicated-mach",
"pitch": "/instrumentation/iesi/pitch-deg",
"qnh_hpa": "/instrumentation/altimeter[6]/setting-hpa",
"qnh_inhg": "/instrumentation/altimeter[6]/setting-inhg",
"qnh_hpa_iesi": "/instrumentation/altimeter[6]/setting-hpa",
"qnh_inhg_iesi": "/instrumentation/altimeter[6]/setting-inhg",
"roll": "/orientation/roll-deg",
"skid": "/instrumentation/iesi/slip-skid",
"showMach": "/instrumentation/iesi/display/show-mach",
"skid": "/instrumentation/iesi/slip-skid",
};
foreach (var name; keys(input)) {
emesary.GlobalTransmitter.NotifyAll(notifications.FrameNotificationAddProperty.new("A320 IESI", name, input[name]));
}
# Helper functions
var showIESI = func {
var dlg = canvas.Window.new([512, 512], "dialog").set("resize", 1);
dlg.setCanvas(A320IESI.MainScreen.canvas);
}
var roundabout = func(x) {
var y = x - int(x);
return y < 0.5 ? int(x) : 1 + int(x);
return (x - int(x)) < 0.5 ? int(x) : 1 + int(x);
};
var roundaboutAlt = func(x) {
var y = x * 0.2 - int(x * 0.2);
return y < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2);
return (x * 0.2 - int(x * 0.2)) < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2);
};

View file

@ -16,7 +16,6 @@ var alt_inhg = props.globals.getNode("/instrumentation/altimeter/setting-inhg",
var aoa_1 = props.globals.getNode("/systems/navigation/adr/output/aoa-1", 1);
var aoa_2 = props.globals.getNode("/systems/navigation/adr/output/aoa-2", 1);
var aoa_3 = props.globals.getNode("/systems/navigation/adr/output/aoa-3", 1);
var elapsedtime = props.globals.getNode("/sim/time/elapsed-sec", 1);
var hundredAbove = props.globals.getNode("/instrumentation/pfd/hundred-above", 1);
var minimum = props.globals.getNode("/instrumentation/pfd/minimums", 1);
@ -26,6 +25,7 @@ var amberFlash = [0, 0];
var dhFlash = 0;
var ilsFlash = [0,0];
var qnhFlash = [0,0];
var elapsedtime_act = nil;
var du1_test = props.globals.initNode("/instrumentation/du/du1-test", 0, "BOOL");
var du1_test_time = props.globals.initNode("/instrumentation/du/du1-test-time", 0.0, "DOUBLE");
var du1_offtime = props.globals.initNode("/instrumentation/du/du1-off-time", 0.0, "DOUBLE");
@ -876,7 +876,7 @@ var canvas_pfd = {
obj["flap_max"].hide();
}
}),
props.UpdateManager.FromHashValue("Ctrgt", , 0.1, func(val) {
props.UpdateManager.FromHashValue("Ctrgt", 0.1, func(val) {
obj["clean_speed"].setTranslation(0, val * -6.6);
}),
props.UpdateManager.FromHashValue("Ftrgt", 0.1, func(val) {
@ -1995,7 +1995,7 @@ var canvas_pfd = {
me.testTimeNode = du1_test_time;
}
var elapsedtime_act = elapsedtime.getValue();
elapsedtime_act = pts.Sim.Time.elapsedSec.getValue();
if (me.powerNode.getValue() >= 110) {
if (!me.on) {
if (me.offTimeNode.getValue() + 3 < elapsedtime_act) {
@ -2245,20 +2245,19 @@ setlistener("/systems/electrical/bus/ac-2", func() {
}, 0, 0);
# Helper Functions
var roundabout = func(x) {
var y = x - int(x);
return y < 0.5 ? int(x) : 1 + int(x);
return (x - int(x)) < 0.5 ? int(x) : 1 + int(x);
};
var roundaboutAlt = func(x) {
var y = x * 0.2 - int(x * 0.2);
return y < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2);
return (x * 0.2 - int(x * 0.2)) < 0.5 ? 5 * int(x * 0.2) : 5 + 5 * int(x * 0.2);
};
var _fontSizeHDGTempVar = nil;
var fontSizeHDG = func(input) {
var test = input / 3;
if (test == int(test)) {
_fontSizeHDGTempVar = input / 3;
if (_fontSizeHDGTempVar == int(_fontSizeHDGTempVar)) {
return 42;
} else {
return 32;
@ -2274,6 +2273,7 @@ var showPFD2 = func {
var dlg = canvas.Window.new([512, 512], "dialog").set("resize", 1);
dlg.setCanvas(A320PFD2.MainScreen.canvas);
}
# Flash managers
var ils_going1 = 0;
var ilsTimer1 = maketimer(0.50, func {
@ -2380,4 +2380,4 @@ setlistener("/modes/pfd/fma/pitch-mode", func(pitch) {
} else {
autoland_pitch_land.setBoolValue(0);
}
},0,0);
}, 0, 0);

View file

@ -554,21 +554,23 @@ var fmaAthr = func {
}
}
var elapsedTimeBoxes = nil;
var showAllBoxes = func {
elapsedTimeBoxes = pts.Sim.Time.elapsedSec.getValue();
if (Modes.PFD.FMA.rollMode.getValue() != " ") {
Modes.PFD.FMA.rollModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
Modes.PFD.FMA.rollModeTime.setValue(elapsedTimeBoxes);
}
if (Modes.PFD.FMA.pitchMode.getValue() != " ") {
Modes.PFD.FMA.pitchModeTime.setValue(pts.Sim.Time.elapsedSec.getValue());
Modes.PFD.FMA.pitchModeTime.setValue(elapsedTimeBoxes);
}
if (Modes.PFD.FMA.rollModeArmed.getValue() != " ") {
Modes.PFD.FMA.rollModeArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue());
Modes.PFD.FMA.rollModeArmedTime.setValue(elapsedTimeBoxes);
}
if (Modes.PFD.FMA.pitchModeArmed.getValue() != " ") {
Modes.PFD.FMA.pitchModeArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue());
Modes.PFD.FMA.pitchModeArmedTime.setValue(elapsedTimeBoxes);
}
if (Modes.PFD.FMA.pitchMode2Armed.getValue() != " ") {
Modes.PFD.FMA.pitchMode2ArmedTime.setValue(pts.Sim.Time.elapsedSec.getValue());
Modes.PFD.FMA.pitchMode2ArmedTime.setValue(elapsedTimeBoxes);
}
}

View file

@ -571,6 +571,7 @@
<product>
<value>4</value>
<property>/controls/lighting/DU/iesi</property>
<property>/instrumentation/iesi/power/power-on</property>
</product>
</sum>
</function>