From e69865a1a3739740201bac8782b721da35d49923 Mon Sep 17 00:00:00 2001
From: patrick.xu <patrick.xu@broconcentric.com>
Date: 星期一, 25 一月 2021 18:45:28 +0800
Subject: [PATCH] 1. gocator添加重试和清理缓存操作 2. gts板卡调整监听频率 3. 记录产品数据使用filsstream避免程序崩溃影响

---
 src/Bro.Device.GTSCard/GTSCardDriver.cs |   54 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs
index 303ddb4..a1c7aa6 100644
--- a/src/Bro.Device.GTSCard/GTSCardDriver.cs
+++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -312,7 +312,6 @@
             }
         }
 
-
         public override bool AllAxisOn()
         {
             List<Task<bool>> taskList = new List<Task<bool>>(); ;
@@ -387,7 +386,7 @@
                 responseMessage.Result = resultList.All(u => u == true);
                 if (!responseMessage.Result)
                 {
-                    responseMessage.Message = $"鐐逛綅杩愬姩寮傚父";
+                    responseMessage.Message = $"鐐逛綅杩愬姩寮傚父,杩愬姩缁撴灉锛歿string.Join(" ", resultList.Select(u => u ? "1" : "0"))}";
                 }
             }
             return responseMessage;
@@ -400,24 +399,28 @@
         /// <returns></returns>
         private bool SetAxisParam(MovingOption optionPara)
         {
-            List<short> resultCode = new List<short>() { 0 };
+            List<short> resultCode = new List<short>();
             GTSCardAPI.TTrapPrm trapprm = new GTSCardAPI.TTrapPrm();
             short axisIndex = short.Parse(optionPara.AxisIndexStr);
             resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, axisIndex));
-            resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm));
-            trapprm.smoothTime = 1;
 
-            if (optionPara.VelocityPara.Acc != 0)
+            if (optionPara.VelocityPara.Acc != 0 || optionPara.VelocityPara.Dec != 0)
             {
-                trapprm.acc = optionPara.VelocityPara.Acc;
-            }
+                resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm));
+                trapprm.smoothTime = 1;
 
-            if (optionPara.VelocityPara.Dec != 0)
-            {
-                trapprm.dec = optionPara.VelocityPara.Dec;
-            }
+                if (optionPara.VelocityPara.Acc != 0)
+                {
+                    trapprm.acc = optionPara.VelocityPara.Acc;
+                }
 
-            resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm));
+                if (optionPara.VelocityPara.Dec != 0)
+                {
+                    trapprm.dec = optionPara.VelocityPara.Dec;
+                }
+
+                resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm));
+            }
 
             if (optionPara.VelocityPara.Velocity != 0)
             {
@@ -427,9 +430,10 @@
             var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK);
             if (!resultOK)
             {
-                throw new ProcessException("杞�" + optionPara.AxisIndex + "璁剧疆鍙傛暟寮傚父锛岄敊璇爜锛�" + string.Join(",", resultCode));
+                //throw new ProcessException("杞�" + optionPara.AxisIndex + "璁剧疆鍙傛暟寮傚父锛岄敊璇爜锛�" + string.Join(",", resultCode));
+                LogAsync(DateTime.Now, $"杞磠optionPara.AxisIndex}璁剧疆鍙傛暟寮傚父锛岄敊璇爜锛歿string.Join(",", resultCode)}", "");
             }
-            return resultOK;
+            return true;
         }
 
         TaskFactory taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning);
@@ -765,7 +769,14 @@
                     repeatTime--;
                 }
 
-                return (ret == (short)GTSRetCode.GRCRunOK) && isStop;
+                if (repeatTime <= 0)
+                {
+                    LogAsync(DateTime.Now, "杞�" + optionPara.AxisIndex + "APS_absolute_move鏈仠姝�", "");
+                    return false;
+                }
+
+                //return (ret == (short)GTSRetCode.GRCRunOK) && isStop;
+                return true;
             }
             catch (Exception ex)
             {
@@ -1051,6 +1062,10 @@
                 OnExceptionOccured?.Invoke(DateTime.Now, ex);
                 return false;
             }
+            finally
+            { 
+            
+            }
         }
 
         /// <summary>
@@ -1230,7 +1245,9 @@
                             }
                         });
 
-                        _positionWait.SpinOnce();
+                        Task.Delay(100).Wait();
+
+                        //_positionWait.SpinOnce();
                     }
                     catch (Exception ex)
                     {
@@ -1267,7 +1284,8 @@
                             }
                         });
 
-                        _statusWait.SpinOnce();
+                        Thread.Sleep(10);
+                        //Task.Delay(10).Wait();
                     }
                     catch (Exception ex)
                     {

--
Gitblit v1.8.0