Ejemplo n.º 1
0
 /// <summary>
 /// Close bus connection
 /// </summary>
 /// <returns>true if success, false if error</returns>
 public bool Disconnect()
 {
     FramingTimer.Stop();
     // Stop link thread
     LinkThread.Abort();
     return(PHY.Disconnect());
 }
Ejemplo n.º 2
0
        private void ClearState()
        {
            DisposeAudioComponents();
            if (_doAudioOperations != null)
            {
                _doAudioOperations.Clear();
            }
            if (_sessCreatedFlag)
            {
                _isCanvasCleared = WaveFormDisplay.ClearCanvas();
            }

            _waveDisplay.ChannelPosition = 0.0d;
            _isPlaying        = false;
            _sessCreatedFlag  = false;
            trialName.Content = "";

            PlayEnabled(false);
            _settingsObject.SessionCreatedFlag = false;
            LoopBtn.Content = (Image)FindResource("NoLoop");
            _microTimer.Stop();
            _sessionIndex = 0;
            _loopFalg     = false;
            WaveFormDisplay.RepeatRegionHeight = 0;
            WaveFormDisplay.RepeatRegionWidth  = 0;
            _current = -1;
            _next    = -1;
            StartText.Clear();
            StopText.Clear();
        }
Ejemplo n.º 3
0
 public void StopSound()
 {
     lock (speakerLock) {
         speakerTimer?.Stop();
         speakerTimer = null;
         speakerStream?.Close();
         speakerStream = null;
         speakerData   = null;
         //speakerPrebuffered = null;
     }
 }
Ejemplo n.º 4
0
 private void button2_Click(object sender, EventArgs e)
 {
     //Start/stop the timer
     if (button2.Text == "Start")
     {
         //Change button to stop
         button2.Text = "Stop";
         //Progress used to update UI
         if (update == null)
         {
             update = new Progress <int>();
             //also uses the UpdateUI function
             update.ProgressChanged += UpdateUI;
             //Assign the Progress object to the MicroTimer
             msTimer.Updater = update;
         }
         //Start the timer
         msTimer.Start();
     }
     else
     {
         //Stop the timer
         msTimer.Stop();
         //Change button to start
         button2.Text = "Start";
     }
 }
Ejemplo n.º 5
0
        private void ClearState()
        {
            DisposeAudioComponents();
            if (_doAudioOperations != null)
            {
                _doAudioOperations.Clear();
            }
            _waveDisplay.ChannelPosition       = 0.0d;
            WaveFormDisplay.RepeatRegionHeight = 0;
            WaveFormDisplay.RepeatRegionWidth  = 0;
            SelectEnd   = 0.0f;
            SelectBegin = 0.0f;
            _waveDisplay.SelectionBegin = TimeSpan.Zero;
            _waveDisplay.SelectionEnd   = TimeSpan.Zero;
            _isCanvasCleared            = WaveFormDisplay.ClearCanvas();
            LoopBtn.Content             = FindResource("NoLoop");
            PlayEnabled(false);
            HighlightPlayingAudio(-1);
            _settingsObject.SessionCreatedFlag = false;
            trialName.Content = "";
            _microTimer.Stop();

            _clickedButton   = 0;
            _loopFalg        = false;
            _sessionIndex    = 0;
            _isPlaying       = false;
            _sessCreatedFlag = false;
            StartText.Clear();
            StopText.Clear();
        }
Ejemplo n.º 6
0
        /*----------------------------------------------------------------------------
        *       %%Function:GetOptionsTextValueMappingFromControlId
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.GetOptionsTextValueMappingFromControlId
        *  ----------------------------------------------------------------------------*/
        public static Dictionary <string, string> GetOptionsTextValueMappingFromControlId(IWebDriver driver, IStatusReporter srpt, string sid)
        {
            MicroTimer timer = new MicroTimer();

            Dictionary <string, string> mp = GetOptionsTextValueMappingFromControl(driver.FindElement(By.Id(sid)), srpt);

            timer.Stop();
            srpt.LogData($"GetOptionsTextValueMappingFromControlId({sid}) elapsed: {timer.MsecFloat}", 1, MSGT.Body);
            return(mp);
        }
