终端一体化运控平台
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.
 
 
 

83 lines
3.8 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. 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. public void Init()
  17. {
  18. if (IsConnected)
  19. {
  20. ThreadManage.GetInstance().StartLong(new Action(() =>
  21. {
  22. var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(1);
  23. var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2);
  24. var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(3);
  25. if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
  26. {
  27. ActionManage.GetInstance.Send("西门子下发配方", res);
  28. res.Ask_For_Send_Bit = false;
  29. this.Siemens_PLC_S7.WriteClass<DL_Start_DB>(res, 1);
  30. }
  31. if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0]))
  32. {
  33. ActionManage.GetInstance.Send("AGV到工位1信号", res1);
  34. res1.Allow_AGV_Put[0] = false;
  35. this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
  36. }
  37. if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1]))
  38. {
  39. ActionManage.GetInstance.Send("AGV到工位2信号", res1);
  40. res1.Allow_AGV_Put[1] = false;
  41. this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
  42. }
  43. if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2]))
  44. {
  45. ActionManage.GetInstance.Send("AGV到工位3信号", res1);
  46. res1.Allow_AGV_Put[2] = false;
  47. this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
  48. }
  49. if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3]))
  50. {
  51. ActionManage.GetInstance.Send("AGV到工位4信号", res1);
  52. res1.Allow_AGV_Put[3] = false;
  53. this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
  54. }
  55. if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4]))
  56. {
  57. ActionManage.GetInstance.Send("AGV到工位5信号", res1);
  58. res1.Allow_AGV_Put[4] = false;
  59. this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
  60. }
  61. if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5]))
  62. {
  63. ActionManage.GetInstance.Send("AGV到工位6信号", res1);
  64. res1.Allow_AGV_Put[5] = false;
  65. this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
  66. }
  67. if (res2 != null && res2.Ask_For_Finish_PLC)
  68. {
  69. ActionManage.GetInstance.Send("配料完成信号确认完成");
  70. res2.Ask_For_Finish_PLC = false;
  71. this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(res2, 3);
  72. }
  73. Thread.Sleep(10);
  74. }), "监听服务数据");
  75. }
  76. }
  77. }
  78. }