IRobotControlService.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System.Threading.Tasks;
  2. namespace Team.Utility
  3. {
  4. public interface IRobotControlService
  5. {
  6. /// <summary>
  7. /// 写点地址
  8. /// </summary>
  9. /// <param name="id">字地址</param>
  10. /// <returns></returns>
  11. Task<bool> SavePointAsync(int id);
  12. /// <summary>
  13. /// 连接到modbus 服务
  14. /// </summary>
  15. /// <returns></returns>
  16. bool Connect();
  17. /// <summary>
  18. /// 读保持寄存器位地址
  19. /// </summary>
  20. /// <param name="address">字地址</param>
  21. /// <param name="bitNo">字位</param>
  22. /// <returns></returns>
  23. Task<bool> ReadAsync(int address, int bitNo);
  24. //void SetDataFormat(DataFormat dataFormat);
  25. /// <summary>
  26. /// 设置连接超时时间
  27. /// </summary>
  28. /// <param name="duration">单位second</param>
  29. void SetConnectTimeout(int duration);
  30. bool IsConnect { get; }
  31. /// <summary>
  32. /// 写字地址
  33. /// </summary>
  34. /// <param name="id">字地址</param>
  35. /// <param name="value"></param>
  36. /// <returns></returns>
  37. Task<bool> WriteShortAsync(int id,int value);
  38. Task<bool> WriteUshortAsync(int id, ushort value);
  39. Task<bool> WriteIntAsync(int id, int value);
  40. Task<bool> WriteUintAsync(int id, uint value);
  41. Task<bool> WriteFloatAsync(int id, float value);
  42. Task<bool> WriteDoubleAsync(int id, double value);
  43. Task<bool> WriteStringAsync(int id, string value);
  44. /// <summary>
  45. /// 在modbus服务器写入32位整数
  46. /// </summary>
  47. /// <param name="address">地址开始位</param>
  48. /// <returns></returns>
  49. Task<int> ReadInt32Async(int address);
  50. /// <summary>
  51. /// 在modbus服务器写入32正位整数
  52. /// </summary>
  53. /// <param name="address">地址开始位</param>
  54. /// <returns></returns>
  55. Task<uint> ReadUintAsync(int address);
  56. /// <summary>
  57. /// 在modbus服务器写入32浮点数
  58. /// </summary>
  59. /// <param name="address">地址开始位</param>
  60. /// <returns></returns>
  61. Task<float> ReadFloatAsync(int address);
  62. /// <summary>
  63. /// 在modbus服务器写入64浮点数
  64. /// </summary>
  65. /// <param name="address">地址开始位</param>
  66. /// <returns></returns>
  67. Task<double> ReadDoubleAsync(int address);
  68. /// <summary>
  69. /// 在modbus服务器写入16位整数
  70. /// </summary>
  71. /// <param name="address">地址开始位</param>
  72. /// <returns></returns>
  73. Task<short> ReadShortAsync(int address);
  74. /// <summary>
  75. /// 在modbus服务器写入16正位整数
  76. /// </summary>
  77. /// <param name="address">地址开始位</param>
  78. /// <returns></returns>
  79. Task<ushort> ReadUshortAsync(int address);
  80. /// <summary>
  81. /// 在modbus服务器写入字符串
  82. /// </summary>
  83. /// <param name="address">地址开始位</param>
  84. /// <param name="length">字符串长度</param>
  85. /// <returns></returns>
  86. Task<string> ReadStringAsync(int address, ushort length);
  87. }
  88. }