using System; using System.Collections.Generic; namespace Uestc.Auto6.Dso.ComModel { public enum ChannelId { C1 = 0, C2, C3, C4, C5, C6, C7, C8, M1 = 100, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15, M16, M17, M18, M19, M20, M21, M22, M23, M24, M25, M26, M27, M28, M29, M30, M31, M32, M33, M34, M35, M36, M37, M38, M39, M40, M41, M42, M43, M44, M45, M46, M47, M48, R1 = 200, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, B1 = 300, B2, D1 = 400, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, D31, D32, D33, D34, D35, D36, D37, D38, D39, D40, D41, D42, D43, D44, D45, D46, D47, D48, D49, D50, D51, D52, D53, D54, D55, D56, D57, D58, D59, D60, D61, D62, D63, D64, P1 = 1100, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15, P16, AWG1 = 1200, AWG2, AWG3, AWG4, DVM = 1240, Ext = 1250, Ext5, AC, USER = 1300, RF1 = 1400, RF2, RF3, RF4, RF5, RF6, RF7, RF8, RF, AVT1 = 1500, AVT2, AVT3, AVT4, AVT5, AVT6, AVT7, AVT8, AVT, PVT1 = 1600, PVT2, PVT3, PVT4, PVT5, PVT6, PVT7, PVT8, PVT, PVF1 = 1700, PVF2, PVF3, PVF4, PVF5, PVF6, PVF7, PVF8, PVF, PGD1 = 1800, PGD2, PGD3, PGD4, PGD5, PGD6, PGD7, PGD8, PGD, TVF1 = 1900, TVF2, TVF3, TVF4, TVF5, TVF6, TVF7, TVF8, TVF, FVT1 = 2000, FVT2, FVT3, FVT4, FVT5, FVT6, FVT7, FVT8, FVT, } public static class ChannelIdExt { static ChannelIdExt() { MaxAChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxAChId)]?.ToString() ?? "C4"); MaxMChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxMChId)]?.ToString() ?? "M8"); MaxRChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxRChId)]?.ToString() ?? "R4"); MaxDChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxDChId)]?.ToString() ?? "D16"); MaxBChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxBChId)]?.ToString() ?? "B2"); MaxPChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxPChId)]?.ToString() ?? "P8"); MaxAwgId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxAwgId)]?.ToString() ?? "AWG1"); MaxRFChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxRFChId)]?.ToString() ?? "RF"); MaxAVTChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxAVTChId)]?.ToString() ?? "AVT"); MaxPVTChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxPVTChId)]?.ToString() ?? "PVT"); MaxPVFChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxPVFChId)]?.ToString() ?? "PVF"); MaxPGDChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxPGDChId)]?.ToString() ?? "PGD"); MaxTVFChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxPGDChId)]?.ToString() ?? "TVF"); MaxFVTChId = Enum.Parse(AppConfigureHelper.AppSettings[nameof(MaxPGDChId)]?.ToString() ?? "FVT"); AnaChnlNum = MaxAChId - MinAChId + 1; DigiChnlNum = MaxDChId - MinDChId + 1; MathChnlNum = MaxMChId - MinMChId + 1; RefChnlNum = MaxRChId - MinRChId + 1; BusChnlNum = MaxBChId - MinBChId + 1; MeasChnlNum = MaxPChId - MinPChId + 1; AwgNum = MaxAwgId - MinAwgId + 1; RFChnlNum = MaxRFChId - MinRFChId + 1; } public static readonly Int32 AnaChnlNum; public static readonly Int32 DigiChnlNum; public static readonly Int32 MathChnlNum; public static readonly Int32 RefChnlNum; public static readonly Int32 BusChnlNum; public static readonly Int32 MeasChnlNum; public static readonly Int32 AwgNum; public static readonly Int32 DvmNum = 1; public static readonly Int32 RFChnlNum; public static readonly Int32 AVTChnlNum; public static readonly Int32 PVTChnlNum; public static readonly Int32 PVFChnlNum; public static readonly Int32 PGDChnlNum; public static readonly Int32 TVFChnlNum; public static readonly Int32 FVTChnlNum; public static readonly ChannelId MinAChId = ChannelId.C1; public static readonly ChannelId MaxAChId; public static Boolean IsAnalog(this ChannelId id) => id >= MinAChId && id <= MaxAChId; public static IEnumerable GetAnalogs() { for (ChannelId id = MinAChId; id <= MaxAChId; id++) { yield return id; } //return Enum.GetValues().Where(id => id.IsAnalog()); } public static readonly ChannelId MinMChId = ChannelId.M1; public static readonly ChannelId MaxMChId; public static Boolean IsMath(this ChannelId id) => id >= MinMChId && id <= MaxMChId; public static IEnumerable GetMaths() { for (ChannelId id = MinMChId; id <= MaxMChId; id++) { yield return id; } } public static readonly ChannelId MinRChId = ChannelId.R1; public static readonly ChannelId MaxRChId; public static Boolean IsReference(this ChannelId id) => id >= MinRChId && id <= MaxRChId; public static IEnumerable GetReferences() { for (ChannelId id = MinRChId; id <= MaxRChId; id++) { yield return id; } } public static readonly ChannelId MinDChId = ChannelId.D1; public static readonly ChannelId MaxDChId; public static Boolean IsDigital(this ChannelId id) => id >= MinDChId && id <= MaxDChId; public static IEnumerable GetDigitals() { for (ChannelId id = MinDChId; id <= MaxDChId; id++) { yield return id; } } public static readonly ChannelId MinBChId = ChannelId.B1; public static readonly ChannelId MaxBChId; public static Boolean IsDecode(this ChannelId id) => id >= MinBChId && id <= MaxBChId; public static IEnumerable GetDecodes() { for (ChannelId id = MinBChId; id <= MaxBChId; id++) { yield return id; } } public static readonly ChannelId MinPChId = ChannelId.P1; public static readonly ChannelId MaxPChId; public static Boolean IsMeasure(this ChannelId id) => id >= MinPChId && id <= MaxPChId; public static IEnumerable GetMeasures() { for (ChannelId id = MinPChId; id <= MaxPChId; id++) { yield return id; } } public static readonly ChannelId MinAwgId = ChannelId.AWG1; public static readonly ChannelId MaxAwgId; public static Boolean IsAWG(this ChannelId id) => id >= MinAwgId && id <= MaxAwgId; public static IEnumerable GetAWGs() { for (ChannelId id = MinAwgId; id <= MaxAwgId; id++) { yield return id; } } //public static Boolean IsExtTrigger(this ChannelId id) => id >= ChannelId.Ext && id < ChannelId.USER; public static Boolean IsExtTrigger(this ChannelId id) => id == ChannelId.Ext; public static IEnumerable GetTriggerSources() { for (ChannelId id = MinAChId; id <= MaxAChId; id++) { yield return id; } for (ChannelId id = MinDChId; id <= MaxDChId; id++) { yield return id; } yield return ChannelId.Ext; } public static readonly ChannelId MinRFChId = ChannelId.RF1; public static readonly ChannelId MaxRFChId; public static Boolean IsRadioFrequency(this ChannelId id) => id >= MinRFChId && id <= MaxRFChId; public static IEnumerable GetRadioFrequencies() { for (ChannelId id = MinRFChId; id <= MaxRFChId; id++) yield return id; } public static readonly ChannelId MinAVTChId = ChannelId.AVT1; public static readonly ChannelId MaxAVTChId; public static Boolean IsAmpVSTime(this ChannelId id) => id >= MinAVTChId && id <= MaxAVTChId; public static IEnumerable GetAmpVSTimes() { for (ChannelId id = MinAVTChId; id <= MaxAVTChId; id++) yield return id; } public static readonly ChannelId MinPVTChId = ChannelId.PVT1; public static readonly ChannelId MaxPVTChId; public static Boolean IsPhaseVSTime(this ChannelId id) => id >= MinPVTChId && id <= MaxPVTChId; public static IEnumerable GetPhaseVSTimes() { for (ChannelId id = MinPVTChId; id <= MaxPVTChId; id++) yield return id; } public static readonly ChannelId MinPVFChId = ChannelId.PVF1; public static readonly ChannelId MaxPVFChId; public static Boolean IsPhaseVSFrequency(this ChannelId id) => id >= MinPVFChId && id <= MaxPVFChId; public static IEnumerable GetPhaseVSFrequencies() { for (ChannelId id = MinPVFChId; id <= MaxPVFChId; id++) yield return id; } public static readonly ChannelId MinPGDChId = ChannelId.PGD1; public static readonly ChannelId MaxPGDChId; public static Boolean IsPhaseGroupDelay(this ChannelId id) => id >= MinPGDChId && id <= MaxPGDChId; public static IEnumerable GetPhaseGroupDelaies() { for (ChannelId id = MinPGDChId; id <= MaxPGDChId; id++) yield return id; } public static readonly ChannelId MinTVFChId = ChannelId.TVF1; public static readonly ChannelId MaxTVFChId; public static Boolean IsTimeVSFrequency(this ChannelId id) => id >= MinTVFChId && id <= MaxTVFChId; public static IEnumerable GetTimeVSFrequencies() { for (ChannelId id = MinTVFChId; id <= MaxTVFChId; id++) yield return id; } public static readonly ChannelId MinFVTChId = ChannelId.FVT1; public static readonly ChannelId MaxFVTChId; public static Boolean IsFrequencyVSTime(this ChannelId id) => id >= MinFVTChId && id <= MaxFVTChId; public static IEnumerable GetFrequencyVSTimes() { for (ChannelId id = MinFVTChId; id <= MaxFVTChId; id++) yield return id; } } }