MotionPluginModels.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System.ComponentModel;
  2. using Plugins.Motion.Core;
  3. using PropertyGridLib.Attributes;
  4. using PropertyGridLib.Controls;
  5. using TeamAAS.FlowEditor.Plugins;
  6. using TeamAAS.FlowEngine.FormulaData;
  7. namespace Plugins.Motion.Models
  8. {
  9. [System.Serializable]
  10. public class MotionAxisModel : BasePluginModel
  11. {
  12. [DisplayName("运动卡")]
  13. [Description("从已配置的运动卡中选择;选中后「轴」下拉会填充该卡的轴列表")]
  14. [Category("I.设备")]
  15. [RefreshProperties(RefreshProperties.All)]
  16. [TypeConverter(typeof(MotionCardNameConverter))]
  17. public string MotionCardName { get; set; } = "";
  18. [Browsable(false)]
  19. public int AxisNo { get; set; } = 0;
  20. [DisplayName("轴")]
  21. [Description("根据所选运动卡的轴配置自动列出;使能/下使能/停止可用「-1 全部轴」")]
  22. [Category("I.设备")]
  23. [TypeConverter(typeof(MotionAxisNoConverter))]
  24. public string Axis
  25. {
  26. get => MotionAxisNoConverter.Format(AxisNo, this);
  27. set
  28. {
  29. if (string.IsNullOrWhiteSpace(value)) return;
  30. AxisNo = MotionAxisNoConverter.Parse(value, this);
  31. }
  32. }
  33. [DisplayName("未连接时自动连接")]
  34. [Description("运动卡未连接时先尝试 Open")]
  35. [Category("II.执行选项")]
  36. public bool AutoConnect { get; set; } = true;
  37. }
  38. [System.Serializable]
  39. public class MotionEnableModel : MotionAxisModel { }
  40. [System.Serializable]
  41. public class MotionDisableModel : MotionAxisModel { }
  42. [System.Serializable]
  43. public class MotionStopModel : MotionAxisModel
  44. {
  45. [DisplayName("急停")]
  46. [Description("勾选后对整卡急停;不勾选则平滑停止指定轴")]
  47. [Category("II.执行选项")]
  48. public bool Emergency { get; set; } = false;
  49. }
  50. [System.Serializable]
  51. public class MotionWaitModel : MotionAxisModel
  52. {
  53. [DisplayName("未使能时自动使能")]
  54. [Description("当前轴未使能时,先自动使能再执行本节点;不勾选则未使能直接失败")]
  55. [Category("II.执行选项")]
  56. public bool AutoEnable { get; set; } = false;
  57. [DisplayName("等待超时(ms)")]
  58. [Description("等待运动完成的超时时间,0 表示不限时(仍受节点 TimeoutMs 约束)")]
  59. [Category("II.执行选项")]
  60. public int WaitTimeoutMs { get; set; } = 10000;
  61. }
  62. [System.Serializable]
  63. public class MotionHomeModel : MotionWaitModel
  64. {
  65. [DisplayName("回零模式")]
  66. [Description("0=Default,1=限位,2=Home 开关,3=Z 相")]
  67. [Category("III.运动参数")]
  68. public int HomeMode { get; set; } = 0;
  69. }
  70. [System.Serializable]
  71. public class MotionMoveAbsModel : MotionWaitModel
  72. {
  73. [DisplayName("目标位置")]
  74. [Description("绝对定位目标,可用公式绑定视觉补偿")]
  75. [Category("III.运动参数")]
  76. [FormulaEditor(typeof(PluginDataProvider))]
  77. public FormulaBound<double> TargetPosition { get; set; } = new FormulaBound<double>(0);
  78. [DisplayName("速度")]
  79. [Description("定位速度")]
  80. [Category("III.运动参数")]
  81. [FormulaEditor(typeof(PluginDataProvider))]
  82. public FormulaBound<double> Velocity { get; set; } = new FormulaBound<double>(100);
  83. [DisplayName("到位容差")]
  84. [Description("到位后实际位置与目标的允许偏差")]
  85. [Category("III.运动参数")]
  86. public double InPositionTolerance { get; set; } = 0.01;
  87. }
  88. [System.Serializable]
  89. public class MotionMoveRelModel : MotionWaitModel
  90. {
  91. [DisplayName("相对距离")]
  92. [Description("相对当前实际位置的位移,可用公式绑定")]
  93. [Category("III.运动参数")]
  94. [FormulaEditor(typeof(PluginDataProvider))]
  95. public FormulaBound<double> Distance { get; set; } = new FormulaBound<double>(10);
  96. [DisplayName("速度")]
  97. [Description("定位速度")]
  98. [Category("III.运动参数")]
  99. [FormulaEditor(typeof(PluginDataProvider))]
  100. public FormulaBound<double> Velocity { get; set; } = new FormulaBound<double>(100);
  101. [DisplayName("到位容差")]
  102. [Description("到位后实际位移与指令的允许偏差")]
  103. [Category("III.运动参数")]
  104. public double InPositionTolerance { get; set; } = 0.01;
  105. }
  106. }