Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="start"></param>
        /// <param name="start_pin"></param>
        /// <param name="end"></param>
        /// <param name="end_pin"></param>
        /// <returns></returns>
        public Exception Add_Persis_Signal(Cld_FCBlock start, string start_pin, Cld_FCBlock end, string end_pin)
        {
            //检查 从输出到输入的规则是否满足
            bool has = false;

            foreach (Cld_FCOutput outpin in manager.OutputCRUD.GetCld_FCOutputs_By_Cld_FCBlock_ID(start.ID))
            {
                if (outpin.PinName.Equals(start_pin))
                {
                    has = true;
                    break;
                }
            }
            if (!has)
            {
                return(new Exception("cld_fcblock " + start.AlgName + " does not have the pin " + start_pin));
            }
            has = false;
            foreach (Cld_FCInput inpin in manager.InputCRUD.GetCld_FCInputs_By_Cld_FCBlock_ID(end.ID))
            {
                if (inpin.PinName.Equals(end_pin))
                {
                    has = true;
                    break;
                }
            }
            if (!has)
            {
                return(new Exception("cld_fcblocl " + end.AlgName + " does not have the pin " + end_pin));
            }
            //检查 一个输入引脚只能有一个连线的规则是否满足


            return(null);
        }
Beispiel #2
0
        private static void load_commit_test(PrjManager manager)
        {
            Prj_Sheet sheet  = manager.SheetCRUD.Load_Sheet(2316);
            Prj_Sheet backup = ObjectCopier.Clone(sheet);


            Cld_FCBlock block = sheet.New_Cld_FCBlock();

            block.AlgName  = "added";
            block.Sequence = 12;

            Cld_FCInput inpt = block.New_FCInput();

            inpt.Description = "added desc";
            inpt.PinName     = "for test";

            Cld_FCOutput output = block.New_FCOutput();

            output.PinName = "for test output";


            SheetDiffer diff = manager.SheetCRUD.CompareSheet(backup, sheet);

            manager.SheetCRUD.Commit_Sheet(diff);
        }
Beispiel #3
0
        static void Main()
        {
            SessionManager sessionmanager = new SessionManager("hibernate_config.xml");
            ISession       session        = sessionmanager.GetSession();
            // 相关操作的接口
            PrjManager manager = new PrjManager(session);
            //add your code bellow

            Prj_Sheet sheet = manager.SheetCRUD.GetPrj_Sheet_By_ID(202);

            Cld_FCBlock temp = sheet.New_Cld_FCBlock();

            temp.AlgName = "weifdajflkjdlkajfkldjlkajfkdjkaljfkdjajfldjalfjlkajfldjlak";
            manager.persistence_save(temp);



            //释放相关资源
            manager.Close();
            Console.WriteLine("\nPress Enter to Exit !");
            Console.ReadKey();


            //以下为GUI运行
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            //Application.Run(new Form1());
        }
Beispiel #4
0
        /// <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>());
        }
Beispiel #5
0
 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));
 }
 public void AddReference(Cld_FCBlock block)
 {
     if (regAlgName.IsMatch(block.AlgName))
     {
         this.references.Add(block.AlgName);
     }
     else
     {
         throw new Exception("AlgName格式错误!");
     }
 }
        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格式错误!");
            }
        }
Beispiel #8
0
        /// <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);
        }
