Explorar el Código

修改MeasureApp中上半部分文件中的错误。

sunyi hace 5 años
padre
commit
23721939af

+ 39 - 30
OTS/OTSIncAMeasureApp/OTSDataMgrFunction/OTSDataMgrFun.cs

@@ -11,6 +11,8 @@ using Newtonsoft.Json.Linq;
 using OTSDataType;
 using OTSModelSharp;
 using System.Windows;
+using NSOTSController;
+using static OTSDataType.otsdataconst;
 
 namespace OTSIncAMeasureApp
 {
@@ -65,7 +67,12 @@ namespace OTSIncAMeasureApp
         //测量样品链表
         List<COTSSample> m_MeasureSampleList = new List<COTSSample>();
 
-        
+
+        public static NLog.Logger Nloger = NLog.LogManager.GetCurrentClassLogger();
+
+        public OTS_MSR_THREAD_STATUS Status;
+
+
 
         public OTSDataMgrFun(OTSIncAMeasureAppForm MeasureApp)
         {
@@ -281,7 +288,7 @@ namespace OTSIncAMeasureApp
                     if (!m_ProjDataMgr.Save())
                     {
                         //取消保存
-                        m_MeasureAppFrom.Nloger.TraceLog("(OTSDataMgrFun.CreateNewFile) Save Cancel");
+                        Nloger.Trace("(OTSDataMgrFun.CreateNewFile) Save Cancel");
                         return false;
                     }
                 }
@@ -821,7 +828,7 @@ namespace OTSIncAMeasureApp
                 //获取样品孔名称
                 SampleMeasureArea.sHoleName = (m_ProjDataMgr.GetSampleList())[i].GetSampleHoleName();
                 //样品测量区域
-                SampleMeasureArea.MeasureRect = (Rectangle)(m_ProjDataMgr.GetSampleList())[i].GetMsrArea();//.GetRectDomain();         
+                SampleMeasureArea.MeasureRect = (Rectangle)(m_ProjDataMgr.GetSampleList())[i].GetMsrArea().GetRectDomain(); ;//.GetRectDomain();         
                 SampleMeasureAreaList.Add(SampleMeasureArea);
             }
             return true;
@@ -1076,7 +1083,7 @@ namespace OTSIncAMeasureApp
 
         //获取幁图数
         //ref List<Point> pField:  幁图数
-        public bool GetField(ref List<System.Windows.Point> pField, ref System.Drawing.Size iSzie)
+        public bool GetField(ref List<System.Drawing.Point> pField, ref System.Drawing.Size iSzie)
         {
             COTSSample WSample = m_ProjDataMgr.GetWorkingSample();
             if (null == WSample)
@@ -1097,7 +1104,7 @@ namespace OTSIncAMeasureApp
             pSEMDataMsr.SetTotalFields(m_ProjDataMgr.GetWorkingSample().GetSEMDataMsr().GetTotalFields());
             pSEMDataMsr.SetWorkingDistance(m_ProjDataMgr.GetWorkingSample().GetSEMDataMsr().GetWorkingDistance());
             CFieldMgr pFieldMgr = new CFieldMgr();
-            List<System.Windows.Point> listPoint = new List<System.Windows.Point>();
+            List<System.Drawing.Point> listPoint = new List<System.Drawing.Point>();
             listPoint.Clear();
             //设置测量区域
             CSEMDataMsr pSEMDataMsrTemp = pSEMDataMsr;
@@ -1129,7 +1136,7 @@ namespace OTSIncAMeasureApp
                 }
                 catch (Exception ex)
                 {
-                    m_MeasureAppFrom.Nloger.TraceErrorLog("获取幁图数问题:" + ex.ToString());
+                    Nloger.Error("获取幁图数问题:" + ex.ToString());
                 }
                 //初始化
                 if (!pFieldMgr.Init(pMsrArea, pImgScanParam, pSEMDataMsr, listPoint))
@@ -1144,12 +1151,12 @@ namespace OTSIncAMeasureApp
             //获取幁图数
             int iFieldCount = pFieldMgr.GetTotalFields();
 
-            Rect oValue = new Rect();
+            System.Drawing.Rectangle oValue = new System.Drawing.Rectangle();
             if (!pFieldMgr.GetFieldRectByIndex(0,  oValue))
             {                
                 return false;
             }
-            iSzie = ((Rect)oValue).Size;
+            iSzie = oValue.Size;
             //将幁图数赋值给工作样品后
             m_ProjDataMgr.GetWorkingSample().GetSEMDataMsr().SetTotalFields(iFieldCount);
             return true;
@@ -1221,14 +1228,14 @@ namespace OTSIncAMeasureApp
             return false;
             }
 
-            COTSImgProcPrm ImgProcPrm = WSample.GetMsrParams().GetImageProcessParam();
+            OTSDataType.COTSImgProcPrm ImgProcPrm = WSample.GetMsrParams().GetImageProcessParam();
 
-            if (!m_ProjDataMgr.RemoveBackGround(pBSEImageIn, ImgProcPrm, ref pBSEImageOut))
+            if (!m_ProjDataMgr.RemoveBackGround(pBSEImageIn, ImgProcPrm,  pBSEImageOut))
             {
             return false;
             }
 
-            BSEImageNoBG = pBSEImageOut.GetImageDataPtr();
+            BSEImageNoBG = pBSEImageOut.GetImageDataPtr();  //public byte[] GetImageDataPtr();
 
             return true;
         }
@@ -1494,7 +1501,7 @@ namespace OTSIncAMeasureApp
         public void SetMeasureThreadStatus(MSR_THREAD_STATUS ThreadStatus)
         {
             //设置测量线程状态
-            m_MsrThread.SetMsrLoopStatus((int)ThreadStatus);
+            m_MsrThread.SetMsrLoopStatus(Status);
         }
 
         //保存测量样品的
