Просмотр исходного кода

optimize ExtenderWrapperIpc.cs function

gsp 1 год назад
Родитель
Сommit
45287d3a6d

+ 13 - 13
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CMeasure.cs

@@ -248,20 +248,21 @@ namespace OTSModelSharp
                 pSmplMeasure.DoMeasureForOneSample();
 
                 // check if measurement is successful
-                if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
-                {// record end time
-                    m_ThreadStatus.SetStatus(OTS_MSR_THREAD_STATUS.PAUSED);
-                    m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
+                //if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
+                //{// record end time
+                //    m_ThreadStatus.SetStatus(OTS_MSR_THREAD_STATUS.PAUSED);
+                //    m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
 
-                    // update thread measure status class, let the main thread know that this sample measurement stopped
-                    ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_ThreadStatus);
-                    MsgSmpStop.InitThreadPausedMsg();
-                    SendMessageToMeasureGUI(MsgSmpStop);
+                //    // update thread measure status class, let the main thread know that this sample measurement stopped
+                //    ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_ThreadStatus);
+                //    MsgSmpStop.InitThreadPausedMsg();
+                //    SendMessageToMeasureGUI(MsgSmpStop);
 
 
-                    ThreadOver();
-                    return;
-                }else if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.STOPPED)
+                //    ThreadOver();
+                //    return;
+                //}
+                if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.STOPPED)
                 {// record end time
                     m_ThreadStatus.SetStatus(OTS_MSR_THREAD_STATUS.STOPPED);
                     m_ThreadStatus.ComputeTime(OTS_THREAD_TIME_TYPE.STOPPED);
@@ -272,11 +273,10 @@ namespace OTSModelSharp
                     
                     SendMessageToMeasureGUI(MsgSmpStop);
 
-
                     ThreadOver();
                     break;
                 }
-			    else if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.FAILED)
+			     if (pSample.GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.FAILED)
 			    {
                     // measurement failed
                     m_ThreadStatus.SetStatus(OTS_MSR_THREAD_STATUS.FAILED);

+ 3 - 2
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CMeasureThreadWrapper.cs

@@ -56,6 +56,7 @@ namespace OTSMeasureApp
             m_OTSMeasureResult = new OTSMeasureDisplayResult(m_MeasureApp,m_bgWorker);
 
             m_measure = new CMeasure();
+
             m_measure.ProgressEvent += M_MsrThread_ProgressEvent;
             m_measure.HolePreviewEvent += M_measure_HolePreviewEvent;
 
@@ -327,13 +328,13 @@ namespace OTSMeasureApp
                     }
                     else if (MSTMsg.STMSampleStu.iMsrSampleStatu == OTSDataType.OTS_MSR_SAMPLE_STATUS.FAILED)
                     {
-                        //StopMeasure(MSTMsg);
+                        
                         log.Error("(OTSGetMreRetThread) MSTMsg.STMSampleStu.iMeasureSampleStatus = RET_MEASURE_SAMPLE_STATUS.FAILED Failed");
 
                     }
                     else if (MSTMsg.STMSampleStu.iMsrSampleStatu == OTSDataType.OTS_MSR_SAMPLE_STATUS.SUCCESSED)
                     {
-                        //StopMeasure(MSTMsg);
+                        log.Info("Sample measure succeeded");
                     }
                     else if(MSTMsg.STMSampleStu.iMsrSampleStatu == OTSDataType.OTS_MSR_SAMPLE_STATUS.PAUSED)
                     {

+ 1 - 0
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -788,6 +788,7 @@ namespace OTSModelSharp
                     Thread.Sleep(1000);
                     log.Warn("db saving!");
                 }
+
                 TheLastWorkOfSampleMeasure();
             }
     }

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

@@ -277,7 +277,7 @@ namespace OTSMeasureApp
                 }
                 //设置右键菜单中的项 是否可编辑
                 SetContextMenuEnabled(true);
-                GetAcquireBSEImage();
+                AcquireBSEImage();
 
            
            
@@ -289,7 +289,7 @@ namespace OTSMeasureApp
         /// <summary>
         /// 获取BSE图方法
         /// </summary>
-        private void GetAcquireBSEImage()
+        private void AcquireBSEImage()
         {
           
                 //获取电镜中图像大小
@@ -400,6 +400,7 @@ namespace OTSMeasureApp
 
             //电镜设置对象
             IScanController cfun = ScanController.GetScanController();
+            ISemController sem = SemController.GetSEMController();
                 //int GetImgCount = 0;
                 try
                 {
@@ -419,7 +420,7 @@ namespace OTSMeasureApp
                     var bse = cfun.AcquireBSEImage( );
                     bImageData = bse.GetImageDataPtr();
 
-
+                sem.SetScanExternal(false);
                 }
                 catch (Exception ex)
                 {

+ 8 - 43
OTSIncAMeasureApp/Program.cs

@@ -24,13 +24,13 @@ namespace OTSMeasureApp
             if (!System.Diagnostics.Debugger.IsAttached)
             {
                 //判断是否有授权
-                //var reg = new CRegistration();
-                //if (!reg.RegistrationVerification())
-                //{
-                //    MessageBox.Show("Error: missing authorization");
-                //    System.Environment.Exit(0);
-                //    return;
-                //}
+                var reg = new CRegistration();
+                if (!reg.RegistrationVerification())
+                {
+                    MessageBox.Show("Error: missing authorization");
+                    System.Environment.Exit(0);
+                    return;
+                }
             }
 
             //--------------------------只运行一个测量程序--------------------------------
@@ -52,42 +52,7 @@ namespace OTSMeasureApp
             Application.Run(new OTSIncAMeasureAppForm());
            
         }
-        //static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
-        //{
-        //    string dllname = args.Name.Split(',')[0];
-        //    string path;
-        //    if (dllname.Contains("OINA"))
-        //    {
-        //        if (dllname.Contains("resource"))
-        //        {
-        //            return null;
-
-        //        }
-        //        if (dllname.Contains("XmlSerialize"))
-        //        {
-        //            return null;
-
-        //        }
-        //        path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"OxfordExtender");
-
-
-        //}
-        //    else if (dllname.Contains("resource"))
-        //    {
-        //        return null;
-
-        //    }
-        //    else
-        //    {
-        //        path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"OTSCPPDll");
-
-        //    }
-        //    path = System.IO.Path.Combine(path, dllname);
-        //    path = String.Format(@"{0}.dll", path);
-
-        //    //if (path.Contains("CefSharp")) return null;
-        //    return System.Reflection.Assembly.LoadFrom(path);
-        //}
+        
 
     }
 }

