Example #1
0
 public void SetSeries(SeriesGroupNodes basic, SeriesGroupNodes pdp)
 {
     IdToPDPGroup = new Dictionary <string, int[]>();
     Series       = new Dictionary <string, string>();
     foreach (var group in pdp)
     {
         int[] pdpIds = group.Childern.Where(n => n.Name.StartsWith(DSAttConstants.PDPPrefix)).Select(n => int.Parse(n.Name.Replace(DSAttConstants.PDPPrefix, ""))).ToArray();
         foreach (var node in group.Childern)
         {
             if (node.Name.StartsWith(DSAttConstants.TotalPrefix) || node.Name.Contains(DSAttConstants.DeltaPrefix))
             {
                 IdToPDPGroup[node.Name] = pdpIds;
             }
         }
     }
     foreach (var bas in basic)
     {
         foreach (var entry in bas.Childern)
         {
             Series.Add(entry.Name, entry.Text);
         }
     }
     foreach (var p in pdp)
     {
         foreach (var entry in p.Childern)
         {
             Series.Add(entry.Name, entry.Text);
         }
     }
 }
        private SeriesGroupNodes TreeNodesToSeriesGroupNodes(TreeNodeCollection nodes)
        {
            int totalDeltaID        = 0;
            SeriesGroupNodes groups = new SeriesGroupNodes();

            foreach (TreeNode treeGroup in nodes)
            {
                if (treeGroup.Nodes.Count == 0)
                {
                    continue;
                }
                SeriesGroupNode groupNode = new SeriesGroupNode(treeGroup.Name, treeGroup.Text, treeGroup.BackColor);
                foreach (TreeNode treeChild in treeGroup.Nodes)
                {
                    if (treeChild.Name.Contains(DSAttConstants.TotalPrefix) || treeChild.Name.Contains(DSAttConstants.DeltaPrefix))
                    {
                        groupNode.Childern.Add(new SeriesChildNode($"{treeChild.Name}{totalDeltaID++}", treeChild.Text, treeChild.BackColor));
                    }
                    else
                    {
                        groupNode.Childern.Add(new SeriesChildNode(treeChild.Name, treeChild.Text, treeChild.BackColor));
                    }
                }
                groups.Add(groupNode);
            }
            return(groups);
        }
Example #3
0
 public SeriesView()
 {
     InitializeComponent();
     Observers     = new List <SeriesViewObserver>();
     Profiles      = new GroupProfiles();
     NonEditGroups = new SeriesGroupNodes();
     toolTip.SetToolTip(comboBoxProfiles, "Change PDP Profile");
     toolTip.SetToolTip(buttonEditGroups, "Edit PDP Profiles");
 }
Example #4
0
        public object Clone()
        {
            SeriesGroupNodes nodes = new SeriesGroupNodes();

            foreach (var group in this)
            {
                nodes.Add((SeriesGroupNode)group.Clone());
            }
            return(nodes);
        }
Example #5
0
        public void SetSeries(SeriesGroupNodes basic, SeriesGroupNodes pdp)
        {
            treeView1.Nodes.Clear();
            IdToPDPGroup = new Dictionary <string, int[]>();
            TreeNode otherGroup = basic.Find(g => g.Name == "other").ToTreeNode();

            otherGroup.Nodes.RemoveAt(0);
            treeView1.Nodes.Add(otherGroup);

            foreach (var group in pdp)
            {
                if (group.Childern.Count == 0)
                {
                    continue;
                }
                int[]    pdpIds   = group.Childern.Where(n => n.Name.StartsWith(DSAttConstants.PDPPrefix)).Select(n => int.Parse(n.Name.Replace(DSAttConstants.PDPPrefix, ""))).ToArray();
                TreeNode newGroup = group.ToTreeNode();

                foreach (var node in group.Childern)
                {
                    if (node.Name.StartsWith(DSAttConstants.TotalPrefix))
                    {
                        IdToPDPGroup[node.Name] = pdpIds;
                    }
                    if (node.Name.StartsWith(DSAttConstants.DeltaPrefix))
                    {
                        newGroup.Nodes.RemoveByKey(node.Name);
                    }
                }

                foreach (TreeNode node in newGroup.Nodes)
                {
                    node.Text = node.Text + ": ";
                }
                treeView1.Nodes.Add(newGroup);
            }
            treeView1.ExpandAll();
            DisplayEnergy();
        }
