Sfoglia il codice sorgente

bruker driver optimization.

shiyanshi 3 anni fa
parent
commit
27d2473ceb

+ 1 - 1
Bin/x64/Debug/Config/SysData/OTSStage.stg

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<XMLData Modify="true" PathName=".\Config\SysData\OTSStage.stg" WorkingStageId="0">
+<XMLData Modify="true" PathName=".\Config\SysData\OTSStage.stg" WorkingStageId="2">
   <Collection RegName="Stagelist">
     <Member strName="圆形九圆孔50mm">
       <Member RegName="boundary" PolygonPoint="" rectDomian="0,0,50000,0" shape="0" />

+ 2 - 0
OTSCPP/OTSClrInterface/ControlClr/OTSControlFunExport.h

@@ -66,6 +66,8 @@ namespace NSOTSController
 			m_pSem = (m_pHardWareMgr->GetSemControllerMgrPtr()).get();
 			m_pScan = (m_pHardWareMgr->GetScanControllerPtr()).get();
 			m_pEDS = (m_pHardWareMgr->GetEDSControllerPtr()).get();			
+
+			m_pSem->Connect();
 			
 			m_pScan->Init();
 

+ 73 - 80
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.cpp

@@ -22,7 +22,7 @@ namespace OTSController {
 		, m_nClientID(0)
 		, m_bSEMExternal(false)
 		, m_nSPU(FIRST_DETECTOR_ID)
-		, m_bShouldCloseClient(true)
+		, m_bConnected(false)
 		, m_pSpectrumHead(NULL)
 		, m_pBrukerDllHandle()
 		, m_bDoQuantification(false)
@@ -35,7 +35,7 @@ namespace OTSController {
 	COTSBrukerImpl::~COTSBrukerImpl()
 	{
 		// close client if necessary
-		if (m_bShouldCloseClient)
+		if (m_bConnected)
 		{
 			CloseClient();
 		}
@@ -55,25 +55,18 @@ namespace OTSController {
 	// initialization
 	BOOL COTSBrukerImpl::Init(CONTROL_TYPE a_nControlType, BOOL a_b32Bite /*=TRUE*/)
 	{
-		// method return value
-		BOOL bRet = FALSE;
 	
-		// is initialized before?
+	
+		//m_bInit is the dll loading flag,so there's no need to free it on initialtive , it'll be free when the the process  complet.(gsp)
 		if (!m_bInit)
 		{
 			// calculate Bruker client dll name
 			CString strBruckerDllName = "";
-			if (this->GetLoadDllName(strBruckerDllName))
-			{
+			this->GetLoadDllName(strBruckerDllName);
+			
 				// load Bruker client dll name succeed
-				LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::Init: bruker client dll name: %s"), strBruckerDllName);
-			}
-			else
-			{
-				// load Bruker client dll name failed, use default Bruker client dll name Bruker.API.Esprit2.2.dll 
-				LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::Init: failed to call GetLoadDllName method, use default Bruker client dll name Bruker.API.Esprit2.1.dll"));
-				strBruckerDllName = _T("Bruker.API.Esprit2.2.dll");
-			}
+			LogTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::Init: bruker client dll name: %s"), strBruckerDllName);
+			
 			// is dll opened?
 			if (!m_pBrukerDllHandle)
 			{
@@ -83,87 +76,91 @@ namespace OTSController {
 				// load Bruker client dll
 				m_bInit = m_pBrukerDllHandle->LoadDll(strBruckerDllName);
 			}
-
 			// load Bruker client dll OK?
 			if (!m_bInit)
 			{
 				// failed to load bruker client dll
-				AfxMessageBox(_T("cann't load Bruker dll£¡ name:"+ strBruckerDllName));
+				AfxMessageBox(_T("cann't load Bruker dll£¡ name:" + strBruckerDllName));
 				LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::Init: failed to load Bruker Client Dll , Dll Name: %s"), strBruckerDllName);
 				//exit(0);
-				m_bShouldCloseClient = false;
-				return bRet;
-			}
-
-			// return false if failed to call QueryServers or OpenClient methods
-			if (!QueryServers() || !OpenClient())
-			{
-				return bRet;
-			}
-
-			// prepare spectra buffer
-			if (!m_psRTSpectrumBuffer)
-			{
-				m_psRTSpectrumBuffer.reset(new char[(int)BRUKER_PARAM::RT_SPECTRUM_BUFFER_SIZE]);
+				
+				return false;
 			}
-			memset(m_psRTSpectrumBuffer.get(), 0, (int)BRUKER_PARAM::RT_SPECTRUM_BUFFER_SIZE);
+			
 		}
 
 		// initialized? 
-		if (m_bInit)
+		if (!m_bConnected)
 		{
-			// ok, return true
-			bRet = TRUE;
 
-			// control type?
-			switch (a_nControlType)
-			{
-				// SEM
-			case CONTROL_TYPE::BRUKER_SEM:
+		
+			if (QueryServers() && OpenClient())
 			{
-				m_bSEMInst = TRUE;
-			}
-			break;
 
-			// scanner
-			case CONTROL_TYPE::BRUKER_SCAN:
+				if (!m_psRTSpectrumBuffer)
+				{
+					m_psRTSpectrumBuffer.reset(new char[(int)BRUKER_PARAM::RT_SPECTRUM_BUFFER_SIZE]);
+				}
+				memset(m_psRTSpectrumBuffer.get(), 0, (int)BRUKER_PARAM::RT_SPECTRUM_BUFFER_SIZE);
+				// ok, return true
+				m_bConnected = true;
+			}
+			else
 			{
-				m_bScannerInst = TRUE;
+				m_bConnected = false;
 			}
-			break;
+		}
+		
 
-			// x-ray control
-			case CONTROL_TYPE::BRUKER_XRAY:
-			{
-				// check detector states and set m_nSPU
-				if (!SetSPU())
+				// control type?
+				switch (a_nControlType)
 				{
-					return FALSE;
+					// SEM
+				case CONTROL_TYPE::BRUKER_SEM:
+				{
+					m_bSEMInst = TRUE;
 				}
+				break;
 
-				m_bXRAyControllerInst = TRUE;
-			}
-			break;
+				// scanner
+				case CONTROL_TYPE::BRUKER_SCAN:
+				{
+					m_bScannerInst = TRUE;
+				}
+				break;
 
-			default:
-			{
-				// invalid control type, something wrong
-				LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::Init: invalid control type."));
-				return FALSE;
-			}
-			break;
-			}
-		}
+				// x-ray control
+				case CONTROL_TYPE::BRUKER_XRAY:
+				{
+					// check detector states and set m_nSPU
+					if (!SetSPU())
+					{
+						return FALSE;
+					}
 
-		// return method return flag
-		return bRet;
+					m_bXRAyControllerInst = TRUE;
+				}
+				break;
+
+				default:
+				{
+					// invalid control type, something wrong
+					LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::Init: invalid control type."));
+					return FALSE;
+				}
+				break;
+				}
+			
+		
+		return m_bConnected;
 	}
 
 	BOOL COTSBrukerImpl::DisConnect()
 	{
-		if (m_bShouldCloseClient)
+		if (m_bConnected)
 		{
 			CloseClient();
+			m_bConnected = false;
 		}
 		return true;
 	}
@@ -1612,7 +1609,7 @@ namespace OTSController {
 			if (!CheckConnection(bConnected))
 			{
 				// failed to check connection
-				m_bShouldCloseClient = false;
+				m_bConnected = false;
 				return FALSE;
 			}
 
@@ -1625,19 +1622,15 @@ namespace OTSController {
 				if (!bRet)
 				{
 					LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::OpenClient: call OpenClient failed at the second attempt."));
-					m_bShouldCloseClient = false;
+					m_bConnected = false;
 				}
 			}
 		}
 		if (bRet)
 		{
-			m_bShouldCloseClient = true;
-		}
-		if (bConnected)
-		{
-			m_bShouldCloseClient = true;
+			m_bConnected = true;
 		}
-
+		
 		// return method return flag
 		return bRet;
 	}
@@ -1664,7 +1657,7 @@ namespace OTSController {
 			{
 				// -201 -- there is an opened instance.
 				bRet = TRUE;
-				m_bShouldCloseClient = FALSE;			// FALSE, do not close the interface when the controller is deleted
+				m_bConnected = FALSE;			// FALSE, do not close the interface when the controller is deleted
 				LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::OpenClient: client dll is in used."));
 			}
 			else
@@ -1817,7 +1810,7 @@ BOOL COTSBrukerImpl::CloseClient(void)
 	ASSERT(m_pBrukerDllHandle);
 	if (!m_pBrukerDllHandle)
 	{
-		// error, invalid m_pBrukerDllHandle
+		
 		LogErrorTrace(__FILE__, __LINE__, "  COTSBrukerImpl::CloseClient: invalid m_pBrukerDllHandle");
 		return FALSE;
 	}
@@ -1827,8 +1820,8 @@ BOOL COTSBrukerImpl::CloseClient(void)
 		LogErrorTrace(__FILE__, __LINE__, "  COTSBrukerImpl::CloseClient   failed  ");
 		return FALSE;
 	}
-
-	// ok, return true
+	m_nClientID = 0;	
+	
 	return TRUE;
 }
 /// collect a x ray point

+ 1 - 1
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.h

@@ -219,7 +219,7 @@ namespace OTSController {
 		DWORD m_nClientID;
 		BOOL m_bSEMExternal;
 		int m_nSPU;
-		BOOL m_bShouldCloseClient;
+		BOOL m_bConnected;
 
 		BOOL m_bDoQuantification;                           // if do x-ray quantification
 

+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceGraphicsPanelFun.cs

@@ -456,7 +456,7 @@ namespace OTSMeasureApp
             //图片
             Bitmap bitmap = null;
             //将byte数据转换为图片
-            bitmap = ImageDispose.ToGrayBitmap(ImageByte, width, height);
+            bitmap = Imagepro.ToGrayBitmap(ImageByte, width, height);
             return bitmap;
         }
         #endregion

+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -4306,7 +4306,7 @@ namespace OTSMeasureApp
                         ImgRegionHeight = Convert.ToInt32(m_ImageSingleGDIObjects[i].RegionF.Height);
 
                         //获取图片
-                        bseImage = OTSSysMgrTools.ImageDispose.ToGrayBitmap(ImageData, m_iWidth, m_iHeigh);
+                        bseImage = OTSSysMgrTools.Imagepro.ToGrayBitmap(ImageData, m_iWidth, m_iHeigh);
                         //获取工作样品位置
                         Point drawImageLocation = itemWorkSample.Region.Location;
                         //绘制图像

+ 3 - 3
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs

@@ -142,7 +142,7 @@ namespace OTSMeasureApp
         {
             try
             {
-                Bitmap bitmap = ImageDispose.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
+                Bitmap bitmap = Imagepro.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
                 pbBSEImage.Image = bitmap;
                 //设置Pictrue显示位置
                 pbBSEImage.Height = this.RestoreBounds.Height;
@@ -173,7 +173,7 @@ namespace OTSMeasureApp
         {
             try
             {
-                return ImageDispose.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
+                return Imagepro.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
             }
             catch (Exception ex)
             {
@@ -1875,7 +1875,7 @@ namespace OTSMeasureApp
             int grayEnd = 0;
             if (bBseData != null)
             {
-                Bitmap bitmap = ImageDispose.ToGrayBitmap(bBseData, m_iWidth, m_iHeight);
+                Bitmap bitmap = Imagepro.ToGrayBitmap(bBseData, m_iWidth, m_iHeight);
                 toolWindow.BseImg = bitmap;
                 toolWindow.BBseData = bBseData;
                 //获取去背景灰度值

+ 1 - 1
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/ToolWindow.cs

@@ -260,7 +260,7 @@ namespace OTSMeasureApp
                 bool bfResult = imagefun.GetBSEImage(bBseData, m_iHeight, m_iWidth, grayStart, grayEnd, ref cBseData);
                 if (bfResult)
                 {
-                    Bitmap reImg= ImageDispose.ToGrayBitmap(cBseData, m_iWidth, m_iHeight);
+                    Bitmap reImg= Imagepro.ToGrayBitmap(cBseData, m_iWidth, m_iHeight);
                     return reImg;
                 }
                 else

+ 2 - 2
OTSSysMgrApp/ControllerSettingForm.cs

@@ -246,14 +246,14 @@ namespace OTSSysMgrApp
                     Bitmap bitmap = null;
                     int iWidth = Convert.ToInt32(tbRWidth.Text);
                     int iHeight = Convert.ToInt32(tbRHeight.Text);
-                    int resultValue = ImageDispose.GetScanImage(iWidth, iHeight, ddlDwellTime.Text, ref ImageByte);
+                    int resultValue = Imagepro.GetScanImage(iWidth, iHeight, ddlDwellTime.Text, ref ImageByte);
                     string str2 = table["str2"].ToString();
 
                     if (resultValue > 0)
                     {
                         if (ImageByte != null)
                         {
-                            bitmap = ImageDispose.ToGrayBitmap(ImageByte, width, height);
+                            bitmap = Imagepro.ToGrayBitmap(ImageByte, width, height);
                             pbImage.Image = bitmap;
                             btnSaveImage.Enabled = true;
                             log.Info("Image capture success!\nImage resolution:" + tbRWidth.Text + "X" + tbRHeight.Text + ";");

+ 5 - 70
OTSSysMgrApp/OTSSystemManagerForms.cs

@@ -25,7 +25,6 @@ namespace OTSSysMgrApp
         static string XMLFileName = string.Empty;//System.Configuration.ConfigurationManager.ConnectionStrings["XMLFileName"].ConnectionString;
         static string DLLXMLFileName = string.Empty;//System.Configuration.ConfigurationManager.ConnectionStrings["DLLXMLFileName"].ConnectionString;
         //设置日志路径
-        //public static NSLogFunExport.CFunExportClass cfunClass = null;// new NSLogFunExport.CFunExportClass();
         static NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
         string SubKey = "OTSDevName";
         //国际化
@@ -47,9 +46,7 @@ namespace OTSSysMgrApp
                 LogAppPath = System.Configuration.ConfigurationManager.ConnectionStrings["LogAppPath"].ConnectionString;
                 XMLFileName = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFileName"].ConnectionString;
                 DLLXMLFileName = System.Configuration.ConfigurationManager.ConnectionStrings["DLLXMLFileName"].ConnectionString;
-                //cfunClass = NLog.LogManager.GetCurrentClassLogger();
-                ////初始化日志路径
-                //cfunClass.InitLog(LogAppPath);
+               
                 InitializeComponent();
 
             }
@@ -580,56 +577,9 @@ namespace OTSSysMgrApp
 
         private void btnRequest_Click(object sender, EventArgs e)
         {
-            //打开注册License通行证信息
-            //OpenLicenseDialog();
+          
         }
-        //static OTSINTERFACE.COTSLicMgrClr fun = null;
-        //static OTSINTERFACE.COTSLicenseInfoClr otsInfoClr = null;
-        //private void btnActive_Click(object sender, EventArgs e)
-        //{
-        //    try
-        //    {
-        //        //1.获取License通行证信息
-        //        bool result = fun.LoadLicenseInfoFromFile(ref otsInfoClr);
-        //        if (result)
-        //        {
-        //            //1.写入XML
-        //            SaveSetting("ComupterName", fun.m_ComputerNicName);
-        //            SaveSetting("HardwareID", fun.m_MachineId);
-        //            SaveSetting("OTSProduct", fun.m_PackId == 0 ? "OTSIncA" : "OtsPartA");
-        //            SaveSetting("PassType", fun.m_LicType == 0 ? "Online" : "Offline");
-        //            SaveSetting("ExpireDate", fun.m_oExpireDate.ToString());
-
-        //            string MessageInfo = string.Empty;
-        //            if (!IsValidLicense(ref MessageInfo))
-        //            {
-        //                MessageBox.Show(MessageInfo);
-        //            }
-        //            else
-        //            {
-        //                //获取XML中的注册信息
-        //                //tbLComupterName.Text = GetLicenseInfo("ComupterName");
-        //                //tbLHardwareID.Text = GetLicenseInfo("HardwareID");
-        //                //tbOTSProduct.Text = GetLicenseInfo("OTSProduct");
-        //                //tbPassType.Text = GetLicenseInfo("PassType");
-        //                //tbExpireDate.Text = Convert.ToDateTime(GetLicenseInfo("ExpireDate")).ToString("yyyy-MM-dd");
-        //                //显示硬件Tab菜单
-        //                tabHardwareSet.Parent = tabControl1;
-        //                //国际化
-        //                lan = new OTSSysMgrTools.Language(this);
-        //            }
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        log.Error("OTSSystemManagerForms_btnActive_Click_Exception:" + ex.Message.ToString() + "");
-        //    }
-        //    finally
-        //    {
-        //        //fun.FreePointer();
-        //        //otsInfoClr.FreePointer();
-        //    }
-        //}
+       
       
         #region 判断当前License信息是否正确
         //public static bool IsValidLicense(ref string MessageInfo)
@@ -796,23 +746,8 @@ namespace OTSSysMgrApp
 
         private void OTSSystemManagerForms_FormClosing(object sender, FormClosingEventArgs e)
         {
-            //if (fun != null)
-            //{
-            //    fun.FreePointer();
-            //}
-            //if (otsInfoClr != null)
-            //{
-            //    otsInfoClr.FreePointer();
-            //}
-            
-            //SaveSEMAndEDSController();
-            //写入
-            //bool SEMSetting = WTRegedit("SEMName", CmbSEMController.SelectedItem.ToString());
-            //bool EDSSetting = WTRegedit("EDSName", CmbEDSController.SelectedItem.ToString());
-            //if (SEMSetting && EDSSetting)
-            //{
-            //    //设置注册表成功
-            //}
+           
+           
         }
 
         private void lnklab_about_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

+ 13 - 13
OTSSysMgrApp/SemTestForms.cs

@@ -515,19 +515,19 @@ namespace OTSSysMgrApp
 
         private void SemTestForms_FormClosing(object sender, FormClosingEventArgs e)
         {
-            try
-            {
-                //断开电镜连接
-                cfun.DisconnectSem();
-                //释放DLL内存
-                //cfun.FreeHardware();
-                
-            }
-            catch (Exception ex)
-            {
-                //记录日志信息(异常日志)
-                log.Error(ex.Message.ToString());
-            }
+            //try
+            //{
+            //    //断开电镜连接
+            cfun.DisconnectSem();
+            //    //释放DLL内存
+            //    //cfun.FreeHardware();
+
+            //}
+            //catch (Exception ex)
+            //{
+            //    //记录日志信息(异常日志)
+            //    log.Error(ex.Message.ToString());
+            //}
         }
 
         private void btnGPositionXYR_Click(object sender, EventArgs e)

+ 0 - 452
OTSSysMgrTools/ImageDispose.cs

@@ -1,452 +0,0 @@
-
-using NSOTSController;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace OTSSysMgrTools
-{
-    public class ImageDispose
-    {
-        
-        public ImageDispose()
-        {
-        }
-        #region 通过byte数组生成BMP图像文件
-        /// <summary>    
-        /// 将一个byte的数组转换为8bit灰度位图
-        /// </summary>    
-        /// <param name="data">数组</param>    
-        /// <param name="width">图像宽度</param>    
-        /// <param name="height">图像高度</param>    
-        /// <returns>位图</returns>    
-        public static Bitmap ToGrayBitmap(byte[] data, int width, int height)
-        {
-            //// 申请目标位图的变量,并将其内存区域锁定    
-            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
-            //// BitmapData这部分内容  需要 using System.Drawing.Imaging;  
-            BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height),
-            ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
-
-            //// 获取图像参数    
-            // 扫描线的宽度   
-            int stride = bmpData.Stride;
-            // 显示宽度与扫描线宽度的间隙  
-            int offset = stride - width;
-            // 获取bmpData的内存起始位置
-            IntPtr iptr = bmpData.Scan0;
-            // 用stride宽度,表示这是内存区域的大小
-            int scanBytes = stride * height;
-
-            //// 下面把原始的显示大小字节数组转换为内存中实际存放的字节数组    
-            int posScan = 0;
-            int posReal = 0;// 分别设置两个位置指针,指向源数组和目标数组    
-            byte[] pixelValues = new byte[scanBytes];  //为目标数组分配内存    
-
-            //for (int x = height-1;x>=0 ; x--) data[startIndex+ y];//
-            for (int x = 0; x < height; x++)
-            {
-                int startIndex = x * width;
-                //// 下面的循环节是模拟行扫描    
-                for (int y = 0; y < width; y++)
-                {
-                    pixelValues[posScan++] = data[posReal++];
-                }
-                posScan += offset;  //行扫描结束,要将目标位置指针移过那段“间隙”    
-            }
-            //// 用Marshal的Copy方法,将刚才得到的内存字节数组复制到BitmapData中    
-            System.Runtime.InteropServices.Marshal.Copy(pixelValues, 0, iptr, scanBytes);
-            bmp.UnlockBits(bmpData);  // 解锁内存区域    
-
-            //// 下面的代码是为了修改生成位图的索引表,从伪彩修改为灰度    
-            ColorPalette tempPalette;
-            using (Bitmap tempBmp = new Bitmap(1, 1, PixelFormat.Format8bppIndexed))
-            {
-                tempPalette = tempBmp.Palette;
-            }
-            for (int i = 0; i < 256; i++)
-            {
-                tempPalette.Entries[i] = Color.FromArgb(i, i, i);
-            }
-            bmp.Palette = tempPalette;
-
-            //// 算法到此结束,返回结果    
-            return bmp;
-        }
-        #endregion
-
-
-        #region 将文件转换成byte[] 数组
-        /// <summary>
-        /// 将文件转换成byte[] 数组
-        /// </summary>
-        /// <param name="fileUrl">文件路径文件名称</param>
-        /// <returns>byte[]</returns>
-        //public static byte[] GetFileData(string fileUrl)
-        //{
-        //    FileStream pFileStream = null;
-        //    byte[] pReadByte = new byte[0];
-        //    try
-        //    {
-        //        //读取文本文件
-        //        pFileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read);
-        //        //实例读取字节流对象
-        //        StreamReader sr = new StreamReader(pFileStream, System.Text.Encoding.Default);
-        //        string temp = sr.ReadToEnd();
-        //        //转换byte数组
-        //        byte[] byteArray = System.Text.Encoding.Default.GetBytes(temp);
-        //        //生成字符数组
-        //        string[] tempGroup = temp.Split(',');
-        //        //关闭读取对象
-        //        sr.Close();
-        //        string AppendStr = string.Empty;
-        //        for (int i = 0; i < tempGroup.Length; i++)
-        //        {
-        //            //十进制转十六进制
-        //            AppendStr += Convert.ToString(Convert.ToInt32(tempGroup[i]), 16) + " ";
-        //        }
-        //        //替换字符符号
-        //        AppendStr = AppendStr.Replace(" ", "");
-        //        if ((AppendStr.Length % 2) != 0)
-        //        {
-        //            AppendStr += " ";
-        //        }
-        //        byte[] returnBytes = new byte[AppendStr.Length / 2];
-        //        //转换为byte[]数组
-        //        for (int i = 0; i < returnBytes.Length; i++)
-        //        {
-        //            returnBytes[i] = Convert.ToByte(AppendStr.Substring(i * 2, 2), 16);
-        //        }
-        //        return returnBytes;
-        //    }
-        //    catch
-        //    {
-        //        return pReadByte;
-        //    }
-        //    finally
-        //    {
-        //        if (pFileStream != null)
-        //            pFileStream.Close();
-        //    }
-        //}
-        #endregion
-
-        #region 根据分辨率获取图像
-        //public static bool GetScanImage(string ImgWidth, string ImgHeight, string DwellTime, COTSControlFunExport cfun, ref byte[] ImageByte)
-        //{
-        //    try
-        //    {
-
-        //        //设置图像分辨率
-        //        int width = 0;
-        //        int height = 0;
-        //        //获取宽度
-        //        width = Convert.ToInt32(ImgWidth);
-        //        height = Convert.ToInt32(ImgHeight);
-                
-        //        int a_ExternalMode = 0;
-        //        //获取终止模式
-        //        a_ExternalMode = cfun.GetSemExternalMode();
-                
-        //        //保存初始模式变量
-        //        int a_oldMode = 0;
-        //        //获取初始模式
-        //        if (!cfun.GetSemScanMode(ref a_oldMode))
-        //        {
-        //            return false;
-        //        }
-        //        //设置当前模式
-        //        if (!cfun.SetSemScanMode(a_ExternalMode))
-        //        {
-        //            return false;
-        //        }
-                
-        //        #region BeamBlank
-        //        int a_nBeamBlank = 0;
-        //        //获取参数
-        //        if (!cfun.GetSemBeamBlank(ref a_nBeamBlank))
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //            return false;
-        //        }
-        //        //设置参数
-        //        if (!cfun.SetSemBeamBlank(0))
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //            return false;
-        //        }
-        //        #endregion
-               
-        //        #region 获得放大倍数
-        //        //获得放大倍数
-        //        double a_dMagnification = 0;
-        //        //获取参数
-        //        if (!cfun.GetSemMagnification(ref a_dMagnification))
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //            return false;
-        //        }
-        //        #endregion
-
-
-                
-
-        //        #region 获取 电镜 X、Y轴 与角度
-        //        //获取 电镜 X、Y轴 与角度
-        //        double PositionX = 0;
-        //        double PositionY = 0;
-        //        double PositionR = 0;
-        //        //获取参数
-        //        if (!cfun.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR))
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //            return false;
-        //        }
-        //        #endregion
-
-        //        #region 设置图像分辨率
-        //        //设置宽度
-        //        if (!cfun.SetImageSize(width, height))
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //            return false;
-        //        }
-        //        #endregion
-
-        //        #region 采集时间
-        //        //采集时间
-        //        int nDwellTime = 16;
-        //        nDwellTime = Convert.ToInt32(DwellTime);
-        //        //nDwellTime = Convert.ToInt32(tbCollectionTime.Text);
-        //        //设置采集时间
-        //        if (!cfun.SetDwellTime(nDwellTime))
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //            return false;
-        //        }
-        //        #endregion
-
-        //        #region MatrixSize
-        //        //获得放大倍数
-        //        int a_MatrixSize = 0;
-        //        Size size = new Size();
-        //        //获取参数
-        //        size = cfun.GetMatrixSize(a_MatrixSize);
-        //        #endregion
-                
-        //        //获取图像数据
-        //        int resultCount = width * height;
-        //        int GetImgCount = cfun.AcquireBSEImage(0, 0, 0, ref ImageByte);
-
-        //        if (resultCount == GetImgCount)
-        //        {
-        //            //设置为原始 扫描模式
-        //            cfun.SetSemScanMode(a_oldMode);
-        //        }
-        //        else
-        //        {
-        //            cfun.SetSemScanMode(a_oldMode);
-        //        }
-        //        return true;
-
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        //记录日志
-        //         //NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
-        //         // log.Error(ex.Message.ToString());
-        //        return false;
-        //    }
-        //}
-        #endregion
-
-        public static int GetScanImage(int iWidth, int iHeigh, string DwellTime, ref byte[] bImageData)
-        {
-            //电镜设置对象
-            COTSControlFunExport cfun = new COTSControlFunExport();
-            int GetImgCount = 0;
-            try
-            {
-                //连接电镜
-                bool IsConnec = cfun.ConncetSem();
-                if (!IsConnec)
-                {
-                    return 0;
-                }
-                //实例电镜初始化
-                bool IsScan = cfun.ScanInit();
-                if (!IsScan)
-                {
-                    return 0;
-                }
-                int a_ExternalMode = 0;
-                //获取终止模式
-                
-                a_ExternalMode = cfun.GetSemExternalMode();
-
-                //保存初始模式变量
-                int a_oldMode = 0;
-                //获取初始模式
-                if (!cfun.GetSemScanMode(ref a_oldMode))
-                {
-                    return 0;
-                }
-                //设置当前模式
-                if (!cfun.SetSemScanMode(a_ExternalMode))
-                {
-                    return 0;
-                }
-
-                #region BeamBlank
-                int a_nBeamBlank = 0;
-                //获取参数
-                if (!cfun.GetSemBeamBlank(ref a_nBeamBlank))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return 0;
-                }
-                //设置参数
-                if (!cfun.SetSemBeamBlank(0))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return 0;
-                }
-                #endregion
-
-                #region 获得放大倍数
-                //获得放大倍数
-                double a_dMagnification = 0;
-                //m_MsrApp.m_LogFunExport.TraceLog("APP_GetSemMagnification-----begin------");
-                //获取参数
-                if (!cfun.GetSemMagnification(ref a_dMagnification))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return 0;
-                }
-                //m_MsrApp.m_LogFunExport.TraceLog("APP_GetSemMagnification_a_dMagnification:" + a_dMagnification + "------");
-                //m_MsrApp.m_LogFunExport.TraceLog("APP_GetSemMagnification-----end------");
-                #endregion
-
-                #region 获取 电镜 X、Y轴 与角度
-                //获取 电镜 X、Y轴 与角度
-                double PositionX = 0;
-                double PositionY = 0;
-                double PositionR = 0;
-                //获取参数
-                if (!cfun.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return 0;
-                }
-                #endregion
-
-                #region 设置图像分辨率
-                //设置宽度
-                if (!cfun.SetImageSize(iWidth, iHeigh))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return 0;
-                }
-                #endregion
-
-                #region 采集时间
-                //采集时间
-                int nDwellTime = Convert.ToInt32(DwellTime);
-                //设置采集时间
-                if (!cfun.SetDwellTime(nDwellTime))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return 0;
-                }
-                #endregion
-
-                #region MatrixSize
-                //获得放大倍数
-                int a_MatrixSize = 0;
-                Size size = new Size();
-                //获取参数
-                size = cfun.GetMatrixSize(a_MatrixSize);
-                #endregion
-
-                //获取图像数据
-
-                int resultCount = iWidth * iHeigh;
-                GetImgCount = cfun.AcquireBSEImage(0, 0, 0, ref bImageData);
-                //记录日志
-                if (resultCount == GetImgCount)
-                {
-                    //设置为原始 扫描模式
-                    cfun.SetSemScanMode(a_oldMode);
-                    //Scan类结束
-
-                    //初始化电镜参数
-                    //if (!cfun.SetAndStartScan())
-                    //{
-                    //    return 0;
-                    //}
-                   
-                }
-                else
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    //记录日志
-                    //初始化电镜参数
-                    //if (!cfun.SetAndStartScan())
-                    //{
-                    //    return 0;
-                    //}
-                }
-
-            }
-            catch (Exception ex)
-            {
-                throw ex;
-            }
-            finally
-            {
-                //cfun.ScanFinishedInstance();
-                //cfun.DisConnectSem();
-                //cfun.FreeDll();
-            }
-
-            return GetImgCount;
-        }
-
-        /// <summary>
-        /// 将byte数组转换为文件并保存到指定地址
-        /// </summary>
-        /// <param name="buff">byte数组</param>
-        /// <param name="savepath">保存地址</param>
-        //public static void BytesConvertToFile(byte[] buff, string savepath, string fileName)
-        //{
-        //    try
-        //    {
-
-        //        //如果不存在就创建Enclosure文件夹 
-        //        if (Directory.Exists(savepath + @"\Enclosure\") == false)
-        //        {
-        //            Directory.CreateDirectory(savepath + @"\Enclosure\");
-        //        }
-
-        //        if (System.IO.File.Exists(savepath + @"\Enclosure\" + fileName))
-        //        {
-        //            System.IO.File.Delete(savepath + @"\Enclosure\" + fileName);
-        //        }
-        //        Bitmap bitmap=ToGrayBitmap(buff, 1024, 768);
-               
-        //        bitmap.Save(savepath + @"\Enclosure\" + fileName);
-                
-        //    }
-        //    catch (Exception)
-        //    {
-
-        //    }
-        //}
-    }
-}

+ 1 - 1
OTSSysMgrTools/OTSSysMgrTools.csproj

@@ -98,7 +98,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="ImageDispose.cs" />
+    <Compile Include="Imagepro.cs" />
     <Compile Include="Language.cs" />
     <Compile Include="MergedparticlesHelper.cs" />
     <Compile Include="ParticleData.cs" />