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

59 lines
2.4 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.JXJFoodSmallStation.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<XL_Start_DB>(1);
  23. var res1 = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2);
  24. var res2 = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(3);
  25. if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
  26. {
  27. ActionManage.GetInstance.Send("SiemensRecipeRecive", res);
  28. res.Ask_For_Send_Bit = false;
  29. this.Siemens_PLC_S7.WriteClass<XL_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<XL_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<XL_Status_DB>(res1, 2);
  42. }
  43. if (res2 != null && res2.Ask_For_Finish_PLC)
  44. {
  45. ActionManage.GetInstance.Send("配料完成信号确认完成");
  46. res2.Ask_For_Finish_PLC = false;
  47. this.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(res2, 3);
  48. }
  49. Thread.Sleep(10);
  50. }),"监听服务数据");
  51. }
  52. }
  53. }
  54. }