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

feat(fm): new flight model #379

Open
wants to merge 97 commits into
base: flight-model
Choose a base branch
from

Conversation

boufogre
Copy link
Contributor

No description provided.

boufogre and others added 30 commits May 11, 2021 16:57
Comment on lines +146 to +202
/*calculateAlt(p) {
//const alt = ((this.r * sat) / (this.g * this.mm)) * Math.log(this.p0 / p) * this.mToFeet;
const altH = this.h1 - ((this.r * this.t1) / (this.g0 * this.mm)) * Math.log(p / this.p1);
SimVar.SetSimVarValue ("L:74S_ADC_ALTH", "feet", altH);
const altL = this.h0 + ((p / this.p0) ** ((-this.r * this.l0) / (this.g0 * this.mm)) - 1) * (this.t0 / this.l0);
SimVar.SetSimVarValue("L:74S_ADC_ALTL", "feet", altL);
const alt = 15000;
if (!this.altSample) {
this.alt0 = alt;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = alt;
this.t1 = performance.now();
this.altSample = false;
}
if (alt < -1000 || alt > 50000) {
return this.ncd;
}
if (p >= 22632) {
if (!this.altSample) {
this.alt0 = altL;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altL;
this.t1 = performance.now();
this.altSample = false;
}
if (altL < -1000 || altL > 50000) {
return this.ncd;
}
//SimVar.SetSimVarValue("L:74S_ADC_ALTL", "feet", altL);
const alt = altL;
return alt;
}
else {
if (!this.altSample) {
this.alt0 = altH;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altH;
this.t1 = performance.now();
this.altSample = false;
}
if (altH < -1000 || altH > 50000) {
return this.ncd;
}
//SimVar.SetSimVarValue("L:74S_ADC_ALTH", "feet", altH);
const alt = altH;
return alt;
}
}*/

Choose a reason for hiding this comment

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

Suggested change
/*calculateAlt(p) {
//const alt = ((this.r * sat) / (this.g * this.mm)) * Math.log(this.p0 / p) * this.mToFeet;
const altH = this.h1 - ((this.r * this.t1) / (this.g0 * this.mm)) * Math.log(p / this.p1);
SimVar.SetSimVarValue ("L:74S_ADC_ALTH", "feet", altH);
const altL = this.h0 + ((p / this.p0) ** ((-this.r * this.l0) / (this.g0 * this.mm)) - 1) * (this.t0 / this.l0);
SimVar.SetSimVarValue("L:74S_ADC_ALTL", "feet", altL);
const alt = 15000;
if (!this.altSample) {
this.alt0 = alt;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = alt;
this.t1 = performance.now();
this.altSample = false;
}
if (alt < -1000 || alt > 50000) {
return this.ncd;
}
if (p >= 22632) {
if (!this.altSample) {
this.alt0 = altL;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altL;
this.t1 = performance.now();
this.altSample = false;
}
if (altL < -1000 || altL > 50000) {
return this.ncd;
}
//SimVar.SetSimVarValue("L:74S_ADC_ALTL", "feet", altL);
const alt = altL;
return alt;
}
else {
if (!this.altSample) {
this.alt0 = altH;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altH;
this.t1 = performance.now();
this.altSample = false;
}
if (altH < -1000 || altH > 50000) {
return this.ncd;
}
//SimVar.SetSimVarValue("L:74S_ADC_ALTH", "feet", altH);
const alt = altH;
return alt;
}
}*/

Comment on lines +204 to +255
calculateAlt(p) {
//const alt = ((this.r * sat) / (this.g * this.mm)) * Math.log(this.p0 / p) * this.mToFeet;
const altH = (this.h1 - ((this.r * this.temp1) / (this.g * this.mm)) * Math.log(p / this.p1)) * this.mToFeet;
const altL = (this.h0 + ((p / this.p0) ** ((-this.r * this.l0) / (this.g * this.mm)) - 1) * (this.temp0 / this.l0)) * this.mToFeet;
/*if (!this.altSample) {
this.alt0 = alt;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = alt;
this.t1 = performance.now();
this.altSample = false;
}
if (alt < -1000 || alt > 50000) {
return this.ncd;
}*/
if (p >= 22632) {
if (!this.altSample) {
this.alt0 = altL;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altL;
this.t1 = performance.now();
this.altSample = false;
}
if (altL < -1000 || altL > 50000) {
return this.ncd;
}
const alt = altL;
return alt;
}
else {
if (!this.altSample) {
this.alt0 = altH;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altH;
this.t1 = performance.now();
this.altSample = false;
}
if (altH < -1000 || altH > 50000) {
return this.ncd;
}
const alt = altH;
return alt;
}
}

Choose a reason for hiding this comment

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

