/// <summary> /// send a position changed event /// </summary> /// <param name="sender">event source</param> /// <param name="e">event arguments</param> private void RaceMonitor_PositionEvent(object sender, PositionChangedEventArgs e) { client.SendPosition(e.Timestamp, e.Index, e.NewPosition); // report changes in postition, except for the first reported position if (e.OldPosition != -1) { // NewRaceEvent(e.Timestamp, $"car {e.Index} moved to {e.NewPosition} from {e.OldPosition}"); } }
/// <summary> /// implementation of the ICarCoordinates interface /// </summary> /// <param name="coords">car coordinate data</param> public void ProcessRaceData(JCarCoords coords) { // TODO replace with a more meaningful race model // received new car coordinates // store the information - Car array // calculate speed & publish speed++; speed %= 300; client.SendSpeed(coords.Timestamp, coords.CarIndex, speed); // calculate posision & publish position = random.Next(1, 6); client.SendPosition(coords.Timestamp, coords.CarIndex, position); // identify interesting events & publish if (speed == 1) { client.SendRaceEvent(coords.Timestamp, $"event {position}"); } }