using System;
using System.Collections.Generic;
using Volpe.Cafe.ModelSettings;
using Volpe.Cafe.Reporting.Generators;

using TI = Volpe.Cafe.TechnologyIndexes;

namespace Volpe.Cafe.Reporting.ModelingReports
{
    /// <summary>
    /// Provides support for generating a <b>vehicles diagnostic</b> modeling report.
    /// </summary>
    [Serializable]
    public class VehiclesDiagnosticReport : ModelingReport
    {
        /// <inheritdoc cref="ModelingReport(string, bool, Func{string[]})"/>
        public VehiclesDiagnosticReport(string path, bool append = false)
            : base(path, append, GetHeaders) { }

        /// <inheritdoc/>
        public override ReportDataGenerator GetDataGenerator(
            Scenario scen, ReportingData data, ModelingSettings settings)
        {
            return new VehiclesDiagnosticReportDataGenerator(scen, data, settings);
        }

        private static new string[] GetHeaders()
        {
            List<string> headers = new List<string>() { 
                //----- header columns -----
                "Scenario", "Model Year", "Manufacturer", "Veh Code",
                
                //----- regulatory classification -----
                "Veh Class", "Reg Class", "Tech Class", "Eng Tech Class",
                
                //----- planning info (redesign/refresh and leader state)
                "Veh Redesign/Refresh", "Plt Redesign/Refresh", "Eng Redesign/Refresh", "Trn Redesign/Refresh",
                "Component Leader",

                //----- tech-keys -----
                "TechKey Initial", "TechKey",

                //----- curb weight -----
                "CW (MR0)", "GW (MR0)", "CW Initial", "CW", "Delta CW",
                
                //----- fuel economy/fuel share -----
                "FE Primary Initial", "FE Secondary Initial", "FE Initial", "Fuel Initial", "FS Initial",
                "FE Primary", "FE Secondary", "FE", "Fuel", "Fuel Share",

                //----- FE adjustment factors -----
                "FE1 Adj Factor Initial", "FE2 Adj Factor Initial", "FE1 Adj Factor", "FE2 Adj Factor",

                //----- unit costs -----
                "Tech Cost", "Battery Tech Cost Initial", "Battery Tech Cost",
                "Battery Learning Rate Initial", "Battery Learning Rate"
            };

            //----- tech utilization and veh/eng cost -----
            Array.ForEach(TI.TechNames, techName => headers.Add(techName));
            Array.ForEach(TI.TechNames, techName => headers.Add($"{techName}_VehCost"));
            Array.ForEach(TI.TechNames, techName => headers.Add($"{techName}_EngCost"));

            return headers.ToArray();
        }

    }
}
