public static PEGMoveViewModel GetPEGMoveModel(int objectWidth, int objectHeight, CameraSpecViewModel spec, bool isYOnly)
        {
            PEGMoveViewModel model = null;
            var verticalPixels = Math.Ceiling(objectHeight / spec.HorizontalPixelSize);
            var yMovelPixelTimes = Math.Ceiling(verticalPixels / spec.HorizontalResolution);
            var yMovePixel = yMovelPixelTimes * spec.HorizontalResolution;
            model = new PEGMoveViewModel()
            {
                XMovePixel = 0,
                XMoveLoop = 1,
                YMovePixel = (int)yMovePixel,
                YMoveLoop = 1,

            };
            return model;
        }
        public void TestGetPEGMoveModel(int width, int height, int hResolution, int vResolution
            , double hPixelsize, double vPixelsize
            , int expectedXMovingPixels, int expectedXMoveLoop)
        {
            //assign
            var spec = new CameraSpecViewModel()
            {
                HorizontalPixelSize = hPixelsize,
                HorizontalResolution = hResolution,
                VerticalPixelSize = vPixelsize,
                VerticalResolution = vResolution,
            };

            //act
            var model = PEGCalculator.GetPEGMoveModel(width, height, spec);

            //assert
            Assert.True(model.xMoveLoop == expectedXMoveLoop);
            Assert.True(model.XMovePixel == expectedXMovingPixels);
        }
        /// <summary>
        /// 取得 PEGMoveModel
        /// </summary>
        /// <param name="objectWidth">受測物長度, X 方向 (um)</param>
        /// <param name="objectHeight">受測物寬度, Y 方向 (um)</param>
        /// <param name="spec">Line Scan Camera 的規格 ( Resolution, Pixel Szie, Scan Rate, exposeTime)</param>
        /// <returns></returns>
        public static PEGMoveViewModel GetPEGMoveModel(int objectWidth, int objectHeight, CameraSpecViewModel spec)
        {
            PEGMoveViewModel model = null;
            var xMoveLoop = getMoveLoopCount(objectWidth, spec.HorizontalResolution, spec.HorizontalPixelSize);
            var xMovePixel = getMovePixel(objectWidth, xMoveLoop, spec.HorizontalPixelSize);

            var yMoveLoop = getMoveLoopCount(objectHeight, spec.VerticalResolution, spec.VerticalPixelSize);
            yMoveLoop = 0;
            var yMovePixel = getMovePixel(objectHeight, yMoveLoop, spec.VerticalPixelSize);

            model = new PEGMoveViewModel()
            {
                XMovePixel = xMovePixel,
                XMoveLoop = xMoveLoop,
                YMovePixel = yMovePixel,
                YMoveLoop = yMoveLoop,

            };
            return model;
        }
 public static CameraSpecViewModel GetCameraSpec()
 {
     var model = new CameraSpecViewModel();
     string settingFile = ConfigurationManager.AppSettings["CameraSpecFilepath"] ?? "";
     if (File.Exists(settingFile))
     {
         //read
         var xDoc = XDocument.Load(settingFile);
         if (xDoc != null)
         {
             model = xDoc.Elements("CameraSpec").Select(p => new CameraSpecViewModel()
             {
                 HorizontalPixelSize = Convert.ToDouble(p.Element("HorizontalPixelSize").Value),
                 VerticalPixelSize = Convert.ToDouble(p.Element("VerticalPixelSize").Value),
                 HorizontalResolution = Convert.ToInt32(p.Element("HorizontalResolution").Value),
                 VerticalResolution = Convert.ToInt32(p.Element("VerticalResolution").Value),
             }).SingleOrDefault();
         }
     }
     return model;
 }