Example #1
0
        private void buttonNext_Click(object sender, EventArgs e)
        {
            string path = @"\datas\" + DateTime.Now.ToString("MMddHHmm") + ".csv";

            CycleRoutine.writeDatas(_cycleDataList, path);
            ClearChart();
        }
Example #2
0
        public void OnFreeTick_Timer(object sender, EventArgs e)
        {
            double TimeSecond = FTPTimer.ElapsedMilliseconds / 1000.0;

            if (TimeSecond < 20 * 60 && !giveupFlag)
            {
                labelFtpStatus.Text = "Measuring";
                labelTimer.Text     = TimeSecond.ToString();
                labelVoltage.Text   = CycleRoutine.ToRoundDown((double.Parse(Voltage) / 1000.0), 7).ToString();
                try
                {
                    FTPSum  += double.Parse(textBoxWatt.Text);
                    SumCount = SumCount + 1.0;
                }
                catch (Exception)
                {
                    return;
                }
                labelFTP.Text = CycleRoutine.ToRoundDown(((FTPSum / SumCount) * 0.95), 2).ToString();
            }
            else
            {
                labelFtpStatus.Text = "Confirmed";
            }
        }
Example #3
0
 public void ShowCycleData(CycleDatas cData)
 {
     if (cData.Cadence != null && cData.Speed != null && cData.Watt != null && cData.Timer != null)
     {
         textBoxCadence.Text = CycleRoutine.ToRoundDown(double.Parse(cData.Cadence), 1).ToString();
         textBoxWatt.Text    = CycleRoutine.ToRoundDown(double.Parse(cData.Watt) / 2.25, 1).ToString();
     }
 }
Example #4
0
        public void OnTabataTick_Timer(object sender, EventArgs e)
        {
            double TimeSecond = TabataTimer.ElapsedMilliseconds / 1000.0;

            if (IntervalCounter > 7)
            {
                IntervalCounter     = 0;
                labelFtpStatus.Text = "Completed";

                TabataTimer.Stop();
            }
            if (TimeSecond < 20 + IntervalCounter * 30 && !giveupFlag)
            {
                if (BeepFlag)
                {
                    System.Media.SystemSounds.Beep.Play();
                    BeepFlag = !BeepFlag;
                }
                labelFtpStatus.Text = "Full Power";
                labelTimer.Text     = TimeSecond.ToString();
                labelVoltage.Text   = CycleRoutine.ToRoundDown((double.Parse(Voltage) / 1000.0), 7).ToString();
                try
                {
                    FTPSum  += double.Parse(textBoxWatt.Text);
                    SumCount = SumCount + 1.0;
                }
                catch (Exception)
                {
                    return;
                }
                labelFTP.Text = CycleRoutine.ToRoundDown(((FTPSum / SumCount) * 0.95), 2).ToString();
            }
            else if (TimeSecond < 30 + IntervalCounter * 30 && !giveupFlag)
            {
                if (!BeepFlag)
                {
                    System.Media.SystemSounds.Beep.Play();
                    BeepFlag = !BeepFlag;
                }
                labelFtpStatus.Text = "Rest";
                labelTimer.Text     = TimeSecond.ToString();
                labelVoltage.Text   = CycleRoutine.ToRoundDown((double.Parse(Voltage) / 1000.0), 7).ToString();
                try
                {
                    FTPSum  += double.Parse(textBoxWatt.Text);
                    SumCount = SumCount + 1.0;
                }
                catch (Exception)
                {
                    return;
                }
                labelFTP.Text = CycleRoutine.ToRoundDown(((FTPSum / SumCount) * 0.95), 2).ToString();
            }
            else
            {
                IntervalCounter++;
            }
        }
Example #5
0
        private async void serialPortCycle_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            var sw = new Stopwatch();

            sw.Start();
            await Task.Run(() =>
            {
                try
                {
                    data += serialPortCycle.ReadExisting();
                }
                catch (Exception)
                {
                    return;
                }
            });

            sw.Stop();

            //受信に時間がかかりすぎた場合はbufferを削除します。(いらないかも)
            if (sw.ElapsedMilliseconds > 5000)
            //      serialPortCycle.DiscardInBuffer();

            //データが短すぎるもしくは長すぎる場合は、returnしてdataの中身を調整します。

            #region filter
            {
                try
                {
                    if (data == null)
                    {
                        return;
                    }
                    else if (data.Length < Constants.minDataPoolAmount)
                    {
                        return;
                    }
                    else if (data.Length > Constants.maxDataPoolAmount)
                    {
                        data = null;
                        return;
                    }
                }
                catch (Exception ex) { }
            }
            #endregion

            var tempDataLines = data.Trim().Replace(";\r\n;", "\n").Split('\n');
            var dataLines     = new List <string>();
            foreach (var dataMem in tempDataLines)
            {
                if (dataMem.Length > 20)
                {
                    dataLines.Add(dataMem);
                }
            }
            try
            {
                foreach (var dataLine in dataLines)
                {
                    var datas = dataLine.Trim().Split(';');
                    foreach (var oneData in datas)
                    {
                        if (String.IsNullOrEmpty(oneData))
                        {
                            return;
                        }
                    }

                    if (datas.Count() == 14)
                    {
                        var _cycleData = new CycleDatas();
                        _cycleData.Voltage = datas[5];
                        Voltage            = datas[5];
                        _cycleData.Watt    = CycleRoutine.CadenceToWatt((-double.Parse(datas[13]) / 6.0), _loadLevel).ToString();
                        _cycleData.Speed   = (-double.Parse(datas[13])).ToString();
                        _cycleData.Cadence = (-double.Parse(datas[13]) / 6.0).ToString();
                        _cycleData.Timer   = generalTimer;
                        _cycleDataList.Add(_cycleData);
                        BeginInvoke((MethodInvoker)(() => ShowCycleData(_cycleData)));
                        BeginInvoke(new ChartHandler(ShowChart), _cycleData);
                    }
                }
            }
            catch (Exception)
            {
                return;
            }
        }