MainPage.xaml.cs
/// <summary>
/// when user press play button, this function is called
/// It will continues simulate process
/// </summary>
when user press play button, this function is called
It will continues simulate process
when user press play button this function is called It will continues simulate process
private async void Play_When_ReadFile()
        {
            streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
            Data.Time = sStartTime;
            UInt16 index = 0;
            bPlay = true;
            while (Convert.ToDouble(Data.Time) > (Convert.ToDouble(sDisplayTimeNotFormat))
                || Convert.ToDouble(Data.Time) < (Math.Round(Convert.ToDouble(sDisplayTimeNotFormat), 1) - 0.1))
            {
                strDataFromSerialPort = streamReader.ReadLine();
                processToDrawTrajactory();
                if (streamReader.Peek() <= 0)
                {
                    positions.Clear();
                    positions = new List<BasicGeoposition>();
                    streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                    while (Convert.ToDouble(Data.Time) > (Convert.ToDouble(sDisplayTimeNotFormat))
                        || Convert.ToDouble(Data.Time) < (Math.Round(Convert.ToDouble(sDisplayTimeNotFormat), 1) - 0.1))
                    {
                        strDataFromSerialPort = streamReader.ReadLine();
                        processToDrawTrajactory();
                    }
                    break;
                }
            }
            index = 0;
            old_Lat = dLatGol;
            old_Lon = dLonGol;
            while (streamReader.Peek() >= 0)
            {
                strDataFromSerialPort = streamReader.ReadLine();
                processDataToDrawTrajactory();
                sDisplayTimeNotFormat = Data.Time;
                if (-1 != Data.Time.IndexOf('.'))
                    tblock_Current_Timer.Text = Data.Time.Substring(0, Data.Time.Length - 6) + ':'
                            + Data.Time.Substring(Data.Time.Length - 6, 2) + ':' + Data.Time.Substring(Data.Time.Length - 4, 4);
                else
                    tblock_Current_Timer.Text = Data.Time.Substring(0, Data.Time.Length - 4) + ':'
                            + Data.Time.Substring(Data.Time.Length - 4, 2) + ':' + Data.Time.Substring(Data.Time.Length - 2, 2);
                slider_AdjTime.Value = 100 * (Convert.ToDouble(sDisplayTimeNotFormat) - Convert.ToDouble(sStartTime)) /
                    (Convert.ToDouble(sStopTime) - Convert.ToDouble(sStartTime));
                index++;
                if (index == limitSpeed)
                {
                    await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(0.5));
                    index = 0;
                }
                if (!bPlay) break;
            }
        }
private async void Play_When_ReadFile ( ) { streamReader . BaseStream . Seek ( 0 , SeekOrigin . Begin ) ; Data . Time = sStartTime ; UInt16 index = 0 ; bPlay = true ; while ( Convert . ToDouble ( Data . Time ) > ( Convert . ToDouble ( sDisplayTimeNotFormat ) ) || Convert . ToDouble ( Data . Time ) < ( Math . Round ( Convert . ToDouble ( sDisplayTimeNotFormat ) , 1 ) - 0.1 ) ) { strDataFromSerialPort = streamReader . ReadLine ( ) ; processToDrawTrajactory ( ) ; if ( streamReader . Peek ( ) <= 0 ) { positions . Clear ( ) ; positions = new List < BasicGeoposition > ( ) ; streamReader . BaseStream . Seek ( 0 , SeekOrigin . Begin ) ; while ( Convert . ToDouble ( Data . Time ) > ( Convert . ToDouble ( sDisplayTimeNotFormat ) ) || Convert . ToDouble ( Data . Time ) < ( Math . Round ( Convert . ToDouble ( sDisplayTimeNotFormat ) , 1 ) - 0.1 ) ) { strDataFromSerialPort = streamReader . ReadLine ( ) ; processToDrawTrajactory ( ) ; } break ; } } index = 0 ; old_Lat = dLatGol ; old_Lon = dLonGol ; while ( streamReader . Peek ( ) >= 0 ) { strDataFromSerialPort = streamReader . ReadLine ( ) ; processDataToDrawTrajactory ( ) ; sDisplayTimeNotFormat = Data . Time ; if ( - 1 != Data . Time . IndexOf ( ' ' ) ) tblock_Current_Timer . Text = Data . Time . Substring ( 0 , Data . Time . Length - 6 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 6 , 2 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 4 , 4 ) ; else tblock_Current_Timer . Text = Data . Time . Substring ( 0 , Data . Time . Length - 4 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 4 , 2 ) + ' ' + Data . Time . Substring ( Data . Time . Length - 2 , 2 ) ; slider_AdjTime . Value = 100 * ( Convert . ToDouble ( sDisplayTimeNotFormat ) - Convert . ToDouble ( sStartTime ) ) / ( Convert . ToDouble ( sStopTime ) - Convert . ToDouble ( sStartTime ) ) ; index ++ ; if ( index == limitSpeed ) { await System . Threading . Tasks . Task . Delay ( TimeSpan . FromMilliseconds ( 0.5 ) ) ; index = 0 ; } if ( ! bPlay ) break ; } }
when user press play button, this function is called
It will continues simulate process
when user press play button this function is called It will continues simulate process
//when time sample = 0.2s, we add Convert.ToDouble( Data.Time) != (Convert.ToDouble(tblock_Current_Timer.Text) - 0.1) //find time to start //processDataToGetInf(); //both process and collect point //find time to start //processDataToGetInf(); //both process and collect point //dang chon thoi gian nho hon hien tai //reset index; //update old_lat and old_lon because program will draw 1 line connect before point and current point //tblock_Current_Timer.Text = Data.Time; //format hour:min:sec //have '.' in Data.Time 82754.7 //ProcessData();