当前位置: 首页>>代码示例>>C#>>正文


C# Device.GetReservedCount方法代码示例

本文整理汇总了C#中FiresecAPI.Models.Device.GetReservedCount方法的典型用法代码示例。如果您正苦于以下问题:C# Device.GetReservedCount方法的具体用法?C# Device.GetReservedCount怎么用?C# Device.GetReservedCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FiresecAPI.Models.Device的用法示例。


在下文中一共展示了Device.GetReservedCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeAddresses

		static void InitializeAddresses(Device device, int shleifNo)
		{
			Addresses = new List<DeviceAddress>();

			if (device.Driver.IsChildAddressReservedRange)
			{
				for (int i = 1; i < device.GetReservedCount(); i++)
				{
					Addresses.Add(new DeviceAddress(device.IntAddress + i));
				}
			}
			else
			{
				for (int i = 1; i < 256; i++)
				{
					Addresses.Add(new DeviceAddress(shleifNo * 256 + i));
				}
			}
			if (device.Driver.DriverType == DriverType.MRK_30)
			{
				Addresses = new List<DeviceAddress>();
				for (int i = device.IntAddress % 256; i <= Math.Min(256, device.IntAddress % 256 + 30); i++)
				{
					Addresses.Add(new DeviceAddress(shleifNo * 256 + i));
				}
			}
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:27,代码来源:NewDeviceHelper.cs

示例2: GetMinAddress

        public static int GetMinAddress(Driver driver, Device parentDevice)
        {
            if (driver.UseParentAddressSystem)
            {
                if (driver.DriverType == DriverType.MPT)
                {
                    while (parentDevice.Driver.UseParentAddressSystem)
                    {
                        parentDevice = parentDevice.Parent;
                    }
                }
                else
                {
                    parentDevice = parentDevice.Parent;
                }
            }

            int maxAddress = 0;

            if (driver.IsRangeEnabled)
            {
                maxAddress = driver.MinAddress;
            }
            else
            {
                if (parentDevice.Driver.ShleifCount > 0)
                    maxAddress = 257;

                if (parentDevice.Driver.IsChildAddressReservedRange)
                {
                    maxAddress = parentDevice.IntAddress;
                }
            }

            foreach (var child in FiresecManager.FiresecConfiguration.GetAllChildrenForDevice(parentDevice))
            {
                if (child.Driver.IsAutoCreate)
                    continue;

                if (driver.IsRangeEnabled)
                {
                    if ((child.IntAddress < driver.MinAddress) || (child.IntAddress > driver.MaxAddress))
                        continue;
                }

                if (parentDevice.Driver.IsChildAddressReservedRange)
                {
                    int reservedCount = parentDevice.GetReservedCount();

                    if ((child.IntAddress < parentDevice.IntAddress) && (child.IntAddress > parentDevice.IntAddress + reservedCount - 1))
                        continue;
                }

                if (child.Driver.AutoChildCount > 0)
                {
                    if (child.IntAddress + child.Driver.AutoChildCount - 1 > maxAddress)
                        maxAddress = child.IntAddress + child.Driver.AutoChildCount - 1;
                }
                else
                {
                    if (child.IntAddress > maxAddress)
                        maxAddress = child.IntAddress;
                }

                if (child.Driver.DriverType == DriverType.MRK_30)
                {
                    maxAddress = child.IntAddress + child.GetReservedCount();
                }
            }

            if (parentDevice.Driver.DriverType == DriverType.MRK_30)
                maxAddress = parentDevice.IntAddress;

            if (driver.IsRangeEnabled)
            {
                if (parentDevice.Children.Count > 0)
                    if (maxAddress + 1 <= driver.MaxAddress)
                        maxAddress = maxAddress + 1;
            }
            else
            {
                if (parentDevice.Driver.IsChildAddressReservedRange)
                {
                    int reservedCount = driver.ChildAddressReserveRangeCount;
                    if (parentDevice.Driver.DriverType == DriverType.MRK_30)
                    {
                        reservedCount = 30;

                        var reservedCountProperty = parentDevice.Properties.FirstOrDefault(x => x.Name == "MRK30ChildCount");
                        if (reservedCountProperty != null)
                        {
                            reservedCount = int.Parse(reservedCountProperty.Value);
                        }
                    }

                    if (parentDevice.Children.Count > 0)
                        if (maxAddress + 1 <= parentDevice.IntAddress + reservedCount - 1)
                            maxAddress = maxAddress + 1;
                }
                else
//.........这里部分代码省略.........
开发者ID:hjlfmy,项目名称:Rubezh,代码行数:101,代码来源:NewDeviceHelper.cs

示例3: ValidateMRK30

		void ValidateMRK30(Device device)
		{
			if (device.Driver.DriverType == DriverType.MRK_30)
			{
				var reservedCount = device.GetReservedCount();
				if (reservedCount < 1 || reservedCount > 30)
					Errors.Add(new DeviceValidationError(device, string.Format("Количество подключаемых устройств должно быть в диапазоне 1 - 30: {0}", device.PresentationAddress), ValidationErrorLevel.CannotWrite));

				int minChildAddress = device.IntAddress + 1;
				int maxChildAddress = device.IntAddress + reservedCount;
				if (maxChildAddress / 256 != minChildAddress / 256)
					maxChildAddress = maxChildAddress - maxChildAddress % 256;

				foreach (var childDevice in device.Parent.Children)
				{
					if (childDevice.IntAddress >= minChildAddress && childDevice.IntAddress <= maxChildAddress)
					{
						if (childDevice.Parent.UID != device.UID)
							Errors.Add(new DeviceValidationError(childDevice, string.Format("Устройство находится в зарезервированном диапазоне адресов МРК-30: {0}", device.PresentationAddress), ValidationErrorLevel.CannotWrite));
					}
				}

				foreach (var childDevice in device.Children)
				{
					if (childDevice.IntAddress < minChildAddress || childDevice.IntAddress > maxChildAddress)
					{
						Errors.Add(new DeviceValidationError(childDevice, string.Format("Устройство находится за пределами диапазона адресов МРК-30: {0}", device.PresentationAddress), ValidationErrorLevel.CannotWrite));
					}
				}
			}
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:31,代码来源:Validator.Devices.cs


注:本文中的FiresecAPI.Models.Device.GetReservedCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。