RecipePointPosition.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Newtonsoft.Json;
  2. using Prism.Mvvm;
  3. using SKMC.Api.Motion.Model;
  4. using System;
  5. namespace SKMC.Api.Recipe.Model
  6. {
  7. /// <summary>
  8. /// 点位单轴位置模型
  9. /// </summary>
  10. [JsonObject(MemberSerialization.OptIn)]
  11. public class RecipePointPosition : BindableBase, ICloneable
  12. {
  13. private short _axisNo;
  14. /// <summary>
  15. /// 电机序号
  16. /// </summary>
  17. [JsonProperty]
  18. public short AxisNo
  19. {
  20. get { return _axisNo; }
  21. set { _axisNo = value; RaisePropertyChanged(); }
  22. }
  23. /// <summary>
  24. /// 电机对象
  25. /// </summary>
  26. public MotionAxis MotionAxis { get; set; }
  27. private double _position;
  28. /// <summary>
  29. /// 位置值(通常为绝对值)
  30. /// </summary>
  31. [JsonProperty]
  32. public double Position
  33. {
  34. get { return _position; }
  35. set { _position = Math.Round(value, 3); RaisePropertyChanged(); }
  36. }
  37. private double _offset;
  38. /// <summary>
  39. /// 偏移量
  40. /// </summary>
  41. [JsonProperty]
  42. public double Offset
  43. {
  44. get { return _offset; }
  45. set { _offset = Math.Round(value, 3); RaisePropertyChanged(); }
  46. }
  47. private double _fixsetVal;
  48. /// <summary>
  49. /// 补偿值(只生效一次)
  50. /// </summary>
  51. public double FixsetVal
  52. {
  53. get { return _fixsetVal; }
  54. set { _fixsetVal = value; }
  55. }
  56. public double PosVal
  57. {
  58. get => _position + _offset;
  59. }
  60. public double PosValFixset
  61. {
  62. get => PosVal + _fixsetVal;
  63. }
  64. /// <summary>
  65. /// 单轴速度码, 可以从点位的速度码继承
  66. /// </summary>
  67. public string SpeedCode { get; set; }
  68. public object Clone()
  69. {
  70. var model = new RecipePointPosition
  71. {
  72. AxisNo = this.AxisNo,
  73. MotionAxis = this.MotionAxis,
  74. Position = this.Position,
  75. Offset = this.Offset,
  76. SpeedCode = this.SpeedCode
  77. };
  78. return model;
  79. }
  80. }
  81. }