Commit 2d0637f81664faa176b2bd9a55c4bc403ef2ee19

Authored by 唐召明
1 parent d6ce8986

完善数据解析功能

ApiControllers/BoardController.cs
... ... @@ -209,29 +209,41 @@ namespace DataAcquisitionServer.ApiControllers
209 209 {
210 210 AlarmRate = GetAlarmRate(context, robotEquipment),
211 211 AutoRate = GetAutoRate(context, robotEquipment),
212   - OnLineRate = Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == robotEquipment.Code && x.EquipmentPropertyCode == KukaProps.BootFlag.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / TimeSpan.FromHours(24).Ticks),
  212 + OnLineRate = GetOnLineRate(context, robotEquipment),
213 213 UtilizeRate = UtilizeRate(context, robotEquipment),
214 214 },
215 215 VoltagetList = Math.Round(weld_V, 1),
216 216 };
217 217  
218 218 //故障率
219   - int GetAlarmRate(DataContext context, Equipment kukaEquipment)
  219 + int GetAlarmRate(DataContext context, Equipment robotEquipment)
220 220 {
221 221 if (bootFalgTicks == 0) return 0;
222   - return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == kukaEquipment.Code && x.EquipmentPropertyCode == KukaProps.Alarm.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / bootFalgTicks);
  222 + return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == robotEquipment.Code && x.EquipmentPropertyCode == KukaProps.Alarm.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / bootFalgTicks);
223 223 }
224 224  
225   - int UtilizeRate(DataContext context, Equipment kukaEquipment)
  225 + int UtilizeRate(DataContext context, Equipment robotEquipment)
226 226 {
227 227 if (bootFalgTicks == 0) return 0;
228   - return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == kukaEquipment.Code && x.EquipmentPropertyCode == KukaProps.WorkFlag.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / bootFalgTicks);
  228 + return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == robotEquipment.Code && x.EquipmentPropertyCode == KukaProps.WorkFlag.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / bootFalgTicks);
229 229 }
230 230  
231   - int GetAutoRate(DataContext context, Equipment kukaEquipment)
  231 + int GetAutoRate(DataContext context, Equipment robotEquipment)
232 232 {
233 233 if (bootFalgTicks == 0) return 0;
234   - return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == kukaEquipment.Code && x.EquipmentPropertyCode == KukaProps.Work_Time.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / bootFalgTicks);
  234 + return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == robotEquipment.Code && x.EquipmentPropertyCode == KukaProps.Work_Time.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / bootFalgTicks);
  235 + }
  236 +
  237 + //在线率
  238 + int GetOnLineRate(DataContext context, Equipment robotEquipment)
  239 + {
  240 + var bootFlagStartDay = context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == robotEquipment.Code && x.EquipmentPropertyCode == KukaProps.BootFlag.ToString()).OrderBy(x => x.CreateTime).Select(x => x.CreateTime).FirstOrDefault();
  241 + if (bootFlagStartDay == default) return 0;
  242 + else if (bootFlagStartDay <= DateTime.Today.AddMonths(-1))
  243 + {
  244 + bootFlagStartDay = DateTime.Today.AddMonths(-1);
  245 + }
  246 + return Convert.ToInt32(context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == robotEquipment.Code && x.EquipmentPropertyCode == KukaProps.BootFlag.ToString()).Sum(x => x.UpdateTime.Ticks - x.CreateTime.Ticks) * 100 / (DateTime.Now - bootFlagStartDay).Ticks);
235 247 }
236 248  
237 249 result.Data = new
... ...
Common/Communications/KukaAvarProxyCommunication.cs
1   -using DataAcquisitionServer.Common.Utils;
  1 +using DataAcquisitionServer.Common.Enums;
  2 +using DataAcquisitionServer.Common.Utils;
2 3 using DataAcquisitionServer.Models;
3 4 using HslCommunication;
4 5 using HslCommunication.Robot.KUKA;
  6 +using System.Diagnostics;
