版博士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.

ThicknessProp.cs 4.6 KiB

2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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(24), Browsable(true), Category("3 参数"), DisplayName("3.4 数据判定方式"), Description("对采集数据进行判定处理的方式")]
  38. public DataJudgment JudgmentData { get; set; }
  39. [PropertyOrder(31), Browsable(true), Category("4 补偿"), DisplayName("4.1 补偿值(um)"), Description("测试读取数据后加入的补偿值")]
  40. public double OffsetValue { get; set; }
  41. [PropertyOrder(41), Browsable(true), Category("5 控制"), DisplayName("5.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  42. public bool Disable { get; set; }
  43. public ThicknessProp()
  44. {
  45. TestCnt = 5;
  46. UsePoints = false;
  47. Points = new List<PointF>();
  48. VelLow = 0;
  49. VelHigh = 50;
  50. Acc = 100;
  51. Dec = 100;
  52. WaitTime = 500;
  53. DelayTime = 0;
  54. DataCnt = 1;
  55. ProcessData = DataProcess.均值;
  56. JudgmentData = DataJudgment.均值;
  57. OffsetValue = 0;
  58. Disable = false;
  59. }
  60. /// <summary>
  61. /// 序列化
  62. /// </summary>
  63. /// <param name="obj"></param>
  64. /// <returns></returns>
  65. public string serialize()
  66. {
  67. return JsonConvert.SerializeObject(this);
  68. }
  69. /// <summary>
  70. /// 反序列化
  71. /// </summary>
  72. /// <param name="json"></param>
  73. /// <returns></returns>
  74. public void deserialize(string json)
  75. {
  76. var o = JsonConvert.DeserializeObject<ThicknessProp>(json);
  77. Type type = o.GetType();
  78. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  79. foreach (System.Reflection.PropertyInfo property in properties)
  80. {
  81. string name = property.Name;
  82. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  83. {
  84. var value = property.GetValue(o);
  85. this.GetType().GetProperty(name).SetValue(this, value);
  86. }
  87. }
  88. }
  89. }
  90. }