/// <summary> /// Очистить канал от старой привязки /// </summary> private void ResetChannel() { int propertyNumber = (int)Eplan.EplApi.DataModel.Properties .Article.ARTICLE_TYPENR; string name = GetSelectedIOModuleArticleProperty(propertyNumber); var moduleInfo = new IOModuleInfo(); moduleInfo = moduleInfo.GetIOModuleInfo(name, out _); Dictionary <string, string> devicesComments = EplanDeviceManager.GetAssigment(SelectedClampFunction, moduleInfo, ResetDevicesChannel); foreach (KeyValuePair <string, string> pair in devicesComments) { var deviceName = pair.Key; var deviceComment = pair.Value; var device = DeviceManager.GetInstance().GetDevice(deviceName); string channelName = EplanDeviceManager.GetInstance(). GetChannelNameForIOLinkModuleFromString(deviceComment); device.ClearChannel(moduleInfo.AddressSpaceType, deviceComment, channelName); } }
public void TestGetModuleInfo(string expectedModuleInfoName, string actualModuleInfoName) { const int countOfModulesInfoForTest = 5; FillRandomModulesInfo(countOfModulesInfoForTest); if (!string.IsNullOrEmpty(actualModuleInfoName)) { GetModuleInfoForTest(actualModuleInfoName); } var moduleInfo = IOModuleInfo .GetModuleInfo(actualModuleInfoName, out bool isStub); if (moduleInfo != IOModuleInfo.Stub) { Assert.Multiple(() => { Assert.AreEqual(expectedModuleInfoName, moduleInfo.Name); Assert.IsFalse(isStub); }); } else { Assert.Multiple(() => { Assert.AreEqual(IOModuleInfo.Stub.Name, moduleInfo.Name); Assert.IsTrue(isStub); }); } }
public void TestClone() { IOModuleInfo actualModuleInfo = GetModuleInfoForTest(); var cloned = (IOModuleInfo)actualModuleInfo.Clone(); bool isEqual = actualModuleInfo.AddressSpaceType == cloned.AddressSpaceType && actualModuleInfo.AICount == cloned.AICount && actualModuleInfo.AOCount == cloned.AOCount && actualModuleInfo.DICount == cloned.DICount && actualModuleInfo.DOCount == cloned.DOCount && actualModuleInfo.ChannelAddressesIn .SequenceEqual(cloned.ChannelAddressesIn) && actualModuleInfo.ChannelAddressesOut .SequenceEqual(cloned.ChannelAddressesOut) && actualModuleInfo.ChannelClamps .SequenceEqual(cloned.ChannelClamps) && actualModuleInfo.Description == cloned.Description && actualModuleInfo.GroupName == cloned.GroupName && actualModuleInfo.ModuleColor == actualModuleInfo.ModuleColor && actualModuleInfo.Name == cloned.Name && actualModuleInfo.Number == cloned.Number && actualModuleInfo.TypeName == cloned.TypeName; Assert.IsTrue(isEqual); }
public void TestSetGetModuleColor(string expected, string actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.ModuleColor = Color.FromName(actual); Assert.AreEqual(Color.FromName(expected), testModule.ModuleColor); }
public void TestSetGetGroupName(string expected, string actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.GroupName = actual; Assert.AreEqual(expected, testModule.GroupName); }
public void TestSetGetChannelAddressesIn(int[] expected, int[] actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.ChannelAddressesIn = actual; Assert.AreEqual(expected, testModule.ChannelAddressesIn); }
public void TestSetGetDOCount(int expected, int actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.DOCount = actual; Assert.AreEqual(expected, testModule.DOCount); }
public void TestSetGetChannelClamps(int[] expected, int[] actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.ChannelClamps = actual; Assert.AreEqual(expected, testModule.ChannelClamps); }
public void TestSetGetDescription(string expected, string actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.Description = actual; Assert.AreEqual(expected, testModule.Description); }
public void TestSetGetNumber(int expected, int actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.Number = actual; Assert.AreEqual(expected, testModule.Number); }
public void TestSetGetAddressSpaceType( IOModuleInfo.ADDRESS_SPACE_TYPE expected, IOModuleInfo.ADDRESS_SPACE_TYPE actual) { IOModuleInfo testModule = GetModuleInfoForTest(); testModule.AddressSpaceType = actual; Assert.AreEqual(expected, testModule.AddressSpaceType); }
/// <summary> /// Привязать канал /// </summary> private void BindChannel() { if (SelectedIOModuleFunction == null) { return; } var regex = new Regex(IOModuleNamePattern); var match = regex.Match(SelectedIOModuleFunction.VisibleName); if (match.Success == false) { return; } int propertyNumber = (int)Eplan.EplApi.DataModel .Properties.Article.ARTICLE_TYPENR; string name = GetSelectedIOModuleArticleProperty(propertyNumber); var deviceNumber = Convert.ToInt32(match.Groups["n"].Value); var moduleNumber = deviceNumber % 100; int nodeNumber; var clampNumber = SelectedClampFunction.Properties .FUNC_ADDITIONALIDENTIFYINGNAMEPART.ToInt(); // Есть ли PXC A1 в проекте if (IOManager.GetInstance().IONodes[0].Type == IONode.TYPES.T_PHOENIX_CONTACT_MAIN) { // Если есть "A1", то учитываем, что он первый nodeNumber = deviceNumber / 100; } else { // Если нету, оставляем как было nodeNumber = deviceNumber / 100 - 1; } var moduleInfo = new IOModuleInfo(); moduleInfo = moduleInfo.GetIOModuleInfo(name, out _); var logicalPort = Array.IndexOf(moduleInfo.ChannelClamps, clampNumber) + 1; var moduleOffset = IOManager.GetInstance() .IONodes[nodeNumber]. IOModules[moduleNumber - 1].InOffset; SelectedChannel.SetChannel(nodeNumber, moduleNumber, clampNumber, deviceNumber, logicalPort, moduleOffset); }
private static IOModuleInfo GetModuleInfoForTest( string expectedName = null) { const int IntStub = 0; const string StrStub = ""; const string ColorStub = "White"; string name = expectedName ?? string.Empty; IOModuleInfo.AddModuleInfo(IntStub, name, StrStub, IntStub, StrStub, StrStub, new int[0], new int[0], new int[0], IntStub, IntStub, IntStub, IntStub, ColorStub); return(IOModuleInfo.GetModuleInfo(name, out _)); }
private static void FillRandomModulesInfo(int count, int repeatableCount = 0) { int currentCount = count; int currentRepeatableCount = repeatableCount; int enumSize = Enum .GetValues(typeof(IOModuleInfo.ADDRESS_SPACE_TYPE)).Length; List <KnownColor> colors = Enum.GetValues(typeof(KnownColor)) .Cast <KnownColor>() .ToList(); while (currentCount > 0) { int n = GetRandomIntNumber(); string name = GetRandomString(5); string description = GetRandomString(10); int addressSpaceTypeNum = new Random().Next(0, enumSize); string typeName = GetRandomString(10); string groupName = GetRandomString(7); int[] channelClamps = GetRandomIntArr(); int[] channelAddressesIn = GetRandomIntArr(); int[] channelAddressesOut = GetRandomIntArr(); int DOCount = GetRandomIntNumber(); int DICount = GetRandomIntNumber(); int AOCount = GetRandomIntNumber(); int AICount = GetRandomIntNumber(); string color = colors[new Random().Next(0, colors.Count - 1)] .ToString(); while (currentRepeatableCount > 1) { IOModuleInfo.AddModuleInfo(n, name, description, addressSpaceTypeNum, typeName, groupName, channelClamps, channelAddressesIn, channelAddressesOut, DOCount, DICount, AOCount, AICount, color); currentRepeatableCount--; currentCount--; } IOModuleInfo.AddModuleInfo(n, name, description, addressSpaceTypeNum, typeName, groupName, channelClamps, channelAddressesIn, channelAddressesOut, DOCount, DICount, AOCount, AICount, color); currentCount--; } }
public void TestSetGetName(string expected, string actual) { IOModuleInfo testModule = GetModuleInfoForTest(actual); Assert.AreEqual(expected, testModule.Name); }