终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

166 linhas
8.8 KiB

  1. using BPA.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. TaskManage.GetInstance.StartLong(new Action(() =>
  23. {
  24. if (IsConnected)
  25. {
  26. var res0 = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95);
  27. if (res0 != null && res0 is WindSend_Write WriteData)
  28. {
  29. GVL_SmallStation.GetInstance.WindSendDB95 = WriteData;
  30. }
  31. var res1 = this.Siemens_PLC_S7.ReadClass<WindSend_Read>(94);
  32. if (res1 != null && res1 is WindSend_Read readData)
  33. {
  34. GVL_SmallStation.GetInstance.WindSendDB94 = readData;
  35. GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = readData.HoodLiftInPlace;
  36. Siemens_PLC_S7.Write<bool>("DB95.DBX38.2", GVL_SmallStation.GetInstance.Station1HaveTray);//工站1有托盘
  37. switch (GVL_SmallStation.GetInstance.WindSendDosingStatus)
  38. {
  39. case 0:
  40. if (res1.IsAllowIssue)
  41. {
  42. GVL_SmallStation.GetInstance.WindSendDosingStatus = 1;
  43. }
  44. break;
  45. case 2:
  46. if (res1.RecipeReceiveFinish)
  47. {
  48. Siemens_PLC_S7.Write<bool>("DB95.DBX38.0", false);
  49. GVL_SmallStation.GetInstance.WindSendDosingStatus = 3;
  50. }
  51. break;
  52. case 3:
  53. if (readData.CurrentCompleteSign)
  54. {
  55. Siemens_PLC_S7.Write("DB95.DBX38.1", true);
  56. GVL_SmallStation.GetInstance.WindSendDosingStatus = 4;
  57. }
  58. break;
  59. case 4:
  60. if (!readData.CurrentCompleteSign)
  61. {
  62. Siemens_PLC_S7.Write("DB95.DBX38.1", false);
  63. GVL_SmallStation.GetInstance.WindSendDosingStatus = 5;
  64. }
  65. break;
  66. case 5:
  67. if (readData.HoodLiftInPlace && readData.DisChargeComple)
  68. {
  69. GVL_SmallStation.GetInstance.WindSendDosingComple = true;
  70. GVL_SmallStation.GetInstance.WindSendDosingStatus = 0;
  71. }
  72. break;
  73. //case 5:
  74. // if (TTrig.GetInstance("HoodLiftInPlaceSign").Start(readData.HoodLiftInPlace))
  75. // {
  76. // GVL_SmallStation.GetInstance.WindSendDosingStatus = 6;
  77. // }
  78. // break;
  79. //case 6:
  80. // if (RTrig.GetInstance("HoodLiftInPlaceSign").Start(readData.HoodLiftInPlace))
  81. // {
  82. // GVL_SmallStation.GetInstance.WindSendDosingStatus = 7;
  83. // }
  84. // break;
  85. //case 7:
  86. // GVL_SmallStation.GetInstance.WindSendDosingComple = true;
  87. // GVL_SmallStation.GetInstance.WindSendDosingStatus = 0;
  88. // break;
  89. default:
  90. break;
  91. }
  92. }
  93. //测试
  94. /*var res = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95);
  95. if (res != null && res is WindSend_Write write)
  96. {
  97. if (res1.SystemRunStatus == 1 && test)
  98. {
  99. test = false;
  100. write.RawMaterial1_SetWeight = 1.5f;
  101. write.RawMaterial2_SetWeight = 1.5f;
  102. write.RawMaterial3_SetWeight = 1.5f;
  103. write.RawMaterial4_SetWeight = 1.5f;
  104. write.RawMaterial5_SetWeight = 1.5f;
  105. write.TargetRecipeCode = "qwe123";
  106. write.Station1HaveSign = true;
  107. write.IsAllowDosing = true;
  108. Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
  109. }
  110. if (res1.RecipeReceiveFinish)
  111. {
  112. write.IsAllowDosing = false;
  113. Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
  114. }
  115. }
  116. if (res1 != null && res1 is WindSend_Read read)
  117. {
  118. if (RTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
  119. {
  120. Siemens_PLC_S7.Write("DB95.DBX38.1", true);
  121. }
  122. if (TTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
  123. {
  124. Siemens_PLC_S7.Write("DB95.DBX38.1", false);
  125. }
  126. }*/
  127. /*if (RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign))
  128. {
  129. ActionManage.GetInstance.Send("WindSendDosingFinish");
  130. }
  131. float weightAlarmStockBin1 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(0).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(0).LowerLimitWeightOffset;
  132. float weightAlarmStockBin2 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(1).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(1).LowerLimitWeightOffset;
  133. float weightAlarmStockBin3 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeightOffset;
  134. float weightAlarmStockBin4 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeightOffset;
  135. float weightAlarmStockBin5 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeightOffset;
  136. if (res.RawMaterial1_StockBinWeight < weightAlarmStockBin1)
  137. {
  138. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓1缺料!");
  139. }
  140. if (res.RawMaterial2_StockBinWeight < weightAlarmStockBin2)
  141. {
  142. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓2缺料!");
  143. }
  144. if (res.RawMaterial3_StockBinWeight < weightAlarmStockBin3)
  145. {
  146. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓3缺料!");
  147. }
  148. if (res.RawMaterial4_StockBinWeight < weightAlarmStockBin4)
  149. {
  150. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓4缺料!");
  151. }
  152. if (res.RawMaterial5_StockBinWeight < weightAlarmStockBin5)
  153. {
  154. NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓5缺料!");
  155. }
  156. Thread.Sleep(10);*/
  157. }
  158. Thread.Sleep(10);
  159. }),"监听粉料数据",true);
  160. }
  161. }
  162. }