示例#1
0
        private void CreateBtn_Click(object sender, System.EventArgs e)
        {
            HImage  ImgReduced;
            HRegion Rectangle1 = new HRegion();
            HRegion Rectangle2 = new HRegion();

            CreateBtn.Enabled = false;
            Window.SetColor("red");
            Window.SetDraw("margin");
            Window.SetLineWidth(3);

            ImgReduced = Img.ReduceDomain(Rectangle);
            ImgReduced.InspectShapeModel(out ModelRegion, 1, 30);
            Rectangle1.GenRectangle2(Rect1Row, Rect1Col, RectPhi, RectLength1, RectLength2);
            Rectangle2.GenRectangle2(Rect2Row, Rect2Col, RectPhi, RectLength1, RectLength2);
            ShapeModel = new HShapeModel(ImgReduced, 4, 0, new HTuple(360.0).TupleRad().D,
                                         new HTuple(1.0).TupleRad().D, "none", "use_polarity", 30, 10);

            Window.SetColor("green");
            Window.SetDraw("fill");
            ModelRegion.DispObj(Window);
            Window.SetColor("blue");
            Window.SetDraw("margin");
            Rectangle1.DispObj(Window);
            Rectangle2.DispObj(Window);

            StopBtn.Enabled  = false;
            StartBtn.Enabled = true;
        }
示例#2
0
        public ActionResult Index()
        {
            DAL.DAL dal = new DAL.DAL();

            #region License
            var dsLicense   = dal.GetDataSet("SELECT LICENSE_ID ,LICENSE FROM LICENSE_MASTER");
            var dtLicense   = dsLicense.Tables[0];
            var listLicense = new List <ModelLicenseMaster>();

            foreach (System.Data.DataRow dr in dtLicense.Rows)
            {
                var license = new ModelLicenseMaster()
                {
                    LICENSE    = dr["LICENSE"].ToString(),
                    LICENSE_ID = Convert.ToInt32(dr["LICENSE_ID"].ToString())
                };

                listLicense.Add(new ModelLicenseMaster {
                    LICENSE = license.LICENSE, LICENSE_ID = license.LICENSE_ID
                });
            }
            dsLicense.Dispose();
            dtLicense.Dispose();
            #endregion

            #region Region
            var dsRegion   = dal.GetDataSet("SELECT REGION_ID ,REGION_NAME FROM REGION");
            var dtRegion   = dsRegion.Tables[0];
            var listRegion = new List <ModelRegion>();

            foreach (System.Data.DataRow drArea in dtRegion.Rows)
            {
                var region = new ModelRegion()
                {
                    REGION_NAME = drArea["REGION_NAME"].ToString(),
                    REGION_ID   = Convert.ToInt32(drArea["REGION_ID"].ToString())
                };

                listRegion.Add(new ModelRegion {
                    REGION_NAME = region.REGION_NAME, REGION_ID = region.REGION_ID
                });
            }
            dtRegion.Dispose();
            dsRegion.Dispose();
            #endregion

            ViewData["UserRoleId"]         = UserA.Roleid;
            ViewData["AcceptanceCriteria"] = dal.ReadData(
                "SELECT RISK_CRITERIA, UPDATE_DATE, UPDATE_BY FROM RISK_THRESHOLD",
                x => new ModelAcceptanceCriteria(x)).Select(x => x.RISK_CRITERIA).FirstOrDefault();

            var model = new ModelRisk()
            {
                ListLicense = listLicense,
                ListRegion  = listRegion
            };

            return(View(model));
        }
        // 传入DataRow,将其转换为ModelWO
        private ModelRegion toModel(DataRow dr)
        {
            ModelRegion model = new ModelRegion();

            //通过循环为ModelWO赋值,其中为数据值为空时,DateTime类型的空值为:0001/1/1 0:00:00    int类型得空值为: 0,其余的还没试验
            foreach (PropertyInfo propertyInfo in typeof(ModelRegion).GetProperties())
            {
                //如果数据库的字段为空,跳过其赋值
                if (dr[propertyInfo.Name].ToString() == "")
                {
                    continue;
                }
                //赋值
                model.GetType().GetProperty(propertyInfo.Name).SetValue(model, dr[propertyInfo.Name], null);
            }
            return(model);
        }
