/// <summary> /// XNetDI /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXNetDIBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:75 x 15 // 输入:0 + 1; 输出:1; 参数:n block.Size = new SizeF(75f, 15f); LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = block.Size; LogicPolygon bodyPolygon = new LogicPolygon(); bodyPolygon.Points = new PointF[] { new PointF(block.X, block.Y + block.Height / 2), new PointF(block.X + block.Height / 2, block.Y), new PointF(block.X + block.Width - block.Height / 2, block.Y), new PointF(block.X + block.Width, block.Y + block.Height / 2), new PointF(block.X + block.Width - block.Height / 2, block.Y + block.Height), new PointF(block.X + block.Height / 2, block.Y + block.Height)}; LogicText bodyText = new LogicText(); bodyText.Location = new PointF(block.X + 8f, block.Y + 2f); bodyText.Width = block.Width - 16f; bodyText.Height = block.Height - 4f; foreach (Cld_FCInput pin in block.Cld_FCInput_List) { if (pin.PinName == "GID") { if (pin.PointName != null && pin.PointName != "?") { bodyText.Text = pin.PointName; } else { bodyText.Text = "Null"; } } } LogicPin outputPin = null; foreach (Cld_FCOutput pin in block.Cld_FCOutput_List) { if (pin.PinName == "D") { pin.Point = "75_7.5"; outputPin = new LogicPin(pin, symbolTemp); } } symbolTemp.Graphics.Add(bodyPolygon); symbolTemp.Graphics.Add(bodyText); if (outputPin != null) { symbolTemp.Graphics.Add(outputPin); } LogicPoke poke = NewSymbolPoke(block, bodyText, null); symbolTemp.Graphics.Add(poke); symbols.Add(symbolTemp); }
/// <summary> /// XDO /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXDOBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:75 x 15 // 输入:1 + 1; 输出:0; 参数:n block.Size = new SizeF(75f, 15f); LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = new SizeF(75f, 28f); LogicPolygon bodyPolygon = new LogicPolygon(); bodyPolygon.Points = new PointF[] { symbolTemp.Location, new PointF(block.X + block.Width - block.Height / 2, block.Y), new PointF(block.X + block.Width, block.Y + block.Height / 2), new PointF(block.X + block.Width - block.Height / 2, block.Y + block.Height), new PointF(block.X, block.Y + block.Height) }; LogicText bodyText = new LogicText(); bodyText.Location = new PointF(block.X + 2f, block.Y + 2f); bodyText.Width = block.Width - block.Height / 2 - 4f; bodyText.Height = block.Height - 4f; LogicText parameterText = new LogicText(); parameterText.Location = new PointF(block.X, block.Y + block.Height + 1f); parameterText.Width = block.Width; parameterText.Height = 11f; parameterText.Alignment = Align.TopCenter; LogicPin inputPin = null; foreach (Cld_FCInput pin in block.Cld_FCInput_List) { if (pin.PinName == "Z") { pin.Point = "0_7.5"; inputPin = new LogicPin(pin, symbolTemp); } else if (pin.PinName == "GID") { if (pin.PointName != null && pin.PointName != "?") { bodyText.Text = pin.PointName; } else { bodyText.Text = "Null"; } } } foreach (Cld_FCParameter para in block.Cld_FCParameter_List) { if (para.Name == "Addr") { parameterText.Text = GetAddr(para.PValue); } } symbolTemp.Graphics.Add(bodyPolygon); symbolTemp.Graphics.Add(bodyText); symbolTemp.Graphics.Add(parameterText); if (inputPin != null) { symbolTemp.Graphics.Add(inputPin); } IList<Cld_FCBlock> referenceBlocks = CrossReference.GetOutputReference(block); LogicPoke poke = NewSymbolPoke(block, bodyText, referenceBlocks); symbolTemp.Graphics.Add(poke); symbols.Add(symbolTemp); if (referenceBlocks.Count > 0) { for (int i = 0; i < referenceBlocks.Count; i++) { GenerateXPgDIReferer(block, i, referenceBlocks[i], symbols); } } }
private static void GenerateXPgDIReferer(Cld_FCBlock block, int refererIndex, Cld_FCBlock refBlock, ArrayList symbols) { // 大小:35 x 30 float edgeLength = 17.5f; // 正六边形的边长 LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = new PointF((float)(block.X + block.Width + refererIndex * 35), block.Y + block.Height / 2 - 15f); symbolTemp.Size = new SizeF(35f, 30f); LogicPolygon bodyPolygon = new LogicPolygon(); bodyPolygon.Points = new PointF[] { new PointF(symbolTemp.X, symbolTemp.Y + 15f), new PointF(symbolTemp.X + edgeLength / 2, symbolTemp.Y), new PointF((float)(symbolTemp.X + edgeLength * 1.5), symbolTemp.Y), new PointF(symbolTemp.X + 35f, symbolTemp.Y + 15f), new PointF((float)(symbolTemp.X + edgeLength * 1.5), symbolTemp.Y + 30f), new PointF((float)(symbolTemp.X + edgeLength / 2), symbolTemp.Y + 30f)}; LogicText pageIndexText = new LogicText(); pageIndexText.Location = new PointF(symbolTemp.X + 8f, symbolTemp.Y + 3f); pageIndexText.Width = 19f; pageIndexText.Height = 11f; LogicText blockIndexText = new LogicText(); blockIndexText.Location = new PointF(symbolTemp.X + 8f, symbolTemp.Y + 16f); blockIndexText.Width = 19f; blockIndexText.Height = 11f; string[] ids = refBlock.AlgName.Split('-'); pageIndexText.Text = ids[1]; blockIndexText.Text = ids[2]; symbolTemp.Graphics.Add(bodyPolygon); symbolTemp.Graphics.Add(pageIndexText); symbolTemp.Graphics.Add(blockIndexText); symbols.Add(symbolTemp); }
/// <summary> /// XPgDO /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXPgDOBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:35 x 30 // 输入:1; 输出:0; 参数:0 block.Size = new SizeF(35f, 30f); float edgeLength = 17.5f; LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = block.Size; LogicPolygon bodyPolygon = new LogicPolygon(); bodyPolygon.Points = new PointF[] { new PointF(block.X, block.Y + 15f), new PointF(block.X + edgeLength / 2, block.Y), new PointF((float)(block.X + edgeLength * 1.5), block.Y), new PointF(block.X + 35f, block.Y + 15f), new PointF((float)(block.X + edgeLength * 1.5), block.Y + 30f), new PointF((float)(block.X + edgeLength / 2), block.Y + 30f)}; LogicText bodyText = new LogicText(); bodyText.Location = new PointF(block.X + 8f, block.Y + 10f); bodyText.Width = 19f; bodyText.Height = 11f; bodyText.Text = block.AlgName.Substring(block.AlgName.LastIndexOf('-') + 1); LogicPin inputPin = null; foreach (Cld_FCInput pin in block.Cld_FCInput_List) { if (pin.PinName == "Z") { if (pin.Visible || (pin.PointName != null && LogicPin.RegPointName.IsMatch(pin.PointName))) { pin.Point = "0_15"; inputPin = new LogicPin(pin, symbolTemp); } } } symbolTemp.Graphics.Add(bodyPolygon); symbolTemp.Graphics.Add(bodyText); if (inputPin != null) { symbolTemp.Graphics.Add(inputPin); } IList<Cld_FCBlock> referenceBlocks = CrossReference.GetOutputReference(block); LogicPoke poke = new LogicPoke(block); if (referenceBlocks.Count > 0) { DynCrossReference reference = new DynCrossReference(); foreach (Cld_FCBlock refBlock in referenceBlocks) { reference.AddReference(refBlock); } poke.Dynamics.Add(reference); } symbolTemp.Graphics.Add(poke); symbols.Add(symbolTemp); if (referenceBlocks.Count > 0) { for (int i = 0; i < referenceBlocks.Count; i++) { GenerateXPgDIReferer(block, i, referenceBlocks[i], symbols); } } }
/// <summary> /// XPgDI /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXPgDIBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:35 x 30 // 输入:0; 输出:1; 参数:2 block.Size = new SizeF(35f, 30f); float edgeLength = 17.5f; // 正六边形的边长 LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = PointF.Subtract(block.Location, new SizeF(60f, 0f)); symbolTemp.Size = SizeF.Add(block.Size, new SizeF(60f, 0f)); LogicPolygon bodyPolygon = new LogicPolygon(); bodyPolygon.Points = new PointF[] { new PointF(block.X, block.Y + 15f), new PointF(block.X + edgeLength / 2, block.Y), new PointF((float)(block.X + edgeLength * 1.5), block.Y), new PointF(block.X + 35f, block.Y + 15f), new PointF((float)(block.X + edgeLength * 1.5), block.Y + 30f), new PointF((float)(block.X + edgeLength / 2), block.Y + 30f)}; LogicLine bodyLine = new LogicLine(); bodyLine.Point1 = bodyPolygon.Points[0]; bodyLine.Point2 = bodyPolygon.Points[3]; LogicText pageIndexText = new LogicText(); pageIndexText.Location = new PointF(block.X + 8f, block.Y + 3f); pageIndexText.Width = 19f; pageIndexText.Height = 11f; LogicText blockIndexText = new LogicText(); blockIndexText.Location = new PointF(block.X + 8f, block.Y + 16f); blockIndexText.Width = 19f; blockIndexText.Height = 11f; string[] id = block.AlgName.Split('-'); pageIndexText.Text = id[1]; blockIndexText.Text = id[2]; LogicText textPointName = new LogicText(); textPointName.Location = new PointF(block.X - 60f, block.Y + 2f); textPointName.Width = 58f; textPointName.Height = 11f; textPointName.Alignment = Align.BottomRight; LogicPin outputPin = null; foreach (Cld_FCOutput output in block.Cld_FCOutput_List) { if (output.PinName == "D") { output.Point = "35_15"; outputPin = new LogicPin(output, symbolTemp); } } foreach (Cld_FCParameter para in block.Cld_FCParameter_List) { if (para.Name == "Page") { if (para.PValue != null) { int pageIndex = Convert.ToInt32(para.PValue); if (pageIndex > 0 && pageIndex < 65535) { pageIndexText.Text = para.PValue; } else { pageIndexText.Text = "?"; } } else { pageIndexText.Text = "?"; } } else if (para.Name == "Block") { if (para.PValue != null) { int blockIndex = Convert.ToInt32(para.PValue); if (blockIndex > 0 && blockIndex < 65535) { blockIndexText.Text = para.PValue; } else { blockIndexText.Text = "?"; } } else { blockIndexText.Text = "?"; } } } string[] functions = new string[] { "XDI", "XDO", "XNetDO", "XPgDO" }; IList<string> canReferenceFunctions = new List<string>(functions); Cld_FCBlock referenceBlock = CrossReference.GetInputReference(block); if (referenceBlock != null) { if (canReferenceFunctions.Contains(referenceBlock.FunctionName)) { if (referenceBlock.FunctionName != "XPgDO") { foreach (Cld_FCInput pin in referenceBlock.Cld_FCInput_List) { if (pin.PinName == "GID" && pin.PointName != null && pin.PointName != "?") { textPointName.Text = pin.PointName; } } if (textPointName.Text.Length == 0) { textPointName.Text = "NoDxTag"; // 引用块名称为空(不存在),GID == NULL } } } else { textPointName.Text = "RefError"; // 引用错误 textPointName.ForeColor = Color.Red; } } else { textPointName.Text = "RefNoExist"; // 引用块不存在 textPointName.ForeColor = Color.Red; } symbolTemp.Graphics.Add(bodyPolygon); symbolTemp.Graphics.Add(bodyLine); symbolTemp.Graphics.Add(pageIndexText); symbolTemp.Graphics.Add(blockIndexText); symbolTemp.Graphics.Add(textPointName); if (outputPin != null) { symbolTemp.Graphics.Add(outputPin); } LogicPoke poke = new LogicPoke(block); if (referenceBlock != null) { DynCrossReference refenence = new DynCrossReference(); refenence.AddReference(referenceBlock); poke.Dynamics.Add(refenence); } symbolTemp.Graphics.Add(poke); symbols.Add(symbolTemp); }
/// <summary> /// XNetDO /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXNetDOBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:75 x 15 // 输入:1; 输出:0 + 1; 参数:n block.Size = new SizeF(75f, 15f); LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = block.Size; LogicPolygon bodyPolygon = new LogicPolygon(); bodyPolygon.Points = new PointF[] { new PointF(block.X, block.Y + block.Height / 2), new PointF(block.X + block.Height / 2, block.Y), new PointF(block.X + block.Width - block.Height / 2, block.Y), new PointF(block.X + block.Width, block.Y + block.Height / 2), new PointF(block.X + block.Width - block.Height / 2, block.Y + block.Height), new PointF(block.X + block.Height / 2, block.Y + block.Height)}; LogicText bodyText = new LogicText(); bodyText.Location = new PointF(block.X + 8f, block.Y + 2f); bodyText.Width = block.Width - 16f; bodyText.Height = block.Height - 4f; LogicPin inputPin = null; foreach (Cld_FCInput pin in block.Cld_FCInput_List) { if (pin.PinName == "Z") { if (pin.Visible || (pin.PointName != null && LogicPin.RegPointName.IsMatch(pin.PointName))) { pin.Point = "0_7.5"; inputPin = new LogicPin(pin, symbolTemp); } } else if (pin.PinName == "GID") { if (pin.PointName != null && pin.PointName != "?") { bodyText.Text = pin.PointName; } else { bodyText.Text = "Null"; } } } symbolTemp.Graphics.Add(bodyPolygon); symbolTemp.Graphics.Add(bodyText); if (inputPin != null) { symbolTemp.Graphics.Add(inputPin); } IList<Cld_FCBlock> referenceBlocks = CrossReference.GetOutputReference(block); LogicPoke poke = NewSymbolPoke(block, bodyText, referenceBlocks); symbolTemp.Graphics.Add(poke); symbols.Add(symbolTemp); if (referenceBlocks.Count > 0) { for (int i = 0; i < referenceBlocks.Count; i++) { GenerateXPgDIReferer(block, i, referenceBlocks[i], symbols); } } }