//时间:20200608
//作者:郝爽
//功能:切割孔
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FileManager;
using System.Xml;
namespace MeasureData
{
//操作步骤,在操作失败时,反馈的状态
public enum Operation
{
Init,
PTInsert,
GetCutPosition,
Cut,
PTOut,
GetHole,
Image,
Analysis,
Element
}
//测试结果
public enum State
{
Unmeasured,
Failed,
Success
}
//切割孔
public class CutHole: ISlo
{
#region 切割孔名
///
/// 切割孔名
///
private string m_HoleName;
public string HoleName
{
get { return this.m_HoleName; }
set { this.m_HoleName = value; }
}
#endregion
#region 坐标位置
private SemPosition m_Position;
public SemPosition Position
{
get { return this.m_Position; }
set { this.m_Position = value; }
}
#endregion
#region 工作状态
//操作步骤
private Operation m_opt;
public Operation OPT
{
get { return this.m_opt; }
set { this.m_opt = value; }
}
//开始时间
private DateTime m_start;
public DateTime START
{
get { return this.m_start; }
set { this.m_start = value; }
}
//结束时间
private DateTime m_end;
public DateTime END
{
get { return this.m_end; }
set { this.m_end = value; }
}
//测试结果
private State m_state;
public State STATE
{
get { return this.m_state; }
set { this.m_state = value; }
}
//测量开关
private bool m_switch;
public bool SWITCH
{
get { return this.m_switch; }
set { this.m_switch = value; }
}
#endregion
//构造函数
public CutHole()
{
Init();
}
//初始化函数
private void Init()
{
//设定初始值
m_opt = Operation.Init;
m_state = State.Unmeasured;
m_switch = false;
Position = new SemPosition();
}
//样品孔存储xml文档
public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
{
Slo slo_cuthole = new Slo();
xString regName = new xString();
regName.AssignValue("CutHole");
slo_cuthole.Register("RegName", regName);
//样品名称
xString SampleName = new xString();
SampleName.AssignValue(this.HoleName);
slo_cuthole.Register("SampleName", SampleName);
Slo slo_sp = new Slo();
xDouble ptx = new xDouble();
ptx.AssignValue(this.Position.X);
slo_sp.Register("X", ptx);
xDouble pty = new xDouble();
pty.AssignValue(this.Position.X);
slo_sp.Register("Y", pty);
xDouble ptz = new xDouble();
ptz.AssignValue(this.Position.Z);
slo_sp.Register("Z", ptz);
xDouble ptt = new xDouble();
ptt.AssignValue(this.Position.T);
slo_sp.Register("T", ptt);
xDouble ptr = new xDouble();
ptr.AssignValue(this.Position.R);
slo_sp.Register("R", ptr);
xDouble ptm = new xDouble();
ptx.AssignValue(this.Position.M);
slo_sp.Register("M", ptm);
slo_cuthole.Register("Position", slo_sp);
//操作步骤
xInt OPT = new xInt();
OPT.AssignValue(this.OPT.GetHashCode());
slo_cuthole.Register("OPT", OPT);
//开始时间
xTime_t START = new xTime_t();
START.AssignValue(this.START);
slo_cuthole.Register("START", START);
//结束时间
xTime_t END = new xTime_t();
END.AssignValue(this.END);
slo_cuthole.Register("END", END);
//测量结果
xInt STATE = new xInt();
STATE.AssignValue(this.STATE.GetHashCode());
slo_cuthole.Register("STATE", STATE);
//测量开关
xBool SWITCH = new xBool();
SWITCH.AssignValue(this.SWITCH);
slo_cuthole.Register("SWITCH", SWITCH);
if (isStoring)
{
slo_cuthole.Serialize(true, xml, rootNode);
}
else
{
slo_cuthole.Serialize(false, xml, rootNode);
this.OPT = (Operation)OPT.value();
this.START = START.value();
this.END = END.value();
this.STATE = (State)STATE.value();
this.SWITCH = SWITCH.value();
this.Position.X = (float)ptx.value();
this.Position.Y = (float)pty.value();
this.Position.Z = (float)ptz.value();
this.Position.T = (float)ptt.value();
this.Position.R = (float)ptr.value();
this.Position.M = (float)ptm.value();
}
}
}
}