Explorar o código

实现XYZ,标定时速度设置

徐孝锋 hai 8 meses
pai
achega
351aed0a1f
Modificáronse 1 ficheiros con 28 adicións e 1 borrados
  1. 28 1
      TeamAAS-VM/Core/Robots/XYZU_Robot.cs

+ 28 - 1
TeamAAS-VM/Core/Robots/XYZU_Robot.cs

@@ -397,7 +397,34 @@ namespace TeamAAS_VP.Core.Robots
             return false;
 
         }
-        public Task<bool> CalibParameAsync(PickInfo Pick, int Speed, int Accel, bool Power, int WaitSuction, int WaitBlow) => Task.FromResult(false);
+
+        public async Task<bool> CalibParameAsync(PickInfo Pick, int Speed, int Accel, bool Power, int WaitSuction, int WaitBlow)
+        {
+            if (Plc == null || !Plc.IsConnected) return false;
+            try
+            {
+                Dictionary<string, object> keyValues = new Dictionary<string, object>();
+                foreach (var axis in Axes)
+                {
+                    if (string.IsNullOrWhiteSpace(axis.Parameter.ManuVelocityNode)) continue;
+                    string nodeid = axis.Parameter.ManuVelocityNode;
+                    float value = Speed;
+                    
+                    keyValues.Add(nodeid, value);
+                }
+                // 2. 写入速度给所有轴
+                if (!Plc.WriteNodes(keyValues))
+                {
+                    return false;
+                }
+                return true;
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("为XYZU平台设置速度时出错!", ex);
+                return false;
+            }
+        }
 
         /// <summary>
         /// 阻塞式等待运动完成