Esempio n. 1
0
        public static Lap CreateFrom(D1015_Lap_Type lap_type)
        {
            Lap lap = new Lap();

            lap.Index          = lap_type.index;
            lap.TotalDistance  = lap_type.total_dist;
            lap.MaxSpeed       = lap_type.max_speed;
            lap.Begin          = lap_type.begin;
            lap.End            = lap_type.end;
            lap.CaloriesBurned = (int)lap_type.calories;
            lap.AvgHeartRate   = (int)lap_type.avg_heart_rate;
            lap.MaxHeartRate   = (int)lap_type.max_heart_rate;
            lap.Intensity      = (int)lap_type.intensity;
            lap.AvgCadence     = (int)lap_type.avg_cadence;
            lap.TriggerMethod  = (int)lap_type.trigger_method;


            lap.StartTime = epoch.AddSeconds(lap_type.start_time).ToLocalTime();

            uint days    = lap_type.total_time % 86400;
            uint hours   = (lap_type.total_time - days) % 3600;
            uint minutes = (lap_type.total_time - days - hours) % 60;
            uint seconds = lap_type.total_time - days - hours - minutes;

            lap.TotalTime = new TimeSpan((int)days, (int)hours, (int)minutes, (int)seconds);

            return(lap);
        }
Esempio n. 2
0
        public static Lap CreateFrom(D1015_Lap_Type lap_type)
        {
            Lap lap = new Lap();

            lap.Index = lap_type.index;
            lap.TotalDistance = lap_type.total_dist;
            lap.MaxSpeed = lap_type.max_speed;
            lap.Begin = lap_type.begin;
            lap.End = lap_type.end;
            lap.CaloriesBurned = (int) lap_type.calories;
            lap.AvgHeartRate = (int) lap_type.avg_heart_rate;
            lap.MaxHeartRate = (int) lap_type.max_heart_rate;
            lap.Intensity = (int) lap_type.intensity;
            lap.AvgCadence = (int) lap_type.avg_cadence;
            lap.TriggerMethod = (int) lap_type.trigger_method;

            lap.StartTime = epoch.AddSeconds(lap_type.start_time).ToLocalTime();

            uint days = lap_type.total_time % 86400;
            uint hours = (lap_type.total_time - days) % 3600;
            uint minutes = (lap_type.total_time - days - hours) % 60;
            uint seconds = lap_type.total_time - days - hours - minutes;
            lap.TotalTime = new TimeSpan((int) days, (int) hours, (int) minutes, (int) seconds);

            return lap;
        }
Esempio n. 3
0
        public List <Lap> GetLaps()
        {
            List <Lap>      laps    = new List <Lap>();
            garmin_datatype laptype = (garmin_datatype)this.Configuration["datatype.lap"];

            switch (laptype)
            {
            case garmin_datatype.data_D1015:
                foreach (var lap in Protocol.TransferItems <D1015_Lap_Type>(this, (ushort)Command.ID.Transfer_Laps, Protocol.PacketID.Lap))
                {
                    laps.Add(Lap.CreateFrom(lap));
                }
                break;

            default:
                break;
            }
            return(laps);
        }
Esempio n. 4
0
 public void AddLap(GarminUnit garmin, Lap lap)
 {
     var l = new Laps()
     {
         AvgCadence = lap.AvgCadence,
         AvgHeartRage = lap.AvgHeartRate,
         Calories = lap.CaloriesBurned,
         EndLat = lap.End.lat,
         EndLon = lap.End.lon,
         GarminUnit = (int) garmin.ID,
         Index = lap.Index,
         Intensity = lap.Intensity,
         MaxHeartRage = lap.MaxHeartRate,
         MaxSpeed = lap.MaxSpeed,
         StartLat = lap.Begin.lat,
         StartLon = lap.Begin.lon,
         StartTime = lap.StartTime.,
         TotalDist = lap.TotalDistance,
         TotalTime = lap.TotalTime,
         TriggerMethod = lap.TriggerMethod
     };
     database.Laps.InsertOnSubmit(l);
     database.SubmitChanges();
 }
Esempio n. 5
0
 public bool ContainsLap(GarminUnit garmin, Lap lap)
 {
     if ( database.Laps.Count() == 0 )
         return false;
     var laps = from l in database.Laps
         where l.GarminUnit == (int) garmin.ID
         where l.Index == (int) lap.Index
         select l;
     return (laps.Count() > 0);
 }