Ejemplo n.º 1
0
        public static LadderDiagramViewModel CreateLadderDiagramByXElement(XElement xEle, ProjectModel _projectmodel)
        {
            LadderDiagramViewModel result = new LadderDiagramViewModel(xEle.Attribute("Name").Value, _projectmodel);

            if (xEle.Attribute("IsMain") != null && xEle.Attribute("IsMain").Value == "True")
            {
                result.IsMainLadder = true;
            }
            else
            {
                result.IsMainLadder = false;
            }
            result.IsExpand = bool.Parse(xEle.Attribute("IsExpand").Value);
            result.InitNetworks();
            foreach (XElement netNode in xEle.Elements("Network"))
            {
                var net = CreateLadderNetworkByXElement(netNode, result);
                result.AppendNetwork(net);
                net.IsExpand = bool.Parse(netNode.Attribute("IsExpand").Value);
            }
            return(result);
        }
Ejemplo n.º 2
0
        static private void Read(LadderDiagramViewModel ldvmodel)
        {
            int sz = ReadE32();

            sz += eid;
            ldvmodel.ProgramName = ReadTextE8();
            while (eid < sz)
            {
                int head = edata[eid++];
                switch (head)
                {
                case 0xfe:
                    LadderNetworkViewModel lnvmodel
                        = new LadderNetworkViewModel(ldvmodel, ldvmodel.NetworkCount);
                    ldvmodel.AppendNetwork(lnvmodel);
                    Read(lnvmodel);
                    break;

                default:
                    throw new FormatException(
                              String.Format("非法头标志符0x{0x2X}", head));
                }
            }
        }