终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

76 satır
3.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.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 DL_Status_DB DL_Status = new DL_Status_DB();
  17. bool a = false;
  18. public void Init()
  19. {
  20. if (IsConnected)
  21. {
  22. ThreadManage.GetInstance().StartLong(new Action(() =>
  23. {
  24. var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(2301);
  25. var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2331);
  26. var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(2361);
  27. var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
  28. if (res != null && res is DL_Start_DB start)
  29. {
  30. if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0)
  31. {
  32. GVL_BigStation.SiemensSendRecipeStatus = 1;
  33. this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true);
  34. }
  35. if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1)
  36. {
  37. GVL_BigStation.SiemensSendRecipeStatus = 2;
  38. ActionManage.GetInstance.Send("SiemensSendRecipe", start);
  39. this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false);
  40. }
  41. if (TTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 2)
  42. {
  43. GVL_BigStation.SiemensSendRecipeStatus = 3;
  44. GVL_BigStation.Order_Request = false;
  45. }
  46. }
  47. if (res1 != null && res1 is DL_Status_DB status)
  48. {
  49. DL_Status = status;
  50. }
  51. if (res2 != null && res2 is DL_Finish_DB finish)
  52. {
  53. if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC) && GVL_BigStation.SiemensSendRecipeStatus == 7)
  54. {
  55. finish.Order_No = "";
  56. finish.Product_Code = "";
  57. finish.job_No = 0;
  58. for (int i = 0; i < 20; i++)
  59. {
  60. finish.Material[i] = new UDT1();
  61. }
  62. GVL_BigStation.SiemensSendRecipeStatus = 0;
  63. finish.Ask_For_Finish = false;
  64. finish.ProcessTime = 0;
  65. this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(finish, 2361);
  66. }
  67. }
  68. Thread.Sleep(10);
  69. }), "监听服务数据");
  70. }
  71. }
  72. }
  73. }