using System;
using System.IO;

namespace Adaptation.Shared.Metrology;

public class ScopeInfo : Properties.IScopeInfo
{

    public Test Test { get; private set; }
    public Enum Enum { get; private set; }
    public string HTML { get; private set; }
    public string Title { get; private set; }
    public string FileName { get; private set; }
    public int TestValue { get; private set; }
    public string Header { get; private set; }
    public string QueryFilter { get; private set; }
    public string FileNameWithoutExtension { get; private set; }

    public ScopeInfo(Test test, string fileName, string queryFilter = "", string title = "", string html = "")
    {
        Enum = test;
        Test = test;
        HTML = html;
        Title = title;
        FileName = fileName;
        TestValue = (int)test;
        Header = string.Empty;
        QueryFilter = queryFilter;
        FileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
    }

    public ScopeInfo(Test test)
    {
        Enum = test;
        Test = test;
        TestValue = (int)test;
        switch (Test)
        {
            case Test.AFMRoughness:
                FileNameWithoutExtension = "afm_iqs_01";
                Header = string.Empty;
                QueryFilter = "AFM Roughness";
                Title = "AFM";
                HTML = @"GaN Epi Data\10 - afm.html";
                break;
            case Test.BreakdownVoltageCenter:
                FileNameWithoutExtension = "bv_iqs_01";
                Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
                QueryFilter = "Breakdown Voltage";
                Title = "Breakdown Voltage-Center";
                HTML = @"GaN Epi Data\03 - bv-production.html";
                break;
            case Test.BreakdownVoltageEdge:
                FileNameWithoutExtension = "bv_iqs_01_Edge";
                Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
                QueryFilter = "Breakdown Voltage - Edge";
                Title = "Breakdown Voltage-Edge";
                HTML = @"GaN Epi Data\03 - bv-production.html";
                break;
            case Test.BreakdownVoltageMiddle8in:
                FileNameWithoutExtension = "bv_iqs_01_Middle";
                Header = "Reactor;fDate;fRecipeName;Lot;fPocketNumber;g4Scribe;BV Position;BV Value;Tool";
                QueryFilter = "Breakdown Voltage - Middle";
                Title = "Breakdown Voltage-Middle (8 in)";
                HTML = @"GaN Epi Data\03 - bv-production.html";
                break;
            case Test.CV:
                FileNameWithoutExtension = "cv_iqs_01";
                Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
                QueryFilter = "CV_Ns";
                Title = "CV";
                HTML = @"GaN Epi Data\05 - cv.html";
                break;
            case Test.MonthlyCV:
                FileNameWithoutExtension = "cv_iqs_01";
                Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
                QueryFilter = "CV_Ns";
                Title = "CV Monthly Verification";
                HTML = @"Metrology\07 - cv_verif_monthly.html";
                break;
            case Test.WeeklyCV:
                FileNameWithoutExtension = "cv_iqs_01";
                Header = "Reactor;fDate;fPart;Lot;pocketNumber;g4Scribe;Position;Vp;NdMin;Tool ID;CV Ns;CV Cap";
                QueryFilter = "CV_Ns";
                Title = "CV Weekly Verification";
                HTML = @"Metrology\16 - cv_verif_weekly.html";
                break;
            case Test.CandelaKlarfDC:
                FileNameWithoutExtension = "candela_iqs_01";
                Header = "LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;Epi;SlipLines;Cracks;EpiDef;HazeSpot;SmallLpd;MediumLpd;LargeLpd;Cracks_A;Spirals;Craters;8620 Small;Pits;Tool ID;Defect Count";
                QueryFilter = "Candela Cracking";
                Title = "Candela";
                HTML = @"GaN Epi Data\12 - candela.html";
                break;
            case Test.CandelaLaser:
                FileNameWithoutExtension = "candela_iqs_01";
                Header = "LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;Epi;SlipLines;Cracks;EpiDef;HazeSpot;SmallLpd;MediumLpd;LargeLpd;Cracks_A;Spirals;Craters;Pits;Tool ID;Defect Count";
                QueryFilter = "Candela Cracking";
                Title = "Candela";
                HTML = @"GaN Epi Data\12 - candela.html";
                break;
            case Test.CandelaVerify:
                FileNameWithoutExtension = "candela_iqs_01";
                Header = string.Concat("LotID;OperatorID;RecipeName;CandelaRecipe;WaferID;PocketNumber;RunDate;RunID;Reactor;", "Slip Lines;Cracks;Epi Def;Haze Spot;Small LPD;Medium LPD;Large LPD;Cracks_A;Spirals;Craters;8620 Small;Pits;Tool ID;Defect Count");
                QueryFilter = "Candela Cracking";
                Title = "Candela";
                HTML = @"GaN Epi Data\12 - candela.html";
                break;
            case Test.CandelaPSL:
                FileNameWithoutExtension = "candela_iqs_01";
                Header = string.Empty;
                QueryFilter = "102-83nm";
                Title = "Candela";
                HTML = @"GaN Epi Data\12 - candela.html";
                break;
            case Test.CandelaProdU:
                FileNameWithoutExtension = "candela_iqs_01";
                Header = string.Empty;
                QueryFilter = "SPE verification";
                Title = "Candela";
                HTML = @"GaN Epi Data\12 - candela.html";
                break;
            case Test.Denton:
                FileNameWithoutExtension = "denton_iqs_01";
                Header = "Tool;fDate;Run;Recipe;Operator;Name;Value";
                QueryFilter = "Denton_Voltage_AVG";
                Title = "Denton Data";
                HTML = @"Support Process\03 - ebeam02_denton_v1.html";
                break;
            case Test.Hall:
                FileNameWithoutExtension = "hall_iqs_01";
                Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
                QueryFilter = "Hall Rs";
                Title = "Hall Data";
                HTML = @"GaN Epi Data\04 - hall.html";
                break;
            case Test.MonthlyHall:
                FileNameWithoutExtension = "hall_iqs_01";
                Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
                QueryFilter = "Hall Rs";
                Title = "Hall Monthly Verification";
                HTML = @"Metrology\06 - hall_verif_monthly.html";
                break;
            case Test.WeeklyHall:
                FileNameWithoutExtension = "hall_iqs_01";
                Header = "Lot;Tool;TimeDate;RunDate;RunID;Part;Reactor;Scribe;PocketNumber;Tool ID;Name;Value";
                QueryFilter = "Hall Rs";
                Title = "Hall Weekly Verification";
                HTML = @"Metrology\15 - hall_verif_weekly.html";
                break;
            case Test.Lehighton:
                FileNameWithoutExtension = "lei_iqs_01";
                Header = "Reactor;Date;Recipe;Lot;Pocket;Scribe;Tool;Name;Value";
                QueryFilter = "LEI RS Average value";
                Title = "Lehighton";
                HTML = @"GaN Epi Data\13 - lehighton.html";
                break;
            case Test.VerificationLehighton:
                FileNameWithoutExtension = "___";
                Header = "Reactor;Date;Recipe;Lot;Pocket;Scribe;Tool;Name;Value";
                QueryFilter = "___";
                Title = "LEI Weekly Verification 2 Ohm cm";
                HTML = @"Metrology\14 - lei_verif_weekly.html.html";
                break;
            case Test.Microscope:
                FileNameWithoutExtension = string.Empty;
                Header = string.Empty;
                QueryFilter = "Microscope Center 5x";
                Title = "Total Microscope Defects";
                HTML = string.Empty;
                break;
            case Test.RPMXY:
                FileNameWithoutExtension = "RPM_Data";
                Header = "Lot;Date;Recipe;Reactor;Scribe;Pocket;Tool;Name;Value";
                QueryFilter = "Barrier_Composition_RPM_XY";
                Title = "RPM XY Data ***&*** View Data";
                HTML = @"GaN Epi Data\09 - rpm --- 08 - photoluminescence.html";
                break;
            case Test.RPMAverage:
                FileNameWithoutExtension = "RPMdata-short";
                Header = "fProductId;fDate;average;stdDev;fRecipeName;Reactor;g4Scribe;Pocket Number;Tool ID;Recipe From Rpm File";
                QueryFilter = "Epi Thickness Mean";
                Title = "RPM Average Data";
                HTML = @"GaN Epi Data\09 - rpm.html";
                break;
            case Test.RPMPLRatio:
                FileNameWithoutExtension = "PHOTOLUMINESCENCE_data-short";
                Header = "fProductId;fDate;g4Scribe;fRecipeName;bandEdge_nm;bandEdge_V;yellowBand_Pmw;yellowBand_nm;yellowBand_V;Reactor;Pocket Number;Tool ID";
                QueryFilter = "PL Ratio";
                Title = "Photoluminescence: PL Ratio";
                HTML = @"GaN Epi Data\08 - photoluminescence.html";
                break;
            case Test.DailyRPMXY:
                FileNameWithoutExtension = "RPM_Data";
                Header = "Lot;Date;Recipe;Reactor;Scribe;Pocket;Tool;Name;Value";
                QueryFilter = "Barrier_Composition_RPM_XY";
                Title = "";
                HTML = @"Metrology\?";
                break;
            case Test.DailyRPMAverage:
                FileNameWithoutExtension = "RPMdata-short";
                Header = "fProductId;fDate;average;stdDev;fRecipeName;Reactor;g4Scribe;Pocket Number;Tool ID;Recipe From Rpm File";
                QueryFilter = "Epi Thickness Mean";
                Title = "";
                HTML = @"Metrology\?";
                break;
            case Test.DailyRPMPLRatio:
                FileNameWithoutExtension = "PHOTOLUMINESCENCE_data-short";
                Header = "fProductId;fDate;g4Scribe;fRecipeName;bandEdge_nm;bandEdge_V;yellowBand_Pmw;yellowBand_nm;yellowBand_V;Reactor;Pocket Number;Tool ID";
                QueryFilter = "PL Ratio";
                Title = "RPM Daily Verification";
                HTML = @"Metrology\17 - rpm_verif_daily.html";
                break;
            case Test.VerificationRPM:
                FileNameWithoutExtension = "PhotoLuminescence_Ver";
                Header = "Part;Process;Date;Test;Value";
                QueryFilter = "PL Edge Wavelength";
                Title = "PL Daily Verification - [PL Edge Wavelength]";
                HTML = @"Metrology\18 - photoluminescence_verif_daily.html";
                break;
            case Test.Photoreflectance:
                FileNameWithoutExtension = "photoreflect_iqs_01";
                Header = "Lot;Date;Part;Reactor;Scribe;Pocket;Tool;Point;WaferPosition_PR;PR_Peak";
                QueryFilter = "PR Barrier Composition";
                Title = "Photoreflectance 6 in, Photoreflectance 8 in";
                HTML = @"GaN Epi Data\07 - photoreflectance.html";
                break;
            case Test.UV:
                FileNameWithoutExtension = "uv_iqs_01";
                Header = string.Empty;
                QueryFilter = "UV Broken";
                Title = "UV";
                HTML = @"GaN Epi Data\15 - uv 2.1.html";
                break;
            case Test.VpdIcpmsAnalyte:
                FileNameWithoutExtension = "VPD_iqs_01";
                Header = "Reactor;RunID;RunDate;PartNumber;PocketNumber;WaferScribe;Analyte;Value";
                QueryFilter = "Mg";
                Title = "VpdIcpmsAnalyteData";
                HTML = @"";
                break;
            case Test.WarpAndBow:
                FileNameWithoutExtension = "warp_iqs_01";
                Header = "fDate;fRecipeName;fProductId;g4Scribe;warp;bow;tool;Reactor;Pocket ID;bow_range;BowX;BowY;CenterBow";
                QueryFilter = "BowCenter";
                Title = "Warp and Bow";
                HTML = @"GaN Epi Data\14 - warp.html";
                break;
            case Test.VerificationWarpAndBow:
                FileNameWithoutExtension = "warp_ver_iqs_01";
                Header = "Part;Process;Date;WaferScribe;totWarp;bow";
                QueryFilter = "Bow Calibration";
                Title = "6 Inch Warp/Bow Daily Verification, 8 Inch Warp/Bow Daily Verification";
                HTML = @"Metrology\19 - warp_cal_daily.html";
                break;
            case Test.XRDXY:
                FileNameWithoutExtension = "xrd_iqs_NEW_01";
                Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;ToolID;Name;Value;Group";
                QueryFilter = "SL Period";
                Title = "XRD XY Raw Data Viewer";
                HTML = @"GaN Epi Data\11 - xrd.html";
                break;
            case Test.XRDWeightedAverage:
                FileNameWithoutExtension = "xrd_iqs_NEW_01_WtAVG";
                Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;Name;Value;Group";
                //QueryFilter = "Al% Barrier WTAVG";
                QueryFilter = "SL Period WTAVG";
                Title = "XRD Weighted Average Data";
                HTML = @"GaN Epi Data\11 - xrd.html";
                break;
            case Test.MonthlyXRD:
                FileNameWithoutExtension = "xrd_monthly_ver_iqs_01";
                Header = "Part;Process;Date;TestName;Value";
                QueryFilter = "XRD 2-Theta Position";
                Title = "XRD Monthly Verification";
                HTML = @"Metrology\03 - xrd_verif_monthly.html";
                break;
            case Test.WeeklyXRD:
                FileNameWithoutExtension = "xrd_weekly_ver_iqs_01";
                Header = "Part;Process;Lot;Date;TestName;Value";
                QueryFilter = "XRD Weekly AL% Center";
                Title = "XRD Weekly Verification";
                HTML = @"Metrology\12 - xrd_verif_weekly.html";
                break;
            case Test.JVXRD:
                FileNameWithoutExtension = "xrd_iqs_NEW_01";
                Header = "Reactor;fDate;fRecipeName;Lot;pocketNumber;g4Scribe;ToolID;Name;Value;Group";
                QueryFilter = "SL Period";
                Title = "XRD XY Raw Data Viewer";
                HTML = @"GaN Epi Data\11 - xrd.html";
                break;
            default:
                throw new Exception();
        }
        FileName = string.Concat(FileNameWithoutExtension, ".txt");
    }

    public ScopeInfo ShallowCopy() => (ScopeInfo)MemberwiseClone();

}