Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Flight Model #434

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft

Conversation

boufogre
Copy link
Contributor

@boufogre boufogre commented Apr 17, 2022

New Flight Model

image

  • Lift/Drag
  • Engine Performance
  • Electronic Engine Controls
  • Ground Handling
  • Brakes
  • Fuel Flow
  • Speedbrake
  • High Lift Devices
  • Gear
  • Trim
  • Stability
  • Control Effectiveness
  • Takeoff Performance

@747-4EVER 747-4EVER changed the title initial commit config files New Flight Model Apr 17, 2022
@747-4EVER 747-4EVER marked this pull request as draft April 17, 2022 09:54
@DesertRick13
Copy link

Now this is where things begin to get really interesting! I look forward to good things.

@747-4EVER 747-4EVER mentioned this pull request Jun 6, 2022
Comment on lines +151 to +183
update() {
//t += 0.001;
for (let i = 1; i < 5; i++){
let index = i;
RegisterViewListener("JS_LISTENER_KEYEVENT");
this.keyListener = RegisterViewListener('JS_LISTENER_KEYEVENT', () => {
Coherent.call('INTERCEPT_KEY_EVENT', 'INCREASE_THROTTLE', 0);
Coherent.call('INTERCEPT_KEY_EVENT', 'DECREASE_THROTTLE', 0);
Coherent.call('INTERCEPT_KEY_EVENT', 'THROTTLE_CUT', 0);
//Coherent.call('INTERCEPT_KEY_EVENT', '')
/*this.keyListener.on('keyIntercepted', keyEventName => {
if (keyEventName === 'THROTTLE_CUT') {
console.log('THROTTLE CUT INTERCEPTED');
SimVar.SetSimVarValue("K:AXIS_THROTTLE_SET", "position 16K", 5995);
}
});*/

});
//this.getEAI(index);
//this.getBleed(index);
//this.getAlternate(index);
//this.getTLA(index);
//this.getIdleN1(index);
//this.getMaxN1(index);
this.setCommandedN1(index);
this.setCommandedN2(index);
this.setCommandedFF(index);
//this.setN2(index);
//this.setN1(index);
//this.setFuelFlow(index);
}
return;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
update() {
//t += 0.001;
for (let i = 1; i < 5; i++){
let index = i;
RegisterViewListener("JS_LISTENER_KEYEVENT");
this.keyListener = RegisterViewListener('JS_LISTENER_KEYEVENT', () => {
Coherent.call('INTERCEPT_KEY_EVENT', 'INCREASE_THROTTLE', 0);
Coherent.call('INTERCEPT_KEY_EVENT', 'DECREASE_THROTTLE', 0);
Coherent.call('INTERCEPT_KEY_EVENT', 'THROTTLE_CUT', 0);
//Coherent.call('INTERCEPT_KEY_EVENT', '')
/*this.keyListener.on('keyIntercepted', keyEventName => {
if (keyEventName === 'THROTTLE_CUT') {
console.log('THROTTLE CUT INTERCEPTED');
SimVar.SetSimVarValue("K:AXIS_THROTTLE_SET", "position 16K", 5995);
}
});*/
});
//this.getEAI(index);
//this.getBleed(index);
//this.getAlternate(index);
//this.getTLA(index);
//this.getIdleN1(index);
//this.getMaxN1(index);
this.setCommandedN1(index);
this.setCommandedN2(index);
this.setCommandedFF(index);
//this.setN2(index);
//this.setN1(index);
//this.setFuelFlow(index);
}
return;
}
update() {
for (let i = 1; i < 5; i++){
let index = i;
RegisterViewListener("JS_LISTENER_KEYEVENT");
this.keyListener = RegisterViewListener('JS_LISTENER_KEYEVENT', () => {
Coherent.call('INTERCEPT_KEY_EVENT', 'INCREASE_THROTTLE', 0);
Coherent.call('INTERCEPT_KEY_EVENT', 'DECREASE_THROTTLE', 0);
Coherent.call('INTERCEPT_KEY_EVENT', 'THROTTLE_CUT', 0);
});
}
return;
}

Comment on lines +28 to +38
getIdleN1(index){
//let flaps = this.getFlaps();
let eai = this.getEAI(index);
//let reverser = this.getReverser(index);
let idleN1 = 20.2;
if (eai /*|| flaps >= 20 || reverser*/) {
idleN1 += 14.1;
}
SimVar.SetSimVarValue(`L:SALTY_EEC_IDLE_N1:${index}`, "percent", idleN1);
return idleN1;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getIdleN1(index){
//let flaps = this.getFlaps();
let eai = this.getEAI(index);
//let reverser = this.getReverser(index);
let idleN1 = 20.2;
if (eai /*|| flaps >= 20 || reverser*/) {
idleN1 += 14.1;
}
SimVar.SetSimVarValue(`L:SALTY_EEC_IDLE_N1:${index}`, "percent", idleN1);
return idleN1;
}
getIdleN1(index){
let eai = this.getEAI(index);
let idleN1 = 20.2;
if (eai) {
idleN1 += 14.1;
}
SimVar.SetSimVarValue(`L:SALTY_EEC_IDLE_N1:${index}`, "percent", idleN1);
return idleN1;
}

Comment on lines +39 to +55
getMaxN1(index) {
//let eai = this.getEAI(index);
let bleed = this.getBleed(index);
let alternate = this.getAlternate(index);
let maxN1 = 98.5;
if (bleed) {
maxN1 -= 0.6;
}
if (alternate) {
maxN1 = 106.7;
}
//SimVar.SetGameVarValue(`ENG MAX N1${index}`, "percent", maxN1);
//let test = SimVar.GetGameVarValue(`ENG MAX N1${index}`, "percent");
SimVar.SetSimVarValue("L:SALTY_EEC_MAX_N1", "percent", maxN1);
//console.log(test);
return maxN1;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getMaxN1(index) {
//let eai = this.getEAI(index);
let bleed = this.getBleed(index);
let alternate = this.getAlternate(index);
let maxN1 = 98.5;
if (bleed) {
maxN1 -= 0.6;
}
if (alternate) {
maxN1 = 106.7;
}
//SimVar.SetGameVarValue(`ENG MAX N1${index}`, "percent", maxN1);
//let test = SimVar.GetGameVarValue(`ENG MAX N1${index}`, "percent");
SimVar.SetSimVarValue("L:SALTY_EEC_MAX_N1", "percent", maxN1);
//console.log(test);
return maxN1;
}
getMaxN1(index) {
let bleed = this.getBleed(index);
let alternate = this.getAlternate(index);
let maxN1 = 98.5;
if (bleed) {
maxN1 -= 0.6;
}
if (alternate) {
maxN1 = 106.7;
}
SimVar.SetSimVarValue("L:SALTY_EEC_MAX_N1", "percent", maxN1);
return maxN1;
}

Comment on lines +56 to +68
setCommandedN1(index) {
//let alt = SimVar.GetSimVarValue("PRESSURE ALTITUDE", "feet");
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let theta2 = tat / 288.15;
let tla = this.getTLA(index);
let idleN1 = this.getIdleN1(index);
let maxN1 = this.getMaxN1(index);
let comN1 = 0.01 * (maxN1 - idleN1) * tla + idleN1;
SimVar.SetSimVarValue(`L:SALTY_EEC_COM_N1:${index}`, "number", comN1);
//SimVar.SetSimVarValue(`TURB ENG COMMANDED N1:${index}`, "percent", comN1);
//SimVar.SetSimVarValue(`TURB ENG THROTTLE COMMANDED N1:${index}`, "percent", comN1);
return;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setCommandedN1(index) {
//let alt = SimVar.GetSimVarValue("PRESSURE ALTITUDE", "feet");
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let theta2 = tat / 288.15;
let tla = this.getTLA(index);
let idleN1 = this.getIdleN1(index);
let maxN1 = this.getMaxN1(index);
let comN1 = 0.01 * (maxN1 - idleN1) * tla + idleN1;
SimVar.SetSimVarValue(`L:SALTY_EEC_COM_N1:${index}`, "number", comN1);
//SimVar.SetSimVarValue(`TURB ENG COMMANDED N1:${index}`, "percent", comN1);
//SimVar.SetSimVarValue(`TURB ENG THROTTLE COMMANDED N1:${index}`, "percent", comN1);
return;
}
setCommandedN1(index) {
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let theta2 = tat / 288.15;
let tla = this.getTLA(index);
let idleN1 = this.getIdleN1(index);
let maxN1 = this.getMaxN1(index);
let comN1 = 0.01 * (maxN1 - idleN1) * tla + idleN1;
SimVar.SetSimVarValue(`L:SALTY_EEC_COM_N1:${index}`, "number", comN1);
return;
}

Comment on lines +69 to +109
/*setN1(index) {
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let theta2 = tat / 288.15;
let targetN1 = SimVar.GetSimVarValue(`L:SALTY_EEC_COM_N1:${index}`, "number"); //target N1 set by thrust lever position
let n1 = SimVar.GetSimVarValue(`TURB ENG N1:${index}`, "number") * 100; //actual N1 on the engine
SimVar.SetSimVarValue(`L:SALTY_EEC_N1:${index}`, "percent", n1); //for debugging
let tspool = 7.574 * (Math.log(targetN1) - Math.log(n1)); //time required in seconds
SimVar.SetSimVarValue(`L:SALTY_EEC_SPOOL_TIME:${index}`, "number", tspool); //for debugging
n1 *= Math.exp(0.001 * tspool * 0.132);
SimVar.SetSimVarValue(`L:SALTY_EEC_N1:${index}`, "percent", n1);
//SimVar.SetSimVarValue(`TURB ENG CORRECTED N1:${index}`, "percent", n1);
SimVar.SetSimVarValue(`TURB ENG N1:${index}`, "percent", n1);
}*/
/*setN2(index) {
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let theta2 = tat / 288.15;
let tla = this.getTLA(index);
let maxN2 = (this.getMaxN1(index) + 117.5) / 2.025;
let idleN2 = (this.getIdleN1(index) + 117.5) / 2.025;
let n2 = 0.01 * (maxN2 - idleN2) * tla + idleN2;
SimVar.SetSimVarValue(`L:SALTY_COM_N2:${index}`, "percent", n2);
SimVar.SetSimVarValue(`TURB ENG CORRECTED N2:${index}`, "percent", (n2 / (theta2 ** 0.5)));
SimVar.SetSimVarValue(`TURB ENG N2:${index}`, "percent", n2);
return;
}*/
/*setN2 (index) {
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let theta2 = tat / 288.15;
let targetN1 = SimVar.GetSimVarValue(`L:SALTY_EEC_COM_N1:${index}`, "number"); //target N1 set by thrust lever position
let targetN2 = (targetN1 + 117.5) / 2.025;
SimVar.SetSimVarValue(`L:SALTY_EEC_COM_N2:${index}`, "percent", targetN2);
//let n2 = SimVar.GetSimVarValue(`TURB ENG N2:${index}`, "number") * 100; //actual N2 on the engine
//SimVar.SetSimVarValue(`L:SALTY_EEC_N2:${index}`, "percent", n2); //for debugging
//let tspool = 26.636 * (Math.log(targetN2) - Math.log(n2)); //time required in seconds
//SimVar.SetSimVarValue(`L:SALTY_EEC_SPOOL_TIME:${index}`, "number", tspool); //for debugging
//n2 *= Math.exp(0.001 * tspool * 0.0375);
//SimVar.SetSimVarValue("L:SALTY_EEC_N1", "percent", n1);
//SimVar.SetSimVarValue("L:SALTY_EEC_N12", "percent", n12);
//SimVar.SetSimVarValue(`TURB ENG CORRECTED N2:${index}`, "percent", n2 / (theta2 ** 0.5));
//SimVar.SetSimVarValue(`TURB ENG N2:${index}`, "percent", n2);
}*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about remove comments?

Comment on lines +123 to +130
setFuelFlow(index) {
let targetFF = SimVar.GetSimVarValue(`L:SALTY_EEC_COM_FF:${index}`, "number");
let FF = SimVar.GetSimVarValue(`TURB ENG FUEL FLOW:${index}`, "pound per hour");
let error = targetFF - FF;
/*while (error =! 0) {
//FF +=
}*/
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setFuelFlow(index) {
let targetFF = SimVar.GetSimVarValue(`L:SALTY_EEC_COM_FF:${index}`, "number");
let FF = SimVar.GetSimVarValue(`TURB ENG FUEL FLOW:${index}`, "pound per hour");
let error = targetFF - FF;
/*while (error =! 0) {
//FF +=
}*/
}
setFuelFlow(index) {
let targetFF = SimVar.GetSimVarValue(`L:SALTY_EEC_COM_FF:${index}`, "number");
let FF = SimVar.GetSimVarValue(`TURB ENG FUEL FLOW:${index}`, "pound per hour");
let error = targetFF - FF;
}

Comment on lines +132 to +148
/*setFuelFlow(index) {
let p = SimVar.GetSimVarValue("AMBIENT PRESSURE", "hectopascal");
let p0 = 1013.25;
let oat = SimVar.GetSimVarValue("AMBIENT TEMPERATURE", "kelvin");
let tat = SimVar.GetSimVarValue("TOTAL AIR TEMPERATURE", "kelvin");
let t0 = 288.15;
let mach = SimVar.GetSimVarValue("AIRSPEED MACH", "mach");
let delta = p / p0;
let delta2 = delta * (1 + 0.2 * mach ** 2) ** 3.5;
let theta = oat / t0;
let theta2 = tat / t0;
let cff = SimVar.GetSimVarValue(`TURB ENG CORRECTED FF:${index}`, "pound per hour");
let ff = cff * delta2 * theta2 ** 0.5;
SimVar.SetSimVarValue(`TURB ENG FUEL FLOW:${index}`, "pound per hour", ff);
//SimVar.SetSimVarValue(`TURB ENG CORRECTED FF:${index}`, "pound per hour", ff);
return;
}*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about remove this?

Comment on lines +1681 to +1682
//SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 23.2);
//SimVar.SetSimVarValue("K:AP_N1_HOLD", "bool", 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 23.2);
//SimVar.SetSimVarValue("K:AP_N1_HOLD", "bool", 1);

@@ -1664,7 +1664,7 @@
activateThrustRefMode() {
this.currentAutoThrottleStatus = AutoThrottleModeState.THRREF;
Coherent.call("GENERAL_ENG_THROTTLE_MANAGED_MODE_SET", ThrottleMode.CLIMB);
SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 90);
//SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 90);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 90);

@@ -1618,7 +1618,7 @@
return;
}
this.currentAutoThrottleStatus = AutoThrottleModeState.THR;
SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 80);
//SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 80);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//SimVar.SetSimVarValue("K:AP_N1_REF_SET", "number", 80);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants