FeederRecipe.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using Newtonsoft.Json;
  8. using TeamAAS.Feeder.Enums;
  9. using TeamAAS.Feeder.Models;
  10. namespace TeamAAS.Feeder.Models
  11. {
  12. /// <summary>
  13. /// 供料器配方 —— 调试完成后保存的可复用参数集
  14. /// 插件运行时只需 LoadRecipe → DownloadAllParams → 执行
  15. /// </summary>
  16. public class FeederRecipe : INotifyPropertyChanged
  17. {
  18. private string _recipeName = "";
  19. private string _description = "";
  20. private FeederBrand _brand = FeederBrand.Team;
  21. private DateTime _createdAt = DateTime.Now;
  22. private DateTime _updatedAt = DateTime.Now;
  23. [Category("配方信息"), DisplayName("配方名称")]
  24. public string RecipeName
  25. {
  26. get { return _recipeName; }
  27. set { SetProperty(ref _recipeName, value); }
  28. }
  29. [Category("配方信息"), DisplayName("描述")]
  30. public string Description
  31. {
  32. get { return _description; }
  33. set { SetProperty(ref _description, value); }
  34. }
  35. [Category("配方信息"), DisplayName("品牌")]
  36. public FeederBrand Brand
  37. {
  38. get { return _brand; }
  39. set { SetProperty(ref _brand, value); }
  40. }
  41. [Browsable(false)]
  42. public DateTime CreatedAt
  43. {
  44. get { return _createdAt; }
  45. set { SetProperty(ref _createdAt, value); }
  46. }
  47. [Browsable(false)]
  48. public DateTime UpdatedAt
  49. {
  50. get { return _updatedAt; }
  51. set { SetProperty(ref _updatedAt, value); }
  52. }
  53. /// <summary>
  54. /// 11 个振动动作组参数(A~K,对应 FeederAction 0~10)
  55. /// </summary>
  56. public ObservableCollection<SingleActionParam> ActionGroups { get; set; }
  57. = new ObservableCollection<SingleActionParam>(
  58. Enumerable.Range(0, 11).Select(_ => new SingleActionParam()));
  59. /// <summary>
  60. /// 多个送料流程(序列集),可选
  61. /// </summary>
  62. public ObservableCollection<SequenceSet> Sequences { get; set; }
  63. = new ObservableCollection<SequenceSet>();
  64. public FeederRecipe Clone()
  65. {
  66. var json = JsonConvert.SerializeObject(this);
  67. return JsonConvert.DeserializeObject<FeederRecipe>(json);
  68. }
  69. public event PropertyChangedEventHandler PropertyChanged;
  70. protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
  71. {
  72. if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
  73. storage = value;
  74. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  75. return true;
  76. }
  77. }
  78. }