Example #1
0
 private void CancelMsg(SoundMessage msg)
 {
     if (!msg.Background)
     {
         m_MessagesQueue.Remove(msg);
     }
     msg.Stop();
 }
Example #2
0
        private RitaVoiceProcessor()
        {
            MsgBingoFuel = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_Bingo)
            };
            SupportedMessages.Add(MsgBingoFuel);

            MsgAoAMaximum = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_MaximumAngleOfAttack)
            };
            SupportedMessages.Add(MsgAoAMaximum);

            MsgAoAOverLimit = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_AngleOfAttackOverLimit), Background = true, PlayInOut = false
            };
            SupportedMessages.Add(MsgAoAOverLimit);

            MsgGMaximum = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_GOverLimit)
            };
            SupportedMessages.Add(MsgGMaximum);

            MsgGOverLimit = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_GOverLimit)
            };
            SupportedMessages.Add(MsgGOverLimit);

            MsgPullUp = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_PullUp)
            };
            SupportedMessages.Add(MsgPullUp);

            MsgOverspeed = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_MaximumSpeed)
            };
            SupportedMessages.Add(MsgOverspeed);

            MsgGearUp = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_GearUp)
            };
            SupportedMessages.Add(MsgGearUp);

            MsgGearDown = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.RITA_GearDown)
            };
            SupportedMessages.Add(MsgGearDown);
        }
Example #3
0
 private void ProcessMsg(SoundMessage msg, bool actual)
 {
     if (actual)
     {
         PlayMsg(msg);
     }
     else
     {
         CancelMsg(msg);
     }
 }
Example #4
0
 public void Remove(SoundMessage message)
 {
     lock (m_IOLock)
     {
         if (m_List.Contains(message))
         {
             m_List.RemoveAll(m => m == message);
             if (m_List.Count == 0)
             {
                 m_NotEmptyEvent.Reset();
             }
         }
     }
 }
Example #5
0
 public void Enqueue(SoundMessage message)
 {
     lock (m_IOLock)
     {
         if (!m_List.Contains(message))
         {
             m_List.Add(message);
             if (m_NotEmptyEvent.CurrentCount > 0)
             {
                 m_NotEmptyEvent.Signal();
             }
         }
     }
 }
Example #6
0
 private void PlayMsg(SoundMessage msg)
 {
     if (msg != null)
     {
         if (msg.Background)
         {
             msg.Play();
         }
         else
         {
             m_MessagesQueue.Enqueue(msg);
         }
     }
 }
Example #7
0
        public void Stop()
        {
            lock (m_StartStopMonitor)
            {
                m_Current?.Stop();
                m_Current = null;

                foreach (var msg in SupportedMessages)
                {
                    msg.Stop();
                }

                m_CancellationToken.Cancel();
                m_MessagesQueue.Reset();
            }
        }
Example #8
0
        public void Start()
        {
            lock (m_StartStopMonitor)
            {
                if (m_ProcessingTask != null && !m_ProcessingTask.IsCompleted)
                {
                    m_ProcessingTask.Wait();
                    m_ProcessingTask.Dispose();
                }

                m_CancellationToken?.Dispose();
                m_CancellationToken = new CancellationTokenSource();
                foreach (var msg in SupportedMessages)
                {
                    msg.m_Device = m_Device;
                }

                m_ProcessingTask = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        while (!m_CancellationToken.IsCancellationRequested)
                        {
                            bool playInOut = false;
                            var msgToPlay  = m_MessagesQueue.PeekOrWait(m_CancellationToken.Token);
                            {
                                if (msgToPlay != null)
                                {
                                    m_Current = msgToPlay;
                                    if (!playInOut)
                                    {
                                        playInOut = msgToPlay.PlayInOut;
                                    }

                                    if (playInOut)
                                    {
                                        SoundMsgStart?.PlaySync();
                                    }

                                    msgToPlay.Play();
                                    m_Current = null;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            if (playInOut)
                            {
                                SoundMsgEnd?.PlaySync();
                            }
                        }
                    }
                    catch (ThreadInterruptedException) { /*ignored*/ }
                    catch (OperationCanceledException) { /*ignored*/ }
                    catch (Exception)
                    {
                        if (!m_CancellationToken.IsCancellationRequested)
                        {
                            Start();
                        }
                    }
                }, m_CancellationToken.Token);
            }
        }
Example #9
0
        private BettyVoiceProcessor()
        {
            MsgBingoFuel = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.Bingo)
            };
            SupportedMessages.Add(MsgBingoFuel);

            MsgAoAMaximum = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.MaximumAngleOfAttack), Background = true, PlayInOut = false
            };
            SupportedMessages.Add(MsgAoAMaximum);

            MsgAoAOverLimit = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.AngleOfAttackOverLimit), Background = true, PlayInOut = false
            };
            SupportedMessages.Add(MsgAoAOverLimit);

            MsgGMaximum = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.OverG)
            };
            SupportedMessages.Add(MsgGMaximum);

            MsgGOverLimit = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.GOverLimit)
            };
            SupportedMessages.Add(MsgGOverLimit);

            MsgPullUp = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.PullUp)
            };
            SupportedMessages.Add(MsgPullUp);

            MsgOverspeed = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.MaximumSpeed)
            };
            SupportedMessages.Add(MsgOverspeed);

            MsgGearUp = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.GearUp)
            };
            SupportedMessages.Add(MsgGearUp);

            MsgGearDown = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.GearDown)
            };
            SupportedMessages.Add(MsgGearDown);

            MsgSinkRate = new SoundMessage()
            {
                Sound = new SoundPlayer(Properties.Resources.SinkRate)
            };
            SupportedMessages.Add(MsgSinkRate);
        }