//表に表示するテキストを決定します
        string GetTableText(List <Data> dataList, SleepData.HeadDir headDir, string ibikiLabelName)
        {
            //頭の向き、いびきの大きさ両方の条件に合致したデータ個数
            int detectCount = 0;

            detectCount += dataList.Where(data => data.HeadDir1 == headDir && TransIbikiLoudnessToLabel(data.SnoreVolume1).GetName() == ibikiLabelName).Count();
            detectCount += dataList.Where(data => data.HeadDir2 == headDir && TransIbikiLoudnessToLabel(data.SnoreVolume2).GetName() == ibikiLabelName).Count();
            detectCount += dataList.Where(data => data.HeadDir3 == headDir && TransIbikiLoudnessToLabel(data.SnoreVolume3).GetName() == ibikiLabelName).Count();
            System.TimeSpan timeSpan = new System.TimeSpan(0, 0, detectCount * 10); //データ個数から10秒をかけて検知時間とする
            return(timeSpan.ToString());                                            //hh:mm:ssの形式に変換して返す
        }
Beispiel #2
0
        public IEnumerator UpdateTimer()
        {
            while (timerGoing)
            {
                elapsedTime += Time.deltaTime;
                timeCounter  = TimeSpan.FromSeconds(elapsedTime);

                timeDisplay.text = timeCounter.ToString(@"hh\:mm\:ss\.ff");
                if (timeCounter.TotalDays >= 1)
                {
                    timeDisplay.text = "Too Long";
                }

                yield return(null);
            }
        }
Beispiel #3
0
        public IEnumerator UpdateTimerAroma()
        {
            while (timerGoing)
            {
                elapsedTime += Time.deltaTime;
                timeCounter  = TimeSpan.FromSeconds(elapsedTime);

                timeDisplay.text = timeCounter.ToString(@"hh\:mm\:ss\.ff");
                if (timeCounter.TotalMinutes >= 6 && swappedColours == false)
                {
                    timeDisplay.color = warningColour;
                    swappedColours    = true;
                }
                else if (timeCounter.TotalMinutes >= 7)
                {
                    StartCoroutine(EventManager.instance.DisplayGameOver(false));
                }

                yield return(null);
            }
        }
Beispiel #4
0
        private void mnuExportPeriodByDay_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (cboPeriod.Text != "Custom")
                {
                    MessageBox.Show("This summary is only valid for the Custom view");
                    return;
                }

                Timer timer = this.GetSelectedTimer();
                if (timer == null)
                {
                    return;
                }

                DateTime start = dtFromFilter.Value;
                DateTime end   = this.dtToPicker.Value;

                System.IO.StringWriter sw = new System.IO.StringWriter();
                while (start < end)
                {
                    TimeSpan duration = timer.GetTotal(start, start.AddDays(1));
                    sw.WriteLine(start.ToString() + "\t" + duration.ToString());


                    start = start.AddDays(1);
                }

                System.Windows.Forms.Clipboard.SetDataObject(sw.ToString(), true);
                MessageBox.Show("The data has been successfully copied to the clipboard");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteValue(_value.ToString());
 }
