init
This commit is contained in:
236
Common/DTS.Common/Classes/Groups/GroupHelper.cs
Normal file
236
Common/DTS.Common/Classes/Groups/GroupHelper.cs
Normal file
@@ -0,0 +1,236 @@
|
||||
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<int, string> StaticGroupNames = new Dictionary<int, string>();
|
||||
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<int> EmbeddedGroupIdList = new List<int>();
|
||||
|
||||
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<int, int> TestSetupGroupIds = new Dictionary<int, int>();
|
||||
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<int, List<int>> GroupChannelIds = new Dictionary<int, List<int>>();
|
||||
public static void ClearGroupChannelIds()
|
||||
{
|
||||
GroupChannelIds.Clear();
|
||||
}
|
||||
public static void AddGroupChannelId(int sensorId, int groupId)
|
||||
{
|
||||
if (!GroupChannelIds.ContainsKey(sensorId))
|
||||
{
|
||||
GroupChannelIds.Add(sensorId, new List<int>());
|
||||
}
|
||||
GroupChannelIds[sensorId].Add(groupId);
|
||||
}
|
||||
public static List<int> GetGroupIdsFromChannels(int sensorId)
|
||||
{
|
||||
var groupIdList = new List<int>();
|
||||
|
||||
if (GroupChannelIds.ContainsKey(sensorId))
|
||||
{
|
||||
groupIdList = GroupChannelIds[sensorId];
|
||||
}
|
||||
|
||||
return groupIdList;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DASIds
|
||||
private static Dictionary<string, int> DASIds = new Dictionary<string, int>();
|
||||
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<string, Dictionary<string, List<int>>> BaseModuleChannelIndexList = new Dictionary<string, Dictionary<string, List<int>>>();
|
||||
public static void ClearBaseModuleChannelIndexList()
|
||||
{
|
||||
BaseModuleChannelIndexList.Clear();
|
||||
}
|
||||
public static void SetBaseModuleChannelIndexList(string baseSerialNumberSubstring, Dictionary<string, List<int>> tempDictionary)
|
||||
{
|
||||
BaseModuleChannelIndexList[baseSerialNumberSubstring] = tempDictionary;
|
||||
}
|
||||
public static List<int> GetChannelIndexes(string targetBaseSerialNumber, string targetModuleSerialNumber)
|
||||
{
|
||||
var channelIndexList = new List<int>();
|
||||
|
||||
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<int, Dictionary<int, int>> DASIdChannelIndexGroupIdList = new Dictionary<int, Dictionary<int, int>>();
|
||||
public static void ClearDASIdChannelIndexGroupIdList()
|
||||
{
|
||||
DASIdChannelIndexGroupIdList.Clear();
|
||||
}
|
||||
public static void SetDASIdChannelIndexGroupIdList(int dasId, Dictionary<int, int> tempDictionary)
|
||||
{
|
||||
DASIdChannelIndexGroupIdList[dasId] = tempDictionary;
|
||||
}
|
||||
public static List<int> GetGroupIds(int targetDasId, List<int> targetChannelIndexList)
|
||||
{
|
||||
var groupIdList = new List<int>();
|
||||
|
||||
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<int, List<int>> TestSetupHardwareIds = new Dictionary<int, List<int>>();
|
||||
public static void ClearTestSetupHardwareIds()
|
||||
{
|
||||
TestSetupHardwareIds.Clear();
|
||||
}
|
||||
public static void AddTestSetupHardwareId(int dasId, int testSetupId)
|
||||
{
|
||||
if (!TestSetupHardwareIds.ContainsKey(dasId))
|
||||
{
|
||||
TestSetupHardwareIds.Add(dasId, new List<int>());
|
||||
}
|
||||
TestSetupHardwareIds[dasId].Add(testSetupId);
|
||||
}
|
||||
public static List<int> GetTestSetupHardwareIds(int DASId)
|
||||
{
|
||||
var testSetupIdList = new List<int>();
|
||||
|
||||
if (TestSetupHardwareIds.ContainsKey(DASId))
|
||||
{
|
||||
testSetupIdList = TestSetupHardwareIds[DASId];
|
||||
}
|
||||
|
||||
return testSetupIdList;
|
||||
}
|
||||
#endregion TestSetupHardwareIds
|
||||
|
||||
#region GroupHardwareIds
|
||||
private static Dictionary<int, List<int>> GroupHardwareIds = new Dictionary<int, List<int>>();
|
||||
public static void ClearGroupHardwareIds()
|
||||
{
|
||||
GroupHardwareIds.Clear();
|
||||
}
|
||||
public static void AddGroupHardwareId(int dasId, int groupId)
|
||||
{
|
||||
if (!GroupHardwareIds.ContainsKey(dasId))
|
||||
{
|
||||
GroupHardwareIds.Add(dasId, new List<int>());
|
||||
}
|
||||
GroupHardwareIds[dasId].Add(groupId);
|
||||
}
|
||||
public static List<int> GetGroupHardwareIds(int DASId)
|
||||
{
|
||||
var groupIdList = new List<int>();
|
||||
|
||||
if (GroupHardwareIds.ContainsKey(DASId))
|
||||
{
|
||||
groupIdList = GroupHardwareIds[DASId];
|
||||
}
|
||||
|
||||
return groupIdList;
|
||||
}
|
||||
#endregion GroupHardwareIds
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user