版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

89 lines
4.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Xml.Linq;
  9. using MaiMuAOI.SysUI.StepUI.PropExtend;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Serialization;
  12. using static ProductionControl.UI.UIAxisDev;
  13. namespace ProductionControl.UI
  14. {
  15. //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
  16. public class DefectLibProp
  17. {
  18. public DefectLibProp(Size cut_size, Size resize,float thresholds) {
  19. CutSize = cut_size;
  20. Resize=resize;
  21. Thresholds = thresholds;
  22. }
  23. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.1 源图"), JsonIgnore, Description("源图")]
  24. public string BmpPath { get; set; }
  25. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.2 模型"), JsonIgnore, Description("模型")]
  26. public string ModelPath { get; set; }
  27. [PropertyOrder(11), Browsable(true), Category("2 参数"), DisplayName("2.1 切割大小"), Description("切割大小")]
  28. public Size CutSize { get;set; }
  29. [PropertyOrder(12), Browsable(true), Category("2 参数"), DisplayName("2.2 重置大小"), Description("重置大小")]
  30. public Size Resize { get; set; }
  31. [PropertyOrder(13), Browsable(true), Category("2 参数"), DisplayName("2.3 阀值"), Description("阀值")]
  32. public float Thresholds { get; set; }
  33. [PropertyOrder(13), Browsable(true), Category("2 参数"), DisplayName("2.4 种类阀值"), Description("多个用半号逗号(,)或分号(;)分隔")]
  34. public string ThresholdsClass { get; set; }
  35. [PropertyOrder(13), Browsable(true), Category("2 参数"), DisplayName("2.5 种类个数"), Description("种类阀值的数量")]
  36. public int ThresholdsClassCount { get; set; }
  37. [PropertyOrder(15), Browsable(true), Category("3 结果"), DisplayName("结果"), JsonIgnore, Description("结果"), ReadOnly(true)]
  38. public string InformationList { get; set; }
  39. //public List<Dictionary<int, List<string>[]>> InformationList { get; set; }
  40. [PropertyOrder(15), Browsable(true), Category("3 结果"), DisplayName("信息"), JsonIgnore, Description("信息"), ReadOnly(true)]
  41. public string resultInfo { get; set; }
  42. [PropertyOrder(91), Browsable(true), Category("4 阀值"), DisplayName("阀值上限"), Description("阀值上限")]
  43. public double LimitThresholdVal { get; set; }
  44. [PropertyOrder(92), Browsable(true), Category("4 阀值"), DisplayName("阀值下限"), Description("阀值下限")]
  45. public double LowerThresholdVal { get; set; }
  46. [PropertyOrder(25), Browsable(true), Category("5 控制"), DisplayName("5.1 运行前Sleep(ms)"), Description("休息时间")]
  47. public uint SleepPre { get; set; }
  48. [PropertyOrder(26), Browsable(true), Category("5 控制"), DisplayName("5.2 运行后Sleep(ms)"), Description("休息时间")]
  49. public uint SleepLater { get; set; }
  50. [PropertyOrder(27), Browsable(true), Category("5 控制"), DisplayName("5.4 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  51. public bool Disable { get; set; }
  52. /// <summary>
  53. /// 序列化
  54. /// </summary>
  55. /// <param name="obj"></param>
  56. /// <returns></returns>
  57. public string serialize()
  58. {
  59. return JsonConvert.SerializeObject(this);
  60. }
  61. /// <summary>
  62. /// 反序列化
  63. /// </summary>
  64. /// <param name="json"></param>
  65. /// <returns></returns>
  66. public void deserialize(string json)
  67. {
  68. var o= JsonConvert.DeserializeObject<DefectLibProp>(json);
  69. Type type = o.GetType();
  70. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  71. foreach (System.Reflection.PropertyInfo property in properties)
  72. {
  73. string name = property.Name;
  74. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  75. {
  76. var value = property.GetValue(o);
  77. this.GetType().GetProperty(name).SetValue(this, value);
  78. }
  79. }
  80. }
  81. }
  82. }