using MaiMuAOI.SysCtrl;
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 TensionProp
{
[PropertyOrder(1), Browsable(true), Category("1 测试"), DisplayName("1.1 测试次数"), Description("需要进行的张力测试次数")]
public int TestCnt { get; set; }
[PropertyOrder(2), Browsable(true), Category("2 参数"), DisplayName("2.1 读取延时(ms)"), Description("测试读取数据之前延时ms")]
public int DelayTime { get; set; }
[PropertyOrder(3), Browsable(true), Category("2 参数"), DisplayName("2.2 读取N个数据"), Description("测试读取多少数据")]
public int DataCnt { get; set; }
[PropertyOrder(4), Browsable(true), Category("2 参数"), DisplayName("2.3 单次数据处理"), Description("根据读到的N个数据进行取值处理")]
public DataProcess ProcessData { get; set; }
[PropertyOrder(5), Browsable(true), Category("2 参数"), DisplayName("2.4 数据判定方式"), Description("对采集数据进行判定处理的方式")]
public DataJudgment JudgmentData { get; set; }
[PropertyOrder(6), Browsable(true), Category("3 补偿"), DisplayName("3.1 补偿值"), Description("测试读取数据后加入的补偿值")]
public double OffsetValue { get; set; }
[PropertyOrder(7), Browsable(true), Category("4 控制"), DisplayName("4.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
public bool Disable { get; set; }
public TensionProp()
{
TestCnt = 5;
DelayTime = 0;
DataCnt = 1;
ProcessData = DataProcess.均值;
JudgmentData = DataJudgment.均值;
OffsetValue = 0;
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);
}
}
}
}
}