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

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

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

        private static new string[] GetHeaders()
        {
            string[] headers = {
                //----- header columns -----
                "Scenario", "Scenario Name", "Model Year", "Manufacturer", "Reg-Class",

                //----- sales & employment -----
                "Sales", "Jobs",

                //----- compliance states -----
                "CAFE in Compliance", "CO2 in Compliance", "ZEV in Compliance",

                //----- CAFE compliance metrics -----
                "Prelim-Stnd", "MDPC-Stnd", "Standard", "Standard (gal/100mi)",
                "CAFE (2-cycle)", "CAFE", "CAFE (gal/100mi)",
                "AC Efficiency", "Off-Cycle Credits", "FSP Credits",

                //----- CO-2 compliance metrics -----
                "CO-2 Standard", "CO-2 Rating",
                "CO-2 AC Efficiency", "CO-2 AC Leakage", "CO-2 Off-Cycle Credits", "CO-2 FSP Credits",

                //----- vehicle attributes -----
                "Average CW", "Average FP", "Average WF",
                
                //----- ZEV targets -----
                "ZEV Target", "ZEV Credits",

                //----- cost "totals" -----
                "AC Efficiency Cost", "AC Leakage Cost", "Off-Cycle Cost",
                "Battery Cost", "Non-Battery Cost", "Total Tech Cost",
                "Fines", "Reg-Cost", "Maint/Repair Cost", "Tax Credit", "Battery Tax Credit",

                "Delta HEV Cost", "Delta Tax Credit", "Delta Battery Tax Credit",
                "Delta Consumer WTP", "Tech Burden",

                //----- cost "averages" -----
                "Avg AC Efficiency Cost", "Avg AC Leakage Cost", "Avg Off-Cycle Cost",
                "Avg Battery Cost", "Avg Non-Battery Cost", "Avg Tech Cost",
                "Avg Fines", "Avg Reg-Cost", "Avg Maint/Repair Cost", "Avg Tax Credit", "Avg Battery Tax Credit",

                "Avg Delta HEV Cost", "Avg Delta Tax Credit", "Avg Delta Battery Tax Credit",
                "Avg Delta Consumer WTP", "Avg Tech Burden",

                //----- CAFE & CO-2 credits -----
                "Credits Earned", "Credits Out", "Credits In",
                "CO-2 Credits Earned", "CO-2 Credits Out", "CO-2 Credits In"
            };

            return headers;
        }

    }

    /// <summary>
    /// Provides support for generating an <b>"incremental" compliance</b> modeling report.
    /// </summary>
    [Serializable]
    public class ComplianceIncrementalReport : ComplianceReport
    {
        /// <inheritdoc/>
        public ComplianceIncrementalReport(string path, bool append = false)
            : base(path, append) { }

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

    }
}
