Пример #1
0
        public void PerformUpdate(DataModel.IErg givenErg)
        {
            if (dryRun)
            {
                return;
            }

            if (db == null)
            {
                db = new SQLiteConnection(filename);
                db.CreateTable <rowdata>();
            }

            var s = db.Insert(new rowdata()
            {
                avgpace   = 0.0,
                calhr     = 0.0,
                calories  = givenErg.Calories,
                distance  = givenErg.Distance,
                heartrate = givenErg.Heartrate,
                pace      = givenErg.PaceInSecs,
                power     = givenErg.Power,
                spm       = givenErg.Cadence,
                timestamp = givenErg.ExerciseTime
            });
        }
Пример #2
0
        public void PerformUpdate(DataModel.IErg givenErg)
        {
            Cadence      = givenErg.Cadence + " SPM";
            Calories     = givenErg.Calories.ToString() + " cal";
            Distance     = givenErg.Distance.ToString("#.") + " m";
            ExerciseTime = TimeSpan.FromSeconds(givenErg.ExerciseTime).ToString(@"hh\:mm\:ss");
            Pace         = TimeSpan.FromSeconds(givenErg.PaceInSecs).ToString(@"mm\:ss");
            Power        = givenErg.Power.ToString() + " Watt";

            if (givenErg.ExerciseTime > 5.0)
            {
                double avgPaceDouble = 500.0 / (givenErg.Distance / givenErg.ExerciseTime);
                AvgPace = TimeSpan.FromSeconds(avgPaceDouble).ToString(@"mm\:ss\.fff");
            }

            if (givenErg.ExerciseTime > 5.0)
            {
                double timeLeft       = 1800.0 - givenErg.ExerciseTime; //TODO: Do not assume 30min, make this configurable
                double forecastDouble = givenErg.Distance + (timeLeft * (500.0 / givenErg.PaceInSecs));
                Forecast = forecastDouble.ToString("#.") + " m";
            }

            NotifyOfPropertyChange(() => AvgPace);
            NotifyOfPropertyChange(() => Cadence);
            NotifyOfPropertyChange(() => Calories);
            NotifyOfPropertyChange(() => Distance);
            NotifyOfPropertyChange(() => ExerciseTime);
            NotifyOfPropertyChange(() => Forecast);
            NotifyOfPropertyChange(() => Pace);
            NotifyOfPropertyChange(() => Power);
        }