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

75 lines
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.JXJFoodSmallStation.Model.HK_PLC
  9. {
  10. public class HKDeviceStatus
  11. {
  12. public ModbusTcp ModBusHK = new ModbusTcp();
  13. public string IpAddress => ModBusHK.IPAdress;
  14. public bool IsConnected => ModBusHK.Connected;
  15. public void Init()
  16. {
  17. if (IsConnected)
  18. {
  19. ThreadManage.GetInstance().StartLong(new Action(() =>
  20. {
  21. }),"信号收发处理");
  22. }
  23. }
  24. /// <summary>
  25. /// 单个配料机配料完成
  26. /// </summary>
  27. /// <param name="value"></param>
  28. public void SingleDosing(uint value)
  29. {
  30. if (IsConnected)
  31. {
  32. ModBusHK.SetUint(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
  33. ModBusHK.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
  34. }
  35. }
  36. /// <summary>
  37. /// 复位plc允许接料信号
  38. /// </summary>
  39. public void AllowDosingSignReset()
  40. {
  41. ModBusHK.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
  42. }
  43. /// <summary>
  44. /// 复位plc到达某料仓信号
  45. /// </summary>
  46. public void StockStateSignReset()
  47. {
  48. ModBusHK.Write(HKPlcCommAddress.StockState, (ushort)0);
  49. }
  50. /// <summary>
  51. /// 复位一个配方配料完成信号
  52. /// </summary>
  53. public void RecipeDosingFinishReset()
  54. {
  55. ModBusHK.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
  56. }
  57. /// <summary>
  58. /// 下发配方数据
  59. /// </summary>
  60. /// <param name="BarrelNum">单个桶的编号</param>
  61. /// <param name="StockBinLocation">单个桶对应的料仓位置</param>
  62. public void StockBinPar(uint BarrelNum, ushort StockBinLocation)
  63. {
  64. if (IsConnected)
  65. {
  66. ModBusHK.SetUint(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
  67. ModBusHK.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
  68. }
  69. }
  70. }
  71. }