5 7 using System.Text;
6 8  
7 9 namespace DataAcquisitionServer.Common.Communications
... ... @@ -35,19 +37,58 @@ namespace DataAcquisitionServer.Common.Communications
35 37 {
36 38 try
37 39 {
  40 + var stopwatch = Stopwatch.StartNew();
38 41 foreach (var item in equipmentProperties)
39 42 {
40   - var result = KukaAvar.Read(item.DataAddress);
41   - if (!result.IsSuccess)
  43 + var nodes = item.DataAddress?.Split(';');
  44 + if (item.Code == KukaProps.Work_Mode.ToString() && nodes!.Length > 1)
42 45 {
43   - item.Value = string.Empty;
44   - item.UpdateTime = DateTime.Now;
45   - systemLog.LogError($"读取Kuka机器人[{KukaAvar.IpAddress}]地址{item.DataAddress}数据失败:{result.Message}");
46   - return;
  46 + foreach (var node in nodes)
  47 + {
  48 + var nodeResult = KukaAvar.Read(node);
  49 + if (!nodeResult.IsSuccess)
  50 + {
  51 + systemLog.LogError($"读取Kuka机器人[{KukaAvar.IpAddress}]地址{item.DataAddress}数据失败:{nodeResult.Message}");
  52 + return;
  53 + }
  54 + _ = bool.TryParse(Encoding.Default.GetString(nodeResult.Content), out var val);
  55 + if (val)
  56 + {
  57 + item.Value = $"{Array.IndexOf(nodes, node) + 1}";
  58 + item.UpdateTime = DateTime.Now;
  59 + break;
  60 + }
  61 + }
  62 + }
  63 + else
  64 + {
  65 + var result = KukaAvar.Read(item.DataAddress);
  66 + if (!result.IsSuccess)
  67 + {
  68 + item.Value = string.Empty;
  69 + item.UpdateTime = DateTime.Now;
  70 + systemLog.LogError($"读取Kuka机器人[{KukaAvar.IpAddress}]地址{item.DataAddress}数据失败:{result.Message}");
  71 + return;
  72 + }
  73 + var val = Encoding.Default.GetString(result.Content);
  74 + if (item.Code == KukaProps.Weld_V.ToString())
  75 + {
  76 + _ = float.TryParse(val, out var v);
  77 + item.Value = v > 0 ? $"{v / 32767 * 107}" : "0";
  78 + }
  79 + else if (item.DataType == DataTypeConst.Bool)
  80 + {
  81 + item.Value = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(val.ToLower());
  82 + }
  83 + else
  84 + {
  85 + item.Value = val;
  86 + }
47 87 }
48   - item.Value = Encoding.Default.GetString(result.Content);
49 88 item.UpdateTime = DateTime.Now;
50 89 }
  90 + stopwatch.Stop();
  91 + systemLog.LogInfo($"读取Kuka变量[{equipmentProperties.FirstOrDefault()?.Equipment.CommunicationConfig?.IpAddress}]地址数量:{equipmentProperties.Count()},耗时:{stopwatch.Elapsed}");
51 92 }
52 93 catch (Exception ex)
53 94 {
... ... @@ -57,7 +98,7 @@ namespace DataAcquisitionServer.Common.Communications
57 98  
58 99 public void Read(EquipmentProperty equipmentProperty)
59 100 {
60   - Read(new List<EquipmentProperty> { equipmentProperty });
  101 + Read([equipmentProperty]);
61 102 }
62 103  
63 104 public void Write(IEnumerable<EquipmentProperty> equipmentProperties)
... ... @@ -82,7 +123,7 @@ namespace DataAcquisitionServer.Common.Communications
82 123  
83 124 public void Write(EquipmentProperty equipmentProperty)
84 125 {
85   - Write(new List<EquipmentProperty> { equipmentProperty });
  126 + Write([equipmentProperty]);
86 127 }
87 128 }
88 129 }
... ...
DataAccess/DataSeeding.cs
... ... @@ -230,7 +230,7 @@ namespace DataAcquisitionServer.DataAccess
230 230 DataAddress = "DB7101.70.3",
231 231 DataType= DataTypeConst.Bool,
232 232 Enable = true,
233   - Remark = "焊接程序完成,焊接程序开始清零;焊接结束时为TRUE;WCS统计当日产量;",
  233 + Remark = "焊接程序完成,焊接程序开始清零;焊接开始时为True,焊接结束时为False;WCS统计当日产量;",
