FeederEnums.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.ComponentModel;
  3. using System.Linq;
  4. using System.Reflection;
  5. namespace TeamAAS.Feeder.Enums
  6. {
  7. public enum FeederBrand
  8. {
  9. [Description("TEAM")]
  10. Team = 1,
  11. [Description("AFAG")]
  12. Afag = 2,
  13. }
  14. public enum FeederConnectType
  15. {
  16. TCP = 0,
  17. Serial = 1,
  18. }
  19. /// <summary>
  20. /// 电机输出波形(Flags,可多选叠加)
  21. /// </summary>
  22. [Flags]
  23. public enum WaveShape
  24. {
  25. [Description("不启用")]
  26. None = 0,
  27. [Description("正弦波")]
  28. SignWave = 1,
  29. [Description("上沿锯齿波")]
  30. SawToothWave = 2,
  31. [Description("下沿锯齿波")]
  32. TriangleWave = 4,
  33. }
  34. /// <summary>
  35. /// 11 个平台振动动作方向(对应协议 {CA}~{CK})
  36. /// </summary>
  37. public enum FeederAction
  38. {
  39. [Description("← A 左")] Left = 0,
  40. [Description("↙ B 左下")] LeftAndBottom = 1,
  41. [Description("↖ C 左上")] LeftAndTop = 2,
  42. [Description("↓ D 下")] Bottom = 3,
  43. [Description("↑ E 上")] Top = 4,
  44. [Description("→ F 右")] Right = 5,
  45. [Description("↘ G 右下")] RightAndBottom = 6,
  46. [Description("↗ H 右上")] RightAndTop = 7,
  47. [Description("⤨ I 散开")] Flip = 8,
  48. [Description("⇔ J 水平聚集")] HorizontalAlignment = 9,
  49. [Description("⇕ K 垂直聚集")] VerticalAlignment = 10,
  50. }
  51. public static class FeederActionHelper
  52. {
  53. /// <summary>方向 A-K 的协议字母(FeederAction=0→'A',10→'K')</summary>
  54. public static char GetActionLetter(this FeederAction action)
  55. => (char)('A' + (int)action);
  56. /// <summary>FeederAction→符号(← ↙ ↖ ↓ ↑ → ↘ ↗ ⤨ ⇔ ⇕)</summary>
  57. public static string GetActionSymbol(this FeederAction action)
  58. {
  59. switch (action)
  60. {
  61. case FeederAction.Left: return "←";
  62. case FeederAction.LeftAndBottom: return "↙";
  63. case FeederAction.LeftAndTop: return "↖";
  64. case FeederAction.Bottom: return "↓";
  65. case FeederAction.Top: return "↑";
  66. case FeederAction.Right: return "→";
  67. case FeederAction.RightAndBottom: return "↘";
  68. case FeederAction.RightAndTop: return "↗";
  69. case FeederAction.Flip: return "⤨";
  70. case FeederAction.HorizontalAlignment: return "⇔";
  71. case FeederAction.VerticalAlignment: return "⇕";
  72. default: return "?";
  73. }
  74. }
  75. /// <summary>FeederAction→显示文本 "↙ B 左下"</summary>
  76. public static string GetDisplayName(this FeederAction action)
  77. {
  78. var attr = typeof(FeederAction).GetField(action.ToString())
  79. ?.GetCustomAttribute<DescriptionAttribute>();
  80. return attr?.Description ?? action.ToString();
  81. }
  82. }
  83. }