@@ -1505,7 +1512,7 @@ namespace OTSIncAMeasureApp
             {               
             return false;
             }
-            m_MeasureAppFrom.Nloger.TraceLog("(OTSDataMgrFun.SaveMeasureSampleInfo.GetNewProjMgrClr())  m_ProjDataMgr.GetSampleList().Count = " + m_ProjDataMgr.GetSampleList().Count.ToString());
+            Nloger.Trace("(OTSDataMgrFun.SaveMeasureSampleInfo.GetNewProjMgrClr())  m_ProjDataMgr.GetSampleList().Count = " + m_ProjDataMgr.GetSampleList().Count.ToString());
             if (!m_ProjDataMgr.Save())
             {
             return false;
@@ -1539,13 +1546,13 @@ namespace OTSIncAMeasureApp
 
      
         //获取新的工作文件对象
-        public CProjMgr GetNewProjMgrClr()
+        public COTSProjMgrFile GetNewProjMgrClr()
         {
             if (null == m_MsrThread)
             {                
             return null; ;
             }
-            return m_MsrThread.GetProjMgr();
+            return m_MsrThread.GetProjMgrFile();
         }
 
         // 获取测量结果信息
@@ -1605,7 +1612,7 @@ namespace OTSIncAMeasureApp
             }
             catch (Exception ex)
             {
-                m_MeasureAppFrom.Nloger.TraceErrorLog("(OTSDataMgrFun.GetMsrRetData) Exception:"+ex.ToString());
+                Nloger.Error("(OTSDataMgrFun.GetMsrRetData) Exception:"+ex.ToString());
                 return false;
             }
         }
@@ -1621,7 +1628,7 @@ namespace OTSIncAMeasureApp
             }
 
             MsrSampleName = WSample.GetName();            
-            FieldList = WSample.GetMsrStatus().GetCpltedCenter();
+            FieldList = WSample.GetMsrStatus().GetCompletedFieldsCenter();
             return true;
         }
       
