From d007fd8d64ff33a1edb960fa33cf2312a955d933 Mon Sep 17 00:00:00 2001
From: wells.liu <wells.liu@broconcentric.com>
Date: 星期一, 06 七月 2020 14:02:46 +0800
Subject: [PATCH] 板卡底层优化
---
src/Bro.Device.GTSCard/GTSCardDriver.cs | 82 ++++++++++++++++++++++++++++------------
src/Bro.Common.Model/Model/MotionCardRelated.cs | 11 +----
2 files changed, 60 insertions(+), 33 deletions(-)
diff --git a/src/Bro.Common.Model/Model/MotionCardRelated.cs b/src/Bro.Common.Model/Model/MotionCardRelated.cs
index 757cb42..49c3321 100644
--- a/src/Bro.Common.Model/Model/MotionCardRelated.cs
+++ b/src/Bro.Common.Model/Model/MotionCardRelated.cs
@@ -208,11 +208,6 @@
public string AxisName { get; set; }
/// <summary>
- /// 杩愬姩妯″紡
- /// </summary>
- public MotionMode MoveMode { get; set; }
-
- /// <summary>
/// 褰撳墠浣嶇疆
/// </summary>
public int CurPosition { get; set; }
@@ -225,16 +220,16 @@
/// <summary>
/// 褰撳墠閫熷害鍙傛暟
/// </summary>
- public VelocityPara CurVelocityPara { get; set; }
+ public double CurVelocity { get; set; }
/// <summary>
/// 瑙勫垝閫熷害鍙傛暟
/// </summary>
- public VelocityPara VelocityPara { get; set; }
+ public double PrfVelocity { get; set; }
public string GetDisplayText()
{
- return $"杞磠AxisIndex}:{AxisName}-{MoveMode.ToString()}-褰撳墠锛歿CurPosition}-瑙勫垝锛歿Destination}";
+ return $"杞磠AxisIndex}:{AxisName}-褰撳墠锛歿CurPosition}-瑙勫垝锛歿Destination}";
}
}
diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs
index adba5c9..28e82b1 100644
--- a/src/Bro.Device.GTSCard/GTSCardDriver.cs
+++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -413,6 +413,41 @@
}
/// <summary>
+ /// 鑾峰彇瑙勫垝閫熷害
+ /// </summary>
+ /// <param name="axisNum">Axis number</param>
+ /// <returns></returns>
+ public double GetPrfVelocity(int axisNum)
+ {
+ double prfVel = 0;
+ uint pclock = 0;
+ var ret = GTSCardAPI.GT_GetPrfVel((short)IConfig.CardNum, (short)axisNum, out prfVel, 1, out pclock);
+ if (ret != (short)GTSRetCode.GRCRunOK)
+ {
+ throw new Exception("杞�" + axisNum + "鑾峰彇瑙勫垝閫熷害寮傚父锛岄敊璇爜锛�" + ret);
+ }
+ prfVel = prfVel / IConfig.AxisVelocityRatio;
+ return prfVel;
+ }
+
+ /// <summary>
+ /// 鑾峰彇褰撳墠閫熷害
+ /// </summary>
+ /// <param name="axisNum">Axis number</param>
+ /// <returns></returns>
+ public double GetVelocity(int axisNum)
+ {
+ double vel = 0;
+ var ret = GTSCardAPI.GT_GetVel((short)IConfig.CardNum, (short)axisNum, out vel);
+ if (ret != (short)GTSRetCode.GRCRunOK)
+ {
+ throw new Exception("杞�" + axisNum + "鑾峰彇褰撳墠閫熷害寮傚父锛岄敊璇爜锛�" + ret);
+ }
+ vel = vel / IConfig.AxisVelocityRatio;
+ return vel;
+ }
+
+ /// <summary>
/// Set Single Axis Do Jog Move
/// </summary>
/// <param name="axisNum">AxisNo</param>
@@ -450,29 +485,6 @@
OnExceptionRaised?.Invoke(ex);
return false;
}
-
- }
-
- /// <summary>
- /// Set Single Axis Do stop Jog Move
- /// </summary>
- /// <param name="axisNum">AxisNo</param>
- /// <returns></returns>
- public bool StopJog(int axisNum)
- {
- //鍋滄杩愬姩
- MoveStop(axisNum, 0);
- //杩愬姩寮�濮嬪悗 妫�鏌ヨ繍鍔ㄦ槸鍚﹀仠姝�
- bool isStop = false;
- int repeatTime = 1000;
- do
- {
- isStop = IsStop((short)IConfig.CardNum, (short)axisNum);
- Thread.Sleep(50);
- repeatTime--;
- } while (!isStop && repeatTime > 0);
-
- return isStop;
}
/// <summary>
@@ -803,7 +815,24 @@
#region IMonitor
- //public List<IOItem> MonitorValues { get; set; } = new List<IOItem>();
+ public List<AxisMovingStatus> GetAxisMovingStatus()
+ {
+ List<AxisMovingStatus> axisMovingStatusesList = new List<AxisMovingStatus>();
+ foreach (var axisConfig in IConfig.AxisSettings.FindAll(u => u.IsAxisEnabled))
+ {
+ AxisMovingStatus axisMovingStatus = new AxisMovingStatus();
+ axisMovingStatus.AxisIndex = axisConfig.AxisIndex;
+ axisMovingStatus.AxisName = axisConfig.AxisName;
+ axisMovingStatus.CurPosition = Convert.ToInt32(GetPosition(axisMovingStatus.AxisIndex));
+ axisMovingStatus.Destination = Convert.ToInt32(GetPrfPosition(axisMovingStatus.AxisIndex));
+ axisMovingStatus.CurVelocity = GetVelocity(axisMovingStatus.AxisIndex);
+ axisMovingStatus.PrfVelocity = GetPrfVelocity(axisMovingStatus.AxisIndex);
+ axisMovingStatusesList.Add(axisMovingStatus);
+
+ }
+
+ return axisMovingStatusesList;
+ }
public List<IOItem> GetMonitorValues()
@@ -849,7 +878,8 @@
if (!IConfig.IsEnableMonitor)
return;
var newValues = GetMonitorValues();
- if (newValues == null || newValues.Count == 0)
+ var newAxisMovingStatus = GetAxisMovingStatus();
+ if (newValues == null || newValues.Count == 0 || newAxisMovingStatus == null || newAxisMovingStatus.Count == 0)
continue;
Stopwatch sw = new Stopwatch();
@@ -860,6 +890,8 @@
var tempOld = MonitorValues.DeepSerializeClone();
MonitorCheckAndInvoke(tempNew, tempOld);
}
+
+ AxisMovingOptionValues = new List<AxisMovingStatus>(newAxisMovingStatus);
MonitorValues = new List<IOItem>(newValues);
sw.Stop();
--
Gitblit v1.8.0