using MaiMuAOI.SysUI.StepUI.PropExtend;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MaiMuAOI.SysUI.ProcessStep.Prop
{
public class LightProp
{
[PropertyOrder(1), Browsable(true), Category("1 参数"), DisplayName("1.1 通道"), Description("选择光源通道")]
public int ChannelIndex { get; set; } = 1;
[PropertyOrder(2), Browsable(true), Category("1 参数"), DisplayName("1.2 亮度"), Description("设置光源亮度")]
public int DigitalValue { get; set; }
[PropertyOrder(6), Browsable(true), Category("2 控制"), DisplayName("2.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
public bool Disable { get; set; }
public LightProp()
{
ChannelIndex = 1;
DigitalValue = 100;
Disable = false;
}
///
/// 序列化
///
///
///
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);
}
}
}
}
}