/// <summary> /// Resets the actual Level /// </summary> public void ResetLevel() { SpikeList.Clear(); SlowList.Clear(); CoinList.Clear(); RollList.Clear(); SpeedList.Clear(); BrettList.Clear(); ResetScore(); ResetPhase(); }
public void CalculateSpeedAverages() { var coords = TrackCoordinates.ToList(); var speeds = SpeedList.ToList(); TrackCoordinates.Clear(); SpeedList.Clear(); TrackSpeed = GetAverageTrackSpeed(coords); AverageSpeed = speeds.Any() ? Math.Round(speeds.Average(), 1) : 0.0d; }
private void OnRmcEvent(object sender, Gps.GPSRMC rmc) { if (!rmc.Valid || rmc.Speed == null || rmc.Course == null) { return; } var speed = rmc.Speed.Value * 1.852d; Speed = Math.Round(speed, 1); SpeedList.Add(speed); Time = rmc.TimeStamp; Course = rmc.Course.Value; }
private void ServoControlTask() { while (Activated) { // Doing this here for now CalculateSpeedAverages(); var speed = OpertationMode == AutopilotOperationMode.Average && SpeedList.Any() ? SpeedList.Average() : OpertationMode == AutopilotOperationMode.Track ? TrackSpeed : Speed; var diff = TargetSpeed - speed; if (Math.Abs(diff) > ToleranceSpeed && speed > 0) { if (diff < 0.0d) { ServoPosition -= 1; LogAsync(string.Format("{0} km/h off; decreasing by 1 degree to {1}", diff, ServoPosition)); } if (diff > 0.0d && ServoPosition >= 0) { ServoPosition += 1; LogAsync(string.Format("{0} km/h off; increasing by 1 degree to {1}", diff, ServoPosition)); } ServoController.SetPosition(ServoPosition).AllowTimeToMove(100).Go(); } else { LogAsync(string.Format("Speed of {0} withing tolerance or 0; doing nothing", speed)); } Task.Delay((int)(ToleranceSeconds * 1000)).Wait(); } LogAsync("Speed control loop ended. Setting servo back to 0 degree"); ServoPosition = 0; ServoController.SetPosition(0).AllowTimeToMove(2000).Go(); }
// GET: SpeedAbilities public async Task <IActionResult> Index() { var speedAbility = from ee in _context.SpeedAbility select ee; speedAbility = speedAbility.Where(m => m.user_id == User.Identity.Name); List <SpeedAbility> e = await speedAbility.OrderBy(m => m.create_time).AsNoTracking().ToListAsync(); var lastSpeed = await _context.SpeedAbility.OrderBy(m => m.create_time).LastOrDefaultAsync(m => m.user_id == User.Identity.Name); SpeedList speedList = new SpeedList(); speedList.lastspeed = lastSpeed; speedList.list = e; foreach (var x in e) { speedList.time.Add(x.create_time.ToString("MM-dd")); speedList.Truntime.Add(x.Trun_score.ToString()); speedList.Gruntime.Add(x.Gunrun_score.ToString()); } return(View(speedList)); }