using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using Advantech.Motion; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using ProductionControl.UI.PropExtend; using static ProductionControl.UI.UIAxisDev; namespace ProductionControl.UI { //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化 public class SizeLibProp { //[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.1 引擎路径"), Description("引擎路径")] //public string EnginePath { get; set; } [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.2 引擎文件名"), Description("引擎文件名")] public string EngineName { get; set; } [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.3 源图"), Description("源图"), JsonIgnore] public string BmpPath { get; set; } [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.4 索引"), Description("索引 0-9")] public int Index { get; set; } [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.5 保存标识"), Description("供后续轴移动时引用此标识数据,不设则在本工序内立即进行轴校正。")] public string SizeTag { get; set; } //2023-10-27 新增图纸选点 [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.6 使用点位"), Description("是否使用图纸抓取的点位")] public bool UseMapPoints { get; set; } [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.7 图纸图片"), Description("图纸图片文件名")] public string MapPath { get; set; } [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.8 抓取位置"), Description("图纸上选取的点位,根据选取的5个PT点,9个线宽点,计算真是走位。")] //public double[] GetPointList { get; set; } = new double[23];//默认对应0和2号AXIS public double[] GetPointList { get; set; } = new double[23] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT1"), Description("结果"), ReadOnly(true), JsonIgnore] public double PT1 { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT2"), Description("结果"), ReadOnly(true), JsonIgnore] public double PT2 { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Shanxian"), Description("结果"), ReadOnly(true), JsonIgnore] public double Shanxian { get; set; } //[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("RowP"), Description("结果"), ReadOnly(true), JsonIgnore] //public double RowP { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Ymm"), Description("结果"), ReadOnly(true), JsonIgnore] public double Circle_Ymm { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Xmm"), Description("结果"), ReadOnly(true), JsonIgnore] public double Circle_Xmm { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetX"), Description("结果"), ReadOnly(true), JsonIgnore] public double offsetX { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetY"), Description("结果"), ReadOnly(true), JsonIgnore] public double offsetY { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Mark点"), Description("Mark点"), ReadOnly(true), JsonIgnore] public double[] MarkPointList { get; set; } [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("信息"), Description("信息"), ReadOnly(true), JsonIgnore] public string resultInfo { get; set; } [PropertyOrder(25), Browsable(true), Category("3 控制"), DisplayName("3.1 运行前Sleep(ms)"), Description("休息时间")] public uint SleepPre { get; set; } [PropertyOrder(26), Browsable(true), Category("3 控制"), DisplayName("3.2 运行后Sleep(ms)"), Description("休息时间")] public uint SleepLater { get; set; } [PropertyOrder(27), Browsable(true), Category("3 控制"), DisplayName("3.3 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")] public bool AsynRun { get; set; } = true; [PropertyOrder(28), Browsable(true), Category("3 控制"), DisplayName("3.4 禁用工序"), Description("禁用本工序(True-是;False-否)")] public bool Disable { get; set; } /// /// 序列化 /// /// /// public string serialize() { return JsonConvert.SerializeObject(this); } /// /// 反序列化 /// /// /// public void deserialize(string json) { var o= JsonConvert.DeserializeObject(json); Type type = o.GetType(); System.Reflection.PropertyInfo[] properties = type.GetProperties(); foreach (System.Reflection.PropertyInfo property in properties) { string name = property.Name; if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true)) { var value = property.GetValue(o); this.GetType().GetProperty(name).SetValue(this, value); } } } } }