示例#4
0
        private void CreateTemplete(object sender, EventArgs e)
        {
            HTuple CenterRow    = ObjectRoi.GetDrawingObjectParams("row");
            HTuple CenterColumn = ObjectRoi.GetDrawingObjectParams("column");
            HTuple Phi          = ObjectRoi.GetDrawingObjectParams("phi");
            HTuple Lenght1      = ObjectRoi.GetDrawingObjectParams("length1");
            HTuple Lenght2      = ObjectRoi.GetDrawingObjectParams("length2");

            HObject ModelRegion;

            HOperatorSet.GenEmptyObj(out ModelRegion);
            HOperatorSet.GenRectangle2(out ModelRegion, CenterRow, CenterColumn, Phi, Lenght1, Lenght2);

            HObject TemplateImage;

            HOperatorSet.GenEmptyObj(out TemplateImage);
            HOperatorSet.ReduceDomain(ho_Image, ModelRegion, out TemplateImage);

            HTuple hv_ParameterValue = null, hv_ParameterName = null;

            HOperatorSet.DetermineShapeModelParams(TemplateImage, "auto", 0, (new HTuple(360)).TupleRad(), 0.9, 1.1, "auto", "use_polarity", "auto", "auto", "all", out hv_ParameterName, out hv_ParameterValue);
            HTuple MinContrast          = hv_ParameterValue[7].I.ToString();
            HTuple Location_MaxContrast = hv_ParameterValue[5].I.ToString();

            HOperatorSet.CreateShapeModel(TemplateImage, 0, 0, (new HTuple(360)).TupleRad(), "auto", "auto", "use_polarity", int.Parse(Location_MaxContrast), int.Parse(MinContrast), out hv_ModelID);

            if (File.Exists(Directory.GetCurrentDirectory() + @"/Templete.shm"))
            {
                File.Delete(Directory.GetCurrentDirectory() + @"/Templete.shm");
                HOperatorSet.WriteShapeModel(hv_ModelID, Directory.GetCurrentDirectory() + @"/Templete.shm");
            }
            else
            {
                HOperatorSet.WriteShapeModel(hv_ModelID, Directory.GetCurrentDirectory() + @"/Templete.shm");
            }

            ModelRegion.Dispose();
            TemplateImage.Dispose();
        }