Example #6
0
 public GroupProfile(string name, SeriesGroupNodes groups)
 {
     Name   = name;
     Groups = groups;
 }
Example #7
0
        public void LoadSeries()
        {
            SeriesGroupNode robotMode = new SeriesGroupNode("robotMode", "Robot Mode", SystemColors.ControlLightLight);

            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.DSDisabled, "DS Disabled", Color.DarkGray));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.DSAuto, "DS Auto", Color.Lime));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.DSTele, "DS Tele", Color.Cyan));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.RobotDisabled, "Robot Disabled", Color.DarkGray));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.RobotAuto, "Robot Auto", Color.Lime));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.RobotTele, "Robot Tele", Color.Cyan));

            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.Brownout, "Brownout", Color.OrangeRed));
            robotMode.Childern.Add(new SeriesChildNode(DSAttConstants.Watchdog, "Watchdog", Color.FromArgb(249, 0, 255)));


            SeriesGroupNode basic = new SeriesGroupNode("basic", "Basic", SystemColors.ControlLightLight);

            basic.Childern.Add(new SeriesChildNode(DSAttConstants.CANUtil, "CAN", Color.Silver));
            basic.Childern.Add(new SeriesChildNode(DSAttConstants.Voltage, "Voltage", Color.Yellow));
            basic.Childern.Add(new SeriesChildNode(DSAttConstants.RoboRIOCPU, "roboRIO CPU", Color.Red));



            SeriesGroupNode comms = new SeriesGroupNode("comms", "Comms", SystemColors.ControlLightLight);

            comms.Childern.Add(new SeriesChildNode(DSAttConstants.TripTime, "Trip Time", Color.Lime));
            comms.Childern.Add(new SeriesChildNode(DSAttConstants.LostPackets, "Lost Packets", Color.Chocolate));


            SeriesGroupNode  groupNode = null;
            SeriesGroupNodes defG      = new SeriesGroupNodes();

            for (int i = 0; i < 24; i++)
            {
                if (groupNode == null)
                {
                    groupNode = new SeriesGroupNode($"grouppdp{i}{i + 4}", $"PDP ({i}-{i + 4})", SystemColors.ControlLightLight);
                }


                groupNode.Childern.Add(new SeriesChildNode($"{DSAttConstants.PDPPrefix}{i}", $"PDP {i}", Util.PdpColors[i]));
                if (groupNode.Childern.Count == 4)
                {
                    defG.Add(groupNode);
                    groupNode = null;
                }
            }


            SeriesGroupNode other = new SeriesGroupNode("other", "Other", SystemColors.ControlLightLight);

            other.Childern.Add(new SeriesChildNode(DSAttConstants.Messages, "Messages", Color.Gainsboro));


            other.Childern.Add(new SeriesChildNode(DSAttConstants.TotalPDP, "Total PDP", Color.FromArgb(249, 0, 255)));


            NonEditGroups.Add(comms);
            NonEditGroups.Add(basic);
            NonEditGroups.Add(robotMode);
            NonEditGroups.Add(other);

            treeView.Nodes.Add(comms.ToTreeNode());
            treeView.Nodes.Add(basic.ToTreeNode());
            treeView.Nodes.Add(robotMode.ToTreeNode());
            foreach (var node in defG)
            {
                treeView.Nodes.Add(node.ToTreeNode());
            }
            treeView.Nodes.Add(other.ToTreeNode());

            treeView.ItemHeight = 20;
            treeView.ExpandAll();
            if (File.Exists(Util.ProfilesFile))
            {
                FileStream fileStream = null;
                try
                {
                    XmlSerializer profilesSerializer = new XmlSerializer(typeof(GroupProfiles));
                    fileStream = new FileStream(Util.ProfilesFile, FileMode.Open);
                    Profiles   = (GroupProfiles)profilesSerializer.Deserialize(fileStream);
                } catch (Exception ex)
                {
                    MessageBox.Show($"Profile file is corrupted! {ex.Message}");
                    Profiles.Clear();
                    Profiles.Add(new GroupProfile("Default", defG));
                }
                finally
                {
                    if (fileStream != null)
                    {
                        fileStream.Close();
                    }
                }
            }
            else
            {
                Profiles.Clear();
                Profiles.Add(new GroupProfile("Default", defG));
            }
            comboBoxProfiles.Items.Clear();
            comboBoxProfiles.Items.AddRange(Profiles.Select(e => e.Name).ToArray());
            comboBoxProfiles.SelectedIndex = 0;

            SetChartSeriesEnabled();
            SetChartSeries();
        }
