徐孝锋 8 달 전
부모
커밋
9f727ff737

+ 1 - 1
TeamAAS-VM/Core/Management.cs

@@ -1310,7 +1310,7 @@ namespace TeamAAS_VP.Core
                             Int16 positionIndex = plc.ReadNode<Int16>(addressConfig.In_ProductNum.Address);
                             SendTaskMessage($"编号:{positionIndex}", MessageLevel.Info);
                             //获取当前锁付点
-                            var screwPoint = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex);
+                            var screwPoint = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex+1);
                             //获取当前的机器人点位
                             var robot = _robotService.GetAllRobots().FirstOrDefault();
                             var currentPosition = robot.GetRobotPos();

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

@@ -582,7 +582,7 @@ namespace TeamAAS_VP.Core.Robots
                     }
 
                     // 判断是否至少有一个轴在最近 Timeout 时间内发生过变化(即认为还在运动)
-                    bool anyAxisMovedRecently = actNodes.Any(node => (now - lastChange[node]).TotalMilliseconds <= Timeout);
+                    bool anyAxisMovedRecently = actNodes.Any(node => (now - lastChange[node]).TotalMilliseconds <= 2000);
 
                     // 如果没有任何轴在最近 Timeout 时间内发生变化,则认为出现停滞异常
                     if (!anyAxisMovedRecently && actNodes.Length > 0)

+ 21 - 9
TeamAAS-VM/Core/ScrewDriver/XYD_ScrewDriver.cs

@@ -449,7 +449,7 @@ namespace TeamAAS_VP.Core.ScrewDriver
                 int hour = ToInt16(data, 16);
                 int minute = ToInt16(data, 18);
                 int second = ToInt16(data, 20);
-                ResultDateTime = new DateTime(year, month, day, hour, minute, second);
+                //ResultDateTime = new DateTime(year, month, day, hour, minute, second);
 
                 ProgramNumber = ToInt16(data, 22);
                 // 设备返回的总圈数字段以度为单位,转换为圈
@@ -594,11 +594,15 @@ namespace TeamAAS_VP.Core.ScrewDriver
         /// <returns>解析出的 short 值,出错返回 0</returns>
         private short ToInt16(byte[] value, int startIndex)
         {
-            if (value == null || startIndex < 0 || startIndex + 1 >= value.Length)
+            if (value == null)
+            {
                 return 0;
+            }
 
-            // data is DCBA style (little-endian word swapped)
-            return (short)((value[startIndex + 1] << 8) | value[startIndex]);
+            byte[] data = new byte[2];
+            data[0] = value[startIndex + 1];
+            data[1] = value[startIndex];
+            return BitConverter.ToInt16(data, 0);
         }
 
         /// <summary>
@@ -610,11 +614,19 @@ namespace TeamAAS_VP.Core.ScrewDriver
         /// <returns>解析出的 int 值,出错返回 0</returns>
         private int ToInt32N(byte[] value, int startIndex)
         {
-            if (value == null || startIndex < 0 || startIndex + 3 >= value.Length)
-                return 0;
-
-            // DCBA order -> 构造 32 位整数(高位在后面的索引)
-            return (value[startIndex + 3] << 24) | (value[startIndex + 2] << 16) | (value[startIndex + 1] << 8) | value[startIndex];
+            if (false)
+            {
+                return BitConverter.ToInt32(value, startIndex);
+            }
+            else
+            {
+                byte[] data = new byte[4];
+                data[0] = value[startIndex + 3];
+                data[1] = value[startIndex + 2];
+                data[2] = value[startIndex + 1];
+                data[3] = value[startIndex];
+                return BitConverter.ToInt32(data, 0);
+            }
         }
 
         /// <summary>

+ 1 - 1
TeamAAS-VM/Models/PLC/PlcAddressConfig.cs

@@ -822,7 +822,7 @@ namespace TeamAAS_VP.Models.PLC
             In_WorkDone.Description = "锁附/组装结束 =1OK =2NG";
 
             In_PressureValue = Ensure(In_PressureValue);
-            In_PressureValue.Address = "ns=4;s=DB_Communication|ToPC.PressureValue";
+            In_PressureValue.Address = "ns=4;s=DB_DriveControl|AICtrl[1].Status.UserData";
             In_PressureValue.DataType = "float";
             In_PressureValue.Description = "压力值";
 

+ 4 - 0
TeamAAS-VM/ViewModels/HomeViewModel.cs

@@ -381,6 +381,7 @@ namespace TeamAAS_VP.ViewModels
             // 设置X轴
             var xAxis = new LinearAxis
             {
+                Key="X",
                 Position = AxisPosition.Bottom,
                 Title = "角度 (°)",
                 Minimum = 0,
@@ -391,6 +392,7 @@ namespace TeamAAS_VP.ViewModels
             // 设置Y轴
             var yAxis = new LinearAxis
             {
+                Key = "Y",
                 Position = AxisPosition.Left,
                 Title = "力矩 (kgf)",
                 MajorGridlineStyle = LineStyle.Solid,
@@ -427,6 +429,8 @@ namespace TeamAAS_VP.ViewModels
             //更新曲线图
             App.Current.Dispatcher.BeginInvoke(new Action(() => {
                 var series = LockCurvePlotModel.Series[0] as LineSeries;
+                //var yaxis = LockCurvePlotModel.Axes.FirstOrDefault(p=>p.Key=="Y");
+                //yaxis.Maximum = result.TargetTorque;
                 series.Points.Clear();
                 foreach (var waveData in result.WaveDatas)
                 {

+ 5 - 5
TeamAAS-VM/Views/HomeView.xaml

@@ -102,11 +102,11 @@
                                                     Width="auto"
                                                     IsReadOnly="True" />
                                 <DataGridTextColumn Header="锁付圈数"
-                                                    Binding="{Binding LockTurns}"
+                                                    Binding="{Binding LockTurns, StringFormat={}{0:F1}}"
                                                     Width="auto"
                                                     IsReadOnly="True" />
                                 <DataGridTextColumn Header="锁付扭矩"
-                                                    Binding="{Binding LockTorque}"
+                                                    Binding="{Binding LockTorque, StringFormat={}{0:F3}}"
                                                     Width="auto"
                                                     IsReadOnly="True" />
                                 <DataGridTemplateColumn Header="锁付结果"
@@ -127,7 +127,7 @@
                                                            FontWeight="Bold" />
                                             </Border>
                                             <DataTemplate.Triggers>
-                                                <DataTrigger Binding="{Binding LockPassed}"
+                                                <DataTrigger Binding="{Binding LockPassed, StringFormat={}{0:F3}}"
                                                              Value="True">
                                                     <Setter TargetName="bd"
                                                             Property="Background"
@@ -136,7 +136,7 @@
                                                             Property="Text"
                                                             Value="OK" />
                                                 </DataTrigger>
-                                                <DataTrigger Binding="{Binding LockPassed}"
+                                                <DataTrigger Binding="{Binding LockPassed, StringFormat={}{0:F3}}"
                                                              Value="False">
                                                     <Setter TargetName="bd"
                                                             Property="Background"
@@ -150,7 +150,7 @@
                                     </DataGridTemplateColumn.CellTemplate>
                                 </DataGridTemplateColumn>
                                 <DataGridTextColumn Header="详情"
-                                                    Binding="{Binding Detail}"
+                                                    Binding="{Binding ResultDetails}"
                                                     Width="auto"
                                                     IsReadOnly="True" />
                             </DataGrid.Columns>