234 234 CreateTime = DateTime.Now,
235 235 },
236 236 new EquipmentProperty
... ... @@ -510,7 +510,7 @@ namespace DataAcquisitionServer.DataAccess
510 510 DataAddress = "DB7101.130.3",
511 511 DataType= DataTypeConst.Bool,
512 512 Enable = true,
513   - Remark = "焊接程序完成,焊接程序开始清零;焊接结束时为TRUE;WCS统计当日产量;",
  513 + Remark = "焊接程序完成,焊接程序开始清零;焊接开始时为True,焊接结束时为False;WCS统计当日产量;",
514 514 CreateTime = DateTime.Now,
515 515 },
516 516 new EquipmentProperty
... ... @@ -666,7 +666,7 @@ namespace DataAcquisitionServer.DataAccess
666 666 EquipmentId = 4,
667 667 Code = KukaProps.Work_Mode.ToString(),
668 668 Name = "工作模式",
669   - DataAddress = KukaProps.Work_Mode.ToString(),
  669 + DataAddress = "$T1;$T2;$Aut;$Ext",
670 670 DataType= DataTypeConst.Int16,
671 671 Enable = true,
672 672 Remark = "1:T1模式,2:T2模式;3:自动模式;4:外部自动模式;WCS做状态显示,及做设备利用率计算;",
... ... @@ -699,7 +699,7 @@ namespace DataAcquisitionServer.DataAccess
699 699 EquipmentId = 4,
700 700 Code = KukaProps.Pos_X.ToString(),
701 701 Name = "X轴位置",
702   - DataAddress = KukaProps.Pos_X.ToString(),
  702 + DataAddress = "$Pos_Act.X",
703 703 DataType= DataTypeConst.Real,
704 704 Enable = true,
705 705 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -710,7 +710,7 @@ namespace DataAcquisitionServer.DataAccess
710 710 EquipmentId = 4,
711 711 Code = KukaProps.Pos_Y.ToString(),
712 712 Name = "Y轴位置",
713   - DataAddress = KukaProps.Pos_Y.ToString(),
  713 + DataAddress = "$Pos_Act.Y",
714 714 DataType= DataTypeConst.Real,
715 715 Enable = true,
716 716 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -721,7 +721,7 @@ namespace DataAcquisitionServer.DataAccess
721 721 EquipmentId = 4,
722 722 Code = KukaProps.Pos_Z.ToString(),
723 723 Name = "Z轴位置",
724   - DataAddress = KukaProps.Pos_Z.ToString(),
  724 + DataAddress = "$Pos_Act.Z",
725 725 DataType= DataTypeConst.Real,
726 726 Enable = true,
727 727 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -732,7 +732,7 @@ namespace DataAcquisitionServer.DataAccess
732 732 EquipmentId = 4,
733 733 Code = KukaProps.Pos_A.ToString(),
734 734 Name = "A轴位置",
735   - DataAddress = KukaProps.Pos_A.ToString(),
  735 + DataAddress = "$Pos_Act.A",
736 736 DataType= DataTypeConst.Real,
737 737 Enable = true,
738 738 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -743,7 +743,7 @@ namespace DataAcquisitionServer.DataAccess
743 743 EquipmentId = 4,
744 744 Code = KukaProps.Pos_B.ToString(),
745 745 Name = "B轴位置",
746   - DataAddress = KukaProps.Pos_B.ToString(),
  746 + DataAddress = "$Pos_Act.B",
747 747 DataType= DataTypeConst.Real,
748 748 Enable = true,
749 749 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -754,7 +754,7 @@ namespace DataAcquisitionServer.DataAccess
754 754 EquipmentId = 4,
755 755 Code = KukaProps.Pos_C.ToString(),
756 756 Name = "C轴位置",
757   - DataAddress = KukaProps.Pos_C.ToString(),
  757 + DataAddress = "$Pos_Act.C",
