/// <summary> /// 将给定的Cld_FCBlock和当前的sheet关联起来 /// </summary> /// <param name="to_add"></param> public virtual void Add(Cld_FCBlock to_add) { this.Cld_Constant_List.Add(to_add); to_add.Prj_Sheet_ID = this.ID; to_add.Prj_Document_ID = this.Prj_Document_ID; to_add.Prj_Controller_ID = this.Prj_Controller_ID; }
/// <summary> /// 获取指定 Block 的输出引用块列表 /// </summary> /// <param name="block"></param> /// <returns></returns> public static IList<Cld_FCBlock> GetOutputReference(Cld_FCBlock block) { string[] Numbers = block.AlgName.Split('-'); string dpuNum = Numbers[0]; string pageNum = Numbers[1]; string blockNum = Numbers[2]; string sql = "SELECT * FROM Cld_FCBlock WHERE ID IN (" + " SELECT blocks.Cld_FCBlock_ID" + " FROM Cld_FCParameter AS pages INNER JOIN Cld_FCParameter AS blocks" + " ON pages.Cld_FCBlock_ID = blocks.Cld_FCBlock_ID" + " WHERE pages.Prj_Controller_ID=" + block.Prj_Controller_ID + " AND blocks.Prj_Controller_ID=" + block.Prj_Controller_ID + " AND pages.Name='Page' AND pages.PValue='" + pageNum + "'" + " AND blocks.Name='Block' AND blocks.PValue='" + blockNum + "')"; IList<Cld_FCBlock> blocks = null; try { blocks = GraphicsDocument.session.CreateSQLQuery(sql).AddEntity("ProjectManager.DAL.Cld_FCBlock").List<Cld_FCBlock>(); } catch (Exception e) { throw e; } if (blocks != null) { return blocks; } return new List<Cld_FCBlock>(); }
public LogicPoke(Cld_FCBlock block) { this.Type = LogicObjectType.Poke; this.Location = block.Location; this.Size = block.Size; this.BlockID = Convert.ToInt32(block.AlgName.Substring(block.AlgName.LastIndexOf('-') + 1)); }
/// <summary> /// 返回 此Sheet下面的一个新的Cld_FCBlock对象 /// </summary> /// <returns></returns> public virtual Cld_FCBlock New_Cld_FCBlock() { Cld_FCBlock result = new Cld_FCBlock(); result.Prj_Controller_ID = this.Prj_Controller_ID; result.Prj_Document_ID = this.Prj_Document_ID; result.Prj_Sheet_ID = this.ID; return result; }
/// <summary> /// 返回 此Sheet下面的一个新的Cld_FCBlock对象 /// </summary> /// <returns></returns> public virtual Cld_FCBlock New_Cld_FCBlock() { Cld_FCBlock result = new Cld_FCBlock(); result.Prj_Controller_ID = this.Prj_Controller_ID; result.Prj_Document_ID = this.Prj_Document_ID; result.Prj_Sheet_ID = this.ID; return(result); }
public void AddReference(Cld_FCBlock block) { if (regAlgName.IsMatch(block.AlgName)) { this.references.Add(block.AlgName); } else { throw new Exception("AlgName格式错误!"); } }
/// <summary> /// 返回 此Sheet下面的一个新的Cld_FCBlock对象 /// </summary> /// <returns></returns> public virtual Cld_FCBlock New_Cld_FCBlock() { Cld_FCBlock result = new Cld_FCBlock(); result.Prj_Controller_ID = this.Prj_Controller_ID; //result.Prj_Controller = this.Prj_Controller; result.Prj_Document_ID = this.Prj_Document_ID; //result.Prj_Document = this.Prj_Document; result.Prj_Sheet_ID = this.ID; //result.Prj_Sheet = this; this.Cld_FCBlock_List.Add(result); return result; }
/// <summary> /// 获得给定条件所有的Blocks,以及与其相关的所有后代对象 /// </summary> /// <param name="wherestring"></param> /// <returns></returns> public IList <Cld_FCBlock> Load_Blocks(string wherestring) { string sql = "select * from Cld_FCBlock where " + wherestring; IList <Cld_FCBlock> blocks; ITransaction transacton = this.session.BeginTransaction(); try { blocks = this.session.CreateSQLQuery(sql).AddEntity("ProjectManager.DAL.Cld_FCBlock").List <Cld_FCBlock>(); transacton.Commit(); } catch (Exception e) { transacton.Rollback(); throw e; } Hashtable table = new Hashtable(); IList <Cld_FCInput> inputs = Get_FCInput_List(blocks); IList <Cld_FCOutput> outputs = Get_FCOutput_List(blocks); IList <Cld_FCParameter> parameters = Get_FCParameter_List(blocks); foreach (Cld_FCBlock block in blocks) { table[block.ID] = block; block.Cld_FCInput_List = new MyList(block); block.Cld_FCOutput_List = new MyList(block); block.Cld_FCParameter_List = new MyList(block); } //双向关联Input foreach (Cld_FCInput input in inputs) { Cld_FCBlock block = (Cld_FCBlock)table[input.Cld_FCBlock_ID]; block.Cld_FCInput_List.Add(input); input.Cld_FCBlock = block; } //双向关联output foreach (Cld_FCOutput output in outputs) { Cld_FCBlock block = (Cld_FCBlock)table[output.Cld_FCBlock_ID]; block.Cld_FCOutput_List.Add(output); output.Cld_FCBlock = block; } //双向关联Parameter foreach (Cld_FCParameter p in parameters) { Cld_FCBlock block = (Cld_FCBlock)table[p.Cld_FCBlock_ID]; block.Cld_FCParameter_List.Add(p); p.Cld_FCBlock = block; } return(null); }
/// <summary> /// 返回 此Sheet下面的一个新的Cld_FCBlock对象 /// </summary> /// <returns></returns> public virtual Cld_FCBlock New_Cld_FCBlock() { Cld_FCBlock result = new Cld_FCBlock(); result.Prj_Controller_ID = this.Prj_Controller_ID; //result.Prj_Controller = this.Prj_Controller; result.Prj_Document_ID = this.Prj_Document_ID; //result.Prj_Document = this.Prj_Document; result.Prj_Sheet_ID = this.ID; //result.Prj_Sheet = this; this.Cld_FCBlock_List.Add(result); return(result); }
/// <summary> /// 根据ID获得Cld_FCBlock /// </summary> /// <param name="condition">ID type:int</param> /// <returns></returns> public Cld_FCBlock GetCld_FCBlock_By_ID(int condition) { using (ITransaction transaction = session.BeginTransaction()){ try{ Cld_FCBlock result = this.session.Get <Cld_FCBlock>(condition); transaction.Commit(); return(result); }catch (Exception e) { transaction.Rollback(); throw e; } } }
/// <summary> /// 默认构造函数 /// <summary> public Cld_FCParameter() : base() { m_ID = -1; m_Name = String.Empty; m_PValue = String.Empty; m_Cld_FCBlock_ID = -1; m_Cld_FCBlock = null; m_Prj_Sheet_ID = -1; m_Prj_Sheet = null; m_Prj_Document_ID = -1; m_Prj_Document = null; m_Prj_Controller_ID = -1; m_Prj_Controller = null; }
/// <summary> /// 默认构造函数 /// <summary> public Cld_FCInput():base(){ m_ID = -1; m_PinName = String.Empty; m_PointName = String.Empty; m_InitialValue = String.Empty; m_Point = String.Empty; m_Visible = false; m_Description = String.Empty; m_Cld_FCBlock_ID = -1; m_Cld_FCBlock = null; m_Prj_Sheet_ID = -1; m_Prj_Sheet = null; m_Prj_Document_ID = -1; m_Prj_Document = null; m_Prj_Controller_ID = -1; m_Prj_Controller = null; }
/// <summary> /// 默认构造函数 /// <summary> public Cld_FCInput() : base() { m_ID = -1; m_PinName = String.Empty; m_PointName = String.Empty; m_InitialValue = String.Empty; m_Point = String.Empty; m_Visible = false; m_Description = String.Empty; m_Cld_FCBlock_ID = -1; m_Cld_FCBlock = null; m_Prj_Sheet_ID = -1; m_Prj_Sheet = null; m_Prj_Document_ID = -1; m_Prj_Document = null; m_Prj_Controller_ID = -1; m_Prj_Controller = null; }
public virtual bool Compare(Cld_FCBlock block) { if (this.ID != block.ID) { throw new Exception("id should be equal"); } if (this.AlgName != block.AlgName || this.Sequence != block.Sequence || this.FunctionName != block.FunctionName || this.X_Y != block.X_Y || this.SymbolName != block.SymbolName || this.Description != block.Description || this.Prj_Controller_ID != block.Prj_Controller_ID || this.Prj_Document_ID != block.Prj_Document_ID || this.Prj_Sheet_ID != block.Prj_Sheet_ID ) { return(false); } else { return(true); } }
/// <summary> /// 获得与给定prj_sheet相关的cld_fcblock以及所有相关的后代对象 /// </summary> /// <param name="sheets"></param> /// <returns></returns> public IList <Cld_FCBlock> Load_FCBlock_List(IList <Prj_Sheet> sheets) { IList <Cld_FCBlock> blocks = Get_FCBlock_List(sheets); IList <Cld_FCInput> inputs = (new Cld_FCBlockCRUD(this.session)).Get_FCInput_List(blocks); IList <Cld_FCOutput> outputs = (new Cld_FCBlockCRUD(this.session)).Get_FCOutput_List(blocks); IList <Cld_FCParameter> parameters = (new Cld_FCBlockCRUD(this.session)).Get_FCParameter_List(blocks); Hashtable table = new Hashtable(); foreach (Cld_FCBlock block in blocks) { table[block.ID] = block; block.Cld_FCInput_List = new ArrayList(); block.Cld_FCOutput_List = new ArrayList(); block.Cld_FCParameter_List = new ArrayList(); } //双向关联input foreach (Cld_FCInput input in inputs) { Cld_FCBlock block = (Cld_FCBlock)table[input.Cld_FCBlock_ID]; block.Cld_FCInput_List.Add(input); input.Cld_FCBlock = block; } //双向关联output foreach (Cld_FCOutput output in outputs) { Cld_FCBlock block = (Cld_FCBlock)table[output.Cld_FCBlock_ID]; block.Cld_FCOutput_List.Add(output); output.Cld_FCBlock = block; } //双向关联parameter foreach (Cld_FCParameter p in parameters) { Cld_FCBlock block = (Cld_FCBlock)table[p.Cld_FCBlock_ID]; block.Cld_FCParameter_List.Add(p); p.Cld_FCBlock = block; } return(blocks); }
public void AddLoopReference(Cld_FCBlock block) { if (regAlgName.IsMatch(block.AlgName)) { string algName; if (block.FunctionName != "XNetAI" && block.FunctionName != "XNetDI") { algName = "net:*" + block.AlgName; } else { algName = "net:" + block.AlgName; } this.references.Add(algName); loopRefCount++; } else { throw new Exception("AlgName格式错误!"); } }
/// <summary> /// 获取 XPgAI/XPgDI 的输入引用块 /// </summary> /// <param name="block"></param> /// <returns></returns> public static Cld_FCBlock GetInputReference(Cld_FCBlock block) { string dpuNum = block.AlgName.Substring(0, block.AlgName.IndexOf('-')); string pageNum = ""; string blockNum = ""; foreach (Cld_FCParameter para in block.Cld_FCParameter_List) { if (para.Name == "Page") { pageNum = para.PValue; } else if (para.Name == "Block") { blockNum = para.PValue; } } string sql = "SELECT * FROM Cld_FCBlock WHERE AlgName='" + dpuNum + "-" + pageNum + "-" + blockNum + "'"; IList<Cld_FCBlock> blocks; try { blocks = GraphicsDocument.session.CreateSQLQuery(sql).AddEntity("ProjectManager.DAL.Cld_FCBlock").List<Cld_FCBlock>(); } catch (Exception e) { throw e; } if (blocks.Count > 0) { return blocks[0]; } return null; }
/// <summary> /// XPI /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXPIBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:75 x 15 // 输入:1 + 1; 输出:1; 参数:n block.Size = new SizeF(75f, 15f); LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = new SizeF(75f, 28f); LogicRectangle bodyRectangle = new LogicRectangle(); bodyRectangle.Location = block.Location; bodyRectangle.Size = new SizeF(67.5f, 15f); // 右端的半圆 LogicArc bodyArc = new LogicArc(); bodyArc.CentrePoint = new PointF(block.X + 67.5f, block.Y + 7.5f); bodyArc.Radius = 7.5f; bodyArc.StartAngle = -90; bodyArc.EndAngle = 90; // GID,块中间显示的文本 LogicText bodyText = new LogicText(); bodyText.Location = new PointF(bodyRectangle.X + 2f, bodyRectangle.Y + 2f); bodyText.Width = bodyRectangle.Width - 4f; bodyText.Height = bodyRectangle.Height - 4f; // Addr,块下方显示的参数文本(数据存储位置不确定) //WangXiang LogicText parameterText = new LogicText(); parameterText.Location = new PointF(bodyRectangle.X + 2f, bodyRectangle.Y + bodyRectangle.Height + 1f); parameterText.Width = bodyText.Width; parameterText.Height = 11f; parameterText.Alignment = Align.TopCenter; LogicPin inputPin = null; foreach (Cld_FCInput pin in block.Cld_FCInput_List) { if (pin.PinName == "Rst") { 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"; } } } LogicPin outputPin = null; foreach (Cld_FCOutput pin in block.Cld_FCOutput_List) { if (pin.PinName == "Y") { pin.Point = "75_7.5"; outputPin = new LogicPin(pin, symbolTemp); } } foreach (Cld_FCParameter para in block.Cld_FCParameter_List) { if (para.Name == "Addr") { parameterText.Text = GetAddr(para.PValue); } } symbolTemp.Graphics.Add(bodyRectangle); symbolTemp.Graphics.Add(bodyArc); symbolTemp.Graphics.Add(bodyText); symbolTemp.Graphics.Add(parameterText); if (inputPin != null) { symbolTemp.Graphics.Add(inputPin); } if (outputPin != null) { symbolTemp.Graphics.Add(outputPin); } 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++) { GenerateXPgAIReferer(block, i, referenceBlocks[i], symbols); } } }
/// <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); } } }
/// <summary> /// 根据FCBlock构造Symbol /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> private static void GenerateCommonBlock(Cld_FCBlock block, ArrayList symbols) { // 开始构造一个Symbol LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.GeneralSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = block.Size; // 主体矩形 LogicRectangle symbolBody = new LogicRectangle(); symbolBody.Location = block.Location; symbolBody.Size = block.Size; symbolTemp.Graphics.Add(symbolBody); #region 模块名称(内部,上中) // SymbolName LogicText symbolNameText = new LogicText(); symbolNameText.Location = new PointF(block.X + 2f, block.Y + 1f); symbolNameText.Width = block.Width - 4f; symbolNameText.Height = LogicSymbol.HeadHeight - 3f; symbolNameText.Text = block.FunctionName; symbolNameText.Font = new Font(LogicText.DefaultFamily, 12, FontStyle.Bold); symbolNameText.Alignment = Align.TopCenter; symbolNameText.ForeColor = Color.Black; symbolTemp.Graphics.Add(symbolNameText); #endregion #region I/O引脚 // 遍历输入引脚 foreach (Cld_FCInput input in block.Cld_FCInput_List) { bool isConnected = input.PointName != null ? LogicPin.RegPointName.IsMatch(input.PointName) : false; if (input.Visible || isConnected) { LogicPin pin = new LogicPin(input, symbolTemp); symbolTemp.Graphics.Add(pin); symbolTemp.InputCount++; } } // 遍历输出引脚 foreach (Cld_FCOutput output in block.Cld_FCOutput_List) { bool enable = false; if (!output.Visible) { foreach (Cld_FCInput input in block.Cld_FCInput_List) { if (input.Visible && input.PointName == output.PointName) { enable = true; break; } } } if (output.Visible || enable) { LogicPin pin = new LogicPin(output, symbolTemp); symbolTemp.Graphics.Add(pin); symbolTemp.OutputCount++; } } #endregion #region 输出块号 // 块号:序号 LogicText symbolIndexText = new LogicText(); symbolIndexText.Location = new PointF(block.X + 2f, block.Y + block.Height - LogicSymbol.FootHeight + 2f); symbolIndexText.Width = block.Width - 4f; symbolIndexText.Height = LogicSymbol.FootHeight - 3f; symbolIndexText.Text = block.AlgName.Substring(block.AlgName.LastIndexOf('-') + 1) + ":" + block.Sequence; symbolTemp.Graphics.Add(symbolIndexText); #endregion #region 输出块的参数信息 IList fcParameters = block.Cld_FCParameter_List; if (fcParameters.Count > 0) { symbolTemp.Height += LogicSymbol.ParaHeight; LogicText symbolParaText = new LogicText(); symbolParaText.Location = new PointF(block.X, block.Y + block.Height + 1f); symbolParaText.Width = block.Width; symbolParaText.Height = LogicSymbol.ParaHeight - 2f; symbolParaText.Alignment = Align.TopCenter; symbolParaText.Text = ""; foreach (Cld_FCParameter para in block.Cld_FCParameter_List) { if (para.Name == "Num") { if (symbolParaText.Text.Length == 0) { symbolParaText.Text = "Num=" + para.PValue; } else { symbolParaText.Text = "Num=" + para.PValue + "," + symbolParaText.Text; } } if (para.Name == "Mode") { if (symbolParaText.Text.Length == 0) { symbolParaText.Text = "Num=" + para.PValue; } else { symbolParaText.Text += ",Num=" + para.PValue; } } } symbolTemp.Graphics.Add(symbolParaText); } #endregion LogicPoke poke = new LogicPoke(block); // 操作方式 symbolTemp.Graphics.Add(poke); symbols.Add(symbolTemp); }
private static LogicPoke NewSymbolPoke(Cld_FCBlock block, LogicText bodyText, IList<Cld_FCBlock> referenceBlocks) { IList<Cld_FCBlock> loopReferenceBlocks = bodyText.Text != "Null" ? CrossReference.GetLoopReference(bodyText.Text, block.ID) : null; DynCrossReference reference = null; if (referenceBlocks != null && referenceBlocks.Count > 0) { reference = new DynCrossReference(); foreach (Cld_FCBlock refBlock in referenceBlocks) { reference.AddReference(refBlock); } } if (loopReferenceBlocks != null && loopReferenceBlocks.Count > 0) { if (reference == null) { reference = new DynCrossReference(); } foreach (Cld_FCBlock refBlock in loopReferenceBlocks) { reference.AddLoopReference(refBlock); } } LogicPoke poke = new LogicPoke(block); if (reference != null) { poke.Dynamics.Add(reference); } return poke; }
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); }
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> /// 根据给定的ID加载sheet,以及与其相关的所有后代对象, /// 如果不存在,则返回null /// </summary> /// <param name="sheetid"></param> /// <returns></returns> public Prj_Sheet Load_Sheet(int sheetid) { Hashtable table = new Hashtable(); Prj_Sheet result; IList <Cld_FCBlock> blocks; IList <Cld_Signal> signals; IList <Cld_Constant> consts; IList <Cld_Graphic> graphics; IList <Cld_FCInput> inputs; IList <Cld_FCOutput> outputs; IList <Cld_FCParameter> parameters; using (ITransaction transaction = this.session.BeginTransaction()) { try { result = (Prj_Sheet)this.session.Get(typeof(Prj_Sheet), sheetid); //如果没有找到对应的Prj_Sheet,返回null if (result == null) { return(null); } blocks = this.session.CreateQuery("from Cld_FCBlock as b where b.Prj_Sheet_ID = " + sheetid).List <Cld_FCBlock>(); signals = this.session.CreateQuery("from Cld_Signal as s where s.Prj_Sheet_ID = " + sheetid).List <Cld_Signal>(); consts = this.session.CreateQuery("from Cld_Constant as c where c.Prj_Sheet_ID = " + sheetid).List <Cld_Constant>(); graphics = this.session.CreateQuery("from Cld_Graphic as g where g.Prj_Sheet_ID = " + sheetid).List <Cld_Graphic>(); inputs = this.session.CreateQuery("from Cld_FCInput as i where i.Prj_Sheet_ID = " + sheetid).List <Cld_FCInput>(); outputs = this.session.CreateQuery("from Cld_FCOutput as o where o.Prj_Sheet_ID = " + sheetid).List <Cld_FCOutput>(); parameters = this.session.CreateQuery("from Cld_FCParameter as p where p.Prj_Sheet_ID = " + sheetid).List <Cld_FCParameter>(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw e; } } //List to Hahstable foreach (Cld_FCBlock b in blocks) { table[b.ID] = b; b.Cld_FCInput_List = new ArrayList(); b.Cld_FCOutput_List = new ArrayList(); b.Cld_FCParameter_List = new ArrayList(); } //关联input result.Cld_FCInput_List = new ArrayList(); foreach (Cld_FCInput input in inputs) { //关联到Block if (table.ContainsKey(input.Cld_FCBlock_ID)) { Cld_FCBlock block = (Cld_FCBlock)table[input.Cld_FCBlock_ID]; block.Cld_FCInput_List.Add(input); input.Cld_FCBlock = block; } else { continue; } //关联到sheet result.Cld_FCInput_List.Add(input); input.Prj_Sheet = result; } //关联output result.Cld_FCOutput_List = new ArrayList(); foreach (Cld_FCOutput output in outputs) { //关联到Block if (table.ContainsKey(output.Cld_FCBlock_ID)) { Cld_FCBlock block = (Cld_FCBlock)table[output.Cld_FCBlock_ID]; block.Cld_FCOutput_List.Add(output); output.Cld_FCBlock = block; } else { continue; } //关联到sheet result.Cld_FCOutput_List.Add(output); output.Prj_Sheet = result; } //关联parameter result.Cld_FCParameter_List = new ArrayList(); foreach (Cld_FCParameter p in parameters) { //关联到Block if (table.ContainsKey(p.Cld_FCBlock_ID)) { Cld_FCBlock block = (Cld_FCBlock)table[p.Cld_FCBlock_ID]; block.Cld_FCParameter_List.Add(p); p.Cld_FCBlock = block; } else { continue; } //关联到sheet result.Cld_FCParameter_List.Add(p); p.Prj_Sheet = result; } //关联signal result.Cld_Signal_List = new ArrayList(); foreach (Cld_Signal signal in signals) { result.Cld_Signal_List.Add(signal); signal.Prj_Sheet = result; } //关联constant result.Cld_Constant_List = new ArrayList(); foreach (Cld_Constant c in consts) { result.Cld_Constant_List.Add(c); c.Prj_Sheet = result; } //关联graphic result.Cld_Graphic_List = new ArrayList(); foreach (Cld_Graphic g in graphics) { result.Cld_Graphic_List.Add(g); g.Prj_Sheet = result; } //关联block result.Cld_FCBlock_List = new ArrayList(); foreach (Cld_FCBlock b in blocks) { result.Cld_FCBlock_List.Add(b); b.Prj_Sheet = result; } Console.WriteLine("Load Prj_Sheet OK!"); return(result); }
/// <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> /// XNetAI /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXNetAIBlock(Cld_FCBlock block, ArrayList symbols) { // Body大小:75 x 15 // 输入:0 + 1; 输出:1; 参数:2 block.Size = new SizeF(75f, 15f); LogicSymbol symbolTemp = new LogicSymbol(LogicSymbolType.IOSymbol); symbolTemp.Location = block.Location; symbolTemp.Size = block.Size; LogicRoundRectangle bodyRoundRectangle = new LogicRoundRectangle(); bodyRoundRectangle.Location = block.Location; bodyRoundRectangle.Size = symbolTemp.Size; bodyRoundRectangle.XRadius = 7.5f; bodyRoundRectangle.YRadius = 7.5f; LogicText bodyText = new LogicText(); bodyText.Location = new PointF(symbolTemp.X + 8f, symbolTemp.Y + 2f); bodyText.Width = symbolTemp.Width - 16f; bodyText.Height = 11f; 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 == "Y") { pin.Point = "75_7.5"; outputPin = new LogicPin(pin, symbolTemp); } } symbolTemp.Graphics.Add(bodyRoundRectangle); 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> /// 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); }
/// <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); } } }
public virtual bool Compare(Cld_FCBlock block) { if (this.ID != block.ID) { throw new Exception("id should be equal"); } if (this.AlgName != block.AlgName || this.Sequence != block.Sequence || this.FunctionName != block.FunctionName || this.X_Y != block.X_Y || this.SymbolName != block.SymbolName || this.Description != block.Description || this.Prj_Controller_ID != block.Prj_Controller_ID || this.Prj_Document_ID != block.Prj_Document_ID || this.Prj_Sheet_ID != block.Prj_Sheet_ID ) { return false; } else { return true; } }
/// <summary> /// XNetAO /// </summary> /// <param name="textWriter"></param> /// <param name="fcblock"></param> /// <param name="bll"></param> private static void GenerateXNetAOBlock(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.Size = block.Size; symbolTemp.Location = block.Location; LogicRoundRectangle bodyRoundRectangle = new LogicRoundRectangle(); bodyRoundRectangle.Location = block.Location; bodyRoundRectangle.Size = symbolTemp.Size; bodyRoundRectangle.XRadius = 7.5f; bodyRoundRectangle.YRadius = 7.5f; LogicText bodyText = new LogicText(); bodyText.Location = new PointF(symbolTemp.X + 8f, symbolTemp.Y + 2f); bodyText.Width = symbolTemp.Width - 16f; bodyText.Height = symbolTemp.Height - 4f; 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_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(bodyRoundRectangle); 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++) { GenerateXPgAIReferer(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> /// 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); } } }
/// <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); } } }