// Created with MonoDevelop
//
//    Copyright (C) 2023 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.


using System;
namespace Hiperscan.SGS.Benchtop.TemperatureControl
{
    public class PidControl
    {
        public override string ToString()
        {
            String data = String.Empty;

            if (Double.IsNaN(this.ProportionalComponent))
                data += "P-Component: n/a; ";
            else
                data += String.Format("P-Component: {0:F2}; ", this.ProportionalComponent);

            if (Double.IsNaN(this.IntegralComponent))
                data += "I-Component: n/a; ";
            else
                data += String.Format("I-Component: {0:F2}; ", this.IntegralComponent);

            if (Double.IsNaN(this.DerivativeComponent))
                data += "D-Component: n/a ";
            else
                data += String.Format("D-Component: {0:F2}; ", this.DerivativeComponent);

            return data;
        }

        public PidControl Clone()
        {
            return new PidControl()
            {
                DerivativeComponent = this.DerivativeComponent,
                ProportionalComponent = this.ProportionalComponent,
                IntegralComponent = this.IntegralComponent
            };
        }


        public double ProportionalComponent { get; set; } = double.NaN;
        public double IntegralComponent { get; set; } = double.NaN;
        public double DerivativeComponent { get; set; } = double.NaN;
    }
}