Example #8
0
        public async void SetSeries(SeriesGroupNodes basic, SeriesGroupNodes pdp)
        {
            WaitForLoadingPlotting();
            IdToPDPGroup = new Dictionary <string, int[]>();
            //ClearGraph();
            RemoveDeltaTotalSeries();

            //chart.Series.Clear();
            if (!InitBasic)
            {
                foreach (var group in basic)
                {
                    foreach (var node in group.Childern)
                    {
                        if (group.Name == "robotMode")
                        {
                            var newSeries = MakeSeriesFromSettings(SeriesSettings["modes"], node);
                            chart.Series.Add(newSeries);
                        }
                        else if (group.Name == "basic")
                        {
                            if (node.Name == DSAttConstants.Voltage)
                            {
                                var newSeries = MakeSeriesFromSettings(SeriesSettings["voltage"], node);
                                chart.Series.Add(newSeries);
                            }
                            else
                            {
                                var newSeries = MakeSeriesFromSettings(SeriesSettings["lines"], node);
                                chart.Series.Add(newSeries);
                            }
                        }
                        else if (group.Name == "comms")
                        {
                            var newSeries = MakeSeriesFromSettings(SeriesSettings["lines"], node);
                            chart.Series.Add(newSeries);
                        }
                        else if (group.Name == "other")
                        {
                            if (node.Name == DSAttConstants.Messages)
                            {
                                var newSeries = MakeSeriesFromSettings(SeriesSettings["messages"], node);
                                chart.Series.Add(newSeries);
                            }
                            else
                            {
                                var newSeries = MakeSeriesFromSettings(SeriesSettings["totallines"], node);
                                chart.Series.Add(newSeries);
                            }
                        }
                    }
                }

                foreach (var group in pdp)
                {
                    foreach (var node in group.Childern)
                    {
                        if (!node.Name.StartsWith(DSAttConstants.TotalPrefix) && !node.Name.Contains(DSAttConstants.DeltaPrefix))
                        {
                            var newSeries = MakeSeriesFromSettings(SeriesSettings["lines"], node);
                            chart.Series.Add(newSeries);
                        }
                    }
                }
                InitBasic = true;
            }

            Dictionary <string, Series> deltaTotalSeries = new Dictionary <string, Series>();

            foreach (var group in pdp)
            {
                int[] pdpIds = group.Childern.Where(n => n.Name.StartsWith(DSAttConstants.PDPPrefix)).Select(n => int.Parse(n.Name.Replace(DSAttConstants.PDPPrefix, ""))).ToArray();
                foreach (var node in group.Childern)
                {
                    if (node.Name.StartsWith(DSAttConstants.TotalPrefix) || node.Name.Contains(DSAttConstants.DeltaPrefix))
                    {
                        var newSeries = MakeSeriesFromSettings(SeriesSettings["totallines"], node);
                        IdToPDPGroup[node.Name]     = pdpIds;
                        newSeries.BorderDashStyle   = ChartDashStyle.Dash;
                        deltaTotalSeries[node.Name] = newSeries;
                    }
                    if (node.Name.StartsWith(DSAttConstants.PDPPrefix))
                    {
                        chart.Series[node.Name].Color = node.Color;
                    }
                }
            }

            if (LogInfo != null)
            {
                PlottingLog = true;
                PlotTotalDelta(deltaTotalSeries, 0, LogEntries.Count);

                /// LastEntry = 0;
                //RemoveDeltaTotalSeries();
                //var t = Task.Run(() => { PlotLog(); });
                //await t;
                //EventsView.AddEvents();
            }
            foreach (var s in deltaTotalSeries)
            {
                chart.Series.Add(s.Value);
            }
            PlottingLog = false;
        }