Beispiel #9
0
        /// <summary>
        /// 生成一条连接两个Pin的线
        /// </summary>
        /// <param name="startPin">起始Pin</param>
        /// <param name="endPin">结束Pin</param>
        /// <returns>表示一条线的字符串</returns>
        public string GenerateSignalData(Cld_FCOutput startPin, Cld_FCInput endPin)
        {
            Cld_FCBlock startBlock      = startPin.Cld_FCBlock;
            Cld_FCBlock endBlock        = endPin.Cld_FCBlock;
            IList       startInputList  = startBlock.Cld_FCInput_List;
            IList       startOutputList = startBlock.Cld_FCOutput_List;
            IList       endInputList    = endBlock.Cld_FCInput_List;
            IList       endOutputList   = endBlock.Cld_FCOutput_List;
            PointF      startPoint      = new PointF(startBlock.X + startPin.X, startBlock.Y + startPin.Y);
            PointF      endPoint        = new PointF(endBlock.X + endPin.X, endBlock.Y + endPin.Y);

            StringBuilder signalDatails = new StringBuilder();

            const float spacing   = 8f;     // 相邻两个输入引脚的延伸长度差值
            const float pinLength = 16f;    // 引脚的最小延伸长度


            int startPinIndex;
            int endPinIndex;

            // 添加开始点
            signalDatails.Append(startPoint.X + "_" + startPoint.Y + "{"
                                 + startBlock.AlgName + "." + startPin.PinName + "},");

            if (startPoint.Y != endPoint.Y)
            {
                // 起止点的垂直坐标不在同一直线上,需要增加折点

                if (startPoint.Y < endPoint.Y)
                {
                    startPinIndex = startPin.PinIndex;
                    endPinIndex   = endPin.PinIndex;
                }
                else
                {
                    startPinIndex = startOutputList.Count - startPin.PinIndex - 1;
                    endPinIndex   = endInputList.Count - endPin.PinIndex - 1;
                }

                PointF point = new PointF();
                point.Y = startPoint.Y;
                float firstX = startPoint.X + pinLength + spacing * startPinIndex;  // 第一个折点的 X 坐标
                float lastX  = endPoint.X - pinLength - spacing * endPinIndex;      // 最后一个折点的 X 坐标

                if (firstX < lastX)
                {
                    point.X = lastX;
                }
                else
                {
                    if (startPoint.X < endPoint.X)
                    {
                        point.X = (endPoint.X + startPoint.X) / 2;
                    }
                    else
                    {
                        point.X = firstX;
                        signalDatails.Append(point.X + "_" + point.Y + ",");

                        point.Y = Math.Abs(endPoint.Y + startPoint.Y) / 2;
                        signalDatails.Append(point.X + "_" + point.Y + ",");

                        point.X = lastX;
                    }
                }

                signalDatails.Append(point.X + "_" + point.Y + "," + point.X + "_" + endPoint.Y + ",");
            }
            else if (startPoint.X > endPoint.X)
            {
                // 起止点垂直坐标相同,但起点比终点水平坐标值大

                float upHeight   = (float)(endPoint.Y - endBlock.Y);
                float downHeight = (float)(endBlock.Y + endBlock.Symbol.height - endPoint.Y);

                float FirstX;
                float lastX;
                float signalY;

                if (upHeight < downHeight)
                {
                    // 从Block上面折回
                    FirstX  = startPoint.X + pinLength + spacing * startPin.PinIndex;
                    signalY = (float)(endBlock.Y - pinLength - spacing * endPin.PinIndex);
                    lastX   = endPoint.X - pinLength - spacing * endPin.PinIndex;
                }
                else
                {
                    FirstX = startPoint.X + pinLength + spacing
                             * (startOutputList.Count - startPin.PinIndex - 1);
                    signalY = (float)(endBlock.Y + endBlock.Symbol.height + pinLength + spacing
                                      * (endInputList.Count - endPin.PinIndex - 1));
                    lastX = endPoint.X - pinLength - spacing
                            * (endInputList.Count - endPin.PinIndex - 1);
                }

                signalDatails.Append(FirstX + "_" + startPoint.Y + "," + FirstX + "_" + signalY + ","
                                     + lastX + "_" + signalY + "," + lastX + "_" + endPoint.Y + ",");
            }

            // 添加结束点
            signalDatails.Append(endPoint.X + "_" + endPoint.Y + "{"
                                 + endBlock.AlgName + "." + endPin.PinName + "};");

            return(signalDatails.ToString());
        }