@@ -1713,6 +1720,8 @@ namespace OTSIncAMeasureApp
     public class OTSBSEImageFun : OTSImageInterface
     {       
         OTSIncAMeasureAppForm m_MsrApp = null;
+
+        public static NLog.Logger Nloger = NLog.LogManager.GetCurrentClassLogger();
         public OTSBSEImageFun(OTSIncAMeasureAppForm MsrApp)
         {
             m_MsrApp = MsrApp;            
@@ -1730,7 +1739,7 @@ namespace OTSIncAMeasureApp
                 if (!IsConnec)
                 {
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.ConncetSem() = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                 //实例电镜初始化
@@ -1738,7 +1747,7 @@ namespace OTSIncAMeasureApp
                 if (!IsScan)
                 {
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.ScanInit = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                
@@ -1754,7 +1763,7 @@ namespace OTSIncAMeasureApp
                 if (!cfun.GetSemScanMode(ref a_oldMode))
                 {
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemScanMode = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                
@@ -1763,7 +1772,7 @@ namespace OTSIncAMeasureApp
                 if (!cfun.SetSemScanMode(a_ExternalMode))
                 {
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetSemScanMode = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                 
@@ -1776,7 +1785,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemBeamBlank = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                
@@ -1785,7 +1794,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetSemBeamBlank = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                
@@ -1800,7 +1809,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemMagnification = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
               
@@ -1817,7 +1826,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemPositionXY = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                
@@ -1830,7 +1839,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetImageSize = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                
@@ -1844,7 +1853,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetDwellTime = false  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                     return 0;
                 }
                 
@@ -1888,7 +1897,7 @@ namespace OTSIncAMeasureApp
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.AcquireBSEImage = 0  Failed";
-                    m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                    Nloger.Error(strErrorInfo);
                    
                     //初始化电镜参数                  
                     if (!cfun.SetAndStartScan())
@@ -1901,9 +1910,9 @@ namespace OTSIncAMeasureApp
             catch (Exception ex)
             {
                 //记录日志
-                m_MsrApp.Nloger.TraceErrorLog(ex.Message.ToString());
+                Nloger.Error(ex.Message.ToString());
                 string strErrorInfo = "(OTSBSEImageFun.GetScanImage) Exception   Error Happend";
-                m_MsrApp.Nloger.TraceErrorLog(strErrorInfo);
+                Nloger.Error(strErrorInfo);
 
             }
             finally

+ 11 - 12
OTS/OTSIncAMeasureApp/OTSDisplaySGridData/OTSDisplaySampleGrid.cs

@@ -18,7 +18,7 @@ namespace OTSIncAMeasureApp
 
         int m_Grid_TotalRow = 0;                           //  显示样品信息的Grid的总行数
 
-  
+        public static NLog.Logger Nloger = NLog.LogManager.GetCurrentClassLogger();
         //定义分栏表头样式
         SourceGrid.Cells.Views.Cell m_Col_HeaderMode = null;
         //定义大表头grid表头样式
@@ -458,7 +458,7 @@ namespace OTSIncAMeasureApp
                         { //ref iIndex : 当文件名为空的时候返回 -1
                             if (!m_PropWindow.m_MeasureAppForm.m_DataMgrFun.GetSTDFileName(ref iIndex, ref FileNameList))
                             {
-                                m_PropWindow.m_MeasureAppForm.Nloger.TraceErrorLog("(OTSDisplaySampleGrid.SetGridCellVal)  m_PropWindow.m_MeasureAppForm.m_DataMgrFun.GetSTDFileName(ref iIndex, ref FileNameList) = false ");
+                                Nloger.Error("(OTSDisplaySampleGrid.SetGridCellVal)  m_PropWindow.m_MeasureAppForm.m_DataMgrFun.GetSTDFileName(ref iIndex, ref FileNameList) = false ");
                                 iIndex = -1;
                             }
                         } 
@@ -632,8 +632,8 @@ namespace OTSIncAMeasureApp
             }
         
         }
-        
 
+        
         //点击 Grid标题栏左边的 "-"或者"+" 实现隐藏和显示样品属性行
         private void ShowOrHideCellRow(string sLTitle,int LTitleRow,int StartRow, int EndRow)
         {
@@ -725,7 +725,7 @@ namespace OTSIncAMeasureApp
         public void UpdataNewGridVal(OTS_SAMPLE_PROP_GRID_ITEMS SampleID, object ObjVal, bool bCheckBoxFlag=false)
         {
             
-            m_PropWindow.m_MeasureAppForm.Nloger.TraceLog("******** UpdataNewGridVal ************");
+            Nloger.Trace("******** UpdataNewGridVal ************");
             sSampleid_Val sval = new sSampleid_Val();
             sval.SampleID = SampleID;
             sval.ObjVal = ObjVal;
@@ -735,14 +735,14 @@ namespace OTSIncAMeasureApp
                 if (!m_bgWorker.IsBusy)
                 {
                     m_ReqChangeValFlag = false;
-                    m_PropWindow.m_MeasureAppForm.Nloger.TraceLog("******** Start run WorkThread ************");
+                    Nloger.Trace("******** Start run WorkThread ************");
                     m_bgWorker.RunWorkerAsync(sval);
                 }
             }
  
      
 
-            m_PropWindow.m_MeasureAppForm.Nloger.TraceLog("Exit UpdataNewGridVal");
+          Nloger.Trace("Exit UpdataNewGridVal");
 
         }
 
@@ -765,10 +765,9 @@ namespace OTSIncAMeasureApp
                {
                     if ((OTS_SAMPLE_PROP_GRID_ITEMS)m_PropWindow.PropGrid.Rows[m_ClickRow].Tag == sVal.SampleID)
                         {
-                            m_PropWindow.PropGrid[m_ClickRow, m_ClickColumn].Value = sVal.ObjVal;
-                            m_PropWindow.m_MeasureAppForm.Nloger.TraceLog("    Set Value   ");
-                                   
-                            m_PropWindow.m_MeasureAppForm.Nloger.TraceLog(str);
+                           m_PropWindow.PropGrid[m_ClickRow, m_ClickColumn].Value = sVal.ObjVal;
+                           Nloger.Trace("    Set Value   ");                                  
+                           Nloger.Trace(str);
                         }
               }
                else
@@ -802,7 +801,7 @@ namespace OTSIncAMeasureApp
                         m_PropWindow.PropGrid[m_ClickRow, 2].FindController<SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += m_SelectCheckBoxEvent.SetCheckBoxStatus(m_ClickRow);
                     }
                   
-                    m_PropWindow.m_MeasureAppForm.Nloger.TraceLog(str);
+                    Nloger.Trace(str);
 
                        
 
@@ -817,7 +816,7 @@ namespace OTSIncAMeasureApp
            
             object val = m_PropWindow.PropGrid[m_ClickRow, 2].Value;
       
-            m_PropWindow.m_MeasureAppForm.Nloger.TraceLog("Exit WorkThread");
+           Nloger.Trace("Exit WorkThread");
             m_ReqChangeValFlag = true;
             m_PropWindow.PropGrid.Refresh();
         }

+ 12 - 10
OTS/OTSIncAMeasureApp/OTSDisplayTreeViewData/OTSDisplayTreeBase.cs

@@ -14,6 +14,8 @@ namespace OTSIncAMeasureApp
         //  TreeNode m_Menunode = new TreeNode();     //树的跟节点
         //     String m_csSolutionName = "未加载样品名";
         //    String m_csSampleName = "";
+
+        public static NLog.Logger Nloger = NLog.LogManager.GetCurrentClassLogger();
         public OTSDisplayTreeBase(OTSSolutionWindow SolutionWindow)
         {
             m_SolutionWindow = SolutionWindow;
@@ -390,27 +392,27 @@ namespace OTSIncAMeasureApp
                 GetAfterSortTreeNode(m_SolutionWindow.treeView1.Nodes[iTNodeCount],ref  SampleNameList);
             }
 
-            m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog(" *********************************** **************************************************");
-            m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("                                                                                      ");
-            m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("                                  Begin   SortTreeNodeList()                                                 ");
+            Nloger.Trace(" *********************************** **************************************************");
+            Nloger.Trace("                                                                                      ");
+            Nloger.Trace("                                  Begin   SortTreeNodeList()                                                 ");
 
             for (int i = 0; i < SampleNameList.Count; i++)
             {
-                m_SolutionWindow.m_MeasureAppForm.Nloger.TraceLog(" Sort SampleName = " + SampleNameList[i]);
+                Nloger.Trace(" Sort SampleName = " + SampleNameList[i]);
             }
 
 
             if (!m_SolutionWindow.m_MeasureAppForm.m_DataMgrFun.SortSamplePosition(SampleNameList))
             {
-                m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("(OTSDisplayTreeBase.SortTreeNodeList) m_SolutionWindow.m_MeasureAppForm.m_DataMgrFun.SortSamplePosition(SampleNameList) = false Failed ");
+                Nloger.Error("(OTSDisplayTreeBase.SortTreeNodeList) m_SolutionWindow.m_MeasureAppForm.m_DataMgrFun.SortSamplePosition(SampleNameList) = false Failed ");
                 for (int i = 0; i < SampleNameList.Count; i++)
                 {
-                    m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("Sort SampleName = " + SampleNameList[i]);
+                   Nloger.Error("Sort SampleName = " + SampleNameList[i]);
                 }
             }
-            m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("                                   End    SortTreeNodeList()                                                   ");
-            m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("                                                                                      ");
-            m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog(" *************************************************************************************");
+           Nloger.Error("                                   End    SortTreeNodeList()                                                   ");
+           Nloger.Error("                                                                                      ");
+           Nloger.Error(" *************************************************************************************");
             
         }
 
