版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

106 строки
5.3 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.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace MaiMuAOI.SysUI.ProcessStep.Prop
  11. {
  12. public class TensionProp
  13. {
  14. [PropertyOrder(1), Browsable(true), Category("1 测试"), DisplayName("1.1 测试次数"), Description("需要进行的张力测试次数")]
  15. public int TestCnt { get; set; }
  16. [PropertyOrder(2), Browsable(true), Category("2 参数"), DisplayName("2.1 读取延时(ms)"), Description("测试读取数据之前延时ms")]
  17. public int DelayTime { get; set; }
  18. [PropertyOrder(3), Browsable(true), Category("2 参数"), DisplayName("2.2 读取N个数据"), Description("测试读取多少数据")]
  19. public int DataCnt { get; set; }
  20. [PropertyOrder(4), Browsable(true), Category("2 参数"), DisplayName("2.3 单次数据处理"), Description("根据读到的N个数据进行取值处理")]
  21. public DataProcess ProcessData { get; set; }
  22. [PropertyOrder(5), Browsable(true), Category("2 参数"), DisplayName("2.4 数据判定方式"), Description("对采集数据进行判定处理的方式")]
  23. public DataJudgment JudgmentData { get; set; }
  24. [PropertyOrder(6), Browsable(true), Category("3 补偿"), DisplayName("3.1 补偿值"), Description("测试读取数据后加入的补偿值")]
  25. public double OffsetValue { get; set; }
  26. [PropertyOrder(31), Browsable(true), Category("4 上下限"), DisplayName("4.1 启用流程上下限"), Description("使用流程中设置的上下限判断")]
  27. public bool OpenUseLimit { get; set; }
  28. [PropertyOrder(32), Browsable(true), Category("4 上下限"), DisplayName("4.2 标准值"), Description("设置判断标志值")]
  29. public double StandardValues { get; set; }
  30. [PropertyOrder(33), Browsable(true), Category("4 上下限"), DisplayName("4.3 上限"), Description("设置判断上限")]
  31. public double MaxLimit { get; set; }
  32. [PropertyOrder(34), Browsable(true), Category("4 上下限"), DisplayName("4.4 下限"), Description("设置流程下限")]
  33. public double MinLimit { get; set; }
  34. [PropertyOrder(41), Browsable(true), Category("5 打印"), DisplayName("5.1 开启Excel打印"), Description("启用本工序数据打印")]
  35. public bool OpenPrint { get; set; }
  36. [PropertyOrder(42), Browsable(true), Category("5 打印"), DisplayName("5.2 打印数据"), Description("打印均值数据的位置")]
  37. public string ExcelData { get; set; }
  38. [PropertyOrder(43), Browsable(true), Category("5 打印"), DisplayName("5.3 打印上下限"), Description("打印上下限的位置")]
  39. public string ExcelLimit { get; set; }
  40. [PropertyOrder(44), Browsable(true), Category("5 打印"), DisplayName("5.4 开启标签打印"), Description("启用本工序数据打印")]
  41. public bool OpenPrintLabel { get; set; }
  42. [PropertyOrder(45), Browsable(true), Category("5 打印"), DisplayName("5.5 标签打印数据"), Description("打印均值数据的位置")]
  43. public string LabelData { get; set; }
  44. [PropertyOrder(46), Browsable(true), Category("5 打印"), DisplayName("5.6 标签打印上下限"), Description("打印上下限的位置")]
  45. public string LabelLimit { get; set; }
  46. [PropertyOrder(51), Browsable(true), Category("6 控制"), DisplayName("6.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  47. public bool Disable { get; set; }
  48. public TensionProp()
  49. {
  50. TestCnt = 5;
  51. DelayTime = 0;
  52. DataCnt = 1;
  53. ProcessData = DataProcess.均值;
  54. JudgmentData = DataJudgment.均值;
  55. OffsetValue = 0;
  56. Disable = false;
  57. OpenUseLimit = false;
  58. StandardValues = 0;
  59. MaxLimit = 0;
  60. MinLimit = 0;
  61. OpenPrint = false;
  62. OpenPrintLabel = false;
  63. ExcelData = "";
  64. ExcelLimit = "";
  65. LabelData = "";
  66. LabelLimit = "";
  67. }
  68. /// <summary>
  69. /// 序列化
  70. /// </summary>
  71. /// <param name="obj"></param>
  72. /// <returns></returns>
  73. public string serialize()
  74. {
  75. return JsonConvert.SerializeObject(this);
  76. }
  77. /// <summary>
  78. /// 反序列化
  79. /// </summary>
  80. /// <param name="json"></param>
  81. /// <returns></returns>
  82. public void deserialize(string json)
  83. {
  84. var o = JsonConvert.DeserializeObject<TensionProp>(json);
  85. Type type = o.GetType();
  86. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  87. foreach (System.Reflection.PropertyInfo property in properties)
  88. {
  89. string name = property.Name;
  90. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  91. {
  92. var value = property.GetValue(o);
  93. this.GetType().GetProperty(name).SetValue(this, value);
  94. }
  95. }
  96. }
  97. }
  98. }