758 758 DataType= DataTypeConst.Real,
759 759 Enable = true,
760 760 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -765,7 +765,7 @@ namespace DataAcquisitionServer.DataAccess
765 765 EquipmentId = 4,
766 766 Code = KukaProps.Pos_E1.ToString(),
767 767 Name = "E1轴位置",
768   - DataAddress = KukaProps.Pos_E1.ToString(),
  768 + DataAddress = "$Pos_Act.E1",
769 769 DataType= DataTypeConst.Real,
770 770 Enable = true,
771 771 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -776,7 +776,7 @@ namespace DataAcquisitionServer.DataAccess
776 776 EquipmentId = 4,
777 777 Code = KukaProps.Pos_E2.ToString(),
778 778 Name = "E2轴位置",
779   - DataAddress = KukaProps.Pos_E2.ToString(),
  779 + DataAddress = "$Pos_Act.E2",
780 780 DataType= DataTypeConst.Real,
781 781 Enable = true,
782 782 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -787,7 +787,7 @@ namespace DataAcquisitionServer.DataAccess
787 787 EquipmentId = 4,
788 788 Code = KukaProps.Pos_E3.ToString(),
789 789 Name = "E3轴位置",
790   - DataAddress = KukaProps.Pos_E3.ToString(),
  790 + DataAddress = "$Pos_Act.E3",
791 791 DataType= DataTypeConst.Real,
792 792 Enable = true,
793 793 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -798,7 +798,7 @@ namespace DataAcquisitionServer.DataAccess
798 798 EquipmentId = 4,
799 799 Code = KukaProps.Pos_E4.ToString(),
800 800 Name = "E4轴位置",
801   - DataAddress = KukaProps.Pos_E4.ToString(),
  801 + DataAddress = "$Pos_Act.E4",
802 802 DataType= DataTypeConst.Real,
803 803 Enable = true,
804 804 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -845,7 +845,7 @@ namespace DataAcquisitionServer.DataAccess
845 845 DataAddress = KukaProps.WeldCompleteFlag.ToString(),
846 846 DataType= DataTypeConst.Bool,
847 847 Enable = true,
848   - Remark = "焊接程序完成,焊接程序开始清零;焊接结束时为TRUE;WCS统计当日产量;",
  848 + Remark = "焊接程序完成,焊接程序开始清零;焊接开始时为True,焊接结束时为False;WCS统计当日产量;",
849 849 CreateTime = DateTime.Now,
850 850 },
851 851 new EquipmentProperty
... ... @@ -1085,7 +1085,7 @@ namespace DataAcquisitionServer.DataAccess
1085 1085 EquipmentId = 5,
1086 1086 Code = KukaProps.Pos_C.ToString(),
1087 1087 Name = "C轴位置",
1088   - DataAddress = "DB7102.56.0",
  1088 + DataAddress = "DB7102.46.0",
1089 1089 DataType= DataTypeConst.Real,
1090 1090 Enable = true,
1091 1091 Remark = "机器人本体世界坐标值_[Write]",
... ... @@ -1176,7 +1176,7 @@ namespace DataAcquisitionServer.DataAccess
1176 1176 DataAddress = "DB7102.66.3",
1177 1177 DataType= DataTypeConst.Bool,
1178 1178 Enable = true,
1179   - Remark = "焊接程序完成,焊接程序开始清零;焊接结束时为TRUE;[Write]",
  1179 + Remark = "焊接程序完成,焊接程序开始清零;焊接开始时为True,焊接结束时为False;[Write]",
1180 1180 CreateTime = DateTime.Now,
1181 1181 },
1182 1182 new EquipmentProperty
... ... @@ -1272,7 +1272,7 @@ namespace DataAcquisitionServer.DataAccess
1272 1272 EquipmentId = 6,
1273 1273 Code = KukaProps.Work_Mode.ToString(),
1274 1274 Name = "工作模式",
1275   - DataAddress = KukaProps.Work_Mode.ToString(),
  1275 + DataAddress = "$T1;$T2;$Aut;$Ext",