@@ -652,7 +654,7 @@ namespace OTSIncAMeasureApp
             CTreeSampleParam WSParam = new CTreeSampleParam();
             if (!m_SolutionWindow.m_MeasureAppForm.GetWorkSampleParamLock(ref WSParam))
             {
-                m_SolutionWindow.m_MeasureAppForm.Nloger.TraceErrorLog("(OTSDisplayTreeBase.GetSampleNodeLockStatu )  m_SolutionWindow.m_MeasureAppForm.GetWorkSampleParamLock(ref WSParam) = false  Failed !");
+                Nloger.Error("(OTSDisplayTreeBase.GetSampleNodeLockStatu )  m_SolutionWindow.m_MeasureAppForm.GetWorkSampleParamLock(ref WSParam) = false  Failed !");
                 return false;
             }
             CheckTNodeLockStatu = WSParam.bParamLock;

+ 7 - 4
OTS/OTSIncAMeasureApp/OTSMeasureStatuImageFun/OTSImageData.cs

@@ -9,6 +9,7 @@ using System.IO;
 
 namespace OTSIncAMeasureApp.OTSMeasureStatuImageFun
 {
+    
     public enum idLine
     {
         //曲线
@@ -33,6 +34,8 @@ namespace OTSIncAMeasureApp.OTSMeasureStatuImageFun
         static string XMLFileName = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFileName"].ConnectionString;
 
         static ExcelEdit m_xe = new ExcelEdit();
+
+        public static NLog.Logger Nloger = NLog.LogManager.GetCurrentClassLogger();
         public OTSImageData(OTSMeasureStatusWindow MeasureStatuWindow, OTSIncAMeasureAppForm oTSIncAMeasureAppForm)
         {
             try
@@ -42,7 +45,7 @@ namespace OTSIncAMeasureApp.OTSMeasureStatuImageFun
             }
             catch (Exception ex)
             {
-                m_MeasureApp.Nloger.TraceErrorLog("(OTSMeasureStatusWindow.ShowGrayLevelLine_Click)  " + ex.ToString());
+                Nloger.Error("(OTSMeasureStatusWindow.ShowGrayLevelLine_Click)  " + ex.ToString());
             }
 
         }
@@ -72,7 +75,7 @@ namespace OTSIncAMeasureApp.OTSMeasureStatuImageFun
             }
             catch (Exception ex)
             {
-                m_MeasureApp.Nloger.TraceErrorLog("(OTSMeasureStatusWindow.GetGaryData)  " + ex.ToString());
+                Nloger.Error("(OTSMeasureStatusWindow.GetGaryData)  " + ex.ToString());
                 return null;
             }
         }
@@ -121,7 +124,7 @@ namespace OTSIncAMeasureApp.OTSMeasureStatuImageFun
             }
             catch (Exception ex)
             {
-                m_MeasureApp.Nloger.TraceErrorLog("(OTSMeasureStatusWindow.GetGaryData)  " + ex.ToString());
+                Nloger.Error("(OTSMeasureStatusWindow.GetGaryData)  " + ex.ToString());
                 return null;
             }
         }
@@ -294,7 +297,7 @@ namespace OTSIncAMeasureApp.OTSMeasureStatuImageFun
                 }
                 catch (Exception ex)
                 {
-                    m_MeasureApp.Nloger.TraceErrorLog("InsertDataToExcelTable错误日志: " + ex.ToString());
+                    Nloger.Error("InsertDataToExcelTable错误日志: " + ex.ToString());
                 }
             }
             //关闭excel

+ 23 - 23
OTS/OTSModelSharp/Measure/GetBSEPic/FieldMgr.cs

@@ -25,7 +25,7 @@ namespace OTSModelSharp
         CDomain m_pMeasureArea;
 
         // measured field centre points list
-        List<System.Windows.Point> m_listMeasuredFieldCentrePoints;
+        List<System.Drawing.Point> m_listMeasuredFieldCentrePoints;
 
         // image scan parameter
         COTSImgScanPrm  m_poImageScanParam;
@@ -33,15 +33,15 @@ namespace OTSModelSharp
         const int RESOLUTION_ID_FIRST_TIE = 2;
    
         // field centre points list
-        List<System.Windows.Point> m_listFieldCentrePoints;
+        List<System.Drawing.Point> m_listFieldCentrePoints;
 
         // SEM data (measurement)
         CSEMDataMsr m_poSEMDataMsr;
 
         // unmeasured field centre points list
-        List<System.Windows.Point> m_listUnmeasuredFieldCentrePoints;
+        List<System.Drawing.Point> m_listUnmeasuredFieldCentrePoints;
 
-        public bool Init(CDomain a_pMeasureArea, COTSImgScanPrm  a_poImageScanParam, CSEMDataMsr a_poSEMDataMsr, List<System.Windows.Point> a_listMeasuredFieldCentrePoints)
+        public bool Init(CDomain a_pMeasureArea, COTSImgScanPrm  a_poImageScanParam, CSEMDataMsr a_poSEMDataMsr, List<System.Drawing.Point> a_listMeasuredFieldCentrePoints)
         {
             // assign class member
             m_pMeasureArea = new CDomain(a_pMeasureArea);
@@ -58,7 +58,7 @@ namespace OTSModelSharp
         }
 
         // calculate field centre points list