Beispiel #10
0
        /// <summary>
        /// 产生Cld_FCBlock的大小及引脚坐标
        /// </summary>
        /// <param name="block"></param>
        /// <param name="pos"></param>
        public void generate_Rec_symbol(Cld_FCBlock block, rela_pos pos)
        {
            Regex  regPointName = new Regex(@"^(\d+)((-(\d+)){3})$");
            symbol sym          = new symbol();
            float  width        = 60f;      // 初始宽度
            float  height       = 0f;       // 初始高度
            float  headHeight   = 15f;      // 上边距
            float  footHeight   = 15f;      // 下边距
            float  pinSpace     = 15f;      // 引脚间隔
            //List<string> edges = null;    // 各条边的信息

            List <Cld_FCInput>  VisibleInputs     = new List <Cld_FCInput>();
            List <Cld_FCOutput> VisibleOutputs    = new List <Cld_FCOutput>();
            List <string>       VisiblePointNames = new List <string>();

            foreach (Cld_FCInput input in block.Cld_FCInput_List)
            {
                // InputPin 的索引也从 0 开始  ___WangXiang
                input.PinIndex = get_pin_index(block.FunctionName, input.PinName) - block.Cld_FCOutput_List.Count;

                // input.PointName!=null的时候不管是否Visible也要占一个Pin位置  ___WangXiang
                bool display = input.Visible || (input.PointName != null && regPointName.IsMatch(input.PointName));
                if (display)
                {
                    VisibleInputs.Add(input);
                }
            }

            foreach (Cld_FCOutput output in block.Cld_FCOutput_List)
            {
                output.PinIndex = get_pin_index(block.FunctionName, output.PinName);

                // output的Visible只控制PointName的显示。 ___WangXiang
                // 当Visible==true或outputPin有连线时,始终占一个Pin的位置(未处理)
                if (output.Visible)
                {
                    VisibleOutputs.Add(output);
                }
                else
                {
                    foreach (Cld_FCBlock blockTemp in block.Prj_Sheet.Cld_FCBlock_List)
                    {
                        foreach (Cld_FCInput input in blockTemp.Cld_FCInput_List)
                        {
                            if (input.Visible && input.PointName == output.PointName)
                            {
                                VisibleOutputs.Add(output);
                                break;
                            }
                        }
                    }
                }
            }

            int max = (VisibleInputs.Count > VisibleOutputs.Count) ? VisibleInputs.Count : VisibleOutputs.Count;

            if (max == 0)
            {
                //当模块引脚的个数为0
                height = (float)(headHeight + footHeight);
            }
            else if (max > 0)
            {
                height = (float)(headHeight + footHeight + max * pinSpace);
            }
            else
            {
                throw new Exception("the pin number should not be negative");
            }
            //产生矩形的四条边
            //edges = generate_edge(width, height, Color.Black, pos);


            //根据Pin的Index对输入引脚和输出引脚进行排序
            VisibleInputs.Sort(new Cld_FCInput_Compare());
            VisibleOutputs.Sort(new Cld_FCOutput_Compare());

            switch (pos)
            {
            case rela_pos.UPLEFT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = "0_" + (headHeight + i * pinSpace + pinSpace / 2);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = (width) + "_" + (headHeight + i * pinSpace + pinSpace / 2);
                }
                break;

            case rela_pos.UPRIGHT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = (-width) + "_" + (headHeight + i * pinSpace);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = "0_" + (headHeight + i * pinSpace);
                }
                break;

            case rela_pos.DOWNLEFT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = "0_" + (headHeight + i * pinSpace - height);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = (width) + "_" + (headHeight + i * pinSpace - height);
                }
                break;

            case rela_pos.DOWNRIGHT:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = (-width) + "_" + (headHeight + i * pinSpace - height);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = "0_" + (headHeight + i * pinSpace - height);
                }
                break;

            case rela_pos.CENTER:
                for (int i = 0; i < VisibleInputs.Count; i++)
                {
                    VisibleInputs[i].Point = (-width) + "_" + (headHeight + i * pinSpace - height / 2);
                }
                for (int i = 0; i < VisibleOutputs.Count; i++)
                {
                    VisibleOutputs[i].Point = (width / 2) + "_" + (headHeight + i * pinSpace - height / 2);
                }
                break;

            default:
                break;
            }

            //填充symbol对象
            sym.kind = symbol_kinds.Rectangle;
            //sym.edges = edges;
            sym.height      = height;
            sym.symbol_name = block.FunctionName;
            sym.width       = width;
            block.Symbol    = sym;
            block.Size      = new SizeF(width, height);
        }
Beispiel #11
0
        static void Main()
        {
            SessionManager sessionmanager = new SessionManager("hibernate_config.xml");
            ISession       session        = sessionmanager.GetSession();
            // 相关操作的接口
            PrjManager manager = new PrjManager(session);

            //add your code bellow

            TDK.Core.Logic.URdoLib.URdoManager man = new TDK.Core.Logic.URdoLib.URdoManager();
            StateManager sm = new StateManager();

            for (int i = 169; i <= 179; i++)
            {
                Prj_Sheet sheet = manager.SheetCRUD.Load_Sheet(i, sm);

                Cld_FCBlock weiyuanke = sheet.New_Cld_FCBlock();
                weiyuanke.FunctionName = "fortest";


                manager.Save(weiyuanke);
                Cld_FCInput input = weiyuanke.New_FCInput();



                Console.WriteLine(sheet.State);
                sheet.SheetName = "weiyuantafkjaljfl";
                Console.WriteLine(sheet.State);

                Cld_FCBlock b = sheet.Cld_FCBlock_List[0] as Cld_FCBlock;
                Console.WriteLine(b.State);


                sheet.Cld_FCBlock_List.RemoveAt(0);
                Console.WriteLine(b.State);
                sheet.Cld_FCBlock_List.Add(b);
                Console.WriteLine(b.State);

                Cld_FCBlock temp = sheet.New_Cld_FCBlock();
                Console.WriteLine(temp.State);
                sheet.Cld_FCBlock_List.Add(temp);
                Console.WriteLine(temp.State);
            }

            //GraphicsDocument.GenerateProjects(bll);


            // 产生xml文件的代码
            //Prj_Sheet sheet = bll.manager.SheetCRUD.Load_Sheet(170);
            //Generate_Sheet_Xml(sheet, bll);

            //释放相关资源
            //bll.Close();
            Console.WriteLine("\nPress Enter to Exit !");
            Console.ReadKey();


            //以下为GUI运行
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            //Application.Run(new Form1());
        }