using MwFramework.ManagerService;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MainShell.Recipe.Models
{
    public class AxisFilteringParameter : PropertyChangedBase , IParameterItem
    {
        private int _axisIndex;
        /// <summary>
        /// 轴ID
        /// </summary>
        public int AxisIndex
        {
            get { return _axisIndex; }
            set
            {
                if (SetAndNotify(ref _axisIndex, value))
                {
                    NotifyOfPropertyChange(() => AxisDisplayName);
                }
            }
        }

        public string AxisDisplayName
        {
            get
            {
                string axisName = PidAxisCatalog.GetAxisName(AxisIndex);
                return string.IsNullOrWhiteSpace(axisName) ? AxisIndex.ToString() : axisName;
            }
        }

        private PIDLabel<bool> _isUseNotch = new PIDLabel<bool>() { Name = "PA_SLNothFilth", Value = false };
        /// <summary>
        /// 开启陷波滤波
        /// </summary>
        public PIDLabel<bool> IsUseNotch
        {
            get { return _isUseNotch; }
            set { SetAndNotify(ref _isUseNotch, value); }
        }

        private PIDLabel<double> _notchFrequency = new PIDLabel<double>() { Name = "PA_SLVNFRQ", Value = 0 };
        /// <summary>
        /// 陷波滤波频率
        /// </summary>
        public PIDLabel<double> NotchFrequency
        {
            get { return _notchFrequency; }
            set { SetAndNotify(ref _notchFrequency, value); }
        }

        private PIDLabel<double> _notchWidth = new PIDLabel<double>() { Name = "PA_SLVNWID", Value = 0 };
        /// <summary>
        /// 陷波滤波宽度
        /// </summary>
        public PIDLabel<double> NotchWidth
        {
            get { return _notchWidth; }
            set { SetAndNotify(ref _notchWidth, value); }
        }

        private PIDLabel<double> _notchFalloff = new PIDLabel<double>() { Name = "PA_SLVNATT", Value = 0 };
        /// <summary>
        /// 陷波滤波衰减
        /// </summary>
        public PIDLabel<double> NotchFalloff
        {
            get { return _notchFalloff; }
            set { SetAndNotify(ref _notchFalloff, value); }
        }

        private PIDLabel<bool> _isUseFiltering = new PIDLabel<bool>() { Name = "PA_SLLowPass", Value = false };
        /// <summary>
        /// 开启低通滤波
        /// </summary>
        public PIDLabel<bool> IsUseFiltering
        {
            get { return _isUseFiltering; }
            set { SetAndNotify(ref _isUseFiltering, value); }
        }

        private PIDLabel<double> _filteringFrequency = new PIDLabel<double>() { Name = "PA_SLVSOF", Value = 0 };
        /// <summary>
        /// 低通滤波频率
        /// </summary>
        public PIDLabel<double> FilteringFrequency
        {
            get { return _filteringFrequency; }
            set { SetAndNotify(ref _filteringFrequency, value); }
        }

        private PIDLabel<double> _filteringDamping = new PIDLabel<double>() { Name = "PA_SLVSOFD", Value = 0 };
        /// <summary>
        /// 低通滤波阻尼系数
        /// </summary>
        public PIDLabel<double> FilteringDamping
        {
            get { return _filteringDamping; }
            set { SetAndNotify(ref _filteringDamping, value); }
        }

        public IParameterItem Clone()
        {
            return new AxisFilteringParameter
            {
                AxisIndex = this.AxisIndex,
                IsUseNotch = this.IsUseNotch.Clone() as PIDLabel<bool>,
                NotchFrequency = this.NotchFrequency.Clone() as PIDLabel<double>,
                NotchWidth = this.NotchWidth.Clone() as PIDLabel<double>,
                NotchFalloff = this.NotchFalloff.Clone() as PIDLabel<double>,
                IsUseFiltering = this.IsUseFiltering.Clone() as PIDLabel<bool>,
                FilteringFrequency = this.FilteringFrequency.Clone() as PIDLabel<double>,
                FilteringDamping = this.FilteringDamping.Clone() as PIDLabel<double>
            };
        }
    }
}
