BgEthernetIP.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Prism.Mvvm;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using TeamAAS_VP.Core.RFID;
  6. namespace TeamAAS_VP.Models
  7. {
  8. public class BgEthernetIP : BindableBase
  9. {
  10. private string _IP = "127.0.0.1";
  11. /// <summary>
  12. /// SIG350 IP 地址
  13. /// </summary>
  14. public string IP
  15. {
  16. get { return _IP; }
  17. set { SetProperty(ref _IP, value); }
  18. }
  19. private int _CycleTime = 10;
  20. /// <summary>
  21. /// I/O 循环 RPI(毫秒)
  22. /// </summary>
  23. public int CycleTime
  24. {
  25. get { return _CycleTime; }
  26. set { SetProperty(ref _CycleTime, value); }
  27. }
  28. private int _RfidPortCount = 1;
  29. /// <summary>
  30. /// 启用的 RFID 端口数量(1–8,对应端口 1..N)
  31. /// </summary>
  32. public int RfidPortCount
  33. {
  34. get { return _RfidPortCount; }
  35. set { SetProperty(ref _RfidPortCount, Math.Max(1, Math.Min(8, value))); }
  36. }
  37. private bool _IsEnabled = false;
  38. public bool IsEnabled
  39. {
  40. get { return _IsEnabled; }
  41. set { SetProperty(ref _IsEnabled, value); }
  42. }
  43. /// <summary>返回端口 1 至 <see cref="RfidPortCount"/> 的列表。</summary>
  44. public IReadOnlyList<int> GetEnabledPortNumbers()
  45. {
  46. int count = Math.Max(1, Math.Min(8, RfidPortCount));
  47. return Enumerable.Range(1, count).ToList();
  48. }
  49. /// <summary>固定读取 UID。</summary>
  50. public Rfh5xxReadOptions ToRfh5xxReadOptions()
  51. {
  52. return new Rfh5xxReadOptions { Kind = RfidPayloadKind.Uid };
  53. }
  54. }
  55. }