using FEIApiControl; using OTSCLRINTERFACE; using OTSMeasureApp.ServiceCenter; using System.Drawing; using static OxfordExtenderWrapper.ExtenderIpcUI; namespace OTSModelSharp.ServiceCenter { public class ScanController : IScanController { private OTSCLRINTERFACE.COTSControlFunExport scan; static IScanController scanctrl = null; public static APIClass ApiClass = null; int imageWidth = 0; int imageHeight = 0; public static IScanController GetScanController() { var semtype = FileHelper.GetXMLInformations("SemControllerName"); if (scanctrl == null) { if (semtype == "FEI") { scanctrl = new FEIScanController(); } else if (semtype == "Oxford") { var srcType = FileHelper.GetOxfordInputSourceType(); ImageInputSourceType imageSrcType = ImageInputSourceType.Bse; if (srcType == "SE") { imageSrcType = ImageInputSourceType.SE; } else if (srcType == "BSE") { imageSrcType = ImageInputSourceType.Bse; } scanctrl = new OxfordScanController(imageSrcType); } else { scanctrl = new ScanController(semtype); } } return scanctrl; } private ScanController(string devicetype) { this.scan = OTSCLRINTERFACE.COTSControlFunExport.GetControllerInstance(devicetype); } public CBSEImgClr AcquireBSEImage() { if (!scan.IsConnected()) { return null; } Rectangle r = new Rectangle(0,0,imageWidth,imageHeight); CBSEImgClr bse = new CBSEImgClr(r); NLog.LogManager.GetCurrentClassLogger().Info("Bruker:Begin to acquire BSE image!"); if (!scan.AcquireBSEImage(ref bse)) { return null; } NLog.LogManager.GetCurrentClassLogger().Info("Bruker:End acquiring BSE image!"); return bse; } public bool Init() { if (!scan.IsConnected()) { scan.ConncetSem(); } return scan.ScanInit(); } public bool SetDwellTime(DwellTimeLevel val) { double dwelltime = 2; switch (val) { case DwellTimeLevel.Low: dwelltime = 2; break; case DwellTimeLevel.Medium: dwelltime = 4; break; case DwellTimeLevel.High: dwelltime = 8; break; } if (!scan.IsConnected()) { return false; } return scan.SetDwellTime((int)dwelltime); } public bool SetImageSize(int width, int height) { imageWidth = width; imageHeight = height; if (!scan.IsConnected()) { return false; } return scan.SetImageSize(width, height); } public CBSEImgClr AcquireRectangleBSEImage(Rectangle rec) { return null; } } }