| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | using FEIApiControl;using OTSCLRINTERFACE;using OTSModelSharp.ServiceCenter;using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;namespace OTSMeasureApp.ServiceCenter{    class FEIScanController : IScanController    {        int imageWidth = 0;        int imageHeight = 0;        double dwelltime = 0;       private APIClass ApiClass = null;       public FEIScanController()        {            ApiClass = FEISemController.GetApiClassInstance();        }        public CBSEImgClr AcquireBSEImage()        {            Rectangle r = new Rectangle();            CBSEImgClr bse = new CBSEImgClr(r);            bse.InitImageData(imageWidth, imageHeight);            byte[] imgData = new byte[imageWidth * imageHeight];            NLog.LogManager.GetCurrentClassLogger().Info("FEI:Begin to acquire BSE image!");            if (!ApiClass.RunAcquireImage(imageWidth, imageHeight, dwelltime, "", ref imgData))            {                return null;            }            NLog.LogManager.GetCurrentClassLogger().Info("FEI:End acquiring BSE image!");            bse.SetImageData(imgData, imageWidth, imageHeight);            return bse;        }        public CBSEImgClr AcquireRectangleBSEImage(System.Drawing.Rectangle rec)        {            int fieldWidth = 3072;            int fieldHeight = 2048;            //Rectangle r = new Rectangle();            //double curwidth=0, curheight=0;            //ApiClass.GetCurrentResolution(ref curwidth, ref curheight);            double mag =0;            CBSEImgClr bse = new CBSEImgClr(rec);            //bse.InitImageDa/*t*/a(imageWidth, imageHeight);            byte[] imgData= new byte[0];            //double mag=0;            if (!ApiClass.RunAcquireImageRect(fieldWidth, fieldHeight, rec,ref mag, 2, "", ref imgData))            {                return null;            }            bse.SetImageData(imgData, (int)(rec.Width*mag), (int)(rec.Height*mag));            return bse;        }        public bool Init()        {            string FEIIP = FileHelper.GetXMLInformations("FEIIP");            string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");            if (FEIIP == "" || FEIPORT == "")            {                NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");                return false;            }            if (ApiClass.isConnect())            {                return true;            }            return ApiClass.Connect(FEIIP, FEIPORT);        }        public bool SetDwellTime(DwellTimeLevel val)        {             dwelltime = 0.5;            switch (val)            {                case DwellTimeLevel.Low:                    dwelltime = 0.5;                    break;                case DwellTimeLevel.Medium:                    dwelltime = 1;                    break;                case DwellTimeLevel.High:                    dwelltime = 4;                    break;            }                                             return true;        }        public bool SetImageSize(int nWidth, int nHeight)        {            imageWidth = nWidth;            imageHeight = nHeight;            return   ApiClass.SetResolution(imageWidth, imageHeight); ;        }    }}
 |