using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace MainShell.ProcessResult
{
    public class ProductionDashboardState : ProcessResultBase, INotifyPropertyChanged
    {
        private string _productId = string.Empty;
        private string _chipId = string.Empty;
        private int _processedSubstrateTotal;
        private int _pendingCount;
        private int _processedCount;
        private int _realTimeUph;
        private int _yieldUph;
        private double _mappingProgress;

        public event PropertyChangedEventHandler PropertyChanged;

        public string ProductId
        {
            get => _productId;
            set => SetField(ref _productId, value);
        }

        public string ChipId
        {
            get => _chipId;
            set => SetField(ref _chipId, value);
        }

        public int ProcessedSubstrateTotal
        {
            get => _processedSubstrateTotal;
            set => SetField(ref _processedSubstrateTotal, value);
        }

        public int PendingCount
        {
            get => _pendingCount;
            set => SetField(ref _pendingCount, value);
        }

        public int ProcessedCount
        {
            get => _processedCount;
            set => SetField(ref _processedCount, value);
        }

        public int RealTimeUph
        {
            get => _realTimeUph;
            set => SetField(ref _realTimeUph, value);
        }

        public int YieldUph
        {
            get => _yieldUph;
            set => SetField(ref _yieldUph, value);
        }

        public double MappingProgress
        {
            get => _mappingProgress;
            set => SetField(ref _mappingProgress, value);
        }

        private void SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (EqualityComparer<T>.Default.Equals(field, value))
            {
                return;
            }

            field = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}