终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SiemensDeviceStatus.cs 2.8 KiB

2 years ago
2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
  11. {
  12. public class SiemensDeviceStatus
  13. {
  14. public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
  15. public bool IsConnected => Siemens_PLC_S7.IsConnected;
  16. bool a = false;
  17. public void Init()
  18. {
  19. if (IsConnected)
  20. {
  21. ThreadManage.GetInstance().StartLong(new Action(() =>
  22. {
  23. var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(2301);
  24. var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2331);
  25. var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(2361);
  26. var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
  27. if (res != null && res is DL_Start_DB start)
  28. {
  29. if (a)
  30. {
  31. start.RecipeName = "配方1";
  32. start.RecipeCode = "1201";
  33. start.Order_Request_Ack = true;
  34. for (int i = 0; i < GVL_BigStation.StockBinNum ; i++)
  35. {
  36. start.Material[i] = new UDT();
  37. start.Material[i].Material_Name = "" + (i +1);
  38. start.Material[i].Material_Weight = 100 + (i + 1);
  39. start.Material[i].Material_BarrelNum = (short)(i + 1);
  40. }
  41. }
  42. if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request))
  43. {
  44. start.Order_Request = true;
  45. Siemens_PLC_S7.WriteClass<DL_Start_DB>(start, 2301);
  46. }
  47. if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack))
  48. {
  49. ActionManage.GetInstance.Send("SiemensSendRecipe", start);
  50. }
  51. }
  52. if (res1 != null && res1 is DL_Status_DB status)
  53. {
  54. }
  55. if (res2 != null && res2.Ask_For_Finish_PLC)
  56. {
  57. ActionManage.GetInstance.Send("配料完成信号确认完成");
  58. res2.Ask_For_Finish_PLC = false;
  59. this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(res2, 3);
  60. }
  61. Thread.Sleep(10);
  62. }), "监听服务数据");
  63. }
  64. }
  65. }
  66. }