//时间：20200911
//作者：郝爽
//功能：测量参数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using FileManager;
using System.Xml;
using System.IO;

namespace MeasureData
{
    public class FocusParamold : ISlo
    {
        #region 内容
        //图像存储路径
        private string m_sPath;
        public string Path
        {
            get { return this.m_sPath; }
            set { this.m_sPath = value; }
        }

        //调节上限
        private float m_fUp;
        public float UP
        {
            get { return this.m_fUp; }
            set { this.m_fUp = value; }
        }
        //调节下限
        private float m_fDown;
        public float Down
        {
            get { return this.m_fDown; }
            set { this.m_fDown = value; }
        }
        //调节步长
        private float m_fStep;
        public float Step
        {
            get { return this.m_fStep; }
            set { this.m_fStep = value; }
        }
        //精调范围
        private float m_ffRange;
        public float Range
        {
            get { return this.m_ffRange; }
            set { this.m_ffRange = value; }
        }
        //精调步长
        private float m_ffStep;
        public float fStep
        {
            get { return this.m_ffStep; }
            set { this.m_ffStep = value; }
        }
        //调试控制量
        //enum WorkType
        //{
        //    AutoFocus = 1, //SEM自动对焦
        //    AutoStigx = 2, //SEM自动消像散x
        //    AutoStigy = 3, //SEM自动消像散y
        //    AutoFIBFocus = 4, //FIB自动对焦
        //    AllThing = 5
        //};
        private int m_nType;
        public int TYPE
        {
            get { return this.m_nType; }
            set { this.m_nType = value; }
        }
        #endregion

        public FocusParamold()
        {
            Init();
        }

        public void Init()
        {
            this.UP = 0;
            this.Down = 0;
            this.Step = 0;
            this.Range = 0;
            this.fStep = 0;
            this.TYPE = 1;
        }

        //XML文件保存测量参数
        public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
        {
            Slo slo_fcsparam = new Slo();

            xDouble dUp = new xDouble();
            xDouble dDown = new xDouble();
            xDouble dStep = new xDouble();
            xDouble dRange = new xDouble();
            xDouble dfStep = new xDouble();
            xInt nType = new xInt();

            dUp.AssignValue(this.UP);
            dDown.AssignValue(this.Down);
            dStep.AssignValue(this.Step);
            dRange.AssignValue(this.Range);
            dfStep.AssignValue(this.fStep);
            nType.AssignValue(this.TYPE);

            slo_fcsparam.Register("UP", dUp);
            slo_fcsparam.Register("Down", dDown);
            slo_fcsparam.Register("Step", dStep);
            slo_fcsparam.Register("Range", dRange);
            slo_fcsparam.Register("fStep", dfStep);
            slo_fcsparam.Register("Type", nType);

            dUp.AssignValue(this.UP);
            dDown.AssignValue(this.Down);
            dStep.AssignValue(this.Step);
            dRange.AssignValue(this.Range);
            dfStep.AssignValue(this.fStep);

            slo_fcsparam.Register("UP", dUp);
            slo_fcsparam.Register("DOWN", dDown);
            slo_fcsparam.Register("STEP", dStep);
            slo_fcsparam.Register("RANGE", dRange);
            slo_fcsparam.Register("FSTEP", dfStep);

            if (isStoring)
            {
                slo_fcsparam.Serialize(true, xml, rootNode);
            }
            else
            {
                slo_fcsparam.Serialize(false, xml, rootNode);

                this.UP = (float)dUp.value();
                this.Down = (float)dDown.value();
                this.Step = (float)dStep.value();
                this.Range = (float)dRange.value();
                this.fStep = (float)dfStep.value();
                this.TYPE = (int)nType.value();
            }
        }
    }
}