终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

65 строки
2.3 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. namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
  9. {
  10. public class SiemensDeviceStatus
  11. {
  12. public ModbusTcp SiemensTcp = new ModbusTcp();
  13. public bool IsConnected => SiemensTcp.Connected;
  14. public string IpAddress => SiemensTcp.IPAdress;
  15. /// <summary>
  16. /// 配方接收信号复位
  17. /// </summary>
  18. public void RecipeSignReset()
  19. {
  20. this.SiemensTcp.Write(SiemensCommAddress.RecipeState, (ushort)0);
  21. }
  22. /// <summary>
  23. /// AGV到位信号复位
  24. /// </summary>
  25. public void AgvSignReset()
  26. {
  27. this.SiemensTcp.Write(SiemensCommAddress.TrayState, (ushort)0);
  28. }
  29. public void Init()
  30. {
  31. if (IsConnected)
  32. {
  33. ThreadManage.GetInstance().StartLong(new Action(() =>
  34. {
  35. var res = this.SiemensTcp.Read(SiemensCommAddress.RecipeState);
  36. if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
  37. {
  38. ActionManage.GetInstance.Send("西门子下发配方");
  39. RecipeSignReset();
  40. }
  41. var AgvState = this.SiemensTcp.Read(SiemensCommAddress.TrayState);
  42. if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
  43. {
  44. ActionManage.GetInstance.Send("AGV到位信号");
  45. AgvSignReset();
  46. }
  47. }),"监听服务数据");
  48. }
  49. }
  50. /// <summary>
  51. /// 配方配料完成信号
  52. /// </summary>
  53. /// <param name="TrayLocation"></param>
  54. /// <param name="recipeID"></param>
  55. private void DosingFinsih(int TrayLocation,int recipeID)
  56. {
  57. this.SiemensTcp.Write(SiemensCommAddress.TrayLocationNumToPLC, TrayLocation);
  58. this.SiemensTcp.Write(SiemensCommAddress.TrayStateToPLC, 1);
  59. this.SiemensTcp.Write(SiemensCommAddress.TrayRecipeIDToPLC, recipeID);
  60. }
  61. }
  62. }