示例#5
0
        private void Action()
        {
            double    S1, S2;
            HTuple    RowCheck, ColumnCheck, AngleCheck, Score;
            HHomMat2D Matrix = new HHomMat2D();
            HRegion   ModelRegionTrans;
            HTuple    Rect1RowCheck, Rect1ColCheck;
            HTuple    Rect2RowCheck, Rect2ColCheck;
            HRegion   Rectangle1 = new HRegion();
            HRegion   Rectangle2 = new HRegion();
            HMeasure  Measure1, Measure2;
            HTuple    RowEdgeFirst1, ColumnEdgeFirst1;
            HTuple    AmplitudeFirst1, RowEdgeSecond1;
            HTuple    ColumnEdgeSecond1, AmplitudeSecond1;
            HTuple    IntraDistance1, InterDistance1;
            HTuple    RowEdgeFirst2, ColumnEdgeFirst2;
            HTuple    AmplitudeFirst2, RowEdgeSecond2;
            HTuple    ColumnEdgeSecond2, AmplitudeSecond2;
            HTuple    IntraDistance2, InterDistance2;
            HTuple    MinDistance;
            int       NumLeads;

            HSystem.SetSystem("flush_graphic", "false");
            Img.GrabImage(Framegrabber);
            Img.DispObj(Window);

            // Find the IC in the current image.
            S1 = HSystem.CountSeconds();
            ShapeModel.FindShapeModel(Img, 0,
                                      new HTuple(360).TupleRad().D,
                                      0.7, 1, 0.5, "least_squares",
                                      4, 0.9, out RowCheck, out ColumnCheck,
                                      out AngleCheck, out Score);
            S2 = HSystem.CountSeconds();
            MatchingTimeLabel.Text = "Time: " +
                                     String.Format("{0,4:F1}", (S2 - S1) * 1000) + "ms";
            MatchingScoreLabel.Text = "Score: ";

            if (RowCheck.Length == 1)
            {
                MatchingScoreLabel.Text = "Score: " +
                                          String.Format("{0:F5}", Score.D);
                // Rotate the model for visualization purposes.
                Matrix.VectorAngleToRigid(new HTuple(Row), new HTuple(Column), new HTuple(0.0),
                                          RowCheck, ColumnCheck, AngleCheck);

                ModelRegionTrans = ModelRegion.AffineTransRegion(Matrix, "false");
                Window.SetColor("green");
                Window.SetDraw("fill");
                ModelRegionTrans.DispObj(Window);
                // Compute the parameters of the measurement rectangles.
                Matrix.AffineTransPixel(Rect1Row, Rect1Col,
                                        out Rect1RowCheck, out Rect1ColCheck);
                Matrix.AffineTransPixel(Rect2Row, Rect2Col,
                                        out Rect2RowCheck, out Rect2ColCheck);

                // For visualization purposes, generate the two rectangles as
                // regions and display them.
                Rectangle1.GenRectangle2(Rect1RowCheck.D, Rect1ColCheck.D,
                                         RectPhi + AngleCheck.D,
                                         RectLength1, RectLength2);
                Rectangle2.GenRectangle2(Rect2RowCheck.D, Rect2ColCheck.D,
                                         RectPhi + AngleCheck.D,
                                         RectLength1, RectLength2);
                Window.SetColor("blue");
                Window.SetDraw("margin");
                Rectangle1.DispObj(Window);
                Rectangle2.DispObj(Window);
                // Do the actual measurements.
                S1       = HSystem.CountSeconds();
                Measure1 = new HMeasure(Rect1RowCheck.D, Rect1ColCheck.D,
                                        RectPhi + AngleCheck.D,
                                        RectLength1, RectLength2,
                                        ImgWidth, ImgHeight, "bilinear");
                Measure2 = new HMeasure(Rect2RowCheck.D, Rect2ColCheck.D,
                                        RectPhi + AngleCheck.D,
                                        RectLength1, RectLength2,
                                        ImgWidth, ImgHeight, "bilinear");
                Measure1.MeasurePairs(Img, 2, 90,
                                      "positive", "all",
                                      out RowEdgeFirst1,
                                      out ColumnEdgeFirst1,
                                      out AmplitudeFirst1,
                                      out RowEdgeSecond1,
                                      out ColumnEdgeSecond1,
                                      out AmplitudeSecond1,
                                      out IntraDistance1,
                                      out InterDistance1);
                Measure2.MeasurePairs(Img, 2, 90,
                                      "positive", "all",
                                      out RowEdgeFirst2,
                                      out ColumnEdgeFirst2,
                                      out AmplitudeFirst2,
                                      out RowEdgeSecond2,
                                      out ColumnEdgeSecond2,
                                      out AmplitudeSecond2,
                                      out IntraDistance2,
                                      out InterDistance2);
                S2 = HSystem.CountSeconds();
                MeasureTimeLabel.Text = "Time: " +
                                        String.Format("{0,5:F1}", (S2 - S1) * 1000) + "ms";
                Window.SetColor("red");
                Window.DispLine(RowEdgeFirst1 - RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeFirst1 - RectLength2 * Math.Sin(AngleCheck),
                                RowEdgeFirst1 + RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeFirst1 + RectLength2 * Math.Sin(AngleCheck));
                Window.DispLine(RowEdgeSecond1 - RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeSecond1 - RectLength2 * Math.Sin(AngleCheck),
                                RowEdgeSecond1 + RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeSecond1 + RectLength2 * Math.Sin(AngleCheck));
                Window.DispLine(RowEdgeFirst2 - RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeFirst2 - RectLength2 * Math.Sin(AngleCheck),
                                RowEdgeFirst2 + RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeFirst2 + RectLength2 * Math.Sin(AngleCheck));
                Window.DispLine(RowEdgeSecond2 - RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeSecond2 - RectLength2 * Math.Sin(AngleCheck),
                                RowEdgeSecond2 + RectLength2 * Math.Cos(AngleCheck),
                                ColumnEdgeSecond2 + RectLength2 * Math.Sin(AngleCheck));
                NumLeads             = IntraDistance1.Length + IntraDistance2.Length;
                MeasureNumLabel.Text = "Number of leads: " +
                                       String.Format("{0:D2}", NumLeads);
                MinDistance           = InterDistance1.TupleConcat(InterDistance2).TupleMin();
                MeasureDistLabel.Text = "Minimum lead distance: " +
                                        String.Format("{0:F3}", MinDistance.D);
                HSystem.SetSystem("flush_graphic", "true");
                // Force the graphics window update by displaying an offscreen pixel
                Window.DispLine(-1.0, -1.0, -1.0, -1.0);
            }
        }
