diff --git a/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/Shared/CJ4_Shared.js b/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/Shared/CJ4_Shared.js index 121e7e64b..ed374a508 100644 --- a/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/Shared/CJ4_Shared.js +++ b/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/Shared/CJ4_Shared.js @@ -3053,16 +3053,146 @@ class CJ4_SystemAnnunciations extends Cabin_Annunciations { super(); this.rootElementName = ""; this.offStart = true; + this.warningTone = true; + this.warningToneNameZ = new Name_Z("WT_tone_warning"); + this.cautionToneNameZ = new Name_Z("WT_tone_caution"); } init(_root) { super.init(_root); this.annunciations = _root.querySelector(".SystemAnnunciations"); } - onUpdate(_dTime) { - if (!this.annunciations) - return; - super.onUpdate(_dTime); + onUpdate(_deltaTime) { + this.FrameCounterForAlternation++; + let masterWarningAcknowledged = SimVar.GetSimVarValue("MASTER WARNING ACKNOWLEDGED", "Bool"); + let masterCautionAcknowledged = SimVar.GetSimVarValue("MASTER CAUTION ACKNOWLEDGED", "Bool"); + for (let i = 0; i < this.allMessages.length; i++) { + let message = this.allMessages[i]; + if (message.Visible && !message.Acknowledged) { + if (message.Type == Annunciation_MessageType.CAUTION && masterCautionAcknowledged) { + this.needReload = true; + message.Acknowledged = true; + if (this.firstAcknowledge && this.isAnnunciationsManager) { + if (this.gps.playInstrumentSound("aural_warning_ok")) + this.firstAcknowledge = false; + } + } + else if (message.Type == Annunciation_MessageType.WARNING && masterWarningAcknowledged) { + this.needReload = true; + message.Acknowledged = true; + } + } + } + for (var i = (this.FrameCounterForAlternation & 7); i < this.allMessages.length; i += 8) { + var message = this.allMessages[i]; + var value = false; + if (message.Handler) + value = message.Handler() != 0; + if (value != message.Visible) { + this.needReload = true; + message.Visible = value; + message.Acknowledged = (this.gps.getTimeSinceStart() < 10000 && !this.offStart); + if (value) { + switch (message.Type) { + case Annunciation_MessageType.WARNING: + this.displayWarning.push(message); + break; + case Annunciation_MessageType.CAUTION: + this.displayCaution.push(message); + if (!message.Acknowledged && !this.isPlayingWarningTone && this.isAnnunciationsManager) { + let res = this.gps.playInstrumentSound("WT_tone_caution"); + if (res) + this.isPlayingWarningTone = true; + } + break; + case Annunciation_MessageType.ADVISORY: + this.displayAdvisory.push(message); + break; + } + } + else { + switch (message.Type) { + case Annunciation_MessageType.WARNING: + for (let i = 0; i < this.displayWarning.length; i++) { + if (this.displayWarning[i].Text == message.Text) { + this.displayWarning.splice(i, 1); + break; + } + } + break; + case Annunciation_MessageType.CAUTION: + for (let i = 0; i < this.displayCaution.length; i++) { + if (this.displayCaution[i].Text == message.Text) { + this.displayCaution.splice(i, 1); + break; + } + } + break; + case Annunciation_MessageType.ADVISORY: + for (let i = 0; i < this.displayAdvisory.length; i++) { + if (this.displayAdvisory[i].Text == message.Text) { + this.displayAdvisory.splice(i, 1); + break; + } + } + break; + } + } + } + } + if (this.annunciations) + diffAndSetAttribute(this.annunciations, "state", this.gps.blinkGetState(800, 400) ? "Blink" : "None"); + if (this.needReload) { + let warningOn = 0; + let cautionOn = 0; + let messages = ""; + for (let i = this.displayWarning.length - 1; i >= 0; i--) { + messages += '
"; + } + for (let i = this.displayCaution.length - 1; i >= 0; i--) { + messages += ' "; + } + for (let i = this.displayAdvisory.length - 1; i >= 0; i--) { + messages += '