using Logger;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TSMasterCAN;
using UIShare.UIViewModel;
using static UIShare.UIViewModel.ParameterVM;

namespace UIShare.GlobalVariable
{
    public class SystemConfig
    {
        [JsonIgnore]
        public string SystemPath { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ACP");
        [JsonIgnore]
        public string DLLFilePath { get; set; } = @"D:\ACP\指令\";
        [JsonIgnore]
        public string TSMasterName { get; set; } = "ACP测试上位机";
        public string SubProgramFilePath { get; set; } = @"D:\ACP\子程序\";
        public string Title { get; set; } = string.Empty;
        public string CurrentACPFile { get; set; }
        public int PerformanceLevel { get; set; } = 50;
        public string DefaultProgramFilePath { get; set; } = "";
        public string DefaultBLFFilePath { get; set; } = "";
        public string DefaultDBCFilePath { get; set; } = "";
        public ObservableCollection<DeviceInfoVM> DeviceList = new();
        public ObservableCollection<SharedParameter> SharedParameterList = new();
        public ObservableCollection<CANSignalConfig> ConfigurationList = new();
        public ObservableCollection<AutoDBCLoadItem> DBCAutoLoadList = new();
        public ObservableCollection<ValueLimitVM> ValueLimitList = new();
        [JsonIgnore]
        public ObservableCollection<MonitorChannelVM> Channels = new();
        /// <summary>
        /// 监测通道持久化配置列表（包含 Fingerprint、MethodName、IsDisplayed）
        /// </summary>
        public ObservableCollection<MonitorChannelConfig> MonitorChannels = new();
        public CAN CANFD = new();
        [JsonIgnore]
        public ObservableCollection<ParameterVM> ParameterList = new()
        {
            new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "台架序号",
                Value = 1,
                IsEditable=false
            },
             new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "直流负载通道",
                Value = 1,
                IsEditable=false
            },
              new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "交流电源通道",
                Value = 1,
                IsEditable=false
            },
            new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "CAN通道",
                Value = 0,
                IsEditable=false
            },
            new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "示波器通道1",
                Value = 0,
                IsEditable=false
            },
              new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "示波器通道2",
                Value = 0,
                IsEditable=false
            },
              new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "功率分析仪通道1",
                Value = 0,
                IsEditable=false
            },
                new ParameterVM
            {
                Category = ParameterCategory.Input,
                Type = typeof(int),
                Name = "功率分析仪通道2",
                Value = 0,
                IsEditable=false
            },
        };
//        public ObservableCollection<DeviceInfoVM> DeviceList { get; set; } = new()
//{
//    new DeviceInfoVM
//    {
//        DeviceName = "IT7800E",
//        DeviceType = "IT7800E",
//        Remark = "交流可编程电源供应器",
//        ConnectionType = "Tcp",
//        IsEnabled = true,
//        IsConnected = false
//    },

        //    new DeviceInfoVM
        //    {
        //        DeviceName = "N36200",
        //        DeviceType = "N36200",
        //        Remark = "宽范围可编程直流电源",
        //        ConnectionType = "Tcp",
        //        IsEnabled = true,
        //        IsConnected = false
        //    },

        //    new DeviceInfoVM
        //    {
        //        DeviceName = "N36600",
        //        DeviceType = "N36600",
        //        Remark = "便携式宽范围可编程直流电源",
        //        ConnectionType = "Tcp",
        //        IsEnabled = false,
        //        IsConnected = false
        //    },

        //    new DeviceInfoVM
        //    {
        //        DeviceName = "N69200",
        //        DeviceType = "N69200",
        //        Remark = "可编程直流电子负载",
        //        ConnectionType = "Tcp",
        //        IsEnabled = true,
        //        IsConnected = false
        //    },

        //    new DeviceInfoVM
        //    {
        //        DeviceName = "SDS2000X_HD",
        //        DeviceType = "SDS2000X_HD",
        //        Remark = "数字存储示波器",
        //        ConnectionType = "Tcp",
        //        IsEnabled = true,
        //        IsConnected = false
        //    },

        //    new DeviceInfoVM
        //    {
        //        DeviceName = "SPAW7000",
        //        DeviceType = "SPAW7000",
        //        Remark = "功率分析记录仪",
        //        ConnectionType = "Tcp",
        //        IsEnabled = true,
        //        IsConnected = false
        //    }
        //};
    }
}
