88 lines
4.1 KiB
C#
88 lines
4.1 KiB
C#
|
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 AssistClient.UI.PropExtend;
|
|||
|
using static AssistClient.UI.UIAxisDev;
|
|||
|
|
|||
|
namespace AssistClient.UI
|
|||
|
{
|
|||
|
//[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
|
|||
|
public class DefectLibProp
|
|||
|
{
|
|||
|
public DefectLibProp(Size cut_size, Size resize,float thresholds) {
|
|||
|
CutSize = cut_size;
|
|||
|
Resize=resize;
|
|||
|
Thresholds = thresholds;
|
|||
|
}
|
|||
|
|
|||
|
[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("源图"), JsonIgnore, Description("源图")]
|
|||
|
public string BmpPath { get; set; }
|
|||
|
[PropertyOrder(11), Browsable(true), Category("2 参数"), DisplayName("2.1 切割大小"), Description("切割大小")]
|
|||
|
public Size CutSize { get;set; }
|
|||
|
[PropertyOrder(12), Browsable(true), Category("2 参数"), DisplayName("2.2 重置大小"), Description("重置大小")]
|
|||
|
public Size Resize { get; set; }
|
|||
|
[PropertyOrder(13), Browsable(true), Category("2 参数"), DisplayName("2.3 阀值"), Description("阀值")]
|
|||
|
public float Thresholds { get; set; }
|
|||
|
[PropertyOrder(13), Browsable(true), Category("2 参数"), DisplayName("2.4 种类阀值"), Description("多个用半号逗号(,)或分号(;)分隔")]
|
|||
|
public string ThresholdsClass { get; set; }
|
|||
|
[PropertyOrder(13), Browsable(true), Category("2 参数"), DisplayName("2.5 种类个数"), Description("种类阀值的数量")]
|
|||
|
public int ThresholdsClassCount { get; set; }
|
|||
|
|
|||
|
[PropertyOrder(15), Browsable(true), Category("3 结果"), DisplayName("结果"), JsonIgnore, Description("结果"), ReadOnly(true)]
|
|||
|
public string InformationList { get; set; }
|
|||
|
//public List<Dictionary<int, List<string>[]>> InformationList { get; set; }
|
|||
|
[PropertyOrder(15), Browsable(true), Category("3 结果"), DisplayName("信息"), JsonIgnore, Description("信息"), ReadOnly(true)]
|
|||
|
public string resultInfo { get; set; }
|
|||
|
[PropertyOrder(91), Browsable(true), Category("4 阀值"), DisplayName("阀值上限"), Description("阀值上限")]
|
|||
|
public double LimitThresholdVal { get; set; }
|
|||
|
[PropertyOrder(92), Browsable(true), Category("4 阀值"), DisplayName("阀值下限"), Description("阀值下限")]
|
|||
|
public double LowerThresholdVal { get; set; }
|
|||
|
[PropertyOrder(25), Browsable(true), Category("5 控制"), DisplayName("5.1 运行前Sleep(ms)"), Description("休息时间")]
|
|||
|
public uint SleepPre { get; set; }
|
|||
|
[PropertyOrder(26), Browsable(true), Category("5 控制"), DisplayName("5.2 运行后Sleep(ms)"), Description("休息时间")]
|
|||
|
public uint SleepLater { get; set; }
|
|||
|
[PropertyOrder(27), Browsable(true), Category("5 控制"), DisplayName("5.4 禁用工序"), Description("禁用本工序")]
|
|||
|
public bool Disable { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 序列化
|
|||
|
/// </summary>
|
|||
|
/// <param name="obj"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public string serialize()
|
|||
|
{
|
|||
|
return JsonConvert.SerializeObject(this);
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 反序列化
|
|||
|
/// </summary>
|
|||
|
/// <param name="json"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public void deserialize(string json)
|
|||
|
{
|
|||
|
var o= JsonConvert.DeserializeObject<DefectLibProp>(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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|