版博士V2.0程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

96 linhas
4.4 KiB

  1. using MaiMuAOI.SysCtrl;
  2. using MaiMuAOI.SysUI.StepUI.PropExtend;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace MaiMuAOI.SysUI.ProcessStep.Prop
  12. {
  13. public class ThicknessProp
  14. {
  15. [PropertyOrder(1), Browsable(true), Category("1 测试"), DisplayName("1.1 测试点位数"), Description("需要进行的厚度测试次数")]
  16. public int TestCnt { get; set; }
  17. [PropertyOrder(2), Browsable(true), Category("1 测试"), DisplayName("1.2 图纸获取点位"), Description("是否从图纸获取点位(True-是;False-否)")]
  18. public bool UsePoints { get; set; }
  19. [PropertyOrder(3), Browsable(true), Category("1 测试"), DisplayName("1.3 测试点位列表"), Description("当不从图纸获取点位时,需要手动输入点位")]
  20. public List<PointF> Points { get; set; }
  21. [PropertyOrder(11), Browsable(true), Category("2 动作"), DisplayName("2.1 起始速度(mm/s)"), Description("起始速度")]
  22. public double VelLow { get; set; }
  23. [PropertyOrder(12), Browsable(true), Category("2 动作"), DisplayName("2.2 运行速度(mm/s)"), Description("运行速度")]
  24. public double VelHigh { get; set; }
  25. [PropertyOrder(13), Browsable(true), Category("2 动作"), DisplayName("2.3 加速度(mm/s)"), Description("加速度")]
  26. public double Acc { get; set; }
  27. [PropertyOrder(14), Browsable(true), Category("2 动作"), DisplayName("2.4 减速度(mm/s)"), Description("减速度")]
  28. public double Dec { get; set; }
  29. [PropertyOrder(15), Browsable(true), Category("2 动作"), DisplayName("2.5 等待稳定时间(ms)"), Description("测高度探头伸出等待稳定时间")]
  30. public int WaitTime { get; set; }
  31. [PropertyOrder(21), Browsable(true), Category("3 参数"), DisplayName("3.1 读取延时(ms)"), Description("测试读取数据之前延时ms")]
  32. public int DelayTime { get; set; }
  33. [PropertyOrder(22), Browsable(true), Category("3 参数"), DisplayName("3.2 读取N个数据"), Description("测试读取多少数据")]
  34. public int DataCnt { get; set; }
  35. [PropertyOrder(23), Browsable(true), Category("3 参数"), DisplayName("3.3 单次数据处理"), Description("根据读到的N个数据进行取值处理")]
  36. public DataProcess ProcessData { get; set; }
  37. [PropertyOrder(31), Browsable(true), Category("4 补偿"), DisplayName("4.1 补偿值(um)"), Description("测试读取数据后加入的补偿值")]
  38. public double OffsetValue { get; set; }
  39. [PropertyOrder(41), Browsable(true), Category("5 控制"), DisplayName("5.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  40. public bool Disable { get; set; }
  41. public ThicknessProp()
  42. {
  43. TestCnt = 5;
  44. UsePoints = false;
  45. Points = new List<PointF>();
  46. VelLow = 0;
  47. VelHigh = 50;
  48. Acc = 100;
  49. Dec = 100;
  50. WaitTime = 500;
  51. DelayTime = 0;
  52. DataCnt = 1;
  53. ProcessData = DataProcess.均值;
  54. OffsetValue = 0;
  55. Disable = false;
  56. }
  57. /// <summary>
  58. /// 序列化
  59. /// </summary>
  60. /// <param name="obj"></param>
  61. /// <returns></returns>
  62. public string serialize()
  63. {
  64. return JsonConvert.SerializeObject(this);
  65. }
  66. /// <summary>
  67. /// 反序列化
  68. /// </summary>
  69. /// <param name="json"></param>
  70. /// <returns></returns>
  71. public void deserialize(string json)
  72. {
  73. var o = JsonConvert.DeserializeObject<ThicknessProp>(json);
  74. Type type = o.GetType();
  75. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  76. foreach (System.Reflection.PropertyInfo property in properties)
  77. {
  78. string name = property.Name;
  79. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  80. {
  81. var value = property.GetValue(o);
  82. this.GetType().GetProperty(name).SetValue(this, value);
  83. }
  84. }
  85. }
  86. }
  87. }