using System;
using System.Linq;
using Volpe.Cafe.DfsSrModels.Aggregators;

namespace Volpe.Cafe.DfsSrModels
{
    /// <summary>
    /// Defines helper variables, properties, and methods for the DFS/SR model and modules.
    /// </summary>
    [Serializable]
    internal static class DfsSrHelpers
    {
        /// <summary>
        /// Specifies an <see cref="VehicleStyles.AltList"/> filtered for the light-duty only style(s).
        /// </summary>
        public static readonly VehicleStyle[] VehStylesLightDuty =
            VehicleStyles.AltList.Where(vehStyle => vehStyle != VehicleStyle.Generic2b3).ToArray();

        /// <summary>
        /// Specifies an <see cref="VehicleStyles.AltList"/> filtered for the HDPUV only style(s).
        /// </summary>
        public static readonly VehicleStyle[] VehStylesHdpuv = { VehicleStyle.Generic2b3 };

        /// <summary>
        /// Returns a vehicle class, using the specified forecast vehicle data, that the fleet aggregator and sales
        /// rescaler can use for binning vehicles.
        /// </summary>
        public static VehicleClass GetBinningVehClass(ForecastVehicleData forecastVehData)
        {
            var regClass = forecastVehData.RegClass;
            var vehClass = forecastVehData.VehClass;

            return (vehClass.IsLDT2b3() && regClass.IsLD())
                ? VehicleClass.LDT12a
                : vehClass;
        }

        /// <summary>
        /// Returns a regulatory class, using the specified forecast vehicle data, that the fleet aggregator and sales
        /// rescaler can use for binning vehicles.
        /// </summary>
        /// <param name="forecastVehData">
        ///     The forecast vehicle data that for which to obtain a reg-class for binning.
        /// </param>
        /// <param name="aggregateByBaseRC">
        ///     <inheritdoc cref="ForecastFleetAggregatorRegClass(ModelSettings.ModelingSettings, bool)"
        ///                 path="/param[@name='aggregateByBaseRegClass']"/>
        /// </param>
        public static RegulatoryClass GetBinningRegClass(ForecastVehicleData forecastVehData, bool aggregateByBaseRC)
        {
            return aggregateByBaseRC
                ? forecastVehData.RevisionInfo.BaselineInfo.RegClass
                : forecastVehData.RegClass;
        }

    }
}
