| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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,
- }
- /// <summary>
- /// 电机输出波形(Flags,可多选叠加)
- /// </summary>
- [Flags]
- public enum WaveShape
- {
- [Description("不启用")]
- None = 0,
- [Description("正弦波")]
- SignWave = 1,
- [Description("上沿锯齿波")]
- SawToothWave = 2,
- [Description("下沿锯齿波")]
- TriangleWave = 4,
- }
- /// <summary>
- /// 11 个平台振动动作方向(对应协议 {CA}~{CK})
- /// </summary>
- 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
- {
- /// <summary>方向 A-K 的协议字母(FeederAction=0→'A',10→'K')</summary>
- public static char GetActionLetter(this FeederAction action)
- => (char)('A' + (int)action);
- /// <summary>FeederAction→符号(← ↙ ↖ ↓ ↑ → ↘ ↗ ⤨ ⇔ ⇕)</summary>
- 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 "?";
- }
- }
- /// <summary>FeederAction→显示文本 "↙ B 左下"</summary>
- public static string GetDisplayName(this FeederAction action)
- {
- var attr = typeof(FeederAction).GetField(action.ToString())
- ?.GetCustomAttribute<DescriptionAttribute>();
- return attr?.Description ?? action.ToString();
- }
- }
- }
|