예제 #1
0
        public RTGraph(TelemetryLapManager telemetryLapManager, bool cbest, bool clast, String xlabel, String YLabel)
        {
            this.cbest = cbest;
            this.clast = clast;
            this.Xlabel = xlabel;
            this.Ylabel = YLabel;

            InitializeComponent();

            this.telemetryLapManager = telemetryLapManager;
            GraphPane myPane = zedGraphControl1.GraphPane;

            if (cbest && telemetryLapManager.ComparisonLap != null)
            {
                var fastestLap = telemetryLapManager.ComparisonLap;
                LoadLap(fastestLap, "FastLap", Color.Green);
            }

            PointPairList pl = new PointPairList();
            var myCurve = myPane.AddCurve("RealTime", pl, Color.Red, SymbolType.None);
            myPane.Title.Text = Xlabel + " " + Ylabel;
            myPane.XAxis.Title.Text = Xlabel;
            myPane.YAxis.Title.Text = Ylabel;
            myCurve.Line.Width = 3.0F;

            telemetryLapManager.PacketProcessed += telemetryLapManager_PacketProcessed;
            telemetryLapManager.CompletedFullLap += telemetryLapManager_CompletedFullLap;
            telemetryLapManager.SetFastestLap += telemetryLapManager_SetFastestLap;
            telemetryLapManager.FinishedOutLap += telemetryLapManager_FinishedOutLap;
            telemetryLapManager.RemovedLap += telemetryLapManager_RemovedLap;

            t1.Interval = F1SpeedSettings.RefreshRate;
            t1.Tick += t1_Tick;
            t1.Start();
        }
예제 #2
0
        public TelemetryLapManager GetManager()
        {
            if (manager == null)
                manager = new TelemetryLapManager();

            return manager;
        }
예제 #3
0
 public AllLaps(TelemetryLapManager telemetryLapManager)
 {
     this.telemetryLapManager = telemetryLapManager;
     InitializeComponent();
     LoadDataTable();
     t1 = new Timer();
     t1.Interval = 500;
     t1.Tick += new EventHandler(t1_Tick);
     t1.Start();
 }
예제 #4
0
파일: ApiModule.cs 프로젝트: trv/F1Speed
        public ApiModule(TelemetryLapManagerFactory managerFactory)
            : base("/api")
        {
            _telemetryLapManager = managerFactory.GetManager();

            Get["/packet"] = parameters =>
                {
                    var speedDelta = _telemetryLapManager.GetSpeedDelta();
                    var timeDelta = _telemetryLapManager.GetTimeDelta();

                    if (speedDelta == "--")
                        speedDelta = "+0";

                    var speedPositive = speedDelta.Substring(0, 1) == "+";
                    var timePositive = timeDelta > 0;

                    var speedAbs = speedDelta.Substring(1);

                    var model = new DashViewModel
                        {
                            CircuitName = _telemetryLapManager.Circuit.Name,
                            LapType = _telemetryLapManager.LapType ?? "",
                            SpeedDelta = float.Parse(speedAbs),
                            TimeDelta = timeDelta,
                            IsSpeedDeltaPositive = speedPositive,
                            IsTimeDeltaPositive = timePositive,
                            WheelspinRearLeft = _telemetryLapManager.CurrentWheelSpin(WheelspinWheel.RearLeft),
                            WheelspinRearRight = _telemetryLapManager.CurrentWheelSpin(WheelspinWheel.RearRight),
                            WheelspinFrontLeft = _telemetryLapManager.CurrentWheelSpin(WheelspinWheel.FrontLeft),
                            WheelspinFrontRight = _telemetryLapManager.CurrentWheelSpin(WheelspinWheel.FrontRight),
                            Throttle = _telemetryLapManager.CurrentThrottle,
                            Brake = _telemetryLapManager.CurrentBrake,
                            CurrentLap = _telemetryLapManager.CurrentLapTime,
                            LastLap = _telemetryLapManager.LastLapTime,
                            Sector1 = new SectorTimeViewModel(_telemetryLapManager.Sector1),
                            Sector2 = new SectorTimeViewModel(_telemetryLapManager.Sector2),
                            Sector3 = new SectorTimeViewModel(_telemetryLapManager.Sector3)
                        };

                    if (_telemetryLapManager.FastestLap == null)
                    {
                        model.FastestLap = 0f.AsTimeString();
                    }
                    else
                    {
                        model.FastestLap = _telemetryLapManager.FastestLap.LapTime.AsTimeString();
                    }

                    return Response.AsJson(model);
                };
        }