示例#6
0
        static Database()
        {
            if (!Instance)
            {
                Levels       = DatabaseHelper.Deserialize <ModelLevels>("CharacterLevels.xml").Items;
                Blueprints   = DatabaseHelper.Deserialize <ModelInventoryItemBlueprints>("EconBlueprints.xml").Items;
                Advisors     = DatabaseHelper.Deserialize <ModelInventoryItemAdvisors>("advisors.xml").Items;
                Materials    = DatabaseHelper.Deserialize <ModelInventoryItemMaterials>("econmaterials.xml").Items;
                Consumables  = DatabaseHelper.Deserialize <ModelInventoryItemConsumables>("EconConsumables.xml").Items;
                Designs      = DatabaseHelper.Deserialize <ModelInventoryItemDesigns>("EconDesigns.xml").Items;
                Craftschools = DatabaseHelper.Deserialize <ModelCraftschools>("craftschools.xml").Items;
                Vendors      = DatabaseHelper.Deserialize <ModelVendors>("EconVendors.xml").Items;
                Lootrolls    = DatabaseHelper.Deserialize <ModelInventoryItemLootrolls>("econLootRolls.xml").Items;
                Questgivers  = DatabaseHelper.Deserialize <ModelQuestgivers>("questgivers.xml").Items;
                Equipments   = DatabaseHelper.Deserialize <ModelEquipments>("equipment.xml").Items;
                Nuggets      = DatabaseHelper.Deserialize <ModelNuggets>("nuggets.xml").Items;
                NuggetLogics = DatabaseHelper.Deserialize <ModelNuggetLogics>("nuggetlogics.xml").Items;

                foreach (string CivilizationFile in Directory.GetFiles($"{PathingHelper.gamedatabaseDir}civilizations", "*.xml", SearchOption.TopDirectoryOnly))
                {
                    ModelCivilization Civilization = new ModelCivilization().DeserializeFromFile(CivilizationFile);

                    Civilization.Source = CivilizationFile;

                    Civilizations.Add(Civilization.CivId, Civilization);
                }

                List <string> ExcludedTraitDirectories = new List <string>();

                ExcludedTraitDirectories.Add("_unused");

                if (Convert.ToInt32(ConfigurationManager.AppSettings["UseLosGear"]) != 1)
                {
                    ExcludedTraitDirectories.Add("_los");
                }

                foreach (string TraitFile in Directory.GetFiles($"{PathingHelper.gamedatabaseDir}traits", "*.xml", SearchOption.AllDirectories).Where(f => !DatabaseHelper.IsExcluded(ExcludedTraitDirectories, f)))
                {
                    Trait ObjTrait = new Trait().DeserializeFromFile(TraitFile);

                    ObjTrait.Source = TraitFile;

                    Traits.Add(ObjTrait.Name, ObjTrait);
                }

                foreach (string RegionFile in Directory.GetFiles($"{PathingHelper.gamedatabaseDir}regions", "*.region", SearchOption.TopDirectoryOnly))
                {
                    ModelRegion Region = new ModelRegion().DeserializeFromFile(RegionFile);

                    Region.Source = RegionFile;

                    Regions.Add(Region.Id, Region);
                }

                foreach (string QuestFile in Directory.GetFiles($"{PathingHelper.gamedatabaseDir}quests", "*.quest", SearchOption.AllDirectories))
                {
                    Quest ObjQuest = new Quest().DeserializeFromFile(QuestFile);

                    ObjQuest.Source   = QuestFile.Substring(0, QuestFile.LastIndexOf('.')).Replace($"{PathingHelper.gamedatabaseDir}", string.Empty).ToLower();
                    ObjQuest.Instance = DatabaseHelper.GetQuestInstance(ObjQuest);

                    Quests.Add(ObjQuest.Id, ObjQuest);
                }

                Instance = true;
            }
        }