// Created with MonoDevelop
//
//    Copyright (C) 2023 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System.Collections.Generic;
using Hiperscan.Unix;

namespace Hiperscan.SGS
{
    public static class ProductInfo
    {
        public static string[] GetProductNames(uint vendor_id, uint product_id)
        {
            string[] product_names = null;

            switch(vendor_id)
            {
                case VendorId.FTDI:
                    product_names = ProductInfo.GetFtdiProductNames(product_id);
                    break;

                case VendorId.HIPERSCAN:
                    product_names = ProductInfo.GetHiperscanProductNames(product_id);
                    break;

                default:
                    product_names = ProductInfo.UnknownProductName;
                    break;
            }

            return product_names;
        }

        public static string GetProductNameGroup(uint vendor_id, uint product_id, char separator = '|')
        {
            return string.Join(" " + separator.ToString() + " ", 
                               ProductInfo.GetProductNames(vendor_id, product_id));
        }

        private static string[] GetFtdiProductNames(uint product_id)
        {
            string[] product_names = null;

            switch (product_id)
            {
                case ProductId.SGS1900_GROUP:
                    product_names = new string[] { "SGS1900 TYPE A", "SGS1900 TYP D", "FinderSD", "Apo-Ident" };
                    break;

                case ProductId.SGS1900B:
                    product_names = new string[] { "SGS1900 TYPE B" };
                    break;

                case ProductId.SGS1900C:
                    product_names = new string[] { "SGS1900 TYPE C" };
                    break;

                default:
                    product_names = ProductInfo.UnknownProductName;
                    break;
            }

            return product_names;
        }

        private static string[] GetHiperscanProductNames(uint product_id)
        {
            string[] product_names = null;

            switch (product_id)
            {
                case ProductId.INNO_NIR:
                    product_names = new string[] { "InnoNIR+" };
                    break;

                case ProductId.CALIBRATION_DEVICE:
                    product_names = new string[] { "Calibration Device" };
                    break;

                case ProductId.APOIDENT2_SGS:
                    product_names = new string[] { "ApoIdent 2 (SGS1900)" };
                    break;

                case ProductId.ES20_OEM:
                    product_names = new string[] { "ES20 OEM" };
                    break;

                case ProductId.APOIDENT_2X_ES20:
                    product_names = new string[] { "ApoIdent 2.x (ES20)" };
                    break;

                case ProductId.ES20_SENSOR_FINDER2:
                    product_names = new string[] { "ES20 Sensor Finder 2" };
                    break;

                case ProductId.FINDER2_USB_DEVICE:
                    product_names = new string[] { "Finder 2 USB Device" };
                    break;

                case ProductId.PPF2_FINDER2_:
                    product_names = new string[] { "PPF2 Finder 2 (Sensor Controller)" };
                    break;

                case ProductId.ES22_SENSOR_FINDER2:
                    product_names = new string[] { "ES22 Sensor Finder 2" };
                    break;

                case ProductId.ES22_SENSOR_APOIDENT_2_1:
                    product_names = new string[] { "ES22 Sensor ApoIdent 2.1" };
                    break;

                case ProductId.ES22_SENSOR_FINDERX:
                    product_names = new string[] { "ES22 Sensor FinderX" };
                    break;

                case ProductId.ES20_USB_DFU_BOOTLOADER_:
                    product_names = new string[] { "ES20 USB DFU Bootloader" };
                    break;

                case ProductId.FINDER2_BOOTLOADER:
                    product_names = new string[] { "Finder 2 Bootloader" };
                    break;

                default:
                    product_names = ProductInfo.UnknownProductName;
                    break;
            }

            return product_names;
        }

        private static string[] UnknownProductName => new string[] { Catalog.GetString("Unknown") };
    }
}
