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

89 lines
2.3 KiB

  1. using BPASmart.VariableManager.Enums;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.IO.Ports;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. namespace BPASmart.VariableManager.Models
  11. {
  12. public class ModbusRtu : ICommunicationDevice
  13. {
  14. //public ModbusRtu()
  15. //{
  16. // Init();
  17. //}
  18. /// <summary>
  19. /// 显示/隐藏设置
  20. /// </summary>
  21. //public Visibility ModbusRtuVisible { get; set; } = Visibility.Collapsed;
  22. /// <summary>
  23. /// 串口端口
  24. /// </summary>
  25. public string ComSerialPort { get; set; }
  26. /// <summary>
  27. /// 波特率,110,300--115200(从300开始乘以2,直到结果等于115200)
  28. /// </summary>
  29. public string BaudRate { get; set; } = "9600";
  30. /// <summary>
  31. /// 数据位,默认为 8
  32. /// </summary>
  33. public int DataBit { get; set; } = 8;
  34. /// <summary>
  35. /// 停止位,默认为 1
  36. /// </summary>
  37. public int StopBit { get; set; } = 1;
  38. /// <summary>
  39. /// 站号,默认为 1
  40. /// </summary>
  41. public int StationNo { get; set; } = 1;
  42. /// <summary>
  43. /// 奇偶校验,无,奇校验,偶校验
  44. /// </summary>
  45. public string Parity { get; set; }
  46. //public ObservableCollection<string> Ports { get; set; } = new ObservableCollection<string>();
  47. //public ObservableCollection<string> BaudRates { get; set; } = new ObservableCollection<string>();
  48. //public ObservableCollection<string> Paritys { get; set; } = new ObservableCollection<string>();
  49. //private void Init()
  50. //{
  51. // Ports.Clear();
  52. // foreach (var item in SerialPort.GetPortNames())
  53. // {
  54. // Ports.Add(item);
  55. // }
  56. // BaudRates.Clear();
  57. // BaudRates.Add("110");
  58. // int initValue = 300;
  59. // for (int i = 0; i < 17; i++)
  60. // {
  61. // BaudRates.Add(initValue.ToString());
  62. // initValue *= 2;
  63. // }
  64. // Paritys.Clear();
  65. // foreach (var item in Enum.GetNames(typeof(EParity)))
  66. // {
  67. // Paritys.Add(item);
  68. // }
  69. //}
  70. }
  71. }