1276 1276 DataType= DataTypeConst.Int16,
1277 1277 Enable = true,
1278 1278 Remark = "1:T1模式,2:T2模式;3:自动模式;4:外部自动模式;WCS做状态显示,及做设备利用率计算;",
... ... @@ -1305,7 +1305,7 @@ namespace DataAcquisitionServer.DataAccess
1305 1305 EquipmentId = 6,
1306 1306 Code = KukaProps.Pos_X.ToString(),
1307 1307 Name = "X轴位置",
1308   - DataAddress = KukaProps.Pos_X.ToString(),
  1308 + DataAddress = "$Pos_Act.X",
1309 1309 DataType= DataTypeConst.Real,
1310 1310 Enable = true,
1311 1311 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1316,7 +1316,7 @@ namespace DataAcquisitionServer.DataAccess
1316 1316 EquipmentId = 6,
1317 1317 Code = KukaProps.Pos_Y.ToString(),
1318 1318 Name = "Y轴位置",
1319   - DataAddress = KukaProps.Pos_Y.ToString(),
  1319 + DataAddress = "$Pos_Act.Y",
1320 1320 DataType= DataTypeConst.Real,
1321 1321 Enable = true,
1322 1322 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1327,7 +1327,7 @@ namespace DataAcquisitionServer.DataAccess
1327 1327 EquipmentId = 6,
1328 1328 Code = KukaProps.Pos_Z.ToString(),
1329 1329 Name = "Z轴位置",
1330   - DataAddress = KukaProps.Pos_Z.ToString(),
  1330 + DataAddress = "$Pos_Act.Z",
1331 1331 DataType= DataTypeConst.Real,
1332 1332 Enable = true,
1333 1333 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1338,7 +1338,7 @@ namespace DataAcquisitionServer.DataAccess
1338 1338 EquipmentId = 6,
1339 1339 Code = KukaProps.Pos_A.ToString(),
1340 1340 Name = "A轴位置",
1341   - DataAddress = KukaProps.Pos_A.ToString(),
  1341 + DataAddress = "$Pos_Act.A",
1342 1342 DataType= DataTypeConst.Real,
1343 1343 Enable = true,
1344 1344 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1349,7 +1349,7 @@ namespace DataAcquisitionServer.DataAccess
1349 1349 EquipmentId = 6,
1350 1350 Code = KukaProps.Pos_B.ToString(),
1351 1351 Name = "B轴位置",
1352   - DataAddress = KukaProps.Pos_B.ToString(),
  1352 + DataAddress = "$Pos_Act.B",
1353 1353 DataType= DataTypeConst.Real,
1354 1354 Enable = true,
1355 1355 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1360,7 +1360,7 @@ namespace DataAcquisitionServer.DataAccess
1360 1360 EquipmentId = 6,
1361 1361 Code = KukaProps.Pos_C.ToString(),
1362 1362 Name = "C轴位置",
1363   - DataAddress = KukaProps.Pos_C.ToString(),
  1363 + DataAddress = "$Pos_Act.C",
1364 1364 DataType= DataTypeConst.Real,
1365 1365 Enable = true,
1366 1366 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1371,7 +1371,7 @@ namespace DataAcquisitionServer.DataAccess
1371 1371 EquipmentId = 6,
1372 1372 Code = KukaProps.Pos_E1.ToString(),
1373 1373 Name = "E1轴位置",
1374   - DataAddress = KukaProps.Pos_E1.ToString(),
  1374 + DataAddress = "$Pos_Act.E1",
1375 1375 DataType= DataTypeConst.Real,
1376 1376 Enable = true,
1377 1377 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1382,7 +1382,7 @@ namespace DataAcquisitionServer.DataAccess
1382 1382 EquipmentId = 6,
1383 1383 Code = KukaProps.Pos_E2.ToString(),
1384 1384 Name = "E2轴位置",
1385   - DataAddress = KukaProps.Pos_E2.ToString(),
  1385 + DataAddress = "$Pos_Act.E2",
