TraySlot.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using Newtonsoft.Json;
  2. using Prism.Mvvm;
  3. using SKMC.Api.Recipe.Model;
  4. namespace SKMC.Api.Product.Material.Tray
  5. {
  6. /// <summary>
  7. /// 矩阵物料盘的物料/穴位模型
  8. /// </summary>
  9. [JsonObject(MemberSerialization.OptIn)]
  10. public class TraySlot : BindableBase
  11. {
  12. [JsonProperty]
  13. public int Index { get; set; }
  14. [JsonProperty]
  15. public int ColX { get; set; }
  16. [JsonProperty]
  17. public int RowY { get; set; }
  18. // 是否可用
  19. public bool IsEnable { get; set; } = true;
  20. public int TrayCols { get; set; }
  21. // X方向电机步距
  22. public double PosX { get; set; }
  23. // Y方向电机步距
  24. public double PosY { get; set; }
  25. // X方向间距 mm
  26. public double IntervalX { get; set; }
  27. // Y方向间距 mm
  28. public double IntervalY { get; set; }
  29. // X方向实际距离 mm
  30. public double DistX { get; set; }
  31. // Y方向实际距离 mm
  32. public double DistY { get; set; }
  33. private double _fixsetX;
  34. // X方向的偏移量 mm(视觉辅助)
  35. public double FixsetX
  36. {
  37. get { return _fixsetX; }
  38. set { _fixsetX = value; }
  39. }
  40. private double _fixsetY;
  41. // Y方向的偏移量 mm(视觉辅助)
  42. public double FixsetY
  43. {
  44. get { return _fixsetY; }
  45. set { _fixsetY = value; }
  46. }
  47. // R方向的偏移量 度(视觉辅助)
  48. public double FixsetR { get; set; }
  49. // 是否定位成功 (0:未定位 1:定位成功 2:定位失败)
  50. public byte Located { get; set; }
  51. private string _code;
  52. // 物料二维码
  53. public string Code
  54. {
  55. get { return _code; }
  56. set { _code = value; RaisePropertyChanged(); }
  57. }
  58. private byte _result = (byte)MatterStatus.UNKNOWN;
  59. [JsonProperty]
  60. public byte Result
  61. {
  62. get { return _result; }
  63. set { _result = value; RaisePropertyChanged(); }
  64. }
  65. // 详细结果
  66. public string ResultMsg { get; set; }
  67. // 重试次数
  68. public int RetryTimes { get; set; }
  69. public RecipePoint RecipePoint { get; set; }
  70. public void Set(int index)
  71. {
  72. Index = index;
  73. RowY = index / TrayCols;
  74. ColX = index % TrayCols;
  75. }
  76. /// <summary>
  77. /// 获取产品或穴位定位的偏移量
  78. /// </summary>
  79. /// <param name="traySlot"></param>
  80. public void InjectFixset(TraySlot traySlot)
  81. {
  82. FixsetX = traySlot.FixsetX;
  83. FixsetY = traySlot.FixsetY;
  84. if (RecipePoint != null)
  85. {
  86. RecipePoint.RecipePointPositions[0].FixsetVal = traySlot.FixsetX;
  87. RecipePoint.RecipePointPositions[1].FixsetVal = traySlot.FixsetY;
  88. }
  89. }
  90. public override string ToString()
  91. {
  92. return $"index: {Index}, code: {Code}, result: {Result}, located: {Located}";
  93. }
  94. }
  95. public enum TrayType : byte
  96. {
  97. Main = 0,
  98. NG = 1,
  99. OK = 2
  100. }
  101. public enum MatterStatus : byte
  102. {
  103. UNKNOWN = 0,
  104. OK = 1,
  105. NG = 2,
  106. NGL = 3,
  107. TODO = 4,
  108. EXIST = 5,
  109. NULL = 6,
  110. ERROR = 9
  111. }
  112. public enum LocateStatus : byte
  113. {
  114. TODO = 0,
  115. OK = 1,
  116. FAIL = 2
  117. }
  118. }