Exemplo n.º 1
0
        /// <summary>
        /// 儲存程式編輯
        /// </summary>
        /// <param name="macroName">程式編輯名稱</param>
        /// <param name="macroGuid">程式編輯 ID</param>
        /// <param name="shapeModelFilepath">程式編輯模型檔案路徑</param>
        /// <param name="note">程式編輯描述</param>
        /// <param name="trainingImage">程式編輯訓練影像二元檔</param>
        /// <param name="exportUnit">輸出單位</param>
        /// <param name="matchingParamData">模型參數二元檔</param>
        /// <param name="measureBinaryData">測量資料二元檔</param>
        /// <param name="measureAssistantParamData">測量參數二元檔</param>
        /// <param name="upperLight">上光源</param>
        /// <param name="bottomLight">下光源</param>
        /// <param name="findedShapeViewModel">Matching 模型資訊</param>
        /// <param name="loginUser">登入者</param>
        /// <param name="trainingImageFilepath">程式編輯訓練影像實體路徑</param>
        /// <param name="snapshot">程式編輯縮圖二元檔</param>
        /// <param name="objectXLength">物件大小 X</param>
        /// <param name="objectYLength">物件大小 Y</param>
        /// <param name="technicalDrawingModel">工程圖資訊</param>
        /// <returns></returns>
        public static bool SaveMacroPlan(string macroName, string macroGuid, string shapeModelFilepath, string note, Binary trainingImage
            , string exportUnit, Binary matchingParamData, Binary measureBinaryData, Binary measureAssistantParamData
            , LightChannel upperLight, LightChannel bottomLight
            , ShapeViewModel findedShapeViewModel, string loginUser
            , string trainingImageFilepath
            , Binary snapshot
            , double objectXLength, double objectYLength
            , XDocument technicalDrawingModel)
        {
            bool success = true;
            try
            {
                MacroPlan plan = _dc.MacroPlan.SingleOrDefault(p => p.MacroGuid == macroGuid);
                var isUpdate = (plan != null);
                if (!isUpdate)
                {
                    plan = new MacroPlan() { CreateBy = loginUser, CreateOn = DateTime.Now, MacroGuid = macroGuid };
                }
                plan.MacroName = macroName;
                plan.ShapeModelFilepath = shapeModelFilepath;
                plan.Note = note;
                plan.TrainingImage = trainingImage;
                plan.TrainingImageFilepath = trainingImageFilepath;
                plan.ExportUnit = exportUnit;
                plan.MatchingParamBinaryData = matchingParamData;
                plan.MeasureBinaryData = measureBinaryData;
                plan.UpperLightSwitch = (upperLight.OnOff == LightControl.LightSwitch.On);
                plan.UpperLightValue = upperLight.Intensity.ToString("d3");
                plan.BottomLightSiwtch = (bottomLight.OnOff == LightControl.LightSwitch.On);
                plan.BottomLigthValue = bottomLight.Intensity.ToString("d3");
                plan.ModifiedOn = DateTime.Now;
                plan.ModifiedBy = loginUser;
                plan.MeasureAssistantBinaryData = measureAssistantParamData;
                plan.ModelRow = findedShapeViewModel.Row;
                plan.ModelCol = findedShapeViewModel.Col;
                plan.ModelAngle = findedShapeViewModel.Angle;
                plan.IsDeleted = false;
                plan.Snapshot = snapshot;
                plan.ObjectXLength = objectXLength;
                plan.ObjectYLength = objectYLength;
                plan.TechnicalDrawingModel = XElement.Load(technicalDrawingModel.CreateReader());

                if (!isUpdate)
                {
                    _dc.MacroPlan.InsertOnSubmit(plan);
                }
                _dc.SubmitChanges();
            }
            catch (Exception ex)
            {
                success = false;
                Hanbo.Log.LogManager.Error(ex.Message);
            }
            return success;
        }
Exemplo n.º 2
0
        public void SaveMacroPlanTest(string imagepath)
        {
            //assign
            var shapemodelpath = "filepath";
            var note = "note";
            var exportUnit = "mm";
            var image = new HImage(imagepath);

            var imageBinData = new Binary(ImageConventer.ConvertHalconImageToByteArray(image, false));

            var matchingParam = new MatchingParam();

            var matchingParamByteArray = ModelSerializer.DoSerialize(matchingParam);

            var matchingParamBinData = new Binary(matchingParamByteArray);

            BindingList<GeoDataGridViewModel> a = new BindingList<GeoDataGridViewModel>();
            a.Add(new GeoDataGridViewModel() { RecordID = "aaa" });

            var measureBinData = ModelSerializer.DoSerialize(a);
            //BindingList a;

            var ma = new MeasureAssistant();
            var maParam = ma.GetMeasureAssistantParam();
            var maParamBin = ModelSerializer.DoSerialize(maParam);

            LightChannel upper = new LightChannel() { Channel = "00", Intensity = 100, OnOff = LightSwitch.On };

            LightChannel bottom = new LightChannel() { Channel = "01", Intensity = 200, OnOff = LightSwitch.OFF };
            //act
            var success = SDMSRepo.SaveMacroPlan("Test", Guid.NewGuid().ToString(), shapemodelpath, note, imageBinData, exportUnit, matchingParamBinData, measureBinData, maParamBin, upper, bottom, new ShapeViewModel() { }, "system", "");

            //assert
            Assert.True(success);
        }
Exemplo n.º 3
0
 public static bool SaveMacroPlan(string macroName, string macroGuid, string shapeModelFilepath, string note, Binary trainingImage, string exportUnit, Binary matchingParamData, Binary measureBinaryData, Binary measureAssistantParamData, LightChannel upperLight, LightChannel bottomLight, ShapeViewModel shapeView, string loginUser
     , string trainingImageFilepath
     , double objectXLength, double objectYLength)
 {
     return SaveMacroPlan(macroName, macroGuid, shapeModelFilepath, note, trainingImage, exportUnit, matchingParamData, measureBinaryData, measureAssistantParamData, upperLight, bottomLight, shapeView, loginUser
         , trainingImageFilepath, null
         , objectXLength, objectYLength, null);
 }