1386 1386 DataType= DataTypeConst.Real,
1387 1387 Enable = true,
1388 1388 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1393,7 +1393,7 @@ namespace DataAcquisitionServer.DataAccess
1393 1393 EquipmentId = 6,
1394 1394 Code = KukaProps.Pos_E3.ToString(),
1395 1395 Name = "E3轴位置",
1396   - DataAddress = KukaProps.Pos_E3.ToString(),
  1396 + DataAddress = "$Pos_Act.E3",
1397 1397 DataType= DataTypeConst.Real,
1398 1398 Enable = true,
1399 1399 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1404,7 +1404,7 @@ namespace DataAcquisitionServer.DataAccess
1404 1404 EquipmentId = 6,
1405 1405 Code = KukaProps.Pos_E4.ToString(),
1406 1406 Name = "E4轴位置",
1407   - DataAddress = KukaProps.Pos_E4.ToString(),
  1407 + DataAddress = "$Pos_Act.E4",
1408 1408 DataType= DataTypeConst.Real,
1409 1409 Enable = true,
1410 1410 Remark = "读取机器人本体世界坐标值,WCS做数字孪生显示;",
... ... @@ -1451,7 +1451,7 @@ namespace DataAcquisitionServer.DataAccess
1451 1451 DataAddress = KukaProps.WeldCompleteFlag.ToString(),
1452 1452 DataType= DataTypeConst.Bool,
1453 1453 Enable = true,
1454   - Remark = "焊接程序完成,焊接程序开始清零;焊接结束时为TRUE;WCS统计当日产量;",
  1454 + Remark = "焊接程序完成,焊接程序开始清零;焊接开始时为True,焊接结束时为False;WCS统计当日产量;",
1455 1455 CreateTime = DateTime.Now,
1456 1456 },
1457 1457 new EquipmentProperty
... ... @@ -1691,7 +1691,7 @@ namespace DataAcquisitionServer.DataAccess
1691 1691 EquipmentId = 7,
1692 1692 Code = KukaProps.Pos_C.ToString(),
1693 1693 Name = "C轴位置",
1694   - DataAddress = "DB7102.56.0",
  1694 + DataAddress = "DB7102.46.0",
1695 1695 DataType= DataTypeConst.Real,
1696 1696 Enable = true,
1697 1697 Remark = "机器人本体世界坐标值_[Write]",
... ... @@ -1782,7 +1782,7 @@ namespace DataAcquisitionServer.DataAccess
1782 1782 DataAddress = "DB7102.66.3",
1783 1783 DataType= DataTypeConst.Bool,
1784 1784 Enable = true,
1785   - Remark = "焊接程序完成,焊接程序开始清零;焊接结束时为TRUE;[Write]",
  1785 + Remark = "焊接程序完成,焊接程序开始清零;焊接开始时为True,焊接结束时为False;[Write]",
1786 1786 CreateTime = DateTime.Now,
1787 1787 },
1788 1788 new EquipmentProperty
... ... @@ -1834,9 +1834,7 @@ namespace DataAcquisitionServer.DataAccess
1834 1834  
1835 1835 #endregion
1836 1836  
1837   -
1838 1837 #endregion
1839   -
1840 1838 };
1841 1839 var i = 1;
1842 1840 data.ForEach(x => x.Id = i++);
... ... @@ -2009,7 +2007,7 @@ namespace DataAcquisitionServer.DataAccess
2009 2007 CommunicationType = CommunicationTypeConst.KukaVarProxy,
2010 2008 EquipmentModel = EquipmentModelConst.Kuka_C2,
2011 2009 Enable = true,
2012   - IpAddress = "192.168.2.21",
  2010 + IpAddress = "192.168.0.10",
