/// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public virtual Prj_Sheet New_Prj_Sheet()
 {
     Prj_Sheet result = new Prj_Sheet();
     result.Prj_Controller_ID = this.Prj_Controller_ID;
     result.Prj_Document_ID = this.ID;
     return result;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="to_add"></param>
 public virtual void Add(Prj_Sheet to_add)
 {
     this.Prj_Sheet_List.Add(to_add);
     to_add.Prj_Controller_ID = this.Prj_Controller_ID;
     to_add.Prj_Controller    = this.Prj_Controller;
     to_add.Prj_Document_ID   = this.ID;
     to_add.Prj_Document      = this;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="to_add"></param>
 public virtual void Add(Prj_Sheet to_add)
 {
     this.Prj_Sheet_List.Add(to_add);
     to_add.Prj_Controller_ID = this.Prj_Controller_ID;
     to_add.Prj_Controller = this.Prj_Controller;
     to_add.Prj_Document_ID = this.ID;
     to_add.Prj_Document = this;
 }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual Prj_Sheet New_Prj_Sheet()
        {
            Prj_Sheet result = new Prj_Sheet();

            result.Prj_Controller_ID = this.Prj_Controller_ID;
            result.Prj_Document_ID   = this.ID;
            return(result);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public virtual Prj_Sheet New_Prj_Sheet()
 {
     Prj_Sheet result = new Prj_Sheet();
     result.Prj_Controller_ID = this.Prj_Controller_ID;
     result.Prj_Controller = this.Prj_Controller;
     result.Prj_Document_ID = this.ID;
     result.Prj_Document = this;
     this.Prj_Sheet_List.Add(result);
     return result;
 }
					/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_Constant():base(){
			m_ID = -1;
			m_Name = String.Empty;
			m_X_Y = String.Empty;
			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_Constant() : base()
 {
     m_ID                = -1;
     m_Name              = String.Empty;
     m_X_Y               = String.Empty;
     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>
 /// 根据ID获得Cld_FCBlock
 /// </summary>
 /// <param name="condition">ID type:int</param>
 /// <returns></returns>
 public Prj_Sheet GetPrj_Sheet_By_ID(int condition)
 {
     using (ITransaction transaction = session.BeginTransaction()){
         try{
             Prj_Sheet result = this.session.Get <Prj_Sheet>(condition);
             transaction.Commit();
             return(result);
         }catch (Exception e) {
             transaction.Rollback();
             throw e;
         }
     }
 }
 /// <summary>
 /// 默认构造函数
 /// <summary>
 public Cld_Graphic() : base()
 {
     m_ID                = -1;
     m_Type              = String.Empty;
     m_Layer             = String.Empty;
     m_Data              = String.Empty;
     m_Prj_Controller_ID = -1;
     m_Prj_Controller    = null;
     m_Prj_Document_ID   = -1;
     m_Prj_Document      = null;
     m_Prj_Sheet_ID      = -1;
     m_Prj_Sheet         = null;
 }
					/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_Graphic():base(){
			m_ID = -1;
			m_Type = String.Empty;
			m_Layer = String.Empty;
			m_Data = String.Empty;
			m_Prj_Controller_ID = -1;
			m_Prj_Controller = null;
			m_Prj_Document_ID = -1;
			m_Prj_Document = null;
			m_Prj_Sheet_ID = -1;
			m_Prj_Sheet = null;
			
		}
					/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_Signal():base(){
			m_ID = -1;
			m_Name = String.Empty;
			m_SignalType = String.Empty;
			m_EntityBelongTo = String.Empty;
			m_Data = String.Empty;
			m_Prj_Controller_ID = -1;
			m_Prj_Controller = null;
			m_Prj_Document_ID = -1;
			m_Prj_Document = null;
			m_Prj_Sheet_ID = -1;
			m_Prj_Sheet = null;
			
		}
 /// <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;
 }
Exemple #13
0
 /// <summary>
 /// 默认构造函数
 /// <summary>
 public Cld_Signal() : base()
 {
     m_ID                = -1;
     m_Name              = String.Empty;
     m_SignalType        = String.Empty;
     m_EntityBelongTo    = String.Empty;
     m_Data              = String.Empty;
     m_Prj_Controller_ID = -1;
     m_Prj_Controller    = null;
     m_Prj_Document_ID   = -1;
     m_Prj_Document      = null;
     m_Prj_Sheet_ID      = -1;
     m_Prj_Sheet         = null;
 }
 /// <summary>
 /// true:is equal
 /// false:not equal
 /// </summary>
 /// <param name="sheet"></param>
 /// <returns></returns>
 public virtual bool Compare(Prj_Sheet sheet)
 {
     if (this.ID != sheet.ID)
     {
         throw new Exception("id should be equal");
     }
     if (this.Height != sheet.Height || this.Prj_Controller_ID != sheet.Prj_Controller_ID ||
         this.Prj_Document_ID != sheet.Prj_Document_ID || this.Sequence != sheet.Sequence ||
         this.SheetName != sheet.SheetName || this.SheetNum != sheet.SheetNum || this.Width != sheet.Width
         )
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
					/// <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;
			
		}
Exemple #16
0
 /// <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_FCBlock() : base()
 {
     m_ID = -1;
     m_Cld_FCInput_List     = null;
     m_Cld_FCOutput_List    = null;
     m_Cld_FCParameter_List = null;
     m_AlgName           = String.Empty;
     m_Sequence          = -1;
     m_FunctionName      = String.Empty;
     m_X_Y               = String.Empty;
     m_SymbolName        = String.Empty;
     m_Description       = String.Empty;
     m_Prj_Controller_ID = -1;
     m_Prj_Controller    = null;
     m_Prj_Document_ID   = -1;
     m_Prj_Document      = null;
     m_Prj_Sheet_ID      = -1;
     m_Prj_Sheet         = null;
 }
					/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_FCBlock():base(){
			m_ID = -1;
			m_Cld_FCInput_List = null;
			m_Cld_FCOutput_List = null;
			m_Cld_FCParameter_List = null;
			m_AlgName = String.Empty;
			m_Sequence = -1;
			m_FunctionName = String.Empty;
			m_X_Y = String.Empty;
			m_SymbolName = String.Empty;
			m_Description = String.Empty;
			m_Prj_Controller_ID = -1;
			m_Prj_Controller = null;
			m_Prj_Document_ID = -1;
			m_Prj_Document = null;
			m_Prj_Sheet_ID = -1;
			m_Prj_Sheet = null;
			
		}
Exemple #19
0
        /// <summary>
        /// 比较两个sheet的不同
        /// </summary>
        /// <param name="pre">操作前</param>
        /// <param name="after">操作后</param>
        /// <returns></returns>
        public SheetDiffer CompareSheet(Prj_Sheet pre, Prj_Sheet after)
        {
            SheetDiffer result = new SheetDiffer();

            if (pre.ID != after.ID)
            {
                throw new Exception("sheet id should be equal");
            }
            if (!pre.Compare(after))
            {
                result.Sheet_Modified.Add(after);
            }

            {//signal
                Hashtable id_to_signal1 = new Hashtable();
                foreach (Cld_Signal signal in pre.Cld_Signal_List)
                {
                    id_to_signal1[signal.ID] = signal;
                }

                foreach (Cld_Signal signal in after.Cld_Signal_List)
                {
                    if (id_to_signal1.Contains(signal.ID))
                    {
                        if (!((Cld_Signal)id_to_signal1[signal.ID]).Compare(signal))
                        {
                            result.Signal_Modified.Add(signal);
                        }
                        id_to_signal1.Remove(signal.ID);
                    }
                    else
                    {
                        result.Signal_Newed.Add(signal);
                    }
                }
                foreach (Cld_Signal signal in id_to_signal1.Values)
                {
                    result.Signal_Deleted.Add(signal);
                }
            }
            {//cld_fcblcok
                Hashtable id_to_block = new Hashtable();
                foreach (Cld_FCBlock block in pre.Cld_FCBlock_List)
                {
                    id_to_block[block.ID] = block;
                }

                foreach (Cld_FCBlock block in after.Cld_FCBlock_List)
                {
                    if (id_to_block.Contains(block.ID))
                    {
                        if (!((Cld_FCBlock)id_to_block[block.ID]).Compare(block))
                        {
                            result.Block_Modified.Add(block);
                        }

                        //input
                        Hashtable id_to_input = new Hashtable();
                        foreach (Cld_FCInput input in ((Cld_FCBlock)id_to_block[block.ID]).Cld_FCInput_List)
                        {
                            id_to_input[input.ID] = input;
                        }
                        foreach (Cld_FCInput input in block.Cld_FCInput_List)
                        {
                            if (id_to_input.Contains(input.ID))
                            {
                                if (!((Cld_FCInput)id_to_input[input.ID]).Compare(input))
                                {
                                    result.Input_Modified.Add(input);
                                }
                                id_to_input.Remove(input.ID);
                            }
                            else
                            {
                                result.Input_Newed.Add(input);
                            }
                        }
                        foreach (Cld_FCInput input in id_to_input.Values)
                        {
                            result.Input_Deleted.Add(input);
                        }
                        //output
                        Hashtable id_to_output = new Hashtable();
                        foreach (Cld_FCOutput output in ((Cld_FCBlock)id_to_block[block.ID]).Cld_FCOutput_List)
                        {
                            id_to_output[output.ID] = output;
                        }
                        foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
                        {
                            if (id_to_output.Contains(output.ID))
                            {
                                if (!((Cld_FCOutput)id_to_output[output.ID]).Compare(output))
                                {
                                    result.Output_Modified.Add(output);
                                }
                                id_to_output.Remove(output.ID);
                            }
                            else
                            {
                                result.Output_Newed.Add(output);
                            }
                        }
                        foreach (Cld_FCOutput output in id_to_output.Values)
                        {
                            result.Output_Deleted.Add(output);
                        }
                        //para
                        Hashtable id_to_para = new Hashtable();
                        foreach (Cld_FCParameter p in ((Cld_FCBlock)id_to_block[block.ID]).Cld_FCParameter_List)
                        {
                            id_to_para[p.ID] = p;
                        }
                        foreach (Cld_FCParameter p in block.Cld_FCParameter_List)
                        {
                            if (id_to_para.Contains(p.ID))
                            {
                                if (!((Cld_FCParameter)id_to_para[p.ID]).Compare(p))
                                {
                                    result.Para_Modified.Add(p);
                                }
                                id_to_para.Remove(p.ID);
                            }
                            else
                            {
                                result.Para_Newed.Add(p);
                            }
                        }
                        foreach (Cld_FCParameter p in id_to_para.Values)
                        {
                            result.Para_Deleted.Add(p);
                        }

                        id_to_block.Remove(block.ID);
                    }
                    else
                    {
                        result.Block_Newed.Add(block);
                        block.Orin = true;
                        if (block.Cld_FCInput_List != null)
                        {
                            foreach (Cld_FCInput input in block.Cld_FCInput_List)
                            {
                                result.Input_Newed.Add(input);
                            }
                        }
                        if (block.Cld_FCOutput_List != null)
                        {
                            foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
                            {
                                result.Output_Newed.Add(output);
                            }
                        }
                        if (block.Cld_FCParameter_List != null)
                        {
                            foreach (Cld_FCParameter p in block.Cld_FCParameter_List)
                            {
                                result.Para_Newed.Add(p);
                            }
                        }
                        block.Orin = false;
                    }
                }
                foreach (Cld_FCBlock block in id_to_block.Values)
                {
                    result.Block_Deleted.Add(block);
                    foreach (Cld_FCInput input in block.Cld_FCInput_List)
                    {
                        result.Input_Deleted.Add(input);
                    }
                    foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
                    {
                        result.Output_Deleted.Add(output);
                    }
                    foreach (Cld_FCParameter p in block.Cld_FCParameter_List)
                    {
                        result.Para_Deleted.Add(p);
                    }
                }
            }
            { //cld_const
                Hashtable id_to_const = new Hashtable();
                foreach (Cld_Constant con in pre.Cld_Constant_List)
                {
                    id_to_const[con.ID] = con;
                }

                foreach (Cld_Constant con in after.Cld_Constant_List)
                {
                    if (id_to_const.Contains(con.ID))
                    {
                        if (!((Cld_Constant)id_to_const[con.ID]).Compare(con))
                        {
                            result.Const_Modified.Add(con);
                        }
                        id_to_const.Remove(con.ID);
                    }
                    else
                    {
                        result.Const_Newed.Add(con);
                    }
                }
                foreach (Cld_Constant con in id_to_const.Values)
                {
                    result.Const_Deleted.Add(con);
                }
            }
            { //cld_graphic
                Hashtable id_to_grap = new Hashtable();
                foreach (Cld_Graphic g in pre.Cld_Graphic_List)
                {
                    id_to_grap[g.ID] = g;
                }
                foreach (Cld_Graphic g in after.Cld_Graphic_List)
                {
                    if (id_to_grap.Contains(g))
                    {
                        if (!((Cld_Graphic)id_to_grap[g.ID]).Compare(g))
                        {
                            result.Graphic_Modified.Add(g);
                        }
                        id_to_grap.Remove(g.ID);
                    }
                    else
                    {
                        result.Graphic_Newed.Add(g);
                    }
                }
                foreach (Cld_Graphic g in id_to_grap.Values)
                {
                    result.Graphic_Deleted.Add(g);
                }
            }


            return(result);
        }
 /// <summary>
 /// true:is equal
 /// false:not equal
 /// </summary>
 /// <param name="sheet"></param>
 /// <returns></returns>
 public virtual bool Compare(Prj_Sheet sheet) {
     if (this.ID != sheet.ID) {
         throw new Exception("id should be equal");
     }
     if (this.Height != sheet.Height || this.Prj_Controller_ID != sheet.Prj_Controller_ID
         || this.Prj_Document_ID != sheet.Prj_Document_ID || this.Sequence != sheet.Sequence
         || this.SheetName != sheet.SheetName || this.SheetNum != sheet.SheetNum || this.Width != sheet.Width
         )
     {
         return false;
     }
     else {
         return true;
     }
 }
        /// <summary>
        /// 比较两个sheet的不同
        /// </summary>
        /// <param name="pre">操作前</param>
        /// <param name="after">操作后</param>
        /// <returns></returns>
        public SheetDiffer CompareSheet(Prj_Sheet pre, Prj_Sheet after)
        {
            SheetDiffer result = new SheetDiffer();
            if (pre.ID != after.ID) {
                throw new Exception("sheet id should be equal");
            }
            if (!pre.Compare(after))
            {
                result.Sheet_Modified.Add(after);
            }

            {//signal
                Hashtable id_to_signal1 = new Hashtable();
                foreach (Cld_Signal signal in pre.Cld_Signal_List)
                {
                    id_to_signal1[signal.ID] = signal;
                }

                foreach (Cld_Signal signal in after.Cld_Signal_List)
                {
                    if (id_to_signal1.Contains(signal.ID))
                    {
                        if (!((Cld_Signal)id_to_signal1[signal.ID]).Compare(signal))
                        {
                            result.Signal_Modified.Add(signal);
                        }
                        id_to_signal1.Remove(signal.ID);
                    }
                    else
                    {
                        result.Signal_Newed.Add(signal);
                    }
                }
                foreach (Cld_Signal signal in id_to_signal1.Values)
                {
                    result.Signal_Deleted.Add(signal);
                }
            }
            {//cld_fcblcok
                Hashtable id_to_block = new Hashtable();
                foreach (Cld_FCBlock block in pre.Cld_FCBlock_List)
                {
                    id_to_block[block.ID] = block;
                }

                foreach (Cld_FCBlock block in after.Cld_FCBlock_List)
                {
                    if (id_to_block.Contains(block.ID))
                    {
                        if (!((Cld_FCBlock)id_to_block[block.ID]).Compare(block))
                        {
                            result.Block_Modified.Add(block);
                        }

                        //input 
                        Hashtable id_to_input = new Hashtable();
                        foreach (Cld_FCInput input in ((Cld_FCBlock)id_to_block[block.ID]).Cld_FCInput_List)
                        {
                            id_to_input[input.ID] = input;
                        }
                        foreach (Cld_FCInput input in block.Cld_FCInput_List)
                        {
                            if (id_to_input.Contains(input.ID))
                            {
                                if (!((Cld_FCInput)id_to_input[input.ID]).Compare(input))
                                {
                                    result.Input_Modified.Add(input);
                                }
                                id_to_input.Remove(input.ID);
                            }
                            else
                            {
                                result.Input_Newed.Add(input);
                            }
                        }
                        foreach (Cld_FCInput input in id_to_input.Values)
                        {
                            result.Input_Deleted.Add(input);
                        }
                        //output
                        Hashtable id_to_output = new Hashtable();
                        foreach (Cld_FCOutput output in ((Cld_FCBlock)id_to_block[block.ID]).Cld_FCOutput_List)
                        {
                            id_to_output[output.ID] = output;
                        }
                        foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
                        {
                            if (id_to_output.Contains(output.ID))
                            {
                                if (!((Cld_FCOutput)id_to_output[output.ID]).Compare(output))
                                {
                                    result.Output_Modified.Add(output);
                                }
                                id_to_output.Remove(output.ID);
                            }
                            else
                            {
                                result.Output_Newed.Add(output);
                            }
                        }
                        foreach (Cld_FCOutput output in id_to_output.Values)
                        {
                            result.Output_Deleted.Add(output);
                        }
                        //para
                        Hashtable id_to_para = new Hashtable();
                        foreach (Cld_FCParameter p in ((Cld_FCBlock)id_to_block[block.ID]).Cld_FCParameter_List)
                        {
                            id_to_para[p.ID] = p;
                        }
                        foreach (Cld_FCParameter p in block.Cld_FCParameter_List)
                        {
                            if (id_to_para.Contains(p.ID))
                            {
                                if (!((Cld_FCParameter)id_to_para[p.ID]).Compare(p))
                                {
                                    result.Para_Modified.Add(p);
                                }
                                id_to_para.Remove(p.ID);
                            }
                            else
                            {
                                result.Para_Newed.Add(p);
                            }
                        }
                        foreach (Cld_FCParameter p in id_to_para.Values)
                        {
                            result.Para_Deleted.Add(p);
                        }

                        id_to_block.Remove(block.ID);
                    }
                    else
                    {
                        result.Block_Newed.Add(block);
                        block.Orin = true;
                        if (block.Cld_FCInput_List != null)
                        {
                            foreach (Cld_FCInput input in block.Cld_FCInput_List)
                            {
                                result.Input_Newed.Add(input);
                            }
                        }
                        if (block.Cld_FCOutput_List != null)
                        {
                            foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
                            {
                                result.Output_Newed.Add(output);
                            }
                        }
                        if (block.Cld_FCParameter_List != null)
                        {
                            foreach (Cld_FCParameter p in block.Cld_FCParameter_List)
                            {
                                result.Para_Newed.Add(p);
                            }
                        }
                        block.Orin = false;
                    }
                }
                foreach (Cld_FCBlock block in id_to_block.Values)
                {
                    result.Block_Deleted.Add(block);
                    foreach (Cld_FCInput input in block.Cld_FCInput_List)
                    {
                        result.Input_Deleted.Add(input);
                    }
                    foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
                    {
                        result.Output_Deleted.Add(output);
                    }
                    foreach (Cld_FCParameter p in block.Cld_FCParameter_List)
                    {
                        result.Para_Deleted.Add(p);
                    }
                }
            }
            { //cld_const
                Hashtable id_to_const = new Hashtable();
                foreach (Cld_Constant con in pre.Cld_Constant_List)
                {
                    id_to_const[con.ID] = con;
                }

                foreach (Cld_Constant con in after.Cld_Constant_List)
                {
                    if (id_to_const.Contains(con.ID))
                    {
                        if (!((Cld_Constant)id_to_const[con.ID]).Compare(con))
                        {
                            result.Const_Modified.Add(con);
                        }
                        id_to_const.Remove(con.ID);
                    }
                    else
                    {
                        result.Const_Newed.Add(con);
                    }
                }
                foreach (Cld_Constant con in id_to_const.Values)
                {
                    result.Const_Deleted.Add(con);
                }
            }
            { //cld_graphic

                Hashtable id_to_grap = new Hashtable();
                foreach (Cld_Graphic g in pre.Cld_Graphic_List)
                {
                    id_to_grap[g.ID] = g;
                }
                foreach (Cld_Graphic g in after.Cld_Graphic_List)
                {
                    if (id_to_grap.Contains(g))
                    {
                        if (!((Cld_Graphic)id_to_grap[g.ID]).Compare(g))
                        {
                            result.Graphic_Modified.Add(g);
                        }
                        id_to_grap.Remove(g.ID);
                    }
                    else
                    {
                        result.Graphic_Newed.Add(g);
                    }
                }
                foreach (Cld_Graphic g in id_to_grap.Values)
                {
                    result.Graphic_Deleted.Add(g);
                }
            }


            return result;
        }
        /// <summary>
        /// 生成Block之间的连线关系,Signal的集合,并存储数据
        /// </summary>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public IDictionary<string, Cld_Signal> GenerateSignalLines(Prj_Sheet sheet)
        {
            // 测点名与起始引脚的对应关系
            IDictionary<string, Cld_FCOutput> pointNameToStartPin = new Dictionary<string, Cld_FCOutput>();
            // 
            IDictionary<string, Cld_Signal> pointNameToSignal = new Dictionary<string, Cld_Signal>();

            // 匹配PointName格式为"%-%-%-%"的项
            Regex regPointName = new Regex(@"^(\d+)((-(\d+)){3})$");

            foreach (Cld_FCBlock block in sheet.Cld_FCBlock_List)
            {
                foreach (Cld_FCOutput output in sheet.Cld_FCOutput_List)
                {
                    // 将当前页面所有 Output 与点名的对应关系存储在 pointNameToStartPin 字典中
                    // 在该字典中,通过 PointName 就可以找到对应的 Output
                    if (!pointNameToStartPin.ContainsKey(output.PointName))
                    {
                        pointNameToStartPin.Add(output.PointName, output);
                    }
                }
            }

            foreach (Cld_FCBlock block in sheet.Cld_FCBlock_List)
            {
                foreach (Cld_FCInput input in block.Cld_FCInput_List)
                {
                    if (input.PointName == null || !regPointName.IsMatch(input.PointName) || !input.Visible
                        || !pointNameToStartPin.ContainsKey(input.PointName))
                    {
                        // 该管脚未连接,或不显示信号线,或连接的Pin不在当前Sheet中,继续扫描下一个 Input。
                        continue;
                    }

                    Cld_FCOutput startPin = pointNameToStartPin[input.PointName] as Cld_FCOutput;
                    string signalData;

                    if (startPin.Point != null || input.Point != null)
                    {
                        signalData = GenerateSignalData(startPin, input);
                    }
                    else
                    {
                        throw new Exception("管脚坐标未计算!");
                    }

                    Cld_Signal signalTemp;

                    if (pointNameToSignal.ContainsKey(input.PointName))
                    {
                        signalTemp = pointNameToSignal[input.PointName];
                        signalTemp.Data += signalData;
                        pointNameToSignal[input.PointName] = signalTemp;

                        //manager.Update(signal_temp);
                    }
                    else
                    {
                        signalTemp = new Cld_Signal();
                        signalTemp.Prj_Controller = sheet.Prj_Controller;
                        signalTemp.Prj_Document = sheet.Prj_Document;
                        signalTemp.Prj_Sheet = sheet;
                        signalTemp.Name = startPin.PointName;
                        signalTemp.Data = signalData;

                        signalTemp.SignalType = get_pin_dataType(startPin.Cld_FCBlock.FunctionName, startPin.PinName);

                        pointNameToSignal.Add(input.PointName, signalTemp);

                        //this.manager.Save(signal_temp);
                    }
                }
            }
            //this.manager.Flush();

            return pointNameToSignal;
        }
Exemple #23
0
        /// <summary>
        /// Prj_Sheet To Xml
        /// </summary>
        /// <param name="sheet"></param>
        public static void Generate_Sheet_Xml(Prj_Sheet sheet, BllManager bll)
        {
            //因为此方法采用反射来获取类中的所有共有属性进行输出,因此这里屏蔽对象中的某些不需要输出的属性
            List<string> myclass = new List<string>();
            myclass.Add("Prj_Project");
            myclass.Add("Prj_Network");
            myclass.Add("Prj_Unit");
            myclass.Add("Prj_Controller");
            myclass.Add("Prj_Document");
            myclass.Add("Prj_Sheet");
            myclass.Add("Cld_FCBlock");
            myclass.Add("Cld_Signal");
            myclass.Add("Cld_Constant");
            myclass.Add("Cld_Graphic");
            myclass.Add("X");
            myclass.Add("Y");
            myclass.Add("PinIndex");

            try
            {
                // 创建XmlTextWriter类的实例对象
                XmlTextWriter textWriter = new XmlTextWriter(sheet.ID.ToString() + ".xml", null);
                textWriter.Formatting = Formatting.Indented;

                // 开始写过程,调用WriteStartDocument方法
                textWriter.WriteStartDocument();
                // 写入说明
                textWriter.WriteComment("First Comment XmlTextWriter Sample Example");
                textWriter.WriteComment("w3sky.xml in root dir");

                Type sheet_type = typeof(Prj_Sheet);
                Type fcblock_type = typeof(Cld_FCBlock);
                Type fcconst_type = typeof(Cld_Constant);
                Type fcgraphic_type = typeof(Cld_Graphic);
                Type fcsignal_type = typeof(Cld_Signal);
                Type fcinput_type = typeof(Cld_FCInput);
                Type fcoutput_type = typeof(Cld_FCOutput);
                Type fcpara_type = typeof(Cld_FCParameter);



                //创建sheet结点
                textWriter.WriteStartElement("sheet");
                foreach (PropertyInfo pi in sheet_type.GetProperties())
                {
                    object value_object = pi.GetValue(sheet, null);
                    string value_string = "";

                    if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                    {
                        continue;
                    }
                    if (value_object != null)
                    {
                        value_string = value_object.ToString();
                    }
                    textWriter.WriteAttributeString(pi.Name, value_string);
                }


                //fcblock
                foreach (Cld_FCBlock fcblock in sheet.Cld_FCBlock_List)
                {
                    textWriter.WriteStartElement("element");
                    textWriter.WriteAttributeString("type", "Cld_FCBlock");

                    bll.generate_Rec_symbol(fcblock, TDK.Core.Logic.BLL.BllManager.rela_pos.UPLEFT);

                    foreach (PropertyInfo pi in fcblock_type.GetProperties())
                    {
                        object value_object = pi.GetValue(fcblock, null);
                        string value_string = "";

                        if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                        {
                            continue;
                        }
                        if (value_object != null)
                        {
                            value_string = value_object.ToString();
                        }
                        textWriter.WriteAttributeString(pi.Name, value_string);
                    }

                    foreach (Cld_FCInput input in fcblock.Cld_FCInput_List)
                    {
                        textWriter.WriteStartElement("element");
                        textWriter.WriteAttributeString("type", "Cld_FCInput");
                        foreach (PropertyInfo pi in fcinput_type.GetProperties())
                        {
                            object value_object = pi.GetValue(input, null);
                            string value_string = "";

                            if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                            {
                                continue;
                            }
                            if (value_object != null)
                            {
                                value_string = value_object.ToString();
                            }
                            textWriter.WriteAttributeString(pi.Name, value_string);
                        }
                        textWriter.WriteEndElement();
                    }

                    //foreach (Cld_FCOutput output in fcblock.Cld_FCOutput_List)
                    //{
                    //    textWriter.WriteStartElement("element");
                    //    textWriter.WriteAttributeString("type", "FCOutput");
                    //    foreach (PropertyInfo pi in fcoutput_type.GetProperties())
                    //    {
                    //        object value_object = pi.GetValue(output, null);
                    //        string value_string = "";

                    //        if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                    //        {
                    //            continue;
                    //        }
                    //        if (value_object != null)
                    //        {
                    //            value_string = value_object.ToString();
                    //        }
                    //        textWriter.WriteAttributeString(pi.Name, value_string);
                    //    }
                    //    textWriter.WriteEndElement();
                    //}
                    //foreach (Cld_FCParameter para in fcblock.Cld_FCParameter_List)
                    //{
                    //    textWriter.WriteStartElement("element");
                    //    textWriter.WriteAttributeString("type", "Cld_FCParameter");
                    //    foreach (PropertyInfo pi in fcpara_type.GetProperties())
                    //    {
                    //        object value_object = pi.GetValue(para, null);
                    //        string value_string = "";

                    //        if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                    //        {
                    //            continue;
                    //        }
                    //        if (value_object != null)
                    //        {
                    //            value_string = value_object.ToString();
                    //        }
                    //        textWriter.WriteAttributeString(pi.Name, value_string);
                    //    }
                    //    textWriter.WriteEndElement();
                    //}
                    textWriter.WriteEndElement();
                }

                ////const
                //foreach (Cld_Constant cldconst in sheet.Cld_Constant_List)
                //{
                //    textWriter.WriteStartElement("element");
                //    textWriter.WriteAttributeString("type", "Cld_Constant");
                //    foreach (PropertyInfo pi in fcconst_type.GetProperties())
                //    {
                //        object value_object = pi.GetValue(cldconst, null);
                //        string value_string = "";

                //        if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                //        {
                //            continue;
                //        }
                //        if (value_object == null)
                //        {
                //            value_string = value_object.ToString();
                //        }
                //        textWriter.WriteAttributeString(pi.Name, value_string);
                //    }
                //    textWriter.WriteEndElement();
                //}

                ////graphic
                //foreach (Cld_Graphic graphic in sheet.Cld_Graphic_List)
                //{
                //    textWriter.WriteStartElement("element");
                //    textWriter.WriteAttributeString("type", "Cld_Graphic");
                //    foreach (PropertyInfo pi in fcgraphic_type.GetProperties())
                //    {
                //        object value_object = pi.GetValue(graphic, null);
                //        string value_string = "";

                //        if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                //        {
                //            continue;
                //        }
                //        if (value_object == null)
                //        {
                //            value_string = value_object.ToString();
                //        }
                //        textWriter.WriteAttributeString(pi.Name, value_string);
                //    }
                //    textWriter.WriteEndElement();
                //}

                ////signal
                //foreach (Cld_Signal signal in sheet.Cld_Signal_List)
                //{
                //    textWriter.WriteStartElement("element");
                //    textWriter.WriteAttributeString("type", "Cld_Signal");
                //    foreach (PropertyInfo pi in fcsignal_type.GetProperties())
                //    {
                //        object value_object = pi.GetValue(signal, null);
                //        string value_string = "";

                //        if (pi.PropertyType.Name.Equals("IList") || myclass.Contains(pi.PropertyType.Name))
                //        {
                //            continue;
                //        }
                //        if (value_object == null)
                //        {
                //            value_string = value_object.ToString();
                //        }
                //        textWriter.WriteAttributeString(pi.Name, value_string);
                //    }
                //    textWriter.WriteEndElement();
                //}

                textWriter.WriteEndElement();

                // 关闭textWriter
                textWriter.Close();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }
        /// <summary>
        /// 向数据库提交一个Sheet
        /// 原理:
        /// 先从数据库中删除
        /// 然后在插入
        /// 效率问题????!
        /// </summary>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public bool Commit(Prj_Sheet sheet)
        {
            //首先删除数据库中的相关记录
            this.DeletePrj_Sheet_By_ID(sheet.ID);

            ITransaction transaction = this.session.BeginTransaction();
            int count = 0;
            try
            {
                //在进行操作之前进行缓存的处理,否则会因为对象的状态出现一些问题
                this.session.Flush();
                this.session.Clear();
                this.session.Save(sheet);
                this.session.Flush();
                this.session.Clear();

                //signal
                foreach (Cld_Signal signal in sheet.Cld_Signal_List)
                {
                    count++;
                    signal.Prj_Sheet_ID = sheet.ID;
                    this.session.Save(signal);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //const
                foreach (Cld_Constant con in sheet.Cld_Constant_List)
                {
                    count++;
                    con.Prj_Sheet_ID = sheet.ID;
                    this.session.Save(con);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //block,block重新插入时,ID会重新分配,需进行处理
                Hashtable oldid_to_newid = new Hashtable();
                foreach (Cld_FCBlock block in sheet.Cld_FCBlock_List)
                {
                    count++;
                    block.Prj_Sheet_ID = sheet.ID;
                    int oldid = block.ID;
                    this.session.Save(block);
                    oldid_to_newid[oldid] = block.ID;
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //graphic
                foreach (Cld_Graphic graphic in sheet.Cld_Graphic_List)
                {
                    count++;
                    graphic.Prj_Sheet_ID = sheet.ID;
                    this.session.Save(graphic);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }
                //flush to db and clean cache
                this.session.Flush();
                this.session.Clear();

                //parameter
                foreach (Cld_FCParameter para in sheet.Cld_FCParameter_List)
                {
                    count++;
                    para.Prj_Sheet_ID = sheet.ID;
                    para.Cld_FCBlock_ID = (int)oldid_to_newid[para.Cld_FCBlock_ID];
                    this.session.Save(para);
                    this.session.Flush();
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //out
                foreach (Cld_FCOutput output in sheet.Cld_FCOutput_List)
                {
                    count++;
                    output.Prj_Sheet_ID = sheet.ID;
                    output.Cld_FCBlock_ID = (int)oldid_to_newid[output.Cld_FCBlock_ID];
                    this.session.Save(output);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //input
                foreach (Cld_FCInput input in sheet.Cld_FCInput_List)
                {
                    count++;
                    input.Prj_Sheet_ID = sheet.ID;
                    input.Cld_FCBlock_ID = (int)oldid_to_newid[input.Cld_FCBlock_ID];
                    this.session.Save(input);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }
                transaction.Commit();
                return true;
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
        }
        /// <summary>
        /// 向数据库提交一个Sheet
        /// 原理:
        /// 先从数据库中删除
        /// 然后在插入
        /// 效率问题????!
        /// </summary>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public bool Commit(Prj_Sheet sheet)
        {
            //首先删除数据库中的相关记录
            this.DeletePrj_Sheet_By_ID(sheet.ID);

            ITransaction transaction = this.session.BeginTransaction();
            int          count       = 0;

            try
            {
                //在进行操作之前进行缓存的处理,否则会因为对象的状态出现一些问题
                this.session.Flush();
                this.session.Clear();
                this.session.Save(sheet);
                this.session.Flush();
                this.session.Clear();

                //signal
                foreach (Cld_Signal signal in sheet.Cld_Signal_List)
                {
                    count++;
                    signal.Prj_Sheet_ID = sheet.ID;
                    this.session.Save(signal);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //const
                foreach (Cld_Constant con in sheet.Cld_Constant_List)
                {
                    count++;
                    con.Prj_Sheet_ID = sheet.ID;
                    this.session.Save(con);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //block,block重新插入时,ID会重新分配,需进行处理
                Hashtable oldid_to_newid = new Hashtable();
                foreach (Cld_FCBlock block in sheet.Cld_FCBlock_List)
                {
                    count++;
                    block.Prj_Sheet_ID = sheet.ID;
                    int oldid = block.ID;
                    this.session.Save(block);
                    oldid_to_newid[oldid] = block.ID;
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //graphic
                foreach (Cld_Graphic graphic in sheet.Cld_Graphic_List)
                {
                    count++;
                    graphic.Prj_Sheet_ID = sheet.ID;
                    this.session.Save(graphic);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }
                //flush to db and clean cache
                this.session.Flush();
                this.session.Clear();

                //parameter
                foreach (Cld_FCParameter para in sheet.Cld_FCParameter_List)
                {
                    count++;
                    para.Prj_Sheet_ID   = sheet.ID;
                    para.Cld_FCBlock_ID = (int)oldid_to_newid[para.Cld_FCBlock_ID];
                    this.session.Save(para);
                    this.session.Flush();
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //out
                foreach (Cld_FCOutput output in sheet.Cld_FCOutput_List)
                {
                    count++;
                    output.Prj_Sheet_ID   = sheet.ID;
                    output.Cld_FCBlock_ID = (int)oldid_to_newid[output.Cld_FCBlock_ID];
                    this.session.Save(output);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }

                //input
                foreach (Cld_FCInput input in sheet.Cld_FCInput_List)
                {
                    count++;
                    input.Prj_Sheet_ID   = sheet.ID;
                    input.Cld_FCBlock_ID = (int)oldid_to_newid[input.Cld_FCBlock_ID];
                    this.session.Save(input);
                    if (count % 50 == 0)
                    {
                        this.session.Flush();
                        this.session.Clear();
                    }
                }
                transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
        }