终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

116 rader
6.2 KiB

  1. using BPASmartClient.Helper;
  2. using BPASmartClient.Modbus;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using BPASmartClient.S7Net;
  9. using System.Threading;
  10. using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
  11. using BPASmartClient.CustomResource.UserControls.MessageShow;
  12. using BPASmartClient.CustomResource.UserControls;
  13. namespace BPASmartClient.JXJFoodSmallStation.Model
  14. {
  15. public class WindSendDeviceStatus
  16. {
  17. public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
  18. public bool IsConnected => Siemens_PLC_S7.IsConnected;
  19. public bool test;
  20. public void Init()
  21. {
  22. ThreadManage.GetInstance().StartLong(new Action(() =>
  23. {
  24. if (IsConnected)
  25. {
  26. var res1 = this.Siemens_PLC_S7.ReadClass<WindSend_Read>(94);
  27. if (res1 != null && res1 is WindSend_Read readData)
  28. {
  29. GVL_SmallStation.WindSendAllowAGVPutGet = readData.HoodLiftInPlace;
  30. Siemens_PLC_S7.Write<bool>("DB95.DBX38.2", GVL_SmallStation.Station1HaveTray);//工站1有托盘
  31. if (res1.RecipeReceiveFinish)
  32. {
  33. Siemens_PLC_S7.Write<bool>("DB95.DBX38.0", false);
  34. }
  35. if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign))
  36. {
  37. GVL_SmallStation.WindSendDosingComple = true;
  38. Siemens_PLC_S7.Write("DB95.DBX38.1", true);
  39. }
  40. if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign))
  41. {
  42. Siemens_PLC_S7.Write("DB95.DBX38.1", false);
  43. }
  44. }
  45. //测试
  46. /*var res = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95);
  47. if (res != null && res is WindSend_Write write)
  48. {
  49. if (res1.SystemRunStatus == 1 && test)
  50. {
  51. test = false;
  52. write.RawMaterial1_SetWeight = 1.5f;
  53. write.RawMaterial2_SetWeight = 1.5f;
  54. write.RawMaterial3_SetWeight = 1.5f;
  55. write.RawMaterial4_SetWeight = 1.5f;
  56. write.RawMaterial5_SetWeight = 1.5f;
  57. write.TargetRecipeCode = "qwe123";
  58. write.Station1HaveSign = true;
  59. write.IsAllowDosing = true;
  60. Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
  61. }
  62. if (res1.RecipeReceiveFinish)
  63. {
  64. write.IsAllowDosing = false;
  65. Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
  66. }
  67. }
  68. if (res1 != null && res1 is WindSend_Read read)
  69. {
  70. if (RTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
  71. {
  72. Siemens_PLC_S7.Write("DB95.DBX38.1", true);
  73. }
  74. if (TTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
  75. {
  76. Siemens_PLC_S7.Write("DB95.DBX38.1", false);
  77. }
  78. }*/
  79. /*if (RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign))
  80. {
  81. ActionManage.GetInstance.Send("WindSendDosingFinish");
  82. }
  83. float weightAlarmStockBin1 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(0).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(0).LowerLimitWeightOffset;
  84. float weightAlarmStockBin2 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(1).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(1).LowerLimitWeightOffset;
  85. float weightAlarmStockBin3 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeightOffset;
  86. float weightAlarmStockBin4 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeightOffset;
  87. float weightAlarmStockBin5 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeightOffset;
  88. if (res.RawMaterial1_StockBinWeight < weightAlarmStockBin1)
  89. {
  90. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓1缺料!");
  91. }
  92. if (res.RawMaterial2_StockBinWeight < weightAlarmStockBin2)
  93. {
  94. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓2缺料!");
  95. }
  96. if (res.RawMaterial3_StockBinWeight < weightAlarmStockBin3)
  97. {
  98. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓3缺料!");
  99. }
  100. if (res.RawMaterial4_StockBinWeight < weightAlarmStockBin4)
  101. {
  102. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓4缺料!");
  103. }
  104. if (res.RawMaterial5_StockBinWeight < weightAlarmStockBin5)
  105. {
  106. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓5缺料!");
  107. }
  108. Thread.Sleep(10);*/
  109. }
  110. }),"监听粉料数据",true);
  111. }
  112. }
  113. }