-        public bool CalculateFieldCentrePoints1(List<System.Windows.Point> a_listMeasuredFieldCentrePoints)
+        public bool CalculateFieldCentrePoints1(List<System.Drawing.Point> a_listMeasuredFieldCentrePoints)
         {
 
             // clean up 
@@ -94,7 +94,7 @@ namespace OTSModelSharp
             // field centres need to be aligned with measured field centres
             if (0 < (int)a_listMeasuredFieldCentrePoints.Count)
             {   // get the first measured centre
-                System.Windows.Point poiMeasuredFieldCentre = a_listMeasuredFieldCentrePoints[0];
+                System.Drawing.Point poiMeasuredFieldCentre = a_listMeasuredFieldCentrePoints[0];
                 // distance between the measure domain centre and the first measured field
                 double nDistanceX = Math.Abs(poiDomainCentre.X - poiMeasuredFieldCentre.X);
                 double nDistanceY = Math.Abs(poiDomainCentre.Y - poiMeasuredFieldCentre.Y);
@@ -263,7 +263,7 @@ namespace OTSModelSharp
                 {
                     string strPoint = itr.ToString();
                     string[] strPointArray = strPoint.Split(',');
-                  System.Windows.Point point1 = new System.Windows.Point(int.Parse(strPointArray[0]), int.Parse(strPointArray[1]));
+                  System.Drawing.Point point1 = new System.Drawing.Point(int.Parse(strPointArray[0]), int.Parse(strPointArray[1]));
 
                     m_listFieldCentrePoints.Add(point1);
 
@@ -291,7 +291,7 @@ namespace OTSModelSharp
         public bool Reset(CDomain a_pMeasureArea,
              COTSImgScanPrm  a_poImageScanParam,
              CSEMDataMsr a_poSEMDataMsr,
-           List<System.Windows.Point> a_listMeasuredFieldCentrePoints)
+           List<System.Drawing.Point> a_listMeasuredFieldCentrePoints)
         {
 
             // check if need to re-do field centres calculation 		
@@ -325,7 +325,7 @@ namespace OTSModelSharp
         }
 
         // test if field is in the measured field centre points list
-        public bool IsInMeasuredFieldList(System.Windows.Point a_poiField)
+        public bool IsInMeasuredFieldList(System.Drawing.Point a_poiField)
         {
                
                 for (int itr = 0; itr < m_listMeasuredFieldCentrePoints.Count; itr++)
@@ -417,13 +417,13 @@ namespace OTSModelSharp
         }
 
         // field centre points list
-        public List<System.Windows.Point> GetFieldCentrePoints()
+        public List<System.Drawing.Point> GetFieldCentrePoints()
         {
             return m_listFieldCentrePoints;
         }
 
         // field centre points list
-        public bool GetFieldRectByIndex(int a_nIndex, Rect a_rectField)
+        public bool GetFieldRectByIndex(int a_nIndex, System.Drawing.Rectangle a_rectField)
         {
             // check input
             if (a_nIndex < 0 || a_nIndex > (int)m_listFieldCentrePoints.Count)
@@ -437,13 +437,13 @@ namespace OTSModelSharp
             int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId;
             System.Drawing.Size[] sizePixelImage = RESOLUTION_VALUE;
             // scan field size (x, y)
-            System.Windows.Size sizeImage = new System.Windows.Size();
+            System.Drawing.Size sizeImage = new System.Drawing.Size();
             sizeImage.Width = m_poSEMDataMsr.GetScanFieldSize();
             sizeImage.Height = sizeImage.Width * sizePixelImage.Length/ sizePixelImage.Length;
             // get left top
-            System.Windows.Point ptLeftTop = m_listFieldCentrePoints[a_nIndex];
+            System.Drawing.Point ptLeftTop = m_listFieldCentrePoints[a_nIndex];
             // get field rectangle
-            a_rectField =new Rect(ptLeftTop, sizeImage);
+            a_rectField =new Rectangle(ptLeftTop, sizeImage);
 
             return true;
         }
@@ -453,7 +453,7 @@ namespace OTSModelSharp
             return (int)m_listFieldCentrePoints.Count;
         }
 
-        public void SetFieldCentrePoints(List<System.Windows.Point> listPoint)
+        public void SetFieldCentrePoints(List<System.Drawing.Point> listPoint)
         {
             foreach (var opt in listPoint)
             {
@@ -463,7 +463,7 @@ namespace OTSModelSharp
         }
 
         // unmeasured field centre points list
-        public List<System.Windows.Point> GetUnmeasuredFieldCentrePoints()
+        public List<System.Drawing.Point> GetUnmeasuredFieldCentrePoints()
         {
             return m_listUnmeasuredFieldCentrePoints;
         }
@@ -491,7 +491,7 @@ namespace OTSModelSharp
             return true;
         }
 
-        public bool GetUnmeasuredRandemField(Rect a_rectField)
+        public bool GetUnmeasuredRandemField(Rectangle a_rectField)
         {
             // any field left?
             if (m_listUnmeasuredFieldCentrePoints.Count == 0)
@@ -507,7 +507,7 @@ namespace OTSModelSharp
             System.Drawing.Size sizePixelImage = RESOLUTION_VALUE[nResulotionId];
 
             // scan field size (x, y)
-            System.Windows.Size sizeImage = new System.Windows.Size();
+            System.Drawing.Size sizeImage = new System.Drawing.Size();
             sizeImage.Width = m_poSEMDataMsr.GetScanFieldSize();
             sizeImage.Height = sizeImage.Width * sizePixelImage.Height / sizePixelImage.Width;
 
@@ -520,7 +520,7 @@ namespace OTSModelSharp
             }
 
             // get field rectangle
-            a_rectField = new Rect(m_listUnmeasuredFieldCentrePoints[nIndex], sizeImage);
+            a_rectField = new Rectangle(m_listUnmeasuredFieldCentrePoints[nIndex], sizeImage);
 
             // ok, return TRUE
             return true;
@@ -539,7 +539,7 @@ namespace OTSModelSharp
             return nRet;
         }
 
