Beispiel #1
0
        /*
         * /// <summary>
         * /// Occurs when the Module connects to a Tcp Server
         * /// </summary>
         * public event ModuleConnectionEH Connected;
         *
         * /// <summary>
         * /// Occurs when the Module disconnects from a Tcp Server
         * /// </summary>
         * public event ModuleConnectionEH Disconnected;
         */
        #endregion

        #region Methods

        /// <summary>
        /// Performs Restart Tasks
        /// </summary>
        protected override void DoRestartModule()
        {
            restartRequested     = false;
            restartTestRequested = false;
            Busy = true;

            Unlock();
            dataReceived.Clear();
            if ((client != null) && client.IsOpen)
            {
                try { client.Disconnect(); }
                catch { }
            }
            ExecuteRestartActions();
            Busy = false;
        }
Beispiel #2
0
 /// <summary>
 /// Cancels all audio play operations
 /// </summary>
 public void StopAll()
 {
     playQueue.Clear();
     if (playingAudio != null)
     {
         try
         {
             lock (playingAudio)
             {
                 playingAudio.Pause();
                 playingAudio.Stop();
             }
         }
         catch {}
         lastPlayResult = PlayOperationResult.Canceled;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Performs Restart-test Tasks
        /// </summary>
        protected override void DoRestartTest()
        {
            Busy = true;

            commandsReceived.Clear();
            ExecuteRestartTestActions();

            Busy = false;
        }
Beispiel #4
0
        protected virtual void SpeechThreadTask()
        {
            running = true;
            #region Voices Initialization
            // Voices Initialization
            //while (running && (voiceNames.Count < 1))
            //{
            //    Thread.Sleep(100);
            //    LoadVoices();
            //}
            #endregion

            while (running)
            {
                try
                {
                    SpeechTextTask stt = speechQueue.Consume(100);
                    if (stt == null)
                    {
                        continue;
                    }
                    Speak(stt);
                }
                catch (ThreadInterruptedException tiex)
                {
                    Console.WriteLine("SpeechThread aborted: " + tiex.ToString());
                    return;
                }
                catch (ThreadAbortException taex)
                {
                    Console.WriteLine("SpeechThread aborted: " + taex.ToString());
                    ShutUp();
                    return;
                }
                catch { continue; }
            }
            ShutUp();
            speechQueue.Clear();
        }
Beispiel #5
0
        private void PlayAudioThreadTask()
        {
            PlayAudioTask audioTask;

            running = true;

            while (running)
            {
                try
                {
                    audioTask = playQueue.Consume();
                    if ((audioTask == null) || (audioTask.Audio == null))
                    {
                        continue;
                    }
                    if (!Play(audioTask))
                    {
                        playQueue.Produce(audioTask);
                    }
                }
                catch (ThreadAbortException taex)
                {
                    Console.WriteLine(taex.Message);
                    playQueue.Clear();
                    return;
                }
                catch (ThreadInterruptedException tiex)
                {
                    Console.WriteLine(tiex.Message);
                    continue;
                }
                catch
                {
                    Thread.Sleep(100);
                    continue;
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Clears out all the contents of dataReceived, commandsReceived, responsesReceived and unpairedResponses Queues/Lists
 /// </summary>
 protected virtual void CleanBuffers()
 {
     dataReceived.Clear();
 }