2013 2011 Port = 7000,
2014 2012 },
2015 2013 new CommunicationConfig
... ... @@ -2020,7 +2018,7 @@ namespace DataAcquisitionServer.DataAccess
2020 2018 CommunicationType = CommunicationTypeConst.KukaVarProxy,
2021 2019 EquipmentModel = EquipmentModelConst.Kuka_C2,
2022 2020 Enable = true,
2023   - IpAddress = "192.168.0.10",
  2021 + IpAddress = "192.168.0.20",
2024 2022 Port = 7000,
2025 2023 },
2026 2024 new CommunicationConfig
... ... @@ -2042,7 +2040,7 @@ namespace DataAcquisitionServer.DataAccess
2042 2040 CommunicationType = CommunicationTypeConst.SiemensS7,
2043 2041 EquipmentModel = EquipmentModelConst.Siemens_S1200,
2044 2042 Enable = true,
2045   - IpAddress = "192.168.2.21",
  2043 + IpAddress = "192.168.2.41",
2046 2044 Port = 102
2047 2045 },
2048 2046 new CommunicationConfig
... ... @@ -2052,8 +2050,8 @@ namespace DataAcquisitionServer.DataAccess
2052 2050 Name = "西门子S1200_S7通信",
2053 2051 CommunicationType = CommunicationTypeConst.SiemensS7,
2054 2052 EquipmentModel = EquipmentModelConst.Siemens_S1200,
2055   - Enable = false,
2056   - IpAddress = "192.168.2.31",
  2053 + Enable = true,
  2054 + IpAddress = "192.168.2.21",
2057 2055 Port = 102
2058 2056 },
2059 2057 new CommunicationConfig
... ...
DataAcquisitionServer.csproj
... ... @@ -19,9 +19,9 @@
19 19 <PackageReference Include="AntDesign.Charts" Version="0.5.1" />
20 20 <PackageReference Include="AntDesign.ProLayout" Version="0.17.3" />
21 21 <PackageReference Include="HslCommunication" Version="[7.0.1]" />
22   - <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
23   - <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
24   - <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
  22 + <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
  23 + <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
  24 + <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
25 25 <PrivateAssets>all</PrivateAssets>
26 26 <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27 27 </PackageReference>
... ... @@ -32,5 +32,5 @@
32 32 <ItemGroup>
33 33 <Folder Include="Document\" />
34 34 </ItemGroup>
35   -
  35 +
36 36 </Project>
... ...
Services/DataAnalysis/KukaDataAnalysis.cs
... ... @@ -26,7 +26,7 @@ namespace DataAcquisitionServer.Services.DataAnalysis
26 26 {
27 27 //结束当前设备所有记录
28 28 context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == item.Code && !x.IsEnd).ExecuteUpdate(x => x.SetProperty(p => p.IsEnd, true));
29   - return;
  29 + continue;
30 30 }
31 31  
32 32 var propCodes = new List<KukaProps>
... ... @@ -50,9 +50,13 @@ namespace DataAcquisitionServer.Services.DataAnalysis
50 50 var propCodes2 = new List<KukaProps>
51 51 {
52 52 KukaProps.Weld_Speed,//米/分钟
53   - KukaProps.Gas_Flow,//L/分钟
54 53 };
55 54  
  55 + if (item.Area == 1)
  56 + {
  57 + propCodes2.Add(KukaProps.Gas_Flow);//L/分钟
  58 + }
  59 +
