private void SetSamplingRate_Button_Click(object sender, RoutedEventArgs e) { var dlg = new SamplingRateDialog(); if (dlg.ShowDialog() ?? false) { var cfg = AppConfigSingleton.GetInstance(); cfg.config.samplingInterval = 1000 / ((int)dlg.SamplingRate.Value); sleepTime = cfg.config.samplingInterval; cfg.ExportToCfg(); UpdateLoggingFrequency(); } }
public MainWindow() { InitializeComponent(); UpdateVisibility(); sleepTime = AppConfigSingleton.GetInstance().config.samplingInterval; plots = new TracePlot[28]; plots[0] = new TracePlot() { plotFrame = plotFrameGas, sigplot = plotFrameGas.plt.PlotSignal(dataGas, color: System.Drawing.Color.FromArgb(255, 25, 150, 0), markerSize: 0), sigplotLastLap = plotFrameGas.plt.PlotSignal(dataGasLast, color: System.Drawing.Color.FromArgb(100, 25, 150, 0), markerSize: 0), name = "Gas", yLims = new double[] { -0.2, 1.2 }, }; plots[1] = new TracePlot() { plotFrame = plotFrameBrake, sigplot = plotFrameBrake.plt.PlotSignal(dataBrake, color: System.Drawing.Color.FromArgb(255, 200, 0, 0), markerSize: 0), sigplotLastLap = plotFrameBrake.plt.PlotSignal(dataBrakeLast, color: System.Drawing.Color.FromArgb(100, 200, 0, 0), markerSize: 0), name = "Brake", yLims = new double[] { -0.2, 1.2 }, }; plots[2] = new TracePlot() { plotFrame = plotFrameGear, sigplot = plotFrameGear.plt.PlotSignal(dataGear, color: System.Drawing.Color.Black, markerSize: 0), sigplotLastLap = plotFrameGear.plt.PlotSignal(dataGearLast, color: System.Drawing.Color.FromArgb(100, 0, 0, 0), markerSize: 0), name = "Gear", yLims = new double[] { -1.2, 10.2 }, }; plots[3] = new TracePlot() { plotFrame = plotFrameSteer, sigplot = plotFrameSteer.plt.PlotSignal(dataSteer, color: System.Drawing.Color.FromArgb(255, 100, 0, 200), markerSize: 0), sigplotLastLap = plotFrameSteer.plt.PlotSignal(dataSteerLast, color: System.Drawing.Color.FromArgb(100, 100, 0, 200), markerSize: 0), name = "Steering Angle", yLims = new double[] { -1.2, 1.2 }, }; plots[4] = new TracePlot() { plotFrame = plotFrameSlip, sigplot = plotFrameSlip.plt.PlotSignal(dataSlip.FL, label: "FL", color: fl_colour, markerSize: 0), name = "Tyre Slip", yLims = new double[] { -0.2, 5 }, }; plots[5] = new TracePlot() { plotFrame = plotFrameSlip, sigplot = plotFrameSlip.plt.PlotSignal(dataSlip.FR, label: "FR", color: fr_colour, markerSize: 0), name = "Tyre Slip", yLims = new double[] { -0.2, 5 }, }; plots[6] = new TracePlot() { plotFrame = plotFrameSlip, sigplot = plotFrameSlip.plt.PlotSignal(dataSlip.RL, label: "RL", color: rl_colour, markerSize: 0), name = "Tyre Slip", yLims = new double[] { -0.2, 5 }, }; plots[7] = new TracePlot() { plotFrame = plotFrameSlip, sigplot = plotFrameSlip.plt.PlotSignal(dataSlip.RR, label: "RR", color: rr_colour, markerSize: 0), name = "Tyre Slip", yLims = new double[] { -0.2, 5 }, }; plots[8] = new TracePlot() { plotFrame = plotFrameRPM, sigplot = plotFrameRPM.plt.PlotSignal(dataRPM, color: System.Drawing.Color.Gold, markerSize: 0), name = "RPM", yLims = new double[] { -0.2, 30_000 }, }; plots[9] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempI.FL, label: "FL I", color: fl_colour, markerSize: 0, lineStyle: LineStyle.Dot), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[10] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempI.FR, label: "FR I", color: fr_colour, markerSize: 0, lineStyle: LineStyle.Dot), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[11] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempI.RL, label: "RL I", color: rl_colour, markerSize: 0, lineStyle: LineStyle.Dot), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[12] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempI.RR, label: "RR I", color: rr_colour, markerSize: 0, lineStyle: LineStyle.Dot), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[13] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempM.FL, label: "FL M", color: fl_colour, markerSize: 0, lineStyle: LineStyle.Dash), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[14] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempM.FR, label: "FR M", color: fr_colour, markerSize: 0, lineStyle: LineStyle.Dash), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[15] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempM.RL, label: "RL M", color: rl_colour, markerSize: 0, lineStyle: LineStyle.Dash), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[16] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempM.RR, label: "RR M", color: rr_colour, markerSize: 0, lineStyle: LineStyle.Dash), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[17] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempO.FL, label: "FL O", color: fl_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[18] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempO.FR, label: "FR O", color: fr_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[19] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempO.RL, label: "RL O", color: rl_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[20] = new TracePlot() { plotFrame = plotFrameTyreTemp, sigplot = plotFrameTyreTemp.plt.PlotSignal(dataTyreTempO.RR, label: "RR O", color: rr_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Temperature (Celsius)", yLims = new double[] { 20, 180 }, }; plots[21] = new TracePlot() { plotFrame = plotFrameTyrePressure, sigplot = plotFrameTyrePressure.plt.PlotSignal(dataPressures.FL, label: "FL", color: fl_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Pressure (PSI)", yLims = new double[] { 0, 60 }, }; plots[22] = new TracePlot() { plotFrame = plotFrameTyrePressure, sigplot = plotFrameTyrePressure.plt.PlotSignal(dataPressures.FR, label: "FR", color: fr_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Pressure (PSI)", yLims = new double[] { 0, 60 }, }; plots[23] = new TracePlot() { plotFrame = plotFrameTyrePressure, sigplot = plotFrameTyrePressure.plt.PlotSignal(dataPressures.RL, label: "RL", color: rl_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Pressure (PSI)", yLims = new double[] { 0, 60 }, }; plots[24] = new TracePlot() { plotFrame = plotFrameTyrePressure, sigplot = plotFrameTyrePressure.plt.PlotSignal(dataPressures.RR, label: "RR", color: rr_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Tyre Pressure (PSI)", yLims = new double[] { 0, 60 }, }; plots[25] = new TracePlot() { plotFrame = plotFrameRideHeight, sigplot = plotFrameRideHeight.plt.PlotSignal(dataRideHeightF, label: "F", color: fl_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Ride Height (Physics-Engine Units)", yLims = new double[] { 0, 0.3 }, }; plots[26] = new TracePlot() { plotFrame = plotFrameRideHeight, sigplot = plotFrameRideHeight.plt.PlotSignal(dataRideHeightR, label: "R", color: rl_colour, markerSize: 0, lineStyle: LineStyle.Solid), name = "Ride Height (Physics-Engine Units)", yLims = new double[] { 0, 0.3 }, }; plots[27] = new TracePlot() { plotFrame = plotFrameClutch, sigplot = plotFrameClutch.plt.PlotSignal(dataClutch, color: System.Drawing.Color.FromArgb(255, 0, 0, 255), markerSize: 0), sigplotLastLap = plotFrameClutch.plt.PlotSignal(dataClutch, color: System.Drawing.Color.FromArgb(100, 0, 0, 255), markerSize: 0), name = "Clutch", yLims = new double[] { -0.2, 1.2 }, }; foreach (TracePlot curr in plots) { curr.plotFrame.plt.Title(curr.name); curr.plotFrame.plt.Ticks(displayTickLabelsX: false); curr.plotFrame.plt.Axis(0, 0, curr.yLims[0], curr.yLims[1]); if (curr.sigplotLastLap != null) { curr.sigplotLastLap.visible = false; } } string[] gearYTicks = Enumerable.Range(-1, 12).Select(i => "" + i).ToArray(); gearYTicks[0] = "R"; gearYTicks[1] = "N"; plotFrameGear.plt.YTicks(Enumerable.Range(-1, 12).Select(i => (double)i).ToArray(), gearYTicks); plotFrameSlip.plt.Legend(location: legendLocation.upperRight); plotFrameTyreTemp.plt.Legend(location: legendLocation.upperRight); plotFrameTyrePressure.plt.Legend(location: legendLocation.lowerRight); plotFrameRideHeight.plt.Legend(location: legendLocation.upperRight); plotFrameTyreTemp.plt.PlotAnnotation("Interior: Dotted\nMiddle: Dashed\nOuter: Solid"); plotFrameSteer.plt.PlotHLine(0, System.Drawing.Color.Gray, lineStyle: LineStyle.Dash); UpdateLoggingFrequency(); }
App() { configWrapper = AppConfigSingleton.GetInstance(); configWrapper.ImportFromCfg(); }