/// <summary> /// XPgAO /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXPgAOBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:30 x 30 // 输入:1; 输出:0; 参数:0 block.Size = new SizeF(30f, 30f); LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = block.Size; LogicCircle bodyCircle = new LogicCircle(); bodyCircle.CentrePoint = new PointF(block.X + 15f, block.Y + 15f); bodyCircle.Radius = 15f; LogicText blockIndexText = new LogicText(); blockIndexText.Location = new PointF(block.X + 5f, block.Y + 10f); blockIndexText.Width = 20f; blockIndexText.Height = 11f; blockIndexText.Text = block.AlgName.Substring(block.AlgName.LastIndexOf('-') + 1); LogicPin inputPin = null; foreach (Cld_FCInput pin in block.Cld_FCInput_List) { if (pin.PinName == "X") { if (pin.Visible || (pin.PointName != null && LogicPin.RegPointName.IsMatch(pin.PointName))) { pin.Point = "0_15"; inputPin = new LogicPin(pin, symbolTemp); } } } symbolTemp.Graphics.Add(bodyCircle); symbolTemp.Graphics.Add(blockIndexText); 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++) { GenerateXPgAIReferer(block, i, referenceBlocks[i], symbols); } } }
private static void GenerateXPgAIReferer(Cld_FCBlock block, int refererIndex, Cld_FCBlock refBlock, ArrayList symbols) { // 大小:30 x 30 LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = new PointF((float)(block.X + block.Width + refererIndex * 30), block.Y + block.Height / 2 - 15f); symbolTemp.Size = new SizeF(30f, 30f); LogicCircle bodyCircle = new LogicCircle(); bodyCircle.CentrePoint = new PointF(symbolTemp.X + 15f, symbolTemp.Y + 15f); bodyCircle.Radius = 15f; LogicText pageIndexText = new LogicText(); pageIndexText.Location = new PointF(symbolTemp.X + 5f, symbolTemp.Y + 3f); pageIndexText.Width = 20f; pageIndexText.Height = 11f; LogicText blockIndexText = new LogicText(); blockIndexText.Location = new PointF(symbolTemp.X + 5f, symbolTemp.Y + 16f); blockIndexText.Width = 20f; blockIndexText.Height = 11f; string[] ids = refBlock.AlgName.Split('-'); pageIndexText.Text = ids[1]; blockIndexText.Text = ids[2]; symbolTemp.Graphics.Add(bodyCircle); symbolTemp.Graphics.Add(pageIndexText); symbolTemp.Graphics.Add(blockIndexText); symbols.Add(symbolTemp); }
/// <summary> /// XPgAI /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXPgAIBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:30 x 30 // 输入:0; 输出:1; 参数:2 block.Size = new SizeF(30f, 30f); 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)); LogicCircle bodyCircle = new LogicCircle(); bodyCircle.CentrePoint = new PointF(block.X + 15f, block.Y + 15f); bodyCircle.Radius = 15f; LogicLine bodyLine = new LogicLine(); bodyLine.Point1 = new PointF(block.X, block.Y + 15f); bodyLine.Point2 = new PointF(block.X + 30f, block.Y + 15f); LogicText pageIndexText = new LogicText(); pageIndexText.Location = new PointF(block.X + 5f, block.Y + 3f); pageIndexText.Width = 20f; pageIndexText.Height = 11f; pageIndexText.Text = "Null"; LogicText blockIndexText = new LogicText(); blockIndexText.Location = new PointF(block.X + 5f, block.Y + 16f); blockIndexText.Width = 20f; blockIndexText.Height = 11f; blockIndexText.Text = "Null"; LogicText textPointName = new LogicText(); textPointName.Location = new PointF(block.X - 60f, bodyCircle.Point1.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 == "Y") { output.Point = "30_15"; outputPin = new LogicPin(output, symbolTemp); } } foreach (Cld_FCParameter para in block.Cld_FCParameter_List) { if (para.Name == "Page" && para.PValue != null) { int pageIndex = Convert.ToInt32(para.PValue); if (pageIndex > 0 && pageIndex < 65535) { pageIndexText.Text = para.PValue; } else { pageIndexText.Text = "?"; } } else if (para.Name == "Block" && para.PValue != null) { int blockIndex = Convert.ToInt32(para.PValue); if (blockIndex > 0 && blockIndex < 65535) { blockIndexText.Text = para.PValue; } else { blockIndexText.Text = "?"; } } } string[] functons = new string[] { "XAI", "XAO", "XPI", "XNetAO", "XPgAO" }; IList<string> canReferenceFunctions = new List<string>(functons); Cld_FCBlock referenceBlock = CrossReference.GetInputReference(block); if (referenceBlock != null) { if (canReferenceFunctions.Contains(referenceBlock.FunctionName)) { if (referenceBlock.FunctionName != "XPgAO") { 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 = "NoAxTag"; // 引用块名称为空(不存在),GID == NULL } } } else { textPointName.Text = "RefError"; // 引用错误 textPointName.ForeColor = Color.Red; } } else { textPointName.Text = "RefNoExist"; // 引用块不存在 textPointName.ForeColor = Color.Red; } symbolTemp.Graphics.Add(bodyCircle); 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); }