@@ -3053,16 +3053,146 @@ class CJ4_SystemAnnunciations extends Cabin_Annunciations {
30533053 super ( ) ;
30543054 this . rootElementName = "" ;
30553055 this . offStart = true ;
3056+ this . warningTone = true ;
3057+ this . warningToneNameZ = new Name_Z ( "WT_tone_warning" ) ;
3058+ this . cautionToneNameZ = new Name_Z ( "WT_tone_caution" ) ;
30563059 }
30573060 init ( _root ) {
30583061 super . init ( _root ) ;
30593062 this . annunciations = _root . querySelector ( ".SystemAnnunciations" ) ;
30603063 }
30613064
3062- onUpdate ( _dTime ) {
3063- if ( ! this . annunciations )
3064- return ;
3065- super . onUpdate ( _dTime ) ;
3065+ onUpdate ( _deltaTime ) {
3066+ this . FrameCounterForAlternation ++ ;
3067+ let masterWarningAcknowledged = SimVar . GetSimVarValue ( "MASTER WARNING ACKNOWLEDGED" , "Bool" ) ;
3068+ let masterCautionAcknowledged = SimVar . GetSimVarValue ( "MASTER CAUTION ACKNOWLEDGED" , "Bool" ) ;
3069+ for ( let i = 0 ; i < this . allMessages . length ; i ++ ) {
3070+ let message = this . allMessages [ i ] ;
3071+ if ( message . Visible && ! message . Acknowledged ) {
3072+ if ( message . Type == Annunciation_MessageType . CAUTION && masterCautionAcknowledged ) {
3073+ this . needReload = true ;
3074+ message . Acknowledged = true ;
3075+ if ( this . firstAcknowledge && this . isAnnunciationsManager ) {
3076+ if ( this . gps . playInstrumentSound ( "aural_warning_ok" ) )
3077+ this . firstAcknowledge = false ;
3078+ }
3079+ }
3080+ else if ( message . Type == Annunciation_MessageType . WARNING && masterWarningAcknowledged ) {
3081+ this . needReload = true ;
3082+ message . Acknowledged = true ;
3083+ }
3084+ }
3085+ }
3086+ for ( var i = ( this . FrameCounterForAlternation & 7 ) ; i < this . allMessages . length ; i += 8 ) {
3087+ var message = this . allMessages [ i ] ;
3088+ var value = false ;
3089+ if ( message . Handler )
3090+ value = message . Handler ( ) != 0 ;
3091+ if ( value != message . Visible ) {
3092+ this . needReload = true ;
3093+ message . Visible = value ;
3094+ message . Acknowledged = ( this . gps . getTimeSinceStart ( ) < 10000 && ! this . offStart ) ;
3095+ if ( value ) {
3096+ switch ( message . Type ) {
3097+ case Annunciation_MessageType . WARNING :
3098+ this . displayWarning . push ( message ) ;
3099+ break ;
3100+ case Annunciation_MessageType . CAUTION :
3101+ this . displayCaution . push ( message ) ;
3102+ if ( ! message . Acknowledged && ! this . isPlayingWarningTone && this . isAnnunciationsManager ) {
3103+ let res = this . gps . playInstrumentSound ( "WT_tone_caution" ) ;
3104+ if ( res )
3105+ this . isPlayingWarningTone = true ;
3106+ }
3107+ break ;
3108+ case Annunciation_MessageType . ADVISORY :
3109+ this . displayAdvisory . push ( message ) ;
3110+ break ;
3111+ }
3112+ }
3113+ else {
3114+ switch ( message . Type ) {
3115+ case Annunciation_MessageType . WARNING :
3116+ for ( let i = 0 ; i < this . displayWarning . length ; i ++ ) {
3117+ if ( this . displayWarning [ i ] . Text == message . Text ) {
3118+ this . displayWarning . splice ( i , 1 ) ;
3119+ break ;
3120+ }
3121+ }
3122+ break ;
3123+ case Annunciation_MessageType . CAUTION :
3124+ for ( let i = 0 ; i < this . displayCaution . length ; i ++ ) {
3125+ if ( this . displayCaution [ i ] . Text == message . Text ) {
3126+ this . displayCaution . splice ( i , 1 ) ;
3127+ break ;
3128+ }
3129+ }
3130+ break ;
3131+ case Annunciation_MessageType . ADVISORY :
3132+ for ( let i = 0 ; i < this . displayAdvisory . length ; i ++ ) {
3133+ if ( this . displayAdvisory [ i ] . Text == message . Text ) {
3134+ this . displayAdvisory . splice ( i , 1 ) ;
3135+ break ;
3136+ }
3137+ }
3138+ break ;
3139+ }
3140+ }
3141+ }
3142+ }
3143+ if ( this . annunciations )
3144+ diffAndSetAttribute ( this . annunciations , "state" , this . gps . blinkGetState ( 800 , 400 ) ? "Blink" : "None" ) ;
3145+ if ( this . needReload ) {
3146+ let warningOn = 0 ;
3147+ let cautionOn = 0 ;
3148+ let messages = "" ;
3149+ for ( let i = this . displayWarning . length - 1 ; i >= 0 ; i -- ) {
3150+ messages += '<div class="Warning' ;
3151+ if ( ! this . displayWarning [ i ] . Acknowledged ) {
3152+ messages += '_Blink' ;
3153+ warningOn = 1 ;
3154+ }
3155+ messages += '">' + this . displayWarning [ i ] . Text + "</div>" ;
3156+ }
3157+ for ( let i = this . displayCaution . length - 1 ; i >= 0 ; i -- ) {
3158+ messages += '<div class="Caution' ;
3159+ if ( ! this . displayCaution [ i ] . Acknowledged ) {
3160+ messages += '_Blink' ;
3161+ cautionOn = 1 ;
3162+ }
3163+ messages += '">' + this . displayCaution [ i ] . Text + "</div>" ;
3164+ }
3165+ for ( let i = this . displayAdvisory . length - 1 ; i >= 0 ; i -- ) {
3166+ messages += '<div class="Advisory">' + this . displayAdvisory [ i ] . Text + "</div>" ;
3167+ }
3168+ this . warningTone = warningOn > 0 ;
3169+ if ( this . isAnnunciationsManager ) {
3170+ let masterWarningActive = SimVar . GetSimVarValue ( "MASTER WARNING ACTIVE" , "Bool" ) ;
3171+ if ( ( this . displayWarning . length > 0 ) != masterWarningActive || warningOn ) {
3172+ SimVar . SetSimVarValue ( "K:MASTER_WARNING_SET" , "Bool" , ( this . displayWarning . length > 0 ) ) ;
3173+ }
3174+ if ( this . displayWarning . length > 0 && ! warningOn ) {
3175+ SimVar . SetSimVarValue ( "K:MASTER_WARNING_ACKNOWLEDGE" , "Bool" , 1 ) ;
3176+ }
3177+ let masterCautionActive = SimVar . GetSimVarValue ( "MASTER CAUTION ACTIVE" , "Bool" ) ;
3178+ if ( ( this . displayCaution . length > 0 ) != masterCautionActive || cautionOn ) {
3179+ SimVar . SetSimVarValue ( "K:MASTER_CAUTION_SET" , "Bool" , ( this . displayCaution . length > 0 ) ) ;
3180+ }
3181+ if ( this . displayCaution . length > 0 && ! cautionOn ) {
3182+ SimVar . SetSimVarValue ( "K:MASTER_CAUTION_ACKNOWLEDGE" , "Bool" , 1 ) ;
3183+ }
3184+ SimVar . SetSimVarValue ( "L:Generic_Master_Warning_Active" , "Bool" , warningOn ) ;
3185+ SimVar . SetSimVarValue ( "L:Generic_Master_Caution_Active" , "Bool" , cautionOn ) ;
3186+ }
3187+ if ( this . annunciations )
3188+ diffAndSetHTML ( this . annunciations , messages ) ;
3189+ this . needReload = false ;
3190+ }
3191+ if ( this . warningTone && ! this . isPlayingWarningTone && this . isAnnunciationsManager ) {
3192+ let res = this . gps . playInstrumentSound ( "WT_tone_warning" ) ;
3193+ if ( res )
3194+ this . isPlayingWarningTone = true ;
3195+ }
30663196 }
30673197}
30683198class CJ4_SystemWarnings extends Cabin_Warnings {
0 commit comments