Forráskód Böngészése

实现电镜控制的picosmart 接口,增加获取工作距离

zhongyongming 11 hónapja
szülő
commit
bdc91568bd

+ 4 - 2
OTSIncAMeasureApp/ServiceCenter/PicoSmart/PicoSartScanController.cs

@@ -113,14 +113,16 @@ namespace OTSMeasureApp.ServiceCenter
                 int waittime = get_scan_time();
                 if (m_api.GET_IMAGE_MSGDATA(ref image, waittime) == 1)
                 {
+                    
                     if (!image.Empty())
                     {
+                        Cv2.ImWrite("d:/sem.png", image);
                         Bitmap bitmap = image.ToBitmap();
                         using (MemoryStream stream = new MemoryStream())
                         {
                             bitmap.Save(stream, ImageFormat.Png);  // 你可以选择其它的格式,比如Jpeg  
                             ImageData = stream.ToArray();
-                            bse.SetImageData(ImageData, imageWidth, imageHeight);
+                            bse.SetImageData(ImageData, image.Cols, image.Rows);
                             NLog.LogManager.GetCurrentClassLogger().Info("End acquiring BSE image!");
                         }
                     }
@@ -176,7 +178,7 @@ namespace OTSMeasureApp.ServiceCenter
         bool IScanController.SetImageSize(int nWidth, int nHeight)
         {
             this.imageWidth = nWidth;
-            this.imageWidth = nHeight;
+            this.imageHeight = nHeight;
             return true;
         }
     }

+ 13 - 1
OTSIncAMeasureApp/ServiceCenter/PicoSmart/PicoSmartApi_cshape.cs

@@ -305,7 +305,7 @@ namespace OTSMeasureApp.ServiceCenter
         }
         public int GET_COLUMN_MSGDATA(ref GET_COLUMN_PARAMETERS_STRUCT_HUIHONG COLUMN_PARAMETERS, int iWaitMs)
         {
-
+            GET_COLUMN(0, 0);
             int result = GET_COLUMN_MSGDATA(m_api, ref COLUMN_PARAMETERS, iWaitMs);
             if(result == 1)
             {
@@ -325,6 +325,16 @@ namespace OTSMeasureApp.ServiceCenter
             }
             return false;
         }
+        public bool GetWorkingDistance(ref double a_distance)
+        {
+            GET_COLUMN_PARAMETERS_STRUCT_HUIHONG COLUMN_PARAMETERS = new GET_COLUMN_PARAMETERS_STRUCT_HUIHONG();
+            if (GET_COLUMN_MSGDATA(ref COLUMN_PARAMETERS, 150) == 1)
+            {
+                a_distance = COLUMN_PARAMETERS.dwWD;
+                return true;
+            }
+            return false;
+        }
         public bool GetSemBrightness(ref double a_dSemBrightness)
         {
             GET_COLUMN_PARAMETERS_STRUCT_HUIHONG COLUMN_PARAMETERS = new GET_COLUMN_PARAMETERS_STRUCT_HUIHONG();
@@ -388,6 +398,7 @@ namespace OTSMeasureApp.ServiceCenter
    
         public int GET_STAGE_MSGDATA(ref GET_STAGE_PARAMETERS_STRUCT STAGE_PARAMETERS, int iWaitMs)//硬件最小发送间隔默认为1秒
         {
+            GET_STAGE(m_api, 0, 0);
             int result= GET_STAGE_MSGDATA(m_api, ref STAGE_PARAMETERS, iWaitMs);
             if(result == 1)
             {
@@ -420,6 +431,7 @@ namespace OTSMeasureApp.ServiceCenter
         }
         public int GET_IMAGE_MSGDATA(ref Mat IMAGE, int iWaitMs)
         {
+          
             return GET_IMAGE_MSGDATA(m_api, IMAGE.CvPtr, iWaitMs);
         }
         public void GET_SCANMODE()

+ 1 - 1
OTSIncAMeasureApp/ServiceCenter/PicoSmart/PicoSmartSemController.cs

@@ -116,7 +116,7 @@ namespace OTSMeasureApp.ServiceCenter.PicoSmart
 
         public bool   GetWorkingDistance(ref double a_distance)
         {
-            return false;
+            return m_api.GetWorkingDistance(ref a_distance);
         }
 
         public bool   IsConnected()