using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DTS.Common.Classes.Groups { public abstract class GroupHelper { #region StaticGroupNames private static Dictionary StaticGroupNames = new Dictionary(); public static void ClearStaticGroupNames() { StaticGroupNames.Clear(); } public static void SetStaticGroupName(int id, string name) { StaticGroupNames[id] = name; } public static string GetStaticGroupName(int Id) { var name = string.Empty; if (StaticGroupNames.ContainsKey(Id)) { name = StaticGroupNames[Id]; } return name; } #endregion StaticGroupNames #region EmbeddedGroupIdList private static List EmbeddedGroupIdList = new List(); public static void ClearEmbeddedGroupIdList() { EmbeddedGroupIdList.Clear(); } public static void SetEmbeddedGroupId(int id) { EmbeddedGroupIdList.Add(id); } public static bool IsGroupEmbedded(int Id) { return EmbeddedGroupIdList.Contains(Id); } #endregion EmbeddedGroupIdList #region TestSetupGroupIds private static Dictionary TestSetupGroupIds = new Dictionary(); public static void ClearTestSetupGroupIds() { TestSetupGroupIds.Clear(); } public static void SetTestSetupGroupId(int groupId, int testSetupId) { TestSetupGroupIds[groupId] = testSetupId; } public static int GetTestSetupGroupId(int groupId) { var testSetupGroupId = 0; if (TestSetupGroupIds.ContainsKey(groupId)) { testSetupGroupId = TestSetupGroupIds[groupId]; } return testSetupGroupId; } #endregion TestSetupGroupIds #region GroupChannelIds private static Dictionary> GroupChannelIds = new Dictionary>(); public static void ClearGroupChannelIds() { GroupChannelIds.Clear(); } public static void AddGroupChannelId(int sensorId, int groupId) { if (!GroupChannelIds.ContainsKey(sensorId)) { GroupChannelIds.Add(sensorId, new List()); } GroupChannelIds[sensorId].Add(groupId); } public static List GetGroupIdsFromChannels(int sensorId) { var groupIdList = new List(); if (GroupChannelIds.ContainsKey(sensorId)) { groupIdList = GroupChannelIds[sensorId]; } return groupIdList; } #endregion #region DASIds private static Dictionary DASIds = new Dictionary(); public static void ClearDASIds() { DASIds.Clear(); } public static void SetDASId(string serialNumber, int dasId) { DASIds[serialNumber] = dasId; } public static int GetDASId(string serialNumber) { return DASIds[serialNumber]; } #endregion DASIds #region BaseModuleChannelIndexList public static Dictionary>> BaseModuleChannelIndexList = new Dictionary>>(); public static void ClearBaseModuleChannelIndexList() { BaseModuleChannelIndexList.Clear(); } public static void SetBaseModuleChannelIndexList(string baseSerialNumberSubstring, Dictionary> tempDictionary) { BaseModuleChannelIndexList[baseSerialNumberSubstring] = tempDictionary; } public static List GetChannelIndexes(string targetBaseSerialNumber, string targetModuleSerialNumber) { var channelIndexList = new List(); foreach (var baseModuleIndexListTriple in BaseModuleChannelIndexList) { if (baseModuleIndexListTriple.Key == targetBaseSerialNumber) { var moduleIndexListTuple = baseModuleIndexListTriple.Value; foreach (var moduleSerialNumber in moduleIndexListTuple.Keys) { if (moduleSerialNumber == targetModuleSerialNumber) { channelIndexList = moduleIndexListTuple[moduleSerialNumber]; } } } } return channelIndexList; } #endregion BaseModuleChannelIndexList #region DASIdChannelIndexGroupIdList public static Dictionary> DASIdChannelIndexGroupIdList = new Dictionary>(); public static void ClearDASIdChannelIndexGroupIdList() { DASIdChannelIndexGroupIdList.Clear(); } public static void SetDASIdChannelIndexGroupIdList(int dasId, Dictionary tempDictionary) { DASIdChannelIndexGroupIdList[dasId] = tempDictionary; } public static List GetGroupIds(int targetDasId, List targetChannelIndexList) { var groupIdList = new List(); foreach (var dasIdChannelIndexGroupIdTriple in DASIdChannelIndexGroupIdList) { if (dasIdChannelIndexGroupIdTriple.Key == targetDasId) { var channelIndexGroupIdTuple = dasIdChannelIndexGroupIdTriple.Value; foreach (var channelIndex in channelIndexGroupIdTuple.Keys) { if (targetChannelIndexList.Contains(channelIndex)) { groupIdList.Add(channelIndexGroupIdTuple[channelIndex]); } } } } return groupIdList; } #endregion BaseModuleChannelIndexList #region TestSetupHardwareIds private static Dictionary> TestSetupHardwareIds = new Dictionary>(); public static void ClearTestSetupHardwareIds() { TestSetupHardwareIds.Clear(); } public static void AddTestSetupHardwareId(int dasId, int testSetupId) { if (!TestSetupHardwareIds.ContainsKey(dasId)) { TestSetupHardwareIds.Add(dasId, new List()); } TestSetupHardwareIds[dasId].Add(testSetupId); } public static List GetTestSetupHardwareIds(int DASId) { var testSetupIdList = new List(); if (TestSetupHardwareIds.ContainsKey(DASId)) { testSetupIdList = TestSetupHardwareIds[DASId]; } return testSetupIdList; } #endregion TestSetupHardwareIds #region GroupHardwareIds private static Dictionary> GroupHardwareIds = new Dictionary>(); public static void ClearGroupHardwareIds() { GroupHardwareIds.Clear(); } public static void AddGroupHardwareId(int dasId, int groupId) { if (!GroupHardwareIds.ContainsKey(dasId)) { GroupHardwareIds.Add(dasId, new List()); } GroupHardwareIds[dasId].Add(groupId); } public static List GetGroupHardwareIds(int DASId) { var groupIdList = new List(); if (GroupHardwareIds.ContainsKey(DASId)) { groupIdList = GroupHardwareIds[DASId]; } return groupIdList; } #endregion GroupHardwareIds } }