版博士V2.0程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

68 řádky
2.8 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("3 补偿"), DisplayName("3.1 补偿值"), Description("测试读取数据后加入的补偿值")]
  23. public double OffsetValue { get; set; }
  24. [PropertyOrder(6), Browsable(true), Category("4 控制"), DisplayName("4.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  25. public bool Disable { get; set; }
  26. public TensionProp()
  27. {
  28. TestCnt = 5;
  29. DelayTime = 0;
  30. DataCnt = 1;
  31. ProcessData = DataProcess.均值;
  32. OffsetValue = 0;
  33. Disable = false;
  34. }
  35. /// <summary>
  36. /// 序列化
  37. /// </summary>
  38. /// <param name="obj"></param>
  39. /// <returns></returns>
  40. public string serialize()
  41. {
  42. return JsonConvert.SerializeObject(this);
  43. }
  44. /// <summary>
  45. /// 反序列化
  46. /// </summary>
  47. /// <param name="json"></param>
  48. /// <returns></returns>
  49. public void deserialize(string json)
  50. {
  51. var o = JsonConvert.DeserializeObject<TensionProp>(json);
  52. Type type = o.GetType();
  53. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  54. foreach (System.Reflection.PropertyInfo property in properties)
  55. {
  56. string name = property.Name;
  57. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  58. {
  59. var value = property.GetValue(o);
  60. this.GetType().GetProperty(name).SetValue(this, value);
  61. }
  62. }
  63. }
  64. }
  65. }