using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using LFP_Manager.DataStructure;

namespace LFP_Manager.Controls
{
    public partial class ucCalibrationView : DevExpress.XtraEditors.XtraUserControl
    {
        #region VARIABLES

        DeviceSystemData ModuleData;

        #endregion

        public ucCalibrationView()
        {
            InitializeComponent();

            edBattCapacity.Enabled = false;
            edChgOption.Enabled = false;
            edChgCalibration.Enabled = false;
            edDchCalibration.Enabled = false;
        }

        public void DisplayValue(ref DeviceSystemData[] aSystemData)
        {
            ModuleData = aSystemData[0];

            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(delegate ()
                {
                    edBattCapacity.Text = String.Format("{0}", ModuleData.CalibrationData.Battery.Capacity);
                    if (ModuleData.CalibrationData.Current.ChargeOption == 0)
                        edChgOption.Text = "Full Charge";
                    else
                        edChgOption.Text = "Limit Charge";
                    edChgCalibration.Text = String.Format("{0}", ModuleData.CalibrationData.Current.ChgCalibration_K);
                    edDchCalibration.Text = String.Format("{0}", ModuleData.CalibrationData.Current.DchCalibration_K);
                }));
            }
            else
            {
                edBattCapacity.Text = String.Format("{0}", ModuleData.CalibrationData.Battery.Capacity);
                if (ModuleData.CalibrationData.Current.ChargeOption == 0)
                    edChgOption.Text = "Full Charge";
                else
                    edChgOption.Text = "Limit Charge";
                edChgCalibration.Text = String.Format("{0}", ModuleData.CalibrationData.Current.ChgCalibration_K);
                edDchCalibration.Text = String.Format("{0}", ModuleData.CalibrationData.Current.DchCalibration_K);
            }
        }
    }
}