+ 5 - 3
OTSIncAMeasureApp/ServiceCenter/OxfordExtender/ExtenderWrapperIpc.cs

@@ -33,7 +33,8 @@ namespace OTSMeasureApp.ServiceCenter.OxfordExtender
                     ChannelServices.RegisterChannel(channel, false);
                     extenderRemoteObj = (ExtenderIpcUI)Activator.GetObject(typeof(ExtenderIpcUI), "ipc://ExtenderServerChannel/ExtenderIpcUI");
 
-                    extenderRemoteObj.ConnectToEDSHardware();
+                    //extenderRemoteObj.ConnectToEDSHardware();
+                    return extenderRemoteObj;
                 }
                 else 
                 {
@@ -42,13 +43,14 @@ namespace OTSMeasureApp.ServiceCenter.OxfordExtender
                     ChannelServices.RegisterChannel(channel, false);
                     extenderRemoteObj = (ExtenderIpcUI)Activator.GetObject(typeof(ExtenderIpcUI), "ipc://ExtenderServerChannel/ExtenderIpcUI");
 
-                    extenderRemoteObj.ConnectToEDSHardware();
+                    //extenderRemoteObj.ConnectToEDSHardware();
+                    return extenderRemoteObj;
 
                 }
                
                 
             }
-            extenderRemoteObj.ConnectToEDSHardware();
+            extenderRemoteObj.ConnectToEDSHardware();//reconnect ,prevent the connection be closed by other reason accidentally.
             return extenderRemoteObj;
 
         }

+ 1 - 9
OTSIncAReportApp/Program.cs

@@ -72,15 +72,7 @@ namespace OTSIncAReportApp
             //if (path.Contains("CefSharp")) return null;
             return System.Reflection.Assembly.LoadFrom(path);
         }
-        //static System.Reflection.Assembly CurrentDomain_ResourcesAssemblyResolve(object sender, ResolveEventArgs args)
-        //{
-        //    string dllName = args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll", "");
-        //    dllName = dllName.Replace(".", "_");
-        //    if (dllName.EndsWith("_resources")) return null;
-        //    System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());
-        //    byte[] bytes = (byte[])rm.GetObject(dllName);
-        //    return System.Reflection.Assembly.Load(bytes);
-        //}
+      
 
     }
 }

+ 3 - 5
OxfordExtenderWrapper/ExtenderWrapper.cs

@@ -12,9 +12,7 @@ using OINA.Extender.Processing.Ed;
 using OINA.Extender.Processing.Quant;
 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;
@@ -777,9 +775,9 @@ namespace OxfordExtenderWrapper
             this.microscopeController.ChangeCompleted += this.OnMicroscopeChangeCompleted;
            
 
-            ReadMicroscopeColumn();
+            //ReadMicroscopeColumn();
 
-            ReadStage();
+            //ReadStage();
 
         }
 

+ 27 - 5
OxfordExtenderWrapper/OxfordExtenderWrapper.csproj

@@ -39,17 +39,37 @@
     <Prefer32Bit>true</Prefer32Bit>
   </PropertyGroup>
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <ItemGroup>
-    <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+  <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_oxford61|x64' ">
+    <Reference Include="OINA.Extender, Version=6.1.0.0, Culture=neutral, PublicKeyToken=5efad68c95e0364e, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\OpenDll\Nlog\NLog.dll</HintPath>
+      <HintPath>..\OpenDll\OxfordApi61Dll\OINA.Extender.dll</HintPath>
       <Private>False</Private>
     </Reference>
-    <Reference Include="OINA.Extender, Version=6.1.0.0, Culture=neutral, PublicKeyToken=5efad68c95e0364e, processorArchitecture=MSIL">
+  </ItemGroup>
+  <ItemGroup  Condition=" '$(Configuration)|$(Platform)' == 'Release_oxford60|x64' ">
+
+    <Reference  Include="OINA.Extender, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5efad68c95e0364e, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\OpenDll\OxfordApi60Dll\OINA.Extender.dll</HintPath>
       <Private>False</Private>
     </Reference>
+  </ItemGroup>
+  <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_oxford50|x64' ">
+
+    <Reference Include="OINA.Extender, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5efad68c95e0364e, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\OpenDll\OxfordApi50Dll\OINA.Extender.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+  </ItemGroup>
+
+  <ItemGroup>
+    <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\OpenDll\Nlog\NLog.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+   
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Drawing" />
@@ -88,7 +108,9 @@
     </Compile>
   </ItemGroup>
   <ItemGroup>
-    <None Include="app.config" />
+    <None Include="app.config">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Form1.resx">

+ 2 - 1
OxfordExtenderWrapper/app.config

@@ -5,7 +5,8 @@
   
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-
+      
+    
 
       <dependentAssembly>
         <assemblyIdentity name="SQLitePCLRaw.core" publicKeyToken="1488e028ca7ab535" culture="neutral" />