版博士V2.0程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HeightDevProp.cs 3.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml.Linq;
  8. using MaiMuAOI.SysUI.StepUI.PropExtend;
  9. using Newtonsoft.Json;
  10. using Newtonsoft.Json.Serialization;
  11. using static ProductionControl.UI.UIAxisDev;
  12. namespace ProductionControl.UI
  13. {
  14. //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
  15. public class HeightDevProp
  16. {
  17. public HeightDevProp(string ip,int port) {
  18. IP = ip;
  19. Port = port;
  20. }
  21. [PropertyOrder(1), Browsable(true), Category("1 设备连接"), DisplayName("IP地址"), Description("IP地址"), ReadOnly(true), JsonIgnore]
  22. public string IP { get;private set; }
  23. [PropertyOrder(1), Browsable(true), Category("1 设备连接"), DisplayName("端品号"), Description("端品号"), ReadOnly(true), JsonIgnore]
  24. public int Port { get; private set; }
  25. //
  26. [PropertyOrder(12), Browsable(true), Category("2 数据"), DisplayName("厚度值(um)"), Description("厚度值(um)"), ReadOnly(true), JsonIgnore]
  27. public double HeightValue { get; set; }
  28. [PropertyOrder(91), Browsable(true), Category("3 阀值"), DisplayName("阀值上限"), Description("阀值上限")]
  29. public double LimitThresholdVal { get; set; }
  30. [PropertyOrder(92), Browsable(true), Category("3 阀值"), DisplayName("阀值下限"), Description("阀值下限")]
  31. public double LowerThresholdVal { get; set; }
  32. [PropertyOrder(25), Browsable(true), Category("4 控制"), DisplayName("4.1 运行前Sleep(ms)"), Description("休息时间")]
  33. public uint SleepPre { get; set; }
  34. [PropertyOrder(26), Browsable(true), Category("4 控制"), DisplayName("4.2 运行后Sleep(ms)"), Description("休息时间")]
  35. public uint SleepLater { get; set; }
  36. [PropertyOrder(26), Browsable(true), Category("4 控制"), DisplayName("4.3 用于基准校正"), Description("用于基准校正,后续测量按索引顺序减扣校正值(True-是;False-否)")]
  37. public bool IsRevise { get; set; }
  38. [PropertyOrder(26), Browsable(true), Category("4 控制"), DisplayName("4.4 相对偏移值(um)"), Description("在现有值基础上相对相加此偏移值。")]
  39. public double RelBaseValue { get; set; }
  40. [PropertyOrder(27), Browsable(true), Category("4 控制"), DisplayName("4.5 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  41. public bool Disable { get; set; }
  42. /// <summary>
  43. /// 序列化
  44. /// </summary>
  45. /// <param name="obj"></param>
  46. /// <returns></returns>
  47. public string serialize()
  48. {
  49. return JsonConvert.SerializeObject(this);
  50. }
  51. /// <summary>
  52. /// 反序列化
  53. /// </summary>
  54. /// <param name="json"></param>
  55. /// <returns></returns>
  56. public void deserialize(string json)
  57. {
  58. var o= JsonConvert.DeserializeObject<HeightDevProp>(json);
  59. Type type = o.GetType();
  60. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  61. foreach (System.Reflection.PropertyInfo property in properties)
  62. {
  63. string name = property.Name;
  64. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  65. {
  66. var value = property.GetValue(o);
  67. this.GetType().GetProperty(name).SetValue(this, value);
  68. }
  69. }
  70. }
  71. }
  72. }