#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using Volpe.Cafe.MarketData;
using Volpe.Cafe.MarketData.Design;
using Volpe.Cafe.ModelSettings;
using Volpe.Cafe.TechKeys;

namespace Volpe.Cafe.EffectsModels
{
    /// <summary>
    /// Provides a wrapper around a revision of a vehicle, for use during effects modeling.
    /// </summary>
    public class AnalysisEffectsVehicle : IEffectsVehicle
    {
        #region <<< Constructors >>>

        /// <summary>
        /// Initializes a new instance of the <see cref="AnalysisEffectsVehicle"/> class, based on the specified
        /// revision of a vehicle.
        /// </summary>
        /// <param name="revision">The revision of a vehicle to use for initializing this instance.</param>
        /// <param name="scen">The compliance scenario being analyzed.</param>
        /// <param name="settings">The modeling settings used for analysis.</param>
        public AnalysisEffectsVehicle(IVehicleRevision revision, Scenario scen, ModelingSettings settings)
        {
            this.Revision = revision;
            int year = revision.RevisionYear;

            this.RatedFE = Effects.CalcRatedVehicleFE(scen, year, revision);
            this.OnRoadFE = Effects.ConvertToOnRoadFE(this.RatedFE, revision.Style, settings);
            this.InitRatedFE = Effects.CalcRatedVehicleFE(scen, year, revision.BaselineInfo);
            this.InitOnRoadFE = Effects.ConvertToOnRoadFE(this.InitRatedFE, revision.Style, settings);
        }
        #endregion

        #region <<< Properties >>>

        /// <summary>
        /// Gets the underlying <see cref="IVehicleRevision"/> associated with this <see cref="AnalysisEffectsVehicle"/>
        /// instance.
        /// </summary>
        public IVehicleRevision Revision { get; }

        public int RevisionYear => this.Revision.RevisionYear;

        //----- general vehicle info -----
        public int Code => this.Revision.Code;
        public string ManufacturerName => this.Revision.ManufacturerName;

        public ModelYearKey RefreshYears => this.Revision.RefreshYears;
        public ModelYearKey RedesignYears => this.Revision.RedesignYears;

        public string Brand => this.Revision.Brand;
        public string Model => this.Revision.Model;
        public string Nameplate => this.Revision.Nameplate;

        public int PlatformCode => this.Revision.PlatformCode;
        public int EngineCode => this.Revision.EngineCode;
        public int TransmissionCode => this.Revision.TransmissionCode;

        //----- fuel-economy values -----
        public FuelValue FuelEconomy => this.Revision.FuelEconomy;
        public FuelValue FuelShare => this.Revision.FuelShare;
        public FuelType FuelType => this.FuelShare.FuelType;

        //----- sales/msrp -----
        public double Sales => this.Revision.Sales;
        public double Msrp => this.Revision.Msrp;

        //----- regulatory classification -----
        public RegulatoryClass RegClass => this.Revision.RegClass;
        public SafetyClass SafetyClass => this.Revision.SafetyClass;
        public VehicleClass VehicleClass => this.Revision.VehicleClass;

        public TechnologyClass TechnologyClass => this.Revision.TechnologyClass;
        public EngineTechnologyClass EngineTechnologyClass => this.Revision.EngineTechnologyClass;

        public bool IsZevCandidate => this.Revision.IsZevCandidate;
        public int? ZEVCandidate => this.Revision.ZEVCandidate;
        public int ZevApplicationYear => this.Revision.ZevApplicationYear;
        public int ZevReferenceVehicleCode => this.Revision.ZevReferenceVehicleCode;
        public bool CARBAgreement => this.Revision.CARBAgreement;

        //----- vehicle characteristics -----
        public Origin Origin => this.Revision.Origin;

        public VehicleStyle Style => this.Revision.Style;
        public VehicleFrame Structure => this.Revision.Structure;
        public DriveType Drive => this.Revision.Drive;

        public double Footprint => this.Revision.Footprint;

        public double CurbWeightMR0 => this.Revision.CurbWeightMR0;
        public double CurbWeight => this.Revision.CurbWeight;
        public double GVWR => this.Revision.GVWR;
        public double GCWR => this.Revision.GCWR;

        public double FuelCapacity => this.Revision.FuelCapacity;

        //----- vehicle powertrain -----
        public HEVType HevType => this.Revision.HevType;

        //----- technology utilization -----
        public TechKey128 TechKey => this.Revision.TechKey;

        //----- IEffectsVehicle -----
        public FuelValue RatedFE { get; }
        public FuelValue OnRoadFE { get; }

        public FuelValue InitFuelEconomy => this.Revision.BaselineInfo.FuelEconomy;
        public FuelValue InitRatedFE { get; }
        public FuelValue InitOnRoadFE { get; }
        public FuelValue InitFuelShare => this.Revision.BaselineInfo.FuelShare;
        public FuelType InitFuelType => this.InitFuelShare.FuelType;
        public double InitCurbWeight => this.Revision.BaselineInfo.CurbWeight;

        //----- explicit interface implementation -----
        double IEffectsVehicle.FleetShare => 1;
        bool IEffectsVehicle.IsHistoric => false;

        #endregion
    }
}
