版博士V2.0程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

81 líneas
3.6 KiB

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