/// <summary> /// 生成Pin的子图(PinName,PinValue,PinLine) /// </summary> public void GenerateSubmitGraphics() { // 生成引脚上伸出的线 if (this.point1 != this.point2) { this.pinLine = new LogicLine(this.Point1, this.Point2, Color.Black, DashStyle.Solid); } // 生成引脚名称文本 if (this.pinName != null && this.pinName.Length > 0) { if (this.pinType == LogicPinType.Input) { this.pinNameText = new LogicText(this.pinName, 8f, new PointF(this.Point2.X + 2f, this.Point2.Y - 5f), new SizeF(28f, 10f), Align.MiddleLeft, Color.Black); } else { this.pinNameText = new LogicText(this.pinName, 8f, new PointF(this.Point1.X - 30f, this.Point1.Y - 5f), new SizeF(28f, 10f), Align.MiddleRight, Color.Black); } } // 生成引脚值文本 if (this.pinValue != null && this.pinValue.Length > 0) { if (this.pinType == LogicPinType.Input) { this.pinValueText = new LogicText(this.pinValue, 8f, new PointF(this.Point1.X - 30f, this.Point2.Y - 5f), new SizeF(28f, 10f), Align.MiddleRight, Color.Black); } else { this.pinValueText = new LogicText(this.pinValue, 8f, new PointF(this.Point2.X + 2f, this.Point2.Y - 12f), new SizeF(28f, 10f), Align.MiddleLeft, Color.Black); } // 动态属性(AiValueOut) } }
/// <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> /// 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); }
public void GenerateSubmitGraphicsByPin(LogicSymbol symbol) { if (symbol.SymbolType == LogicSymbolType.GeneralSymbol) { // 生成引脚名称文本 if (this.pinName != null && this.pinName.Length > 0) { if (this.pinType == LogicPinType.Input) { this.pinNameText = new LogicText(this.pinName, 8f, new PointF(this.Point2.X + 3f, this.Point2.Y - 5f), new SizeF(27f, 10f), Align.MiddleLeft, Color.Black); } else if (this.Visible) { this.pinNameText = new LogicText(this.pinName, 8f, new PointF(this.Point1.X - 30f, this.Point1.Y - 5f), new SizeF(27f, 10f), Align.MiddleRight, Color.Black); } } } // 生成引脚上伸出的线 if (this.pinType == LogicPinType.Input) { if ((!this.Visible && this.pointName != null && RegPointName.IsMatch(this.pointName)) || (this.Visible && (this.pointName == null || this.pointName.Trim('?',' ').Length == 0) && (this.pinValue == null || this.pinValue.Trim('?', ' ').Length == 0))) { this.point1 = PointF.Subtract(this.point2, new SizeF(20f, 0f)); this.pinLine = new LogicLine(this.Point1, this.Point2, Color.Black, DashStyle.Solid); if (symbol.X > this.point1.X) { symbol.Width += symbol.X - this.point1.X; symbol.X = this.point1.X; } if (this.PointName != null && RegPointName.IsMatch(this.PointName)) { string str = this.PointName.Substring(this.PointName.IndexOf('-') + 1); this.pinValue = "<" + str.Substring(str.IndexOf('-') + 1) + ">"; } } } // 生成引脚值文本 if (this.pinValue != null && this.pinValue.Length > 0) { if (this.pinType == LogicPinType.Input) { // 输入值 this.pinValueText = new LogicText(this.pinValue, 8f, new PointF(this.Point1.X - 30f, this.Point1.Y - 5f), new SizeF(27f, 10f), Align.MiddleRight, Color.Black); if (symbol.X > this.point1.X - 30f) { symbol.Width += symbol.X - (this.point1.X - 30f); symbol.X = this.point1.X - 30f; } } else { // 输出值 this.pinValueText = new LogicText(this.pinValue, 7f, new PointF(this.Point2.X + 3f, this.Point2.Y - 12f), new SizeF(27f, 10f), Align.MiddleLeft, Color.Black); if (symbol.X + symbol.Width < this.point2.X + 30f) { symbol.Width += this.point2.X + 30f - symbol.X - symbol.Width; } if (symbol.SymbolType == LogicSymbolType.IOSymbol && symbol.Y > this.PinValueText.Y) { // 给 IO 块添加输出值文本后,需要调整块的高度和 Y 坐标 symbol.Height += symbol.Y - this.PinValueText.Y; symbol.Y = this.PinValueText.Y; } // 动态输出值 DynValueOut value = new DynValueOut(this.pointName, 0); this.PinValueText.Dynamics.Add(value); } } }
public void GenerateSubmitGraphicsByPin(LogicSymbol symbol) { if (symbol.SymbolType == LogicSymbolType.GeneralSymbol) { // 生成引脚名称文本 if (this.pinName != null && this.pinName.Length > 0) { if (this.pinType == LogicPinType.Input) { this.pinNameText = new LogicText(this.pinName, 8f, new PointF(this.Point2.X + 3f, this.Point2.Y - 5f), new SizeF(27f, 10f), Align.MiddleLeft, Color.Black); } else if (this.Visible) { this.pinNameText = new LogicText(this.pinName, 8f, new PointF(this.Point1.X - 30f, this.Point1.Y - 5f), new SizeF(27f, 10f), Align.MiddleRight, Color.Black); } } } // 生成引脚上伸出的线 if (this.pinType == LogicPinType.Input) { if ((!this.Visible && this.pointName != null && RegPointName.IsMatch(this.pointName)) || (this.Visible && (this.pointName == null || this.pointName.Trim('?', ' ').Length == 0) && (this.pinValue == null || this.pinValue.Trim('?', ' ').Length == 0))) { this.point1 = PointF.Subtract(this.point2, new SizeF(20f, 0f)); this.pinLine = new LogicLine(this.Point1, this.Point2, Color.Black, DashStyle.Solid); if (symbol.X > this.point1.X) { symbol.Width += symbol.X - this.point1.X; symbol.X = this.point1.X; } if (this.PointName != null && RegPointName.IsMatch(this.PointName)) { string str = this.PointName.Substring(this.PointName.IndexOf('-') + 1); this.pinValue = "<" + str.Substring(str.IndexOf('-') + 1) + ">"; } } } // 生成引脚值文本 if (this.pinValue != null && this.pinValue.Length > 0) { if (this.pinType == LogicPinType.Input) { // 输入值 this.pinValueText = new LogicText(this.pinValue, 8f, new PointF(this.Point1.X - 30f, this.Point1.Y - 5f), new SizeF(27f, 10f), Align.MiddleRight, Color.Black); if (symbol.X > this.point1.X - 30f) { symbol.Width += symbol.X - (this.point1.X - 30f); symbol.X = this.point1.X - 30f; } } else { // 输出值 this.pinValueText = new LogicText(this.pinValue, 7f, new PointF(this.Point2.X + 3f, this.Point2.Y - 12f), new SizeF(27f, 10f), Align.MiddleLeft, Color.Black); if (symbol.X + symbol.Width < this.point2.X + 30f) { symbol.Width += this.point2.X + 30f - symbol.X - symbol.Width; } if (symbol.SymbolType == LogicSymbolType.IOSymbol && symbol.Y > this.PinValueText.Y) { // 给 IO 块添加输出值文本后,需要调整块的高度和 Y 坐标 symbol.Height += symbol.Y - this.PinValueText.Y; symbol.Y = this.PinValueText.Y; } // 动态输出值 DynValueOut value = new DynValueOut(this.pointName, 0); this.PinValueText.Dynamics.Add(value); } } }