Suggested change
calculateAlt(p) {
//const alt = ((this.r * sat) / (this.g * this.mm)) * Math.log(this.p0 / p) * this.mToFeet;
const altH = (this.h1 - ((this.r * this.temp1) / (this.g * this.mm)) * Math.log(p / this.p1)) * this.mToFeet;
const altL = (this.h0 + ((p / this.p0) ** ((-this.r * this.l0) / (this.g * this.mm)) - 1) * (this.temp0 / this.l0)) * this.mToFeet;
/*if (!this.altSample) {
this.alt0 = alt;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = alt;
this.t1 = performance.now();
this.altSample = false;
}
if (alt < -1000 || alt > 50000) {
return this.ncd;
}*/
if (p >= 22632) {
if (!this.altSample) {
this.alt0 = altL;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altL;
this.t1 = performance.now();
this.altSample = false;
}
if (altL < -1000 || altL > 50000) {
return this.ncd;
}
const alt = altL;
return alt;
}
else {
if (!this.altSample) {
this.alt0 = altH;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altH;
this.t1 = performance.now();
this.altSample = false;
}
if (altH < -1000 || altH > 50000) {
return this.ncd;
}
const alt = altH;
return alt;
}
}
calculateAlt(p) {
const altH = (this.h1 - ((this.r * this.temp1) / (this.g * this.mm)) * Math.log(p / this.p1)) * this.mToFeet;
const altL = (this.h0 + ((p / this.p0) ** ((-this.r * this.l0) / (this.g * this.mm)) - 1) * (this.temp0 / this.l0)) * this.mToFeet;
if (p >= 22632) {
if (!this.altSample) {
this.alt0 = altL;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altL;
this.t1 = performance.now();
this.altSample = false;
}
if (altL < -1000 || altL > 50000) {
return this.ncd;
}
const alt = altL;
return alt;
}
else {
if (!this.altSample) {
this.alt0 = altH;
this.t0 = performance.now();
this.altSample = true;
}
else {
this.alt1 = altH;
this.t1 = performance.now();
this.altSample = false;
}
if (altH < -1000 || altH > 50000) {
return this.ncd;
}
const alt = altH;
return alt;
}
}

Comment on lines +257 to +263
/*calculateBaroCorrAlt(sat, p, baroSetting) {
const alt = ((this.r * sat) / (this.g * this.mm)) * Math.log(baroSetting / p) * this.mToFeet;
if (alt < -1000 || alt > 50000) {
return this.ncd;
}
return alt;
}*/

Choose a reason for hiding this comment

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

Suggested change
/*calculateBaroCorrAlt(sat, p, baroSetting) {
const alt = ((this.r * sat) / (this.g * this.mm)) * Math.log(baroSetting / p) * this.mToFeet;
if (alt < -1000 || alt > 50000) {
return this.ncd;
}
return alt;
}*/

@@ -3,15 +3,27 @@ class SaltyBase {
this.irs = new SaltyIRS();
this.pilots = new SaltyPilots();
this.jettison = new SaltyJettison();
this.airground = new SaltyAirGroundLogic();
//this.flightphase = new SaltyFlightPhaseLogic();

Choose a reason for hiding this comment

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

Suggested change
//this.flightphase = new SaltyFlightPhaseLogic();

this.airground = new SaltyAirGroundLogic();
//this.flightphase = new SaltyFlightPhaseLogic();
this.adc = new SaltyADC();
//this.fadec = new SaltyFADEC();

Choose a reason for hiding this comment

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

Suggested change
//this.fadec = new SaltyFADEC();

Comment on lines +68 to +102
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);
this.keyListener.on('keyIntercepted', keyEventName => {
if (keyEventName === 'THROTTLE_CUT') {
if (SimVar.GetSimVarValue("GPS OBS ACTIVE", "boolean")) {
SimVar.SetSimVarValue("K:GPS_OBS_SET", "degrees", SimVar.GetSimVarValue("NAV OBS:1", "degree"));
}
console.log('THROTTLE CUT INTERCEPTED');
SimVar.SetSimVarValue("K:AXIS_THROTTLE_SET", "position 16K", 5995);
}
if (keyEventName === 'VOR1_OBI_DEC') {
if (SimVar.GetSimVarValue("GPS OBS ACTIVE", "boolean")) {
SimVar.SetSimVarValue("K:GPS_OBS_SET", "degrees", SimVar.GetSimVarValue("NAV OBS:1", "degree"));
}
}
});

});*/
//this.getEAI(index);
//this.getBleed(index);
//this.getAlternate(index);
//this.getTLA(index);
//this.getIdleN1(index);
//this.getMaxN1(index);
this.setCommandedN1(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() {
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);
this.keyListener.on('keyIntercepted', keyEventName => {
if (keyEventName === 'THROTTLE_CUT') {
if (SimVar.GetSimVarValue("GPS OBS ACTIVE", "boolean")) {
SimVar.SetSimVarValue("K:GPS_OBS_SET", "degrees", SimVar.GetSimVarValue("NAV OBS:1", "degree"));
}
console.log('THROTTLE CUT INTERCEPTED');
SimVar.SetSimVarValue("K:AXIS_THROTTLE_SET", "position 16K", 5995);
}
if (keyEventName === 'VOR1_OBI_DEC') {
if (SimVar.GetSimVarValue("GPS OBS ACTIVE", "boolean")) {
SimVar.SetSimVarValue("K:GPS_OBS_SET", "degrees", SimVar.GetSimVarValue("NAV OBS:1", "degree"));
}
}
});
});*/
//this.getEAI(index);
//this.getBleed(index);
//this.getAlternate(index);
//this.getTLA(index);
//this.getIdleN1(index);
//this.getMaxN1(index);
this.setCommandedN1(index);
}
return;
}
update() {
for (let i = 1; i < 5; i++){
let index = i;
this.setCommandedN1(index);
}
return;
}

@@ -1606,7 +1606,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);

@@ -1652,7 +1652,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);

Comment on lines +1669 to +1670
//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);

Comment on lines +42 to +44
<!-- <script type="text/html" import-script="/Pages/Salty/SaltyFlightPhaseLogic.js"></script> -->
<script type="text/html" import-script="/Pages/Salty/SaltyADC.js"></script>
<!-- <script type="text/html" import-script="/Pages/Salty/SaltyFADEC.js"></script> -->

Choose a reason for hiding this comment

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

Suggested change
<!-- <script type="text/html" import-script="/Pages/Salty/SaltyFlightPhaseLogic.js"></script> -->
<script type="text/html" import-script="/Pages/Salty/SaltyADC.js"></script>
<!-- <script type="text/html" import-script="/Pages/Salty/SaltyFADEC.js"></script> -->
<script type="text/html" import-script="/Pages/Salty/SaltyADC.js"></script>

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