diff --git a/EasyEplanner.Tests/EplanDevice.Test/Device.Test.cs b/EasyEplanner.Tests/EplanDevice.Test/Device.Test.cs index 9680dc0a..de573c79 100644 --- a/EasyEplanner.Tests/EplanDevice.Test/Device.Test.cs +++ b/EasyEplanner.Tests/EplanDevice.Test/Device.Test.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using EplanDevice; +using NUnit.Framework; namespace Tests.EplanDevices { @@ -195,5 +196,14 @@ public void GetChannels_Test(string channelName, string comment, int expectedCha var channels = dev.GetChannels(IO.IOModuleInfo.ADDRESS_SPACE_TYPE.AOAIDODI, channelName, comment); Assert.AreEqual(expectedChannelsCount, channels.Count); } + + [TestCase("OBJ1" ,"V1")] + [TestCase("" , "V1")] + public void DeviceDesignationTest(string obj, string expectedDesignation) + { + var dev = new V($"{obj}V1", $"+{obj}-V1", "", 1, "OBJ", 1, ""); + + Assert.AreEqual("V1", dev.DeviceDesignation); + } } } diff --git a/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/BaseObject.Test.cs b/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/BaseObject.Test.cs index bd3a91fb..114891c2 100644 --- a/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/BaseObject.Test.cs +++ b/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/BaseObject.Test.cs @@ -501,7 +501,7 @@ private void SetupDeviceManagerMock() var DO1 = new DO("DO1", "DO1", "desc", 1, "", 0); var LS1 = new LS("LS1", "LS1", "desc", 1, "", 0, ""); var TANK1V1 = new V("TANK1V1", "+TANK1-V1", "desc", 1, "TANK", 1, ""); - var TANK2V1 = new V("TANK2V1", "+TANK2V-1", "desc", 1, "TANK", 2, ""); + var TANK2V1 = new V("TANK2V1", "+TANK2-V1", "desc", 1, "TANK", 2, ""); deviceManagerMock.Setup(m => m.GetDeviceByEplanName("LS1")).Returns(LS1); diff --git a/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/UniversalObject.Test/Actions.Test/Action.Test.cs b/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/UniversalObject.Test/Actions.Test/Action.Test.cs index 5fc7c2bd..9f41d66c 100644 --- a/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/UniversalObject.Test/Actions.Test/Action.Test.cs +++ b/EasyEplanner.Tests/TechObject.Test/ObjectsTree.Test/UniversalObject.Test/Actions.Test/Action.Test.cs @@ -1371,6 +1371,7 @@ private static EplanDevice.IDevice MakeMockedDevice(string objName, EplanDevice.DeviceSubType deviceSubType, int devNumber, string devName) { var devMock = new Mock(); + devMock.SetupGet(x => x.DeviceDesignation).Returns($"{devType}{devNumber}"); devMock.SetupGet(x => x.ObjectName).Returns(objName); devMock.SetupGet(x => x.ObjectNumber).Returns(objNum); devMock.SetupGet(x => x.DeviceType).Returns(devType); diff --git a/src/Device/Device.cs b/src/Device/Device.cs index cfc6eb29..a9ba2cca 100644 --- a/src/Device/Device.cs +++ b/src/Device/Device.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace EplanDevice { @@ -176,6 +177,8 @@ public string EplanName } } + public string DeviceDesignation => EplanName.Split('-').LastOrDefault() ?? string.Empty; + public long DeviceNumber { get diff --git a/src/Device/IDevice.cs b/src/Device/IDevice.cs index 2ee00215..f162c691 100644 --- a/src/Device/IDevice.cs +++ b/src/Device/IDevice.cs @@ -12,6 +12,12 @@ public interface IDevice /// string EplanName { get; } + /// + /// Обозначение устройства без объекта. Пример: V1
+ /// Используется если обозначение устройства не соответствует типу: "FC1" (подтип "C") + ///
+ string DeviceDesignation { get; } + /// /// Описание устройства. /// diff --git a/src/TechObject/Base/Properties/ActionParameter.cs b/src/TechObject/Base/Properties/ActionParameter.cs index 116d0859..99d6f008 100644 --- a/src/TechObject/Base/Properties/ActionParameter.cs +++ b/src/TechObject/Base/Properties/ActionParameter.cs @@ -75,11 +75,11 @@ public void ModifyDevName(int newID, int oldID, string objName) if (dev.ObjectNumber == newID && oldID != -1) { - SetNewValue($"{objName}{oldID}{dev.DeviceType}{dev.DeviceNumber}"); + SetNewValue($"{objName}{oldID}{dev.DeviceDesignation}"); } if (oldID == -1 || oldID == dev.ObjectNumber) { - SetNewValue($"{objName}{newID}{dev.DeviceType}{dev.DeviceNumber}"); + SetNewValue($"{objName}{newID}{dev.DeviceDesignation}"); } } diff --git a/src/TechObject/ObjectsTree/UniversalObject/Actions/Action.cs b/src/TechObject/ObjectsTree/UniversalObject/Actions/Action.cs index 502895fe..fab2183d 100644 --- a/src/TechObject/ObjectsTree/UniversalObject/Actions/Action.cs +++ b/src/TechObject/ObjectsTree/UniversalObject/Actions/Action.cs @@ -304,11 +304,11 @@ private string ModifyDevNameChangeTechNumber(string techObjectName, int index, i //Для устройств в пределах объекта меняем номер объекта. if (objNum == newID && oldID != -1) { // 1 -> 2 - COAG2V1 --> COAG1V1 - return $"{objName}{oldID}{device.DeviceType}{device.DeviceNumber}"; + return $"{objName}{oldID}{device.DeviceDesignation}"; } if (oldID == -1 || oldID == objNum) { // COAG1V1 --> COAG(new_id)V1; COAGxV1 -> COAG1V1, COAG2V1 ... - return $"{objName}{newID}{device.DeviceType}{device.DeviceNumber}"; + return $"{objName}{newID}{device.DeviceDesignation}"; } return string.Empty;