예제 #5
0
        //static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
        //const UInt32 SWP_NOSIZE = 0x0001;
        //const UInt32 SWP_NOMOVE = 0x0002;
        //const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
        //[DllImport("user32.dll")]
        //[return: MarshalAs(UnmanagedType.Bool)]
        //public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
        public Form1()
        {
            InitializeComponent();

            manager = new TelemetryLapManager();
            #if DEBUG
            this.Height = 900;

            manager.CompletedFullLap += (s, e) => writeLog(string.Format("Completed Full Lap.  Last={0}...Current={1}", e.PreviousLapNumber, e.CurrentLapNumber));
            manager.RemovedLap += (s, e) => writeLog(string.Format("Removed Lap. Number={0}", e.Lap != null ? e.Lap.LapNumber : -1));
            manager.ReturnedToGarage += (s, e) => writeLog("Now in Garage");
            manager.FinishedOutLap += (s, e) => writeLog("Completed Out Lap");
            manager.StartedOutLap += (s, e) => writeLog("Started Out Lap");
            manager.SetFastestLap += (s, e) => writeLog(string.Format("Set Fastest Lap={0}", e.Lap.LapTime.AsTimeString()));
            manager.DebugPacketProcessed += (s, e) => writeLog(string.Format("Packet: {0}", e.Packet));
            #else
            this.Height = 490;
            #endif

            writeLog("Listing on port " + PORTNUM + " for connections from " +
                         (F1SpeedSettings.AllowConnectionsFromOtherMachines ? "ANY IP" : IP));

            remoteIP = F1SpeedSettings.AllowConnectionsFromOtherMachines ? new IPEndPoint(IPAddress.Any, PORTNUM) : new IPEndPoint(IPAddress.Parse(IP), PORTNUM);

            foreach(var ctrl in this.Controls)
            {
                var grpBox = ctrl as GroupBox;
                if (grpBox == null) continue;
                if (grpBox.Name == "ControlsGroup") continue;
                grpBox.Paint += new PaintEventHandler(grpBox_Paint);
            }

            // Set up the socket for collecting game telemetry
            try
            {
                udpSocket = new UdpClient();
                udpSocket.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                udpSocket.ExclusiveAddressUse = false;
                udpSocket.Client.Bind(remoteIP);
                writeLog("Bound to socket on " + IP + ":" + PORTNUM.ToString());
                StartListening();
            }
            catch (Exception error)
            {
                writeLog(error.ToString());
                // throw;
            }
        }
        public void Returning_to_pits_does_not_set_previous_lap_as_fastest()
        {
            // set outlap
            var manager = new TelemetryLapManager();
            foreach (var packet in TelemetryLapHelper.CreateOutLap().Packets) manager.ProcessIncomingPacket(packet);

            // Add nearly all of a lap
            var firstLap = TelemetryLapHelper.CreatePopulatedLap(lapNumber: 1f, completeLap: true);
            for (var i = 0; i < firstLap.Packets.Count - 2; i++) manager.ProcessIncomingPacket(firstLap.Packets[i]);

            Assert.IsNull(manager.FastestLap);

            var garagePacket = new TelemetryPacket {Lap = 0f, Speed = 0f, LapDistance = -0.001f};
            Assert.IsTrue(garagePacket.IsSittingInPits);
            manager.ProcessIncomingPacket(garagePacket);

            Assert.IsNull(manager.FastestLap);
        }
        public DeltaGraphcs(TelemetryLapManager TelemetryLapManager, DeltaType deltatype)
        {
            this.deltatype = deltatype;
            this.TelemetryLapManager = TelemetryLapManager;

            InitializeComponent();

            if (TelemetryLapManager.FastestLap != null)
                started = true;

            GraphPane myPane = zedGraphControl1.GraphPane;

            {
                PointPairList pl = new PointPairList();
                var myCurve = myPane.AddCurve(RT1, pl, Color.Red, SymbolType.None);
                myPane.Title.Text = deltatype.ToString();
                myPane.XAxis.Title.Text = "NormalizedDistance";
                myPane.YAxis.Title.Text = deltatype.ToString();
                myCurve.Line.Width = 3.0F;
            }
            {
                PointPairList pl = new PointPairList();
                var myCurve = myPane.AddCurve(RT2, pl, Color.Blue, SymbolType.None);
                myPane.Title.Text = deltatype.ToString();
                myPane.XAxis.Title.Text = "NormalizedDistance";
                myPane.YAxis.Title.Text = deltatype.ToString();
                myCurve.Line.Width = 3.0F;
            }

            atual = RT1;
            TelemetryLapManager.PacketProcessed += TelemetryLapManager_PacketProcessed;
            TelemetryLapManager.CompletedFullLap += TelemetryLapManager_CompletedFullLap;
            TelemetryLapManager.FinishedOutLap += TelemetryLapManager_FinishedOutLap;
            TelemetryLapManager.RemovedLap += TelemetryLapManager_RemovedLap;

            timer.Interval = F1SpeedSettings.RefreshRate;
            timer.Tick += timer_Tick;
            timer.Start();
        }
        public void Start_of_first_full_lap_does_not_set_fastest_lap()
        {
            var manager = new TelemetryLapManager();

            foreach (var packet in TelemetryLapHelper.CreateOutLap().Packets) manager.ProcessIncomingPacket(packet);

            var fullLap = TelemetryLapHelper.CreatePopulatedLap(lapNumber: 1f);
            Assert.IsTrue(fullLap.IsFirstPacketStartLine);  // Lap we just added must be a full lap

            manager.ProcessIncomingPacket(fullLap.Packets[0]);

            Assert.IsNull(manager.FastestLap);
        }
 public void SetUp()
 {
     _manager = new TelemetryLapManager();
     foreach (var packet in TelemetryLapHelper.CreateOutLap().Packets) _manager.ProcessIncomingPacket(packet);
     foreach (var packet in TelemetryLapHelper.CreatePopulatedLap(lapNumber: 1f).Packets) _manager.ProcessIncomingPacket(packet);
 }
 public GraphOptions(TelemetryLapManager manager)
 {
     InitializeComponent();
     this.manager = manager;
 }