Ejemplo n.º 7
0
 private void OnSpeakerTimerEllapsed(object sender, MicroTimerEventArgs e)
 {
     if (sender == speakerTimer)
     {
         //Console.WriteLine(speakerWatch.ElapsedMilliseconds);
         //speakerWatch = Stopwatch.StartNew();
         WriteReport(nextSpeakerReport);
         //Console.WriteLine(speakerWatch.ElapsedMilliseconds);
         if (NextSpeakerReport())
         {
             speakerTimer.Stop();
             Trace.WriteLine("Sound END");
         }
     }
 }
        void Run()
        {
            masterTimer.Start();

            while (!_stop)
            {
                Thread.Sleep(1000);
            }

            masterTimer.Stop();

            foreach (TaskElement ele in tasks)
            {
                ele.threadTimer.Abort();
            }
        }
Ejemplo n.º 9
0
        /*----------------------------------------------------------------------------
        *       %%Function:FNavToPage
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.FNavToPage
        *
        *  ----------------------------------------------------------------------------*/
        public bool FNavToPage(string sUrl)
        {
            MicroTimer timer = new MicroTimer();

            try
            {
                Driver.Navigate().GoToUrl(sUrl);
            }
            catch (Exception)
            {
                return(false);
            }

            timer.Stop();
            m_iStatusReporter.LogData($"FNavToPage({sUrl}) elapsed: {timer.MsecFloat}", 1, MSGT.Body);
            return(true);
        }
Ejemplo n.º 10
0
        public void MicroTimer_ClockTicksAreCloseToThreadTimerTicks(int sleepSeconds, long interval, long ignoreIfLateBy, int msThreshold)
        {
            var ticks = 0;
            var clock = new MicroTimer(interval);

            clock.IgnoreEventIfLateBy = ignoreIfLateBy;
            clock.MicroTimerElapsed  += (sender, args) => ticks++;
            clock.Start();

            Thread.Sleep(sleepSeconds * 1000);
            //=== Manual Step : Check CPU to see processor efficiency.

            clock.Stop();
            Console.WriteLine(ticks);

            Assert.That(Math.Abs(ticks - (sleepSeconds * 1000000 / interval)) <= msThreshold);
        }
Ejemplo n.º 11
0
        /*----------------------------------------------------------------------------
        *       %%Function:WaitForPageLoad
        *       %%Qualified:ArbWeb.ArbWebControl_Selenium.WaitForPageLoad
        *  ----------------------------------------------------------------------------*/
        public static void WaitForPageLoad(IStatusReporter srpt, IWebDriver driver, int maxWaitTimeInSeconds)
        {
            MicroTimer timer = new MicroTimer();

            string state = string.Empty;

            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(maxWaitTimeInSeconds));

                //Checks every 500 ms whether predicate returns true if returns exit otherwise keep trying till it returns ture
                wait.Until(d => {
                    // use d instead of driver below?

                    try
                    {
                        state = ((IJavaScriptExecutor)driver).ExecuteScript(@"return document.readyState").ToString();
                    }
                    catch (InvalidOperationException)
                    {
                        //Ignore
                    }
                    catch (NoSuchWindowException)
                    {
                        //when popup is closed, switch to last windows
                        driver.SwitchTo().Window(driver.WindowHandles[driver.WindowHandles.Count - 1]);
                    }
                    //In IE7 there are chances we may get state as loaded instead of complete
                    return(state.Equals("complete", StringComparison.InvariantCultureIgnoreCase) ||
                           state.Equals("loaded", StringComparison.InvariantCultureIgnoreCase));
                });
            }
            catch (TimeoutException)
            {
                //sometimes Page remains in Interactive mode and never becomes Complete, then we can still try to access the controls
                if (!state.Equals("interactive", StringComparison.InvariantCultureIgnoreCase))
                {
                    throw;
                }
            }
            catch (NullReferenceException)
            {
                //sometimes Page remains in Interactive mode and never becomes Complete, then we can still try to access the controls
                if (!state.Equals("interactive", StringComparison.InvariantCultureIgnoreCase))
                {
                    throw;
                }
            }
            catch (WebDriverException)
            {
                if (driver.WindowHandles.Count == 1)
                {
                    driver.SwitchTo().Window(driver.WindowHandles[0]);
                }
                state = ((IJavaScriptExecutor)driver).ExecuteScript(@"return document.readyState").ToString();
                if (!(state.Equals("complete", StringComparison.InvariantCultureIgnoreCase) || state.Equals("loaded", StringComparison.InvariantCultureIgnoreCase)))
                {
                    throw;
                }
            }

            timer.Stop();
            srpt.LogData($"WaitForPageLoad elapsed: {timer.MsecFloat}", 1, MSGT.Body);
        }
 public void Reset()
 {
     timer.Stop();
     mainTicks = 0;
     sideTicks = 0;
 }