private void PlotBasic(Dictionary <string, Series> series, int start, int end) { var tripTimeSeries = series[DSAttConstants.TripTime]; var lostPacketsSeries = series[DSAttConstants.LostPackets]; var voltageSeries = series[DSAttConstants.Voltage]; var canUtilSeries = series[DSAttConstants.CANUtil]; var roborioCPUSeries = series[DSAttConstants.RoboRIOCPU]; var totalPDPSeries = series[DSAttConstants.TotalPDP]; int packetnum = 0; for (int i = start; i < end; i++) { DSLOGEntry en = LogEntries.ElementAt(i); //Adds points to first and last x values double entryTime = en.Time.ToOADate(); if (i == 0 || i == end - 1) { tripTimeSeries.Points.AddXY(entryTime, en.TripTime); voltageSeries.Points.AddXY(entryTime, en.Voltage); lostPacketsSeries.Points.AddXY(entryTime, en.LostPackets * 100); roborioCPUSeries.Points.AddXY(entryTime, en.RoboRioCPU * 100); canUtilSeries.Points.AddXY(entryTime, en.CANUtil * 100); totalPDPSeries.Points.AddXY(entryTime, en.GetDPDTotal() / (TotalPDPScale / 10.0)); } else { var lastEn = LogEntries.ElementAt(i - 1); var nextEn = LogEntries.ElementAt(i + 1); //Checks if value is differnt around it so we don't plot everypoint if (lastEn.TripTime != en.TripTime || nextEn.TripTime != en.TripTime) { tripTimeSeries.Points.AddXY(entryTime, en.TripTime); } if ((lastEn.LostPackets != en.LostPackets || nextEn.LostPackets != en.LostPackets) || lastEn.LostPackets != 0) { //the bar graphs are too much so we have to do this if (packetnum % 4 == 0) { lostPacketsSeries.Points.AddXY(entryTime, 0); } else { lostPacketsSeries.Points.AddXY(entryTime, (en.LostPackets < 1) ? en.LostPackets * 100 : 100); } packetnum++; } if (lastEn.Voltage != en.Voltage || nextEn.Voltage != en.Voltage && en.Voltage < 17) { voltageSeries.Points.AddXY(entryTime, en.Voltage); } if (lastEn.RoboRioCPU != en.RoboRioCPU || nextEn.RoboRioCPU != en.RoboRioCPU) { roborioCPUSeries.Points.AddXY(entryTime, en.RoboRioCPU * 100); } if (lastEn.CANUtil != en.CANUtil || nextEn.CANUtil != en.CANUtil) { canUtilSeries.Points.AddXY(entryTime, en.CANUtil * 100); } if (lastEn.GetDPDTotal() != en.GetDPDTotal() || nextEn.GetDPDTotal() != en.GetDPDTotal()) { totalPDPSeries.Points.AddXY(entryTime, en.GetDPDTotal() / (TotalPDPScale / 10.0)); } } } }
public static string EntryAttToUnit(this DSLOGEntry en, string name, Dictionary <string, int[]> idTOpdp, bool units = true) { if (name == DSAttConstants.TripTime) { return(en.TripTime + ((units) ? "ms":"")); } else if (name == DSAttConstants.LostPackets) { return((en.LostPackets * 100).ToString("0.##") + ((units) ? "%" : "")); } else if (name == DSAttConstants.Voltage) { return(en.Voltage.ToString("0.##") + ((units) ? "V" : "")); } else if (name == DSAttConstants.RoboRIOCPU) { return((en.RoboRioCPU * 100).ToString("0.##") + ((units) ? "%" : "")); } else if (name == DSAttConstants.CANUtil) { return((en.CANUtil * 100).ToString("0.##") + ((units) ? "%" : "")); } else if (name.StartsWith(DSAttConstants.PDPPrefix)) { return(en.GetPDPChannel(int.Parse(name.Substring(3))).ToString("0.##") + ((units) ? "A" : "")); } else if (name == DSAttConstants.DSDisabled) { return(en.DSDisabled.ToString()); } else if (name == DSAttConstants.DSAuto) { return(en.DSAuto.ToString()); } else if (name == DSAttConstants.DSTele) { return(en.DSTele.ToString()); } else if (name == DSAttConstants.RobotDisabled) { return(en.RobotDisabled.ToString()); } else if (name == DSAttConstants.RobotAuto) { return(en.RobotAuto.ToString()); } else if (name == DSAttConstants.RobotTele) { return(en.RobotTele.ToString()); } else if (name == DSAttConstants.Brownout) { return(en.Brownout.ToString()); } else if (name == DSAttConstants.Watchdog) { return(en.Watchdog.ToString()); } else if (name == DSAttConstants.TotalPDP) { return(en.GetDPDTotal().ToString("0.##") + ((units) ? "A" : "")); } else if (name.StartsWith(DSAttConstants.TotalPrefix)) { return(en.GetGroupPDPTotal(idTOpdp[name]).ToString("0.##") + ((units) ? "A" : "")); } else if (name.StartsWith(DSAttConstants.DeltaPrefix)) { return(en.GetGroupPDPSd(idTOpdp[name]).ToString("0.##") + ((units) ? "A" : "")); } return(""); }