版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

TensionProp.cs 3.0 KiB

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