using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FObjBase;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Common;
using Newtonsoft.Json;
using FLY.OBJComponents.Client;

namespace FLY.Thick.Base.Client
{
    /// <summary>
    /// 系统参数服务 客户端代理
    /// </summary>
    public class InitParamServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IInitParamService
    {
        protected override Type InterfaceType => typeof(IInitParamService);

        /// <summary>
        /// 系统参数服务 客户端代理 构造
        /// </summary>
        /// <param name="id">服务Id</param>
        public InitParamServiceClient(UInt32 id) : base(id) { }

        /// <summary>
        /// 系统参数服务 客户端代理 构造
        /// </summary>
        /// <param name="serviceId">服务Id</param>
        /// <param name="connName">连接器</param>
        public InitParamServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }



        #region FlyAd 参数
        /// <summary>
        /// 扫描架长
        /// </summary>
        public int PosLength { get; set; } = 8900;

        /// <summary>
        /// timeGridAdv 使能
        /// </summary>
        public bool IsTimeGridAdvEnabled { get; set; }

        /// <summary>
        /// ad 滞后量  1.28ms
        /// </summary>
        public int ADLag { get; set; }

        /// <summary>
        /// 从 flyad7 获取的
        /// </summary>
        public int PosOfGrid { get; protected set; } = 10;

        /// <summary>
        /// 设置的速度，与 实际速度比例 Speed1 = VScan*Speed1Scale
        /// </summary>
        public double Speed1Scale { get; protected set; } = 1;
        #endregion


        /// <summary>
        /// 自动归原点间距,次数
        /// </summary>
        public int AutoOrgInterval { get; set; }

        /// <summary>
        /// 编码器1 mm/pulse
        /// </summary>
        public double Encoder1_mmpp { get; set; } = 0.1;



        #region FilmPositionDetect 参数


        /// <summary>
        /// 线速度来源
        /// </summary>
        public FilmVSRC FilmVSrc { get; set; }

        /// <summary>
        /// 最小线速度 m/min
        /// </summary>
        public int FilmVThreshold { get; set; } = 2;
        /// <summary>
        /// 线速度:编码器2 mm/pulse
        /// </summary>
        public double Encoder2_mmpp { get; set; } = 0.1;
        /// <summary>
        /// 编码器2 放大
        /// </summary>
        public float Encoder2_comp { get; set; } = 1;

        /// <summary>
        /// 线速度:1圈多少mm
        /// </summary>
        public double MmOfR { get; set; } = 314;

        /// <summary>
        /// 本测厚仪探头与机头测厚仪探头距离单位m
        /// </summary>
        public double VDistanceWithHeader { get; set; }

        /// <summary>
        /// 纵向光纤传感器与本测厚仪探头距离 单位m;
        /// 修改此值，会改变纵向偏移
        /// </summary>
        public double VSensorOffset { get; set; }
        #endregion

        /// <summary>
        /// 数据有效源
        /// </summary>
        public DATAVALIDSRC DataValidSrc { get; set; }



        /// <summary>
        /// 当数据有效状态改变，自动按F1，F3
        /// </summary>
        public bool AutoF1F3 { get; set; }

        /// <summary>
        /// 当数据有效状态  无效->有效 ，等待多久重新扫描 ，单位s
        /// </summary>
        public int ReStartDelay { get; set; }

        /// <summary>
        /// 有按样标定硬件
        /// </summary>
        public bool HasProfileSample { get; set; }

        /// <summary>
        /// 有小托辊
        /// </summary>
        public bool HasHold { get; set; }

        #region 速度

        /// <summary>
        /// 扫描时速度 Velocity Of Scan 
        /// </summary>
        public UInt32 VScan { get; set; }
        /// <summary>
        /// 调试时速度，向前走，向后走 Velocity Of JOG
        /// </summary>
        public UInt32 VJOG { get; set; }
        /// <summary>
        /// 精确速度 Velocity Of Accuracy  如: 机架修正, 样品取样, 机架信息获取
        /// </summary>
        public UInt32 VAccuracy { set; get; }
        /// <summary>
        /// 开始速度 Start Velocity
        /// </summary>
        public UInt32 SVelocity { set; get; }
        /// <summary>
        /// 加速时间
        /// </summary>
        public UInt32 ATime { set; get; }
        /// <summary>
        /// 减速时间
        /// </summary>
        public UInt32 DTime { set; get; }
        /// <summary>
        /// 归0速度1
        /// </summary>
        public UInt32 HVelocity1 { set; get; }
        /// <summary>
        /// 归0速度2
        /// </summary>
        public UInt32 HVelocity2 { set; get; }

        #endregion

        /// <summary>
        /// 数据库保存的月数
        /// </summary>
        public int DBKeepMonth { get; set; }

        /// <summary>
        /// 数据库路径
        /// </summary>
        public string DbPath { get; set; }




        public void Apply() 
        {
            Call("Apply");
        }

    }
}
