Exemple #1
0
 void stree_CommandEventHandler(object sender, CommandEventArgs e)
 {
     CurrentCommandTable   = e.CommandTable;
     chartDataView.Sources = e.CommandTable.Sources;
     aa = 0;
     DrawChart(e.CommandTable.Sources);
     m_TcpMain.appdata.CreateCmdByCommandTable(e.CommandTable);
 }
Exemple #2
0
        private void BuilderNode(TreeNode node, XElement parent)
        {
            foreach (var element in parent.Elements())
            {
                //if (element.Name.ToString() == "Group" && element.Attribute("Name").Value != "Main")
                //{
                //    continue;
                //}
                if (element.Name.ToString() == "Property" && node.Type == "Wait")
                {
                    try
                    {
                        node.TimeOut = Convert.ToInt32(element.Attribute("TimeOut").Value);
                        node.TimeOut = node.TimeOut > 0 ? node.TimeOut : 0;
                    }
                    catch { }
                }


                switch (element.Name.ToString())
                {
                case "Group":
                    //if (element.Attribute("Name").Value != "Main") continue;
                    break;

                case "Property":
                case "Step":
                case "Conditon":
                case "Validate":
                    continue;
                }

                TreeNode tn = new TreeNode();
                tn.Title = element.Name.ToString();
                tn.Type  = element.Name.ToString();
                tn.Code  = _index.ToString();
                _index++;
                switch (tn.Type)
                {
                case "Group":
                    tn.Title = element.Attribute("Name").Value;
                    break;

                case "For": tn.Title = string.Format("For({0})", element.Attribute("LoopCount").Value);
                    For tag = new For();
                    tag.LoopCount = int.Parse(element.Attribute("LoopCount").Value);
                    tn.Tag        = tag;

                    break;

                case "Source":
                    string resid = element.Attribute("ResID").Value;
                    tn.Title = ResourceDictionary.Keys.Contains(resid) ? ResourceDictionary[resid].Name : resid;
                    tn.Code  = resid;
                    break;

                case "InputPopup":
                    tn.Title     = "PopupWindow";
                    tn.PopupText = element.Attribute("Text").Value;
                    break;

                case "CommandTable":
                    tn.Title = element.Attribute("Name").Value;
                    CommandTable ct = new CommandTable();
                    if (node.Type == "For")
                    {
                        ct.LoopCount = (node.Tag as For).LoopCount;
                    }

                    tn.Tag = ct;
                    // 读取sources
                    var sources = element.Elements();
                    foreach (var sourceElement in sources)
                    {
                        Source source = new Source();
                        source.ResID     = sourceElement.Attribute("ResID").Value;
                        source.ObjID     = ResourceDictionary.Keys.Contains(source.ResID) ? ResourceDictionary[source.ResID].ObjID : "";
                        source.Address   = ResourceDictionary.Keys.Contains(source.ResID) ? ResourceDictionary[source.ResID].Address : 0;
                        source.Name      = ResourceDictionary.Keys.Contains(source.ResID) ? ResourceDictionary[source.ResID].Name : source.ResID;
                        source.DigitType = ResourceDictionary.Keys.Contains(source.ResID) ? ResourceDictionary[source.ResID].DigitType : 0;
                        string objcmdstring = ResourceDictionary.Keys.Contains(source.ResID) ? ResourceDictionary[source.ResID].ObjCmd : "";

                        source.ObjCmd = string.IsNullOrEmpty(objcmdstring) ? 0 : int.Parse(objcmdstring);

                        ct.Sources.Add(source);

                        int temp = 0;

                        foreach (var stepElement in sourceElement.Elements())
                        {
                            Step step = new Step();
                            step.Source      = source;
                            step.TargetValue = Convert.ToDouble(stepElement.Attribute("TargetValue").Value);
                            step.PreTime     = Convert.ToInt32(stepElement.Attribute("PreTime").Value);
                            step.ChangeTime  = Convert.ToInt32(stepElement.Attribute("ChangeTime").Value);
                            step.HodeTime    = Convert.ToInt32(stepElement.Attribute("HodeTime").Value);
                            step.Time        = temp + step.PreTime;
                            //step.Time = temp + step.PreTime + step.ChangeTime;
                            temp = step.Time + step.ChangeTime + step.HodeTime;
                            source.Steps.Add(step);
                        }
                    }
                    break;
                }

                node.Children.Add(tn);

                BuilderNode(tn, element);
            }
        }