Exemplo n.º 1
0
        private void ImportSession_Click(object sender, EventArgs e)
        {
            TraceSession ts = new TraceSession();

            ts.Import();
            Sessions.Add(ts);
            TreeNode root = new TreeNode();

            root.Text = root.Name = "Trace: " + Sessions.Count.ToString();
            root.Tag  = ts;
            int i = 0;

            foreach (var td in ts.TD.DataFrames)
            {
                TreeNode dfn = new TreeNode();
                dfn.Text = dfn.Name = "DataFrame: " + i.ToString();
                dfn.Tag  = td;
                ++i;
                foreach (var ds in td.dataSignals)
                {
                    TreeNode dsn = new TreeNode();
                    dsn.Text        = dsn.Name = ds.Description;
                    dsn.ToolTipText = ds.Name;
                    dsn.Tag         = ds;
                    foreach (var s in ds.Signals)
                    {
                        TreeNode sub = new TreeNode();
                        sub.Text        = sub.Name = s.Time;
                        sub.ToolTipText = s.Value.ToString();
                        sub.Tag         = s;
                        dsn.Nodes.Add(sub);
                    }
                    dfn.Nodes.Add(dsn);
                }
                root.Nodes.Add(dfn);
            }
            SampleTree.Nodes.Add(root);
        }
Exemplo n.º 2
0
        public void Import()
        {
            TraceSession ts  = this;
            XmlDocument  doc = new XmlDocument();

            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                doc.Load(ofd.FileName);
                //PULL DATA FRAME
                XmlNodeList nodes = doc.DocumentElement.SelectNodes("/traceSession");

                foreach (XmlNode node in nodes)
                {
                    //parse out the version
                    ts.Version = node.Attributes[0].InnerText;
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        //parse out the kinds
                        if (child.Name == "traceCaptureSetup")
                        {
                        }
                        if (child.Name == "traceDisplaySetup")
                        {
                        }
                        if (child.Name == "traceData")
                        {
                            foreach (XmlNode attr in child.Attributes)
                            {
                                //values
                                if (attr.Name == "dataFrames")
                                {
                                    ts.TD.dataFrames = attr.Value;
                                }
                            }
                            foreach (XmlNode dataFrame in child.ChildNodes)
                            {
                                TraceSession.TraceData.DataFrame df = new TraceSession.TraceData.DataFrame();
                                foreach (XmlNode data in dataFrame.ChildNodes)
                                {
                                    if (data.Name == "frameHeader")
                                    {
                                        df.startTime       = data.Attributes.GetNamedItem("startTime").Value;
                                        df.startTriggerInc = Convert.ToSingle(data.Attributes.GetNamedItem("startTriggerInc").Value);
                                        df.stopTriggerInc  = Convert.ToSingle(data.Attributes.GetNamedItem("stopTriggerInc").Value);
                                        df.stopInc         = Convert.ToSingle(data.Attributes.GetNamedItem("stopInc").Value);
                                    }
                                    if (data.Name == "domain")
                                    {
                                        df.Domain = data.Attributes.GetNamedItem("e1").Value;
                                    }
                                    if (data.Name == "dataSignal")
                                    {
                                        TraceSession.TraceData.DataFrame.DataSignal ds = new TraceSession.TraceData.DataFrame.DataSignal();
                                        ds.Id             = data.Attributes.GetNamedItem("id")?.Value;
                                        ds.Key            = data.Attributes.GetNamedItem("key")?.Value;
                                        ds.Event          = data.Attributes.GetNamedItem("event")?.Value;
                                        ds.EventChannel   = data.Attributes.GetNamedItem("eventChannel")?.Value;
                                        ds.Description    = data.Attributes.GetNamedItem("description")?.Value;
                                        ds.Domain         = data.Attributes.GetNamedItem("domain")?.Value;
                                        ds.Name           = data.Attributes.GetNamedItem("name")?.Value;
                                        ds.DataType       = data.Attributes.GetNamedItem("dataType")?.Value;
                                        ds.Interval       = data.Attributes.GetNamedItem("interval")?.Value;
                                        ds.UnitsType      = data.Attributes.GetNamedItem("unitsType")?.Value;
                                        ds.DisplayRes     = data.Attributes.GetNamedItem("displayRes")?.Value;
                                        ds.DataPointCount = data.Attributes.GetNamedItem("datapointCount")?.Value;
                                        df.dataSignals.Add(ds);
                                    }
                                    if (data.Name == "rec") //actual signals that need t obe parsed baised on "dataSignal"
                                    {
                                        foreach (XmlNode attr in data.Attributes)
                                        {
                                            foreach (var ds in df.dataSignals)
                                            {
                                                if (ds.Id == attr.Name)
                                                {
                                                    TraceSession.TraceData.DataFrame.DataSignal.Signal signal = new TraceSession.TraceData.DataFrame.DataSignal.Signal();
                                                    signal.Time = data.Attributes[0].Value.ToString();
                                                    try
                                                    {
                                                        signal.Value = Convert.ToSingle(attr.Value);
                                                        ds.Signals.Add(signal);
                                                    }
                                                    catch { }
                                                }
                                            }
                                        }
                                    }
                                }
                                ts.TD.DataFrames.Add(df);
                            }
                        }
                    }
                    // var a = node.SelectSingleNode("author").InnerText; //select single item
                }
            }
        }