56 60 foreach (var propCode in propCodes2)
57 61 {
58 62 var property = item[propCode.ToString()];
... ... @@ -153,7 +157,8 @@ namespace DataAcquisitionServer.Services.DataAnalysis
153 157  
154 158 #region 记录加工工件
155 159  
156   - if (prop.Code == KukaProps.Work_Time.ToString())
  160 + //True为开始焊接,False为焊接结束
  161 + if (prop.Code == KukaProps.WeldCompleteFlag.ToString())
157 162 {
158 163 if (propValue)
159 164 {
... ...
Services/DataAnalysis/KukaPLCDataAnalysis.cs
... ... @@ -31,6 +31,10 @@ namespace DataAcquisitionServer.Services.DataAnalysis
31 31  
32 32 if (2 <= plc!.Area && plc!.Area <= 3)
33 33 {
  34 + SaveGasFlowRecord(context, plc);
  35 +
  36 + #region 将Kuka C2数据写入PLC
  37 +
34 38 var equipmentPropertyCodes = new List<KukaProps>
35 39 {
36 40 KukaProps.Weld_V,
... ... @@ -70,6 +74,13 @@ namespace DataAcquisitionServer.Services.DataAnalysis
70 74 if (plcProp == null || robotProp == null) continue;
71 75 else if (string.IsNullOrWhiteSpace(robotProp.Value)) continue;
72 76 else if (robotProp.Value == plcProp.Value) continue;
  77 + //浮点数值一致则跳过
  78 + else if (robotProp.DataType == DataTypeConst.Real && plcProp.DataType == DataTypeConst.Real)
  79 + {
  80 + _ = float.TryParse(robotProp.Value, out var val1);
  81 + _ = float.TryParse(plcProp.Value, out var val2);
  82 + if (val1 == val2) continue;
  83 + }
73 84 propTemps.Add(new EquipmentProperty
74 85 {
75 86 Id = plcProp.Id,
... ... @@ -87,6 +98,8 @@ namespace DataAcquisitionServer.Services.DataAnalysis
87 98 {
88 99 communication?.Write(propTemps);
89 100 }
  101 +
  102 + #endregion
90 103 }
91 104 }
92 105  
... ... @@ -139,6 +152,47 @@ namespace DataAcquisitionServer.Services.DataAnalysis
139 152 }
140 153  
141 154 /// <summary>
  155 + /// 统计混合气体消耗
  156 + /// </summary>
  157 + /// <param name="context"></param>
  158 + /// <param name="plc"></param>
  159 + public void SaveGasFlowRecord(DataContext context, Equipment plc)
  160 + {
  161 + var gasFlowProp = plc[KukaProps.Gas_Flow.ToString()];
  162 + var startTime = DateTime.Today.AddHours(DateTime.Now.Hour);
  163 + var kukaEquipment = context.Equipments.Where(x => x.Area == plc.Area && x.EquipmentType == EquipmentTypeConst.Kuka).Select(x => new
  164 + {
  165 + x.Code,
  166 + x.Name,
  167 + }).FirstOrDefault();
  168 + if (kukaEquipment == null) return;
  169 + _ = float.TryParse(gasFlowProp.Value, out var gasVal);
  170 + if (gasVal <= 0) return;
  171 + var val = gasVal / 60;
  172 + var record = context.EquipmentPropertyRecords.Where(x => x.EquipmentCode == kukaEquipment.Code && x.EquipmentPropertyCode == KukaProps.Gas_Flow.ToString() && !x.IsEnd && x.CreateTime >= startTime).OrderBy(x => x.CreateTime).FirstOrDefault();
  173 + if (record != null)
  174 + {
  175 + _ = float.TryParse(record.Value, out var oldValue);
  176 + context.EquipmentPropertyRecords.Where(x => x.Id == record.Id).ExecuteUpdate(x => x.SetProperty(e => e.Value, (oldValue + val).ToString()).SetProperty(x => x.UpdateTime, DateTime.Now));
  177 + }
  178 + else
  179 + {
  180 + context.EquipmentPropertyRecords.Add(new EquipmentPropertyRecord
  181 + {
  182 + EquipmentCode = kukaEquipment.Code,
  183 + EquipmentName = kukaEquipment.Name,
  184 + EquipmentPropertyCode = gasFlowProp.Code,
  185 + EquipmentPropertyName = gasFlowProp.Name,
  186 + Value = val.ToString(),
  187 + IsEnd = false,
  188 + CreateTime = DateTime.Now,
  189 + UpdateTime = DateTime.Now,
  190 + });
  191 + context.SaveChanges();
  192 + }
  193 + }
  194 +
  195 + /// <summary>
142 196 /// 将焊丝消耗写入PLC
143 197 /// </summary>
144 198 /// <param name="context"></param>
... ...
No preview for this file type