123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
-
- 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);
- }
- }
- }
- }
|