-        public void SetUnmeasuredFieldCentrePoints(List<System.Windows.Point> listPoint)
+        public void SetUnmeasuredFieldCentrePoints(List<System.Drawing.Point> listPoint)
         {
             foreach (var opt in listPoint)
             {
@@ -548,18 +548,18 @@ namespace OTSModelSharp
         }
 
         // measured field centre points list
-        public List<System.Windows.Point> GetMeasuredFieldCentrePoints()
+        public List<System.Drawing.Point> GetMeasuredFieldCentrePoints()
         {
             return m_listMeasuredFieldCentrePoints;
         }
 
-        public void GetMeasuredFieldCentrePoints(List<System.Windows.Point> a_listMeasuredFieldCentrePoints)
+        public void GetMeasuredFieldCentrePoints(List<System.Drawing.Point> a_listMeasuredFieldCentrePoints)
         {
             m_listMeasuredFieldCentrePoints = a_listMeasuredFieldCentrePoints;
         }
 
         // measured field centre points list
-        public void SetMeasuredFieldCentrePoints(List<System.Windows.Point> listPoint)
+        public void SetMeasuredFieldCentrePoints(List<System.Drawing.Point> listPoint)
         {
             foreach (var opt in listPoint)
             {

+ 211 - 1
OTS/OTSModelSharp/Measure/GetBSEPic/MsrThread.cs

@@ -5,6 +5,7 @@ using System.Drawing;
 using OTSIncAMeasureApp.OTSMeasureControl;
 using static OTSDataType.otsdataconst;
 using OTSIncAMeasureApp.OTSMesureControl;
+using OTSModelSharp.MeasureControl;
 
 namespace OTSModelSharp
 {
@@ -114,6 +115,13 @@ namespace OTSModelSharp
         string m_strMAppFormName;
        IMeasureHardware m_HardwareMgr;// there is no correspondense clr,so use this instead temporarilly
         protected static NLog.Logger loger = NLog.LogManager.GetCurrentClassLogger();
+
+       public otsdataconst.OTS_MSR_THREAD_STATUS m_nStatus;
+
+       public COTSImgScanPrm ImageScanParam = new COTSImgScanPrm();
+
+        // measure loop status
+
         public MsrThread()
         {
            // m_pProjMgrFile = nullptr;
@@ -152,6 +160,8 @@ namespace OTSModelSharp
             m_listMeasurableSamples = a_listMeasuableSamples;            
             return true;
         }
+
+        public CMsrThreadStatus GetMsrThreadStatus() { return m_pThreadStatus; }
         bool Init(COTSProjMgrFile a_pProjMgrFile)
         {
             m_pProjMgrFile = a_pProjMgrFile;
@@ -209,7 +219,7 @@ namespace OTSModelSharp
         public bool  IsMeasureRunning() { return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.INPROCESS; }
         public bool  IsMeasureFailed() { return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.FAILED; }
         public bool  IsMeasureCompleted() { return m_pThreadStatus.GetStatus() == OTSIncAMeasureApp.OTSMesureControl.OTS_MSR_THREAD_STATUS.COMPLETED; }
-        void DoMeasure()
+        public   void DoMeasure()
         {
             // start measurement, creat thread measure status class, let the main thread know that measurement started
 
@@ -365,7 +375,207 @@ namespace OTSModelSharp
             ThreadOver();
 	}
 
+        // hole preview
+       public  void DoHolePreview(int a_nHoleID, CDomain a_pMeasureArea)
+        {
+            // start measurement, creat thread measure status class, let the main thread know that measurement started
+            // set measure status to in-process
+            //record time
+            m_pThreadStatus.ComputeTime(OTSIncAMeasureApp.OTSMesureControl.OTS_THREAD_TIME_TYPE.START);
+            DateTime timeStart = m_pThreadStatus.GetStartTime();
+
+            int iYear = timeStart.DayOfYear;
+            int imonth = timeStart.Month;
+            int iDay = timeStart.Day;
+            int iHour = timeStart.Hour;
+            int iMin = timeStart.Minute;
+            int iSec = timeStart.Second;
+
+            String csTime;
+            string.Format("%04d-%02d-%02d %02d:%02d:%02d", iYear, imonth, iDay, iHour, iMin, iSec);
+
+            ST_MSTMsg MsgMsrStart = new ST_MSTMsg();
+           /// memset(&MsgMsrStart, 0, sizeof(ST_MSTMsg));
+            MsgMsrStart.iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
+            MsgMsrStart.STMThreadStu.iMThreadStatus = Convert.ToInt32(otsdataconst.OTS_MSR_THREAD_STATUS.INPROCESS);
+           // strcpy(MsgMsrStart.STMThreadStu.cMsrStartTime, csTime);
+            SendMessageToMeasureApp(MsgMsrStart);
+            // connect hardware
+            if (!m_HardwareMgr.ConnectHardware())
+            {
+                // failed to connect hardware
+                
+                SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.FAILED);
+                m_pThreadStatus.ComputeTime(OTSIncAMeasureApp.OTSMesureControl.OTS_THREAD_TIME_TYPE.STOPPED);
+                ThreadOver();
+            }
+
+           
+	
+            
+            COTSSample pSampleHole = CreateHoleSample(a_pMeasureArea);
+           
+
+            // create a sample measure object for the sample
+            SmplMeasure pSmplMeasure=new CSmplMeasureInc();
+
+            // set sample
+            pSmplMeasure.SetSample(pSampleHole);
+
+            // set measure thread
+            pSmplMeasure.SetMsrThread(this);
+
+            // update thread measure status class, let the main thread know that this sample measurement starts
+            // set working folder string
+            pSmplMeasure.SetWorkingFolder(m_strWorkingFolder);
+
+            // do measure
+            pSmplMeasure.DoHolePreview(a_nHoleID);
+
+            // check if measurement is successful
+            if (pSampleHole.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.STOPPED)
+            {
+                // record end time
+                m_pThreadStatus.ComputeTime(OTSIncAMeasureApp.OTSMesureControl.OTS_THREAD_TIME_TYPE.STOPPED);
+                // measurement stopped
+                SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
+
+                // update thread measure status class, let the main thread know that this sample measurement stopped
+                ST_MSTMsg MsgSmpStop = new ST_MSTMsg();
+               // memset(&MsgSmpStop, 0, sizeof(ST_MSTMsg));
+                MsgSmpStop.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
+                MsgSmpStop.STMSampleStu.iMeasureSampleStatus = (int)OTS_MSR_SAMPLE_STATUS.STOPPED;
+                //memcpy(MsgSmpStop.STMSampleStu.cSampleName, pSampleHole->GetName(), sizeof(pSampleHole->GetName()));
+                SendMessageToMeasureApp(MsgSmpStop);
+
+                ThreadOver();
+                return;
+            }
+            else if (pSampleHole.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.FAILED)
+            {
+                // measurement failed
+                SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.FAILED);
+                // record end time
+                m_pThreadStatus.ComputeTime(OTSIncAMeasureApp.OTSMesureControl.OTS_THREAD_TIME_TYPE.STOPPED);
+
+                // update thread measure status class, let the main thread know that this sample measurement failed
+                ST_MSTMsg MsgSmpFailed = new ST_MSTMsg();
+               // memset(&MsgSmpFailed, 0, sizeof(ST_MSTMsg));
+                MsgSmpFailed.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
+                MsgSmpFailed.STMSampleStu.iMeasureSampleStatus = (int)OTS_MSR_SAMPLE_STATUS.FAILED;
+               // memcpy(MsgSmpFailed.STMSampleStu.cSampleName, pSampleHole->GetName(), sizeof(pSampleHole->GetName()));
+                SendMessageToMeasureApp(MsgSmpFailed);
+                ThreadOver();
+                return;
+            }
+
+            // record end time
+            m_pThreadStatus.ComputeTime(OTSIncAMeasureApp.OTSMesureControl.OTS_THREAD_TIME_TYPE.STOPPED);
+
+            // update thread measure status class, let the main thread know that this sample measurement successes
+            ST_MSTMsg MsgSmpSuccess = new ST_MSTMsg();
+           // memset(&MsgSmpSuccess, 0, sizeof(ST_MSTMsg));
+            MsgSmpSuccess.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
+            MsgSmpSuccess.STMSampleStu.iMeasureSampleStatus = (int)OTS_MSR_SAMPLE_STATUS.SUCCESSED;
+           // memcpy(MsgSmpSuccess.STMSampleStu.cSampleName, pSampleHole->GetName(), sizeof(pSampleHole->GetName()));
+
+
+            SendMessageToMeasureApp(MsgSmpSuccess);
+
+            // measurement completed
+            SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS.COMPLETED);
+            // record end time
+            m_pThreadStatus.ComputeTime(OTSIncAMeasureApp.OTSMesureControl.OTS_THREAD_TIME_TYPE.STOPPED);
+
+            ThreadOver();
+        }
+
+      public  COTSSample CreateHoleSample(CDomain a_pMsrArea)
+        {
+            
+
+            COTSSample pHoleSample = new COTSSample();
+
+            pHoleSample.SetMsrArea(a_pMsrArea);
+
+           
+
+            // get min magnification
+            CSEMStageData pSEMStageData = m_pProjMgrFile.GetSEMStageData();
+            double dMinMag = pSEMStageData.GetMinMag();
+            // get scan field size 100
+            int nScanFieldSize100 = pSEMStageData.GetScanFieldSize100();
+            // get working distance
+            double dWorkingDistance = 0.0;
+            if (!GetSEMWorkingDistanceFromHW(dWorkingDistance))
+            {
+
+                return null;
+            }
+
+            CSEMDataMsr poSEMDataMsr = new CSEMDataMsr();
+            poSEMDataMsr.SetScanFieldSize100(nScanFieldSize100);
+            poSEMDataMsr.SetWorkingDistance(dWorkingDistance);
+            poSEMDataMsr.SetMagnification(dMinMag);
+
+            pHoleSample.SetSEMDataMsr(poSEMDataMsr);
+
+            // Set image scan param
+            COTSImgScanPrm poImageScanParam = new COTSImgScanPrm();
+            poImageScanParam.SetStopMode(OTS_MEASURE_STOP_MODE.CoverMode);
+            poImageScanParam.SetStartImageMode(OTS_GET_IMAGE_MODE.FROM_CENTER);
+            poImageScanParam.SetScanImageSpeed(OTS_THREE_TIES_OPTIONS.TIE1);
+            poImageScanParam.SetImagePixelSize(OTS_FIVE_TIES_OPTIONS.TIE1);
+
+            CMsrParams poMsrParams = pHoleSample.GetMsrParams();
+           
+            poMsrParams.SetImageScanParam(poImageScanParam);
+
+            pHoleSample.SetMsrParams(poMsrParams);
+
+            return pHoleSample;
+        }
+
+      public  bool GetSEMWorkingDistanceFromHW(double a_dWorkingDistance)
+        {
+
+
+
+            // get SEM, scanner and x-ray controller via hardware manager
+            //需要做接口
+            //COTSSemBase pSEMCtrlPtr = m_pHardwareMgr.GetSemControllerMgrPtr();
+           
+
+            //// get SEM controller
+            //if (!pSEMCtrlPtr->IsConnected())
+            //{
+            //    if (!pSEMCtrlPtr->Connect())
+            //    {
+
+            //        return false;
+            //    }
+            //}
+
+            //double dWorkDis = 0;
+            //if (!pSEMCtrlPtr->GetWorkingDistance(a_dWorkingDistance))
+            //{
+
+            //    return false;
+            //}
+
+            return true;
+        }
         public bool GetMeasureAppFormName(string name) { return false; }
 
+        // measure status
+       public void SetMsrLoopStatus(otsdataconst.OTS_MSR_THREAD_STATUS a_nMsrLoopStatus)
+        {
+            if (a_nMsrLoopStatus >= otsdataconst.OTS_MSR_THREAD_STATUS.MIN && a_nMsrLoopStatus <= otsdataconst.OTS_MSR_THREAD_STATUS.MAX)
+            {
+                SetStatus(a_nMsrLoopStatus);
+            }
+        }
+
+      public  void SetStatus(otsdataconst.OTS_MSR_THREAD_STATUS a_nStatus) { m_nStatus = a_nStatus; }
     }
 }