Beispiel #6
0
        public void TestForOneMicrosecond()
        {
            System.Collections.Generic.List <System.Tuple <bool, System.TimeSpan, System.TimeSpan> > l = new System.Collections.Generic.List <System.Tuple <bool, System.TimeSpan, System.TimeSpan> >();

            //Create a Timer that will elapse every `OneMicrosecond`
            for (int i = 0; i < 250; ++i)
            {
                using (Media.Concepts.Classes.Stopwatch sw = new Media.Concepts.Classes.Stopwatch())
                {
                    var started = System.DateTime.UtcNow;

                    System.Console.WriteLine("Started: " + started.ToString("MM/dd/yyyy hh:mm:ss.ffffff tt"));

                    //Define some amount of time
                    System.TimeSpan sleepTime = Media.Common.Extensions.TimeSpan.TimeSpanExtensions.OneMicrosecond;

                    System.Diagnostics.Stopwatch testSw = new System.Diagnostics.Stopwatch();

                    //Start
                    testSw.Start();

                    //Start
                    sw.Start();

                    //while (sw.Elapsed.Ticks < sleepTime.Ticks - (Common.Extensions.TimeSpan.TimeSpanExtensions.OneTick + Common.Extensions.TimeSpan.TimeSpanExtensions.OneTick).Ticks)
                    //{
                    //    //sw.Timer.m_Clock.NanoSleep(0); //System.Threading.Thread.SpinWait(0);

                    //    System.Console.WriteLine(sw.ElapsedNanoseconds);

                    //}

                    while (double.IsNaN(sw.ElapsedNanoseconds))
                    {
                        sw.Timer.m_Clock.NanoSleep(0);
                        //sw.Timer.m_Counter.Join(0);
                    }

                    //while (sw.ElapsedNanoseconds == 0.0 && sw.Elapsed == System.TimeSpan.Zero)
                    //{
                    //    sw.Timer.m_Clock.NanoSleep(0);

                    //    System.Console.WriteLine(sw.ElapsedNanoseconds);
                    //}

                    //Sleep the desired amount
                    //System.Threading.Thread.Sleep(sleepTime);

                    //Stop
                    testSw.Stop();

                    //Stop
                    sw.Stop();

                    System.Console.WriteLine(sw.ElapsedNanoseconds);

                    System.Console.WriteLine(sw.Units);

                    var finished = System.DateTime.UtcNow;

                    var taken = finished - started;

                    var cc = System.Console.ForegroundColor;

                    System.Console.WriteLine("Finished: " + finished.ToString("MM/dd/yyyy hh:mm:ss.ffffff tt"));

                    System.Console.WriteLine("Sleep Time: " + sleepTime.ToString());

                    System.Console.WriteLine("Real Taken Total: " + taken.ToString());

                    if (taken > sleepTime)
                    {
                        System.Console.ForegroundColor = System.ConsoleColor.Red;
                        System.Console.WriteLine("Missed by: " + (taken - sleepTime));
                    }
                    else
                    {
                        System.Console.ForegroundColor = System.ConsoleColor.Green;
                        System.Console.WriteLine("Still have: " + (sleepTime - taken));
                    }

                    System.Console.ForegroundColor = cc;

                    System.Console.WriteLine("Real Taken msec Total: " + taken.TotalMilliseconds.ToString());

                    System.Console.WriteLine("Real Taken sec Total: " + taken.TotalSeconds.ToString());

                    System.Console.WriteLine("Real Taken μs Total: " + Media.Common.Extensions.TimeSpan.TimeSpanExtensions.TotalMicroseconds(taken).ToString());

                    System.Console.WriteLine("Managed Taken Total: " + sw.Elapsed.ToString());

                    System.Console.WriteLine("Diagnostic Taken Total: " + testSw.Elapsed.ToString());

                    System.Console.WriteLine("Diagnostic Elapsed Seconds  Total: " + ((testSw.ElapsedTicks / (double)System.Diagnostics.Stopwatch.Frequency)));

                    //Write the rough amount of time taken in  micro seconds
                    System.Console.WriteLine("Managed Time Estimated Taken: " + sw.ElapsedMicroseconds + "μs");

                    //Write the rough amount of time taken in  micro seconds
                    System.Console.WriteLine("Diagnostic Time Estimated Taken: " + Media.Common.Extensions.TimeSpan.TimeSpanExtensions.TotalMicroseconds(testSw.Elapsed) + "μs");

                    System.Console.WriteLine("Managed Time Estimated Taken: " + sw.ElapsedMilliseconds);

                    System.Console.WriteLine("Diagnostic Time Estimated Taken: " + testSw.ElapsedMilliseconds);

                    System.Console.WriteLine("Managed Time Estimated Taken: " + sw.ElapsedSeconds);

                    System.Console.WriteLine("Diagnostic Time Estimated Taken: " + testSw.Elapsed.TotalSeconds);

                    if (sw.Elapsed < testSw.Elapsed)
                    {
                        System.Console.WriteLine("Faster than Diagnostic StopWatch");
                        l.Add(new System.Tuple <bool, System.TimeSpan, System.TimeSpan>(true, sw.Elapsed, testSw.Elapsed));
                    }
                    else if (sw.Elapsed > testSw.Elapsed)
                    {
                        System.Console.WriteLine("Slower than Diagnostic StopWatch");
                        l.Add(new System.Tuple <bool, System.TimeSpan, System.TimeSpan>(false, sw.Elapsed, testSw.Elapsed));
                    }
                    else
                    {
                        System.Console.WriteLine("Equal to Diagnostic StopWatch");
                        l.Add(new System.Tuple <bool, System.TimeSpan, System.TimeSpan>(true, sw.Elapsed, testSw.Elapsed));
                    }
                }
            }

            int w = 0, f = 0;

            var cc2 = System.Console.ForegroundColor;

            foreach (var t in l)
            {
                if (t.Item1)
                {
                    System.Console.ForegroundColor = System.ConsoleColor.Green;
                    ++w; System.Console.WriteLine("Faster than Diagnostic StopWatch by: " + (t.Item3 - t.Item2));
                }
                else
                {
                    System.Console.ForegroundColor = System.ConsoleColor.Red;
                    ++f; System.Console.WriteLine("Slower than Diagnostic StopWatch by: " + (t.Item2 - t.Item3));
                }
            }

            System.Console.ForegroundColor = System.ConsoleColor.Green;
            System.Console.WriteLine("Wins = " + w);

            System.Console.ForegroundColor = System.ConsoleColor.Red;
            System.Console.WriteLine("Loss = " + f);

            System.Console.ForegroundColor = cc2;
        }
Beispiel #7
0
 public static string ToFormattedString(this System.TimeSpan timeSpan)
 => timeSpan.ToString(@"hh\:mm\:ss\.fff");
Beispiel #8
0
 public string GetTime()
 {
     return(timeCounter.ToString(@"hh\:mm\:ss\.ff"));
 }
Beispiel #9
0
 string GetTimeSpanText(System.TimeSpan span)
 {
     return(span.ToString(CultureStrings.FormatTimeSpan));
 }