| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using TeamAAS.Global.Devices;
- using Newtonsoft.Json;
- namespace TeamAAS.Motion.Models
- {
- /// <summary>单台运动/IO 设备的配置(持久化为 Config\MotionDevices.json)。</summary>
- [Serializable]
- public class MotionDeviceConfig
- {
- /// <summary>设备名称(唯一,状态栏/绑定树显示用)。</summary>
- [DisplayName("设备名称")]
- [Description("设备唯一名称")]
- public string Name { get; set; } = "运动卡1";
- /// <summary>设备适配器唯一标识(如 "Simulated(仿真)", "Leadshine", "Googol")决定实例化哪个品牌适配器</summary>
- [DisplayName("设备类型")]
- [Description("填写适配器注册的唯一字符串键值")]
- public string AdapterKey { get; set; } = "Simulated"; // 默认仿真
- /// <summary>板卡号/设备号(品牌适配器解释,如卡号 0)。</summary>
- [DisplayName("板卡号")]
- [Description("品牌适配器的板卡/设备索引")]
- public int BoardIndex { get; set; } = 0;
- /// <summary>轴数量(有 Axes 时等于配置条数)。不要在 setter 里生成默认轴,反序列化会先写 AxisCount 再追加 Axes,造成列表重复。</summary>
- [DisplayName("轴数量")]
- public int AxisCount
- {
- get => Axes != null && Axes.Count > 0 ? Axes.Count : _axisCount;
- set => _axisCount = Math.Max(1, value);
- }
- private int _axisCount = 4;
- /// <summary>逻辑轴列表(实轴 / 虚轴 / 组合轴)。为空时按 AxisCount 生成默认 X/Y/Z/R。</summary>
- [Browsable(false)]
- [JsonProperty(ObjectCreationHandling = ObjectCreationHandling.Replace)]
- public List<MotionAxisConfig> Axes { get; set; } = new List<MotionAxisConfig>();
- /// <summary>本地端子板 DI 点数。</summary>
- [DisplayName("本地 DI 点数")]
- public int LocalInputCount { get; set; } = 16;
- /// <summary>本地端子板 DO 点数。</summary>
- [DisplayName("本地 DO 点数")]
- public int LocalOutputCount { get; set; } = 16;
- /// <summary>EtherCAT 扩展 DI 点数(无硬件信息时用)。</summary>
- [DisplayName("EtherCAT DI 点数")]
- public int InputCount { get; set; } = 16;
- /// <summary>EtherCAT 扩展 DO 点数(无硬件信息时用)。</summary>
- [DisplayName("EtherCAT DO 点数")]
- public int OutputCount { get; set; } = 16;
- /// <summary>连接参数。汇川卡填设备配置 XML 路径,可用 | 或 ; 分隔系统配置,例如:ENI.xml|System.xml</summary>
- [DisplayName("连接参数")]
- [Description("IP / 串口 / EtherCAT 配置等,由品牌适配器解释")]
- public string ConnectionString { get; set; } = "";
- /// <summary>总急停输入点,-1 表示不启用。</summary>
- [Browsable(false)]
- public int EstopDiIndex { get; set; } = -1;
- [Browsable(false)]
- public MotionIoBank EstopDiBank { get; set; } = MotionIoBank.Local;
- /// <summary>true=DI 为 1 时急停有效(常开);false=DI 为 0 时有效(常闭)。</summary>
- [Browsable(false)]
- public bool EstopActiveHigh { get; set; } = true;
- /// <summary>总停止输入点,-1 表示不启用。</summary>
- [Browsable(false)]
- public int StopDiIndex { get; set; } = -1;
- [Browsable(false)]
- public MotionIoBank StopDiBank { get; set; } = MotionIoBank.Local;
- /// <summary>true=DI 为 1 时停止有效。</summary>
- [Browsable(false)]
- public bool StopActiveHigh { get; set; } = true;
- }
- }
|