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); }); } }
/// <summary> /// Очистить канал от старой привязки /// </summary> private void ResetChannel() { int propertyNumber = (int)Eplan.EplApi.DataModel.Properties .Article.ARTICLE_TYPENR; string name = GetSelectedIOModuleArticleProperty(propertyNumber); var moduleInfo = IOModuleInfo.GetModuleInfo(name, out _); Dictionary <string, string> devicesComments = ProjectConfiguration .GetInstance().GetBindingForResettingChannel( 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 = ApiHelper .GetChannelNameForIOLinkModuleFromString(deviceComment); device.ClearChannel(moduleInfo.AddressSpaceType, deviceComment, channelName); } }
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 _)); }
/// <summary> /// Привязать канал /// </summary> private void BindChannel() { if (SelectedIOModuleFunction == null) { return; } var regex = new Regex(IOManager.IONamePattern); 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 = IOModuleInfo.GetModuleInfo(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); }