//20201112 EDS参数相关类
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 EDSParam : ISlo
    {
        #region 内容
        //Image参数
        //图像存储路径
        private string m_sPath;
        public string Path
        {
            get { return this.m_sPath; }
            set { this.m_sPath = value; }
        }

        //图像分辨率
        private double m_fScanSize;
        public double ScanSize
        {
            get { return this.m_fScanSize; }
            set { this.m_fScanSize = value; }
        }

        //采集时间
        private double m_fDwellTime;
        public double DwellTime
        {
            get { return this.m_fDwellTime; }
            set { this.m_fDwellTime = value; }
        }

        //图像类型
        private int m_nImageType;
        public int ImageType
        {
            get { return this.m_nImageType; }
            set { this.m_nImageType = value; }
        }

        //Xray参数
        //分析方式：点扫描1，面扫描2
        private bool m_PointMode;
        public bool PointMode
        {
            get { return this.m_PointMode; }
            set { this.m_PointMode = value; }
        }

        private bool m_AreaMode;
        public bool AreaMode
        {
            get { return this.m_AreaMode; }
            set { this.m_AreaMode = value; }
        }

        //分析时间
        private double m_nPointTime;
        public double PointTime
        {
            get { return this.m_nPointTime; }
            set { this.m_nPointTime = value; }
        }

        private double m_nAreaTime;
        public double AreaTime
        {
            get { return this.m_nAreaTime; }
            set { this.m_nAreaTime = value; }
        }
        public int XrayCollectMode;//Xray collecting type,0=point mode,1=line mode,2=area mode.
        #endregion

        public EDSParam()
        {
            Init();
        }

        public void Init()
        {
            this.Path = "";
            this.ScanSize = 1024;
            this.DwellTime = 1;
            this.ImageType = 1;
            this.PointMode = true;
            this.AreaMode = true;
            this.PointTime = 100;
            this.AreaTime = 200;
            XrayCollectMode = 0;
        }

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

            //xString ImagePath = new xString();
            xDouble ScanSize = new xDouble();
            xDouble DwellTime = new xDouble();
            xInt ImageType = new xInt();
            xInt XrayType = new xInt();
            xDouble XrayPointTime = new xDouble();
            xDouble XrayAreaTime = new xDouble();
            xBool PointMode = new xBool();
            xBool AreaMode = new xBool();

            //ImagePath.AssignValue(this.Path);
            ScanSize.AssignValue(this.ScanSize);
            DwellTime.AssignValue(this.DwellTime);
            ImageType.AssignValue(this.ImageType);
            //XrayType.AssignValue(this.Mode);
            XrayPointTime.AssignValue(this.PointTime);
            XrayAreaTime.AssignValue(this.AreaTime);
            PointMode.AssignValue(this.PointMode);
            AreaMode.AssignValue(this.AreaMode);

            //slo_edsparam.Register("ImagePath", ImagePath);
            slo_edsparam.Register("ScanSizes", ScanSize);
            slo_edsparam.Register("DwellTime", DwellTime);
            slo_edsparam.Register("ImageType", ImageType);
            //slo_edsparam.Register("XrayMode", XrayType);
            slo_edsparam.Register("XrayPointTime", XrayPointTime);
            slo_edsparam.Register("XrayAreaTime", XrayAreaTime);
            slo_edsparam.Register("PointMode", PointMode);
            slo_edsparam.Register("AreaMode", AreaMode);

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

                //this.Path = ImagePath.value();
                this.ScanSize = ScanSize.value();
                this.DwellTime = DwellTime.value();
                this.ImageType = ImageType.value();
                //this.Mode = XrayType.value();
                this.PointTime = XrayPointTime.value();
                this.AreaTime = XrayAreaTime.value();
                this.PointMode = PointMode.value();
                this.AreaMode = AreaMode.value();

            }
        }

    }
}
