From fccc60d8897642ef5c39176b8c872b63fe819ae2 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期五, 20 十一月 2020 10:44:57 +0800
Subject: [PATCH] gocator添加int4类型数据,暂时注释

---
 src/Bro.Device.GTSCard/GTSCardDriver.cs |   31 +++++++++++++++++++++++--------
 src/Bro.Device.Gocator/GocatorDriver.cs |   22 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs
index d0c3dff..dbea577 100644
--- a/src/Bro.Device.GTSCard/GTSCardDriver.cs
+++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -526,7 +526,7 @@
         /// <returns></returns>
         public double GetPosition(int axisNum)
         {
-            lock (moveLock)
+            //lock (moveLock)
             {
                 double position = 0;
                 double pPos = 0;
@@ -891,6 +891,8 @@
         {
             try
             {
+                Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
+
                 var goHomePara = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex).GoHomePara;
                 bool homeDirection = goHomePara.IsHomeDirPositive;
                 bool isRightLimitReached = false;
@@ -914,6 +916,8 @@
                     PositionReset(movingOption.AxisIndex, 1);
                     ClearStatus(movingOption.AxisIndex, 1);
 
+                    //LogAsync(DateTime.Now, $"{Name}浣嶇疆缃浂", "");
+
                     if (goHomePara.IsCaptureMode)
                     {
                         //鎼滅储璺濈 闃舵1
@@ -922,7 +926,7 @@
                     }
 
                     // 璁剧疆鐐逛綅妯″紡鐩爣浣嶇疆锛屽嵆鍘熺偣鎼滅储璺濈
-                    sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, homeDirection ? 99999999 : -99999999);
+                    sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, homeDirection ? 999999999 : -999999999);
                     // 鍚姩杩愬姩
                     sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
 
@@ -940,7 +944,7 @@
 
                     do
                     {
-                        Thread.Sleep(checkInterval * 2);
+                        Thread.Sleep(checkInterval);
 
                         if (goHomePara.IsCaptureMode)
                         {
@@ -950,11 +954,11 @@
                         else
                         {
                             GTSCardAPI.GT_GetDi((short)IConfig.CardNum, GTSCardAPI.MC_HOME, out int pValue);
-
                             capture = (short)((pValue & (1 << (movingOption.AxisIndex - 1))) == 0 ? 1 : 0);
+                            //LogAsync(DateTime.Now, $"鍘熺偣鐘舵�亄pValue}锛岃酱{movingOption.AxisIndex}鍘熺偣{capture}", "");
                         }
                         isStop = IsStop((short)movingOption.AxisIndex);
-                        repeatTime -= checkInterval * 2;
+                        repeatTime -= checkInterval;
                     } while (!(isStop || capture == 1 || repeatTime <= 0));
 
                     if (repeatTime <= 0)
@@ -965,11 +969,16 @@
 
                     var axisStatus = AxisStatusList.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex);
 
+                    //if (isStop)
+                    //{
+                    //    LogAsync(DateTime.Now, $"杞磠movingOption.AxisIndex}澶嶄綅涓仠姝�", $"Capture鐘舵�亄capture}");
+                    //}
+
                     if (isStop && capture != 1)
                     {
                         if (((axisStatus.AxisStatus & 0x20) != 0) || ((axisStatus.AxisStatus & 0x40) != 0))
                         {
-                            //movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1);
+                            capture = 0;
 
                             //姝i檺浣�
                             if ((axisStatus.AxisStatus & 0x20) != 0 && !goHomePara.IsCaptureDirPositive)
@@ -984,6 +993,8 @@
                             }
 
                             homeDirection = !homeDirection;
+
+                            LogAsync(DateTime.Now, $"杞磠movingOption.AxisIndex}鏋侀檺浣嶇疆鎹㈠悜", "");
                         }
 
                         ClearStatus(movingOption.AxisIndex, 1);
@@ -1018,14 +1029,18 @@
                             repeatTime--;
                         } while (!isStop && repeatTime > 0);
                         PositionReset(movingOption.AxisIndex, 1);
+                        LogAsync(DateTime.Now, $"杞磠movingOption.AxisIndex}澶嶄綅瀹屾垚锛屼綅缃竻闆�", "");
+
                         return (sRtn == (short)GTSRetCode.GRCRunOK) && isStop;
                     }
 
                 } while (!(capture == 1 && isRightLimitReached));
+
                 return false;
             }
             catch (Exception ex)
             {
+                LogAsync(DateTime.Now, $"{Name}鍥炲師鐐瑰紓甯�", ex.GetExceptionMessage());
                 AllMoveStop(true);
                 OnExceptionOccured?.Invoke(DateTime.Now, ex);
                 return false;
@@ -1099,7 +1114,7 @@
         /// <returns></returns>
         public override int GetAxisStatus(int axisNum)
         {
-            lock (moveLock)
+            //lock (moveLock)
             {
                 int sts = 0;
                 uint pclock = 0;
@@ -1122,7 +1137,7 @@
         /// <returns></returns>
         public override bool PositionReset(int startAxisIndex, int count)
         {
-            lock (moveLock)
+            //lock (moveLock)
             {
                 var rtn = GTSCardAPI.GT_ZeroPos((short)IConfig.CardNum, (short)startAxisIndex, (short)count);
                 return rtn == (short)GTSRetCode.GRCRunOK;
diff --git a/src/Bro.Device.Gocator/GocatorDriver.cs b/src/Bro.Device.Gocator/GocatorDriver.cs
index 15f801a..0d22a6f 100644
--- a/src/Bro.Device.Gocator/GocatorDriver.cs
+++ b/src/Bro.Device.Gocator/GocatorDriver.cs
@@ -90,9 +90,12 @@
                             long bufferSize = width * height;
                             IntPtr bufferPointer = surfaceMsg.Data;
 
+
                             float zoomFactor = (float)((double)surfaceMsg.YResolution / (double)surfaceMsg.XResolution);
                             int zoomHeight = (int)(zoomFactor * height);
+
                             IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 2);
+                            //IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 4);
 
                             //娌℃湁鎻掑�硷紝榛樿0
                             //Parallel.For(0, height, h =>
@@ -108,14 +111,33 @@
                                 CopyMemory((IntPtr)((long)zoomPtr + width * 2 * h), (IntPtr)((long)bufferPointer + width * 2 * originHeightIndex), width * 2);
                             });
 
+                            ////浣跨敤涓婁竴琛屽師鏈夋暟鎹�
+                            //Parallel.For(0, zoomHeight, h =>
+                            //{
+                            //    int originHeightIndex = (int)Math.Floor((double)height * h / (double)zoomHeight);
+
+                            //    byte[] rowBuffer = new byte[width * 4];
+                            //    Parallel.For(0, width, w =>
+                            //    {
+                            //        rowBuffer[w * 4 + 2] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2));
+                            //        rowBuffer[w * 4 + 3] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2 + 1));
+                            //    });
+
+                            //    Marshal.Copy(rowBuffer, 0, (IntPtr)((long)zoomPtr + width * 2 * h), rowBuffer.Length);
+                            //});
+
                             if (imgSet != null)
                             {
                                 imgSet.HImage = new HImage();
                                 imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
 
+                                //imgSet.HImage.GenImage1("int4", (int)width, zoomHeight, zoomPtr);
+
                                 imgSet.HImage_2 = new HImage();
                                 imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
 
+                                //imgSet.HImage_2.GenImage1("int4", (int)width, zoomHeight, zoomPtr);
+
                                 LaserScanParam para = new LaserScanParam()
                                 {
                                     Resolution_X = surfaceMsg.XResolution,

--
Gitblit v1.8.0