+ 18 - 0
OTS/OTSModelSharp/Measure/GetBSEPic/SmplMeasure.cs

@@ -95,6 +95,13 @@ namespace OTSModelSharp
 
         }
 
+       public void SetSample(COTSSample a_pSample)
+        {
+            
+            m_pSample = a_pSample;
+
+        }
+
 
         public void SetMsrThread(MsrThread mt)
         {
@@ -267,6 +274,17 @@ namespace OTSModelSharp
             }
             return true;
         }
+
+       public  void SetWorkingFolder(String a_strWorkingFolder)
+        {
+            // add "\\" at the string end if it is not "\\"
+            if (a_strWorkingFolder.PadRight(1)!="\\")
+            {
+                a_strWorkingFolder += "\\";
+            }
+
+            m_strWorkingFolder = a_strWorkingFolder + m_pSample.GetName() + "\\";
+        }
         bool CalculateUnMeasuredFieldsCenters(out List<System.Windows.Point> a_listFieldCenter)
         {
             Debug.Assert(m_pSample == null);

+ 2 - 1
OTS/OTSModelSharp/Measure/GetParam/COTSProjMgrFile.cs

@@ -162,6 +162,7 @@ namespace OTSModelSharp
 
        public  void SetPathName(String a_strPathName) { m_strPathName = a_strPathName; }
 
+        public bool GetNewProjMgrClr() { return false; }
       public  bool Load()
         {
             // use dll resource
@@ -1679,7 +1680,7 @@ namespace OTSModelSharp
         }
 
         // remove background
-      public  bool RemoveBackGround(CBSEImg a_pImgIn, COTSImgProcPrm  a_pImgProcessParam, CBSEImg a_pImgOut)
+      public  bool RemoveBackGround(CBSEImg a_pImgIn, OTSDataType.COTSImgProcPrm  a_pImgProcessParam, CBSEImg a_pImgOut)
         {
            
             /*COTSFieldMgr fldMgr;

+ 2 - 0
OTS/OTSModelSharp/MeasureControl/IMeasureHardware.cs

@@ -11,6 +11,8 @@ namespace OTSIncAMeasureApp.OTSMeasureControl
    public  interface IMeasureHardware
     {
         bool ConnectHardware();
+
+        bool GetSEMWorkingDistanceFromHW(double a_dWorkingDistance);
         void DisconnectHardware();
         bool GetSEMDataGnrFromHw(ref  CSEMDataGnr sd);
 

+ 1 - 1
OTS/OTSModelSharp/OTSDataType/CBSEImg.cs

@@ -64,7 +64,7 @@ namespace OTSDataType
             Init();
         }
 
-        public bool GetImageDataPtr() { return false; }
+        public byte[] GetImageDataPtr() { return null; }
 
         public CBSEImg(Rectangle a_rectImage)                //CBSEImg::CBSEImg(CRect a_rectImage): m_pnImageData(NULL)
         {

+ 2 - 3
OTS/OTSModelSharp/OTSDataType/COTSSample.cs

@@ -176,6 +176,7 @@ public enum   OTS_SAMPLE_PROP_GRID_ITEM_GROUPS
             return true;
         }
 
+        public CDomain GetMsrArea() { return null; }
         public bool SetPropdoubleData(OTS_SAMPLE_PROP_GRID_ITEMS a_nId, double a_dValue)
         {
             switch (a_nId)
@@ -328,9 +329,7 @@ public enum   OTS_SAMPLE_PROP_GRID_ITEM_GROUPS
         }
 
         // measurement area
-        public Rectangle GetMsrArea() {
-            Rectangle rect = new Rectangle();
-            return rect; }
+       
         public void SetMsrArea(CDomain a_poMsrArea)
         {
             m_poMsrArea = a_poMsrArea;