using FEIApiControl; using OTSCLRINTERFACE; using OTSDataType; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace OTSModelSharp.ServiceInterface { public class ScanController : IScanController { private OTSCLRINTERFACE.COTSControlFunExport scan; static ScanController scanctrl=null; public static APIClass ApiClass = null; private static bool isFEI = false; int imageWidth = 0; int imageHeight = 0; public static ScanController GetScanController() { if (FileHelper.GetXMLInformations("SemControllerName") == "FEI") { isFEI = true; } if (scanctrl == null) { scanctrl = new ScanController(); } return scanctrl; } private ScanController() { if (isFEI) { ApiClass = new APIClass(); } else { this.scan = SemController.hw; } } public CBSEImgClr AcquireBSEImage(int matrixIndex, int reads, int dwell) { if (isFEI) { Rectangle r = new Rectangle(); CBSEImgClr bse = new CBSEImgClr(r); bse.InitImageData(imageWidth, imageHeight); byte[] imgData = new byte[imageWidth * imageHeight]; if (!ApiClass.RunAcquireImage(imageWidth, imageHeight, dwell, "", ref imgData)) { return null; } bse.SetImageData(imgData, imageWidth, imageHeight); return bse; } else { if (!scan.IsConnected()) { return null; } Rectangle r = new Rectangle(); CBSEImgClr bse = new CBSEImgClr(r); if (!scan.AcquireBSEImage(matrixIndex, reads, dwell, ref bse)) { return null; } return bse; } } public bool Init() { if (isFEI) { 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); } else { return scan.ScanInit(); } } public bool SetDwellTime(long val) { if (isFEI) { return true; } else { if (!scan.IsConnected()) { return false; } return scan.SetDwellTime((int)val); } } public bool SetImageSize(int width,int height) { imageWidth = width; imageHeight = height; if (isFEI) { return ApiClass.SetResolution(imageWidth, imageHeight); } else { if (!scan.IsConnected()) { return false; } return scan.SetImageSize(width, height); } } } }