using System; using System.ComponentModel; using System.Linq; using System.Reflection; namespace TeamAAS.Feeder.Enums { public enum FeederBrand { [Description("TEAM")] Team = 1, [Description("AFAG")] Afag = 2, } public enum FeederConnectType { TCP = 0, Serial = 1, } /// /// 电机输出波形(Flags,可多选叠加) /// [Flags] public enum WaveShape { [Description("不启用")] None = 0, [Description("正弦波")] SignWave = 1, [Description("上沿锯齿波")] SawToothWave = 2, [Description("下沿锯齿波")] TriangleWave = 4, } /// /// 11 个平台振动动作方向(对应协议 {CA}~{CK}) /// public enum FeederAction { [Description("← A 左")] Left = 0, [Description("↙ B 左下")] LeftAndBottom = 1, [Description("↖ C 左上")] LeftAndTop = 2, [Description("↓ D 下")] Bottom = 3, [Description("↑ E 上")] Top = 4, [Description("→ F 右")] Right = 5, [Description("↘ G 右下")] RightAndBottom = 6, [Description("↗ H 右上")] RightAndTop = 7, [Description("⤨ I 散开")] Flip = 8, [Description("⇔ J 水平聚集")] HorizontalAlignment = 9, [Description("⇕ K 垂直聚集")] VerticalAlignment = 10, } public static class FeederActionHelper { /// 方向 A-K 的协议字母(FeederAction=0→'A',10→'K') public static char GetActionLetter(this FeederAction action) => (char)('A' + (int)action); /// FeederAction→符号(← ↙ ↖ ↓ ↑ → ↘ ↗ ⤨ ⇔ ⇕) public static string GetActionSymbol(this FeederAction action) { switch (action) { case FeederAction.Left: return "←"; case FeederAction.LeftAndBottom: return "↙"; case FeederAction.LeftAndTop: return "↖"; case FeederAction.Bottom: return "↓"; case FeederAction.Top: return "↑"; case FeederAction.Right: return "→"; case FeederAction.RightAndBottom: return "↘"; case FeederAction.RightAndTop: return "↗"; case FeederAction.Flip: return "⤨"; case FeederAction.HorizontalAlignment: return "⇔"; case FeederAction.VerticalAlignment: return "⇕"; default: return "?"; } } /// FeederAction→显示文本 "↙ B 左下" public static string GetDisplayName(this FeederAction action) { var attr = typeof(FeederAction).GetField(action.ToString()) ?.GetCustomAttribute(); return attr?.Description ?? action.ToString(); } } }