1
0
Fork 0

Rewrite APU page to improve efficiency (proof of concept for future

updates). 25% improvement in average update time + considerably reduce
frequency and magnitude of update spikes
This commit is contained in:
Jonathan Redpath 2022-04-19 22:10:54 +01:00
parent 4d63d45c0d
commit 82a8622fc5
13 changed files with 152 additions and 117 deletions

View file

@ -26,46 +26,15 @@ var canvas_lowerECAMPageApu =
# init
obj["APUGenOff"].hide();
obj.apuADRState = 0;
obj.apuBleedPsi = 0.0;
obj.apuEgt = 0.0;
obj.apuOilLevelLow = 0;
obj.showApuParams = 0;
obj.update_items = [
props.UpdateManager.FromHashValue("apuFlap",1, func(val) {
if (val) {
obj["APUFlapOpen"].show();
} else {
obj["APUFlapOpen"].hide();
}
}),
props.UpdateManager.FromHashValue("apuNeedleRot",0.1, func(val) {
obj["APUN-needle"].setRotation((val + 90) * D2R);
}),
props.UpdateManager.FromHashValue("apuEgtRot",0.1, func(val) {
obj["APUEGT-needle"].setRotation((val + 90) * D2R);
}),
props.UpdateManager.FromHashValue("apuAvailable", nil, func(val) {
if (val) {
obj["APUAvail"].show();
} else {
obj["APUAvail"].hide();
}
}),
props.UpdateManager.FromHashList(["apuRpm","apuEgt","apuMaster","apuGenPB"], nil, func(val) {
if (val.apuRpm > 0.001) {
obj["APUN"].setColor(0.0509,0.7529,0.2941);
obj["APUN"].setText(sprintf("%s", math.round(val.apuRpm)));
obj["APUN-needle"].show();
obj["APUEGT"].setColor(0.0509,0.7529,0.2941);
obj["APUEGT"].setText(sprintf("%s", math.round(val.apuEgt, 5)));
obj["APUEGT-needle"].show();
} else {
obj["APUN"].setColor(0.7333,0.3803,0);
obj["APUN"].setText(sprintf("%s", "XX"));
obj["APUN-needle"].hide();
obj["APUEGT"].setColor(0.7333,0.3803,0);
obj["APUEGT"].setText(sprintf("%s", "XX"));
obj["APUEGT-needle"].hide();
}
if (val.apuMaster or val.apuRpm >= 94.9) {
props.UpdateManager.FromHashList(["apuAvailable","apuMaster","apuGenPB"], nil, func(val) {
if (val.apuMaster or val.apuAvailable) {
obj["APUGenbox"].show();
if (val.apuGenPB) {
obj["APUGenOff"].hide();
@ -104,34 +73,61 @@ var canvas_lowerECAMPageApu =
obj["APUfuelLO"].hide();
}
}),
props.UpdateManager.FromHashList(["apuRpm","apuOilLevel","gear0Wow"], nil, func(val) {
if (val.apuRpm >= 94.9 and val.gear0Wow and val.apuOilLevel < 3.69) {
obj["APU-low-oil"].show();
props.UpdateManager.FromHashValue("apuAdr", 0.5, func(val) {
obj.apuADRState = val;
}),
props.UpdateManager.FromHashValue("apuAvailable", nil, func(val) {
if (val) {
obj["APUAvail"].show();
} else {
obj["APU-low-oil"].hide();
obj["APUAvail"].hide();
}
}),
props.UpdateManager.FromHashList(["apuAdr","apuPsi","apuRpm"], nil, func(val) {
if (val.apuAdr and val.apuRpm > 0.001) {
obj["APUBleedPSI"].setColor(0.0509,0.7529,0.2941);
obj["APUBleedPSI"].setText(sprintf("%s", math.round(val.apuPsi)));
props.UpdateManager.FromHashValue("apuBleedValvePos", 0.1, func(val) {
if (val >= 0.9) {
obj["APUBleedValve"].setRotation(90 * D2R);
obj["APUBleedOnline"].show();
} else {
obj["APUBleedPSI"].setColor(0.7333,0.3803,0);
obj["APUBleedPSI"].setText(sprintf("%s", "XX"));
obj["APUBleedValve"].setRotation(0);
obj["APUBleedOnline"].hide();
}
}),
props.UpdateManager.FromHashValue("apuLoad", 0.1, func(val) {
obj["APUGenLoad"].setText(sprintf("%s", math.round(val)));
if (val <= 100) {
obj["APUGenHz"].setColor(0.0509,0.7529,0.2941);
props.UpdateManager.FromHashValue("apuBleedValvePositionsMatch", 1, func(val) {
if (val) {
obj["APUBleedValveCrossBar"].setColor(0.0509,0.7529,0.2941);
obj["APUBleedValveCrossBar"].setColorFill(0.0509,0.7529,0.2941);
obj["APUBleedValve"].setColor(0.0509,0.7529,0.2941);
} else {
obj["APUGenHz"].setColor(0.7333,0.3803,0);
obj["APUBleedValveCrossBar"].setColor(0.7333,0.3803,0);
obj["APUBleedValveCrossBar"].setColorFill(0.7333,0.3803,0);
obj["APUBleedValve"].setColor(0.7333,0.3803,0);
}
}),
props.UpdateManager.FromHashValue("apuHertz", 1, func(val) {
if (val == 0) {
obj["APUGenHz"].setText(sprintf("XX"));
props.UpdateManager.FromHashValue("apuEgt", 0.05, func(val) {
obj.apuEgt = sprintf("%s", math.round(val, 5));
}),
props.UpdateManager.FromHashValue("apuEgtRot", 0.1, func(val) {
obj["APUEGT-needle"].setRotation((val + 90) * D2R);
}),
props.UpdateManager.FromHashValue("apuFlap", 1, func(val) {
if (val) {
obj["APUFlapOpen"].show();
} else {
obj["APUFlapOpen"].hide();
}
}),
props.UpdateManager.FromHashValue("apuGLC", nil, func(val) {
if (val) {
obj["APUGenOnline"].show();
} else {
obj["APUGenOnline"].hide();
}
}),
props.UpdateManager.FromHashValue("apuHertz", 0.5, func(val) {
if (val < 0.5) {
obj["APUGenHz"].setText("XX");
} else {
obj["APUGenHz"].setText(sprintf("%s", math.round(val)));
}
@ -142,7 +138,46 @@ var canvas_lowerECAMPageApu =
obj["APUGenHz"].setColor(0.7333,0.3803,0);
}
}),
props.UpdateManager.FromHashValue("apuVolt", 0.1, func(val) {
props.UpdateManager.FromHashValue("apuLoad", 0.5, func(val) {
obj["APUGenLoad"].setText(sprintf("%s", math.round(val)));
if (val <= 100) {
obj["APUGenLoad"].setColor(0.0509,0.7529,0.2941);
} else {
obj["APUGenLoad"].setColor(0.7333,0.3803,0);
}
}),
props.UpdateManager.FromHashValue("apuNeedleRot", 0.1, func(val) {
obj["APUN-needle"].setRotation((val + 90) * D2R);
}),
props.UpdateManager.FromHashValue("apuOilLevel", 0.05, func(val) {
if (val < 3.7) {
obj.apuOilLevelLow = 1;
} else {
obj.apuOilLevelLow = 0;
}
}),
props.UpdateManager.FromHashValue("apuPsi", 0.5, func(val) {
obj.apuBleedPsi = sprintf("%s", math.round(val));
}),
props.UpdateManager.FromHashValue("apuRpm", 0.5, func(val) {
if (val >= 0.5) {
obj["APUN"].setColor(0.0509,0.7529,0.2941);
obj["APUEGT"].setColor(0.0509,0.7529,0.2941);
obj["APUN-needle"].show();
obj["APUEGT-needle"].show();
obj["APUN"].setText(sprintf("%s", math.round(val)));
obj.showApuParams = 1;
} else {
obj["APUN"].setColor(0.7333,0.3803,0);
obj["APUEGT"].setColor(0.7333,0.3803,0);
obj["APUN-needle"].hide();
obj["APUEGT-needle"].hide();
obj["APUN"].setText("XX");
obj.showApuParams = 0;
}
}),
props.UpdateManager.FromHashValue("apuVolt", 0.5, func(val) {
obj["APUGenVolt"].setText(sprintf("%s", math.round(val)));
if (val >= 110 and val <= 120) {
@ -151,32 +186,6 @@ var canvas_lowerECAMPageApu =
obj["APUGenVolt"].setColor(0.7333,0.3803,0);
}
}),
props.UpdateManager.FromHashValue("apuGLC", nil, func(val) {
if (val) {
obj["APUGenOnline"].show();
} else {
obj["APUGenOnline"].hide();
}
}),
props.UpdateManager.FromHashList(["apuBleedValvePos","apuBleedValveCmd"], nil, func(val) {
if (val.apuBleedValvePos == 1) {
obj["APUBleedValve"].setRotation(90 * D2R);
obj["APUBleedOnline"].show();
} else {
obj["APUBleedValve"].setRotation(0);
obj["APUBleedOnline"].hide();
}
if (val.apuBleedValveCmd == val.apuBleedValvePos) {
obj["APUBleedValveCrossBar"].setColor(0.0509,0.7529,0.2941);
obj["APUBleedValveCrossBar"].setColorFill(0.0509,0.7529,0.2941);
obj["APUBleedValve"].setColor(0.0509,0.7529,0.2941);
} else {
obj["APUBleedValveCrossBar"].setColor(0.7333,0.3803,0);
obj["APUBleedValveCrossBar"].setColorFill(0.7333,0.3803,0);
obj["APUBleedValve"].setColor(0.7333,0.3803,0);
}
}),
];
obj.updateItemsBottom = [
@ -236,7 +245,7 @@ var canvas_lowerECAMPageApu =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -244,7 +253,7 @@ var canvas_lowerECAMPageApu =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}
@ -264,11 +273,37 @@ var canvas_lowerECAMPageApu =
return;
}
if ((notification.apuBleedValveCmd >= 0.95 and notification.apuBleedValvePos) or (notification.apuBleedValveCmd <= 0.05 and !notification.apuBleedValvePos)) {
notification.apuBleedValvePositionsMatch = 1;
} else {
notification.apuBleedValvePositionsMatch = 0;
}
foreach(var update_item; me.update_items)
{
update_item.update(notification);
}
if (me.showApuParams) {
me["APUEGT"].setText(me.apuEgt);
} else {
me["APUEGT"].setText("XX");
}
if (notification.apuAvailable and notification.gear0Wow and me.apuOilLevelLow) {
me["APU-low-oil"].show();
} else {
me["APU-low-oil"].hide();
}
if (me.apuADRState and me.showApuParams) {
me["APUBleedPSI"].setColor(0.0509,0.7529,0.2941);
me["APUBleedPSI"].setText(me.apuBleedPsi);
} else {
me["APUBleedPSI"].setColor(0.7333,0.3803,0);
me["APUBleedPSI"].setText("XX");
}
me.updateBottom(notification);
},
updatePower: func() {

View file

@ -153,7 +153,7 @@ var canvas_lowerECAMPageBleed =
obj["BLEED-Precooler-1-Inlet-Press"].setColor(0.0509,0.7529,0.2941);
}
} else {
obj["BLEED-Precooler-1-Inlet-Press"].setText(sprintf("%s", "XX"));
obj["BLEED-Precooler-1-Inlet-Press"].setText("XX");
obj["BLEED-Precooler-1-Inlet-Press"].setColor(0.7333,0.3803,0);
}
}),
@ -171,7 +171,7 @@ var canvas_lowerECAMPageBleed =
obj["BLEED-Precooler-2-Inlet-Press"].setColor(0.0509,0.7529,0.2941);
}
} else {
obj["BLEED-Precooler-2-Inlet-Press"].setText(sprintf("%s", "XX"));
obj["BLEED-Precooler-2-Inlet-Press"].setText("XX");
obj["BLEED-Precooler-2-Inlet-Press"].setColor(0.7333,0.3803,0);
}
}),
@ -189,7 +189,7 @@ var canvas_lowerECAMPageBleed =
obj["BLEED-Precooler-1-Outlet-Temp"].setColor(0.0509,0.7529,0.2941);
}
} else {
obj["BLEED-Precooler-1-Outlet-Temp"].setText(sprintf("%s", "XX"));
obj["BLEED-Precooler-1-Outlet-Temp"].setText("XX");
obj["BLEED-Precooler-1-Outlet-Temp"].setColor(0.7333,0.3803,0);
}
}),
@ -207,7 +207,7 @@ var canvas_lowerECAMPageBleed =
obj["BLEED-Precooler-2-Outlet-Temp"].setColor(0.0509,0.7529,0.2941);
}
} else {
obj["BLEED-Precooler-2-Outlet-Temp"].setText(sprintf("%s", "XX"));
obj["BLEED-Precooler-2-Outlet-Temp"].setText("XX");
obj["BLEED-Precooler-2-Outlet-Temp"].setColor(0.7333,0.3803,0);
}
}),
@ -453,7 +453,7 @@ var canvas_lowerECAMPageBleed =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -461,7 +461,7 @@ var canvas_lowerECAMPageBleed =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -134,7 +134,7 @@ var canvas_lowerECAMPageCond =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -142,7 +142,7 @@ var canvas_lowerECAMPageCond =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -194,7 +194,7 @@ var canvas_lowerECAMPageCruise =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -202,7 +202,7 @@ var canvas_lowerECAMPageCruise =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -261,7 +261,7 @@ var canvas_lowerECAMPageDoor =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -269,7 +269,7 @@ var canvas_lowerECAMPageDoor =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -731,7 +731,7 @@ var canvas_lowerECAMPageElec =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -739,7 +739,7 @@ var canvas_lowerECAMPageElec =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -189,7 +189,7 @@ var canvas_lowerECAMPageEng =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -197,7 +197,7 @@ var canvas_lowerECAMPageEng =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -526,7 +526,7 @@ var canvas_lowerECAMPageFctl =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -534,7 +534,7 @@ var canvas_lowerECAMPageFctl =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -512,7 +512,7 @@ var canvas_lowerECAMPageFuel =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -520,7 +520,7 @@ var canvas_lowerECAMPageFuel =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -63,7 +63,7 @@ var canvas_lowerECAMPageHyd =
obj["Blue-label"].setColor(0.7333,0.3803,0);
}
} else {
obj["Press-Blue"].setText(sprintf("%s", "XX"));
obj["Press-Blue"].setText("XX");
obj["Blue-Line"].setColor(0.7333,0.3803,0);
obj["Blue-Line"].setColorFill(0.7333,0.3803,0);
obj["Blue-Line-Top"].setColorFill(0.7333,0.3803,0);
@ -101,7 +101,7 @@ var canvas_lowerECAMPageHyd =
obj["Yellow-label"].setColor(0.7333,0.3803,0);
}
} else {
obj["Press-Yellow"].setText(sprintf("%s", "XX"));
obj["Press-Yellow"].setText("XX");
obj["Yellow-Line"].setColor(0.7333,0.3803,0);
obj["Yellow-Line"].setColorFill(0.7333,0.3803,0);
obj["Yellow-Line-Top"].setColorFill(0.7333,0.3803,0);
@ -140,7 +140,7 @@ var canvas_lowerECAMPageHyd =
obj["Green-label"].setColor(0.7333,0.3803,0);
}
} else {
obj["Press-Green"].setText(sprintf("%s", "XX"));
obj["Press-Green"].setText("XX");
obj["Green-Line"].setColor(0.7333,0.3803,0);
obj["Green-Line"].setColorFill(0.7333,0.3803,0);
obj["Green-Line-Top"].setColorFill(0.7333,0.3803,0);
@ -469,7 +469,7 @@ var canvas_lowerECAMPageHyd =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -477,7 +477,7 @@ var canvas_lowerECAMPageHyd =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -159,7 +159,7 @@ var canvas_lowerECAMPagePress =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -167,7 +167,7 @@ var canvas_lowerECAMPagePress =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -85,7 +85,7 @@ var canvas_lowerECAMPageSts =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -93,7 +93,7 @@ var canvas_lowerECAMPageSts =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}

View file

@ -649,7 +649,7 @@ var canvas_lowerECAMPageWheel =
notification.satTemp = dmc.DMController.DMCs[1].outputs[4].getValue();
me["SAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["SAT"].setText(sprintf("%s", "XX"));
me["SAT"].setText("XX");
me["SAT"].setColor(0.7333,0.3803,0);
}
@ -657,7 +657,7 @@ var canvas_lowerECAMPageWheel =
notification.tatTemp = dmc.DMController.DMCs[1].outputs[5].getValue();
me["TAT"].setColor(0.0509,0.7529,0.2941);
} else {
me["TAT"].setText(sprintf("%s", "XX"));
me["TAT"].setText("XX");
me["TAT"].setColor(0.7333,0.3803,0);
}