MotionDeviceConfig.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using TeamAAS.Global.Devices;
  5. using Newtonsoft.Json;
  6. namespace TeamAAS.Motion.Models
  7. {
  8. /// <summary>单台运动/IO 设备的配置(持久化为 Config\MotionDevices.json)。</summary>
  9. [Serializable]
  10. public class MotionDeviceConfig
  11. {
  12. /// <summary>设备名称(唯一,状态栏/绑定树显示用)。</summary>
  13. [DisplayName("设备名称")]
  14. [Description("设备唯一名称")]
  15. public string Name { get; set; } = "运动卡1";
  16. /// <summary>设备适配器唯一标识(如 "Simulated(仿真)", "Leadshine", "Googol")决定实例化哪个品牌适配器</summary>
  17. [DisplayName("设备类型")]
  18. [Description("填写适配器注册的唯一字符串键值")]
  19. public string AdapterKey { get; set; } = "Simulated"; // 默认仿真
  20. /// <summary>板卡号/设备号(品牌适配器解释,如卡号 0)。</summary>
  21. [DisplayName("板卡号")]
  22. [Description("品牌适配器的板卡/设备索引")]
  23. public int BoardIndex { get; set; } = 0;
  24. /// <summary>轴数量(有 Axes 时等于配置条数)。不要在 setter 里生成默认轴,反序列化会先写 AxisCount 再追加 Axes,造成列表重复。</summary>
  25. [DisplayName("轴数量")]
  26. public int AxisCount
  27. {
  28. get => Axes != null && Axes.Count > 0 ? Axes.Count : _axisCount;
  29. set => _axisCount = Math.Max(1, value);
  30. }
  31. private int _axisCount = 4;
  32. /// <summary>逻辑轴列表(实轴 / 虚轴 / 组合轴)。为空时按 AxisCount 生成默认 X/Y/Z/R。</summary>
  33. [Browsable(false)]
  34. [JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
  35. public List<MotionAxisConfig> Axes { get; set; } = new List<MotionAxisConfig>();
  36. /// <summary>本地端子板 DI 点数。</summary>
  37. [DisplayName("本地 DI 点数")]
  38. public int LocalInputCount { get; set; } = 16;
  39. /// <summary>本地端子板 DO 点数。</summary>
  40. [DisplayName("本地 DO 点数")]
  41. public int LocalOutputCount { get; set; } = 16;
  42. /// <summary>EtherCAT 扩展 DI 点数(无硬件信息时用)。</summary>
  43. [DisplayName("EtherCAT DI 点数")]
  44. public int InputCount { get; set; } = 16;
  45. /// <summary>EtherCAT 扩展 DO 点数(无硬件信息时用)。</summary>
  46. [DisplayName("EtherCAT DO 点数")]
  47. public int OutputCount { get; set; } = 16;
  48. /// <summary>连接参数。汇川卡填设备配置 XML 路径,可用 | 或 ; 分隔系统配置,例如:ENI.xml|System.xml</summary>
  49. [DisplayName("连接参数")]
  50. [Description("IP / 串口 / EtherCAT 配置等,由品牌适配器解释")]
  51. public string ConnectionString { get; set; } = "";
  52. /// <summary>总急停输入点,-1 表示不启用。</summary>
  53. [Browsable(false)]
  54. public int EstopDiIndex { get; set; } = -1;
  55. [Browsable(false)]
  56. public MotionIoBank EstopDiBank { get; set; } = MotionIoBank.Local;
  57. /// <summary>true=DI 为 1 时急停有效(常开);false=DI 为 0 时有效(常闭)。</summary>
  58. [Browsable(false)]
  59. public bool EstopActiveHigh { get; set; } = true;
  60. /// <summary>总停止输入点,-1 表示不启用。</summary>
  61. [Browsable(false)]
  62. public int StopDiIndex { get; set; } = -1;
  63. [Browsable(false)]
  64. public MotionIoBank StopDiBank { get; set; } = MotionIoBank.Local;
  65. /// <summary>true=DI 为 1 时停止有效。</summary>
  66. [Browsable(false)]
  67. public bool StopActiveHigh { get; set; } = true;
  68. }
  69. }