Exemplo n.º 1
0
        private void timerStream_Tick(object sender, EventArgs e)
        {
            if (LogStreamer == null || (LogInfo != null && !LogInfo.Live))
            {
                StopStreaming();
                return;
            }

            if (LogStreamer.QueueCount() >= 3)
            {
                WaitForLoadingPlotting();
                PlottingLog = true;
                List <DSLOGEntry> newEntries = new List <DSLOGEntry>();
                while (LogStreamer.QueueCount() != 0)
                {
                    DSLOGEntry entry = LogStreamer.PopEntry();
                    if (entry != null)
                    {
                        LogEntries.Add(entry);
                        newEntries.Add(entry);
                    }
                }
                StreamPlot();
                DateTime now = DateTime.Now;
                if ((now - LastEnergyAdd).Seconds > 2)
                {
                    EnergyView.AddEnergy(newEntries);
                    LastEnergyAdd = now;
                }
                PlottingLog = false;
            }
        }
Exemplo n.º 2
0
        private void PlotPDP(Dictionary <string, Series> series, int start, int end)
        {
            for (int index_l = start; index_l < end; index_l++)
            {
                DSLOGEntry en = LogEntries.ElementAt(index_l);
                //Adds points to first and last x values
                double entryTime = en.Time.ToOADate();

                if (index_l == 0 || index_l == end - 1)
                {
                    for (int i = 0; i < 24; i++)
                    {
                        series[DSAttConstants.PDPPrefix + i].Points.AddXY(entryTime, en.GetPDPChannel(i));
                    }
                }
                else
                {
                    var lastEn = LogEntries.ElementAt(index_l - 1);
                    var nextEn = LogEntries.ElementAt(index_l + 1);
                    //Checks if value is differnt around it so we don't plot everypoint

                    for (int i = 0; i < 24; i++)
                    {
                        if (lastEn.GetPDPChannel(i) != en.GetPDPChannel(i) || nextEn.GetPDPChannel(i) != en.GetPDPChannel(i))
                        {
                            series[DSAttConstants.PDPPrefix + i].Points.AddXY(entryTime, en.GetPDPChannel(i));
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void PlotModes(Dictionary <string, Series> series, int start, int end)
        {
            var dsDisabledSeries    = series[DSAttConstants.DSDisabled];
            var dsAutoSeries        = series[DSAttConstants.DSAuto];
            var dsTeleSeries        = series[DSAttConstants.DSTele];
            var robotDisabledSeries = series[DSAttConstants.RobotDisabled];
            var robotAutoSeries     = series[DSAttConstants.RobotAuto];
            var robotTeleSeries     = series[DSAttConstants.RobotTele];
            var brownoutSeries      = series[DSAttConstants.Brownout];
            var watchdogSeries      = series[DSAttConstants.Watchdog];

            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 (en.DSDisabled)
                {
                    dsDisabledSeries.Points.AddXY(entryTime, 15.9);
                }
                if (en.DSAuto)
                {
                    dsAutoSeries.Points.AddXY(entryTime, 15.9);
                }
                if (en.DSTele)
                {
                    dsTeleSeries.Points.AddXY(entryTime, 15.9);
                }

                if (en.RobotDisabled)
                {
                    robotDisabledSeries.Points.AddXY(entryTime, 16.8);
                }
                if (en.RobotAuto)
                {
                    robotAutoSeries.Points.AddXY(entryTime, 16.5);
                }
                if (en.RobotTele)
                {
                    robotTeleSeries.Points.AddXY(entryTime, 16.2);
                }

                if (en.Brownout)
                {
                    brownoutSeries.Points.AddXY(entryTime, 15.6);
                }
                if (en.Watchdog)
                {
                    watchdogSeries.Points.AddXY(entryTime, 15.3);
                }
            }
        }
Exemplo n.º 4
0
 private void PlotTotalDelta(Dictionary <string, Series> series, int start, int end)
 {
     for (int index_l = start; index_l < end; index_l++)
     {
         DSLOGEntry en = LogEntries.ElementAt(index_l);
         //Adds points to first and last x values
         double entryTime = en.Time.ToOADate();
         if (index_l == 0 || index_l == end - 1)
         {
             foreach (var kv in IdToPDPGroup)
             {
                 if (kv.Key.StartsWith(DSAttConstants.TotalPrefix))
                 {
                     series[kv.Key].Points.AddXY(entryTime, en.GetGroupPDPTotal(kv.Value) / (TotalPDPScale / 10.0));
                 }
                 else
                 {
                     series[kv.Key].Points.AddXY(entryTime, en.GetGroupPDPSd(kv.Value) / (TotalPDPScale / 10.0));
                 }
             }
         }
         else
         {
             foreach (var kv in IdToPDPGroup)
             {
                 var lastEn = LogEntries.ElementAt(index_l - 1);
                 var nextEn = LogEntries.ElementAt(index_l + 1);
                 if (kv.Key.StartsWith(DSAttConstants.TotalPrefix))
                 {
                     if (lastEn.GetGroupPDPTotal(kv.Value) != en.GetGroupPDPTotal(kv.Value) || nextEn.GetGroupPDPTotal(kv.Value) != en.GetGroupPDPTotal(kv.Value))
                     {
                         series[kv.Key].Points.AddXY(entryTime, en.GetGroupPDPTotal(kv.Value) / (TotalPDPScale / 10.0));
                     }
                 }
                 else
                 {
                     if (lastEn.GetGroupPDPSd(kv.Value) != en.GetGroupPDPSd(kv.Value) || nextEn.GetGroupPDPSd(kv.Value) != en.GetGroupPDPSd(kv.Value))
                     {
                         series[kv.Key].Points.AddXY(entryTime, en.GetGroupPDPSd(kv.Value));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 public void SetProbe(DSLOGEntry entry)
 {
     Entry = entry;
     DisplayEntry();
 }
Exemplo n.º 6
0
        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));
                    }
                }
            }
        }
Exemplo n.º 7
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("");
        }