예제 #1
0
		public static int GetMinAddress(Driver driver, Device parentDevice, int shleifNo)
		{
			if (driver.IsRangeEnabled)
			{
				Addresses = new List<DeviceAddress>();
				for (int i = driver.MinAddress; i <= driver.MaxAddress; i++)
				{
					Addresses.Add(new DeviceAddress(i));
				}

				foreach (var child in parentDevice.Children)
				{
					var address = Addresses.FirstOrDefault(x => x.Address == child.IntAddress);
					if (address != null)
					{
						address.IsBuisy = true;
					}
				}
				return GetBestAddress(driver);
			}

			Device panel = parentDevice.ParentPanel;
			if (parentDevice.Driver.IsPanel)
				panel = parentDevice;

			if (panel != null)
			{
				InitializeAddresses(parentDevice, shleifNo);
				SetBuisyChildAddress(panel, parentDevice.Driver.DriverType == DriverType.MRK_30);
				return GetBestAddress(driver);
			}
			return 0;
		}
		public Device AddDevice(Device parentDevice, Driver driver, int intAddress)
		{
			var device = new Device()
			{
				DriverUID = driver.UID,
				Driver = driver,
				IntAddress = intAddress,
				Parent = parentDevice
			};
			if (parentDevice.Driver.DriverType == DriverType.MPT)
			{
				device.ZoneUID = parentDevice.ZoneUID;
			}
            if (driver.DriverType == DriverType.Valve)
            {
                device.Properties.Add(new Property() { Name = "Action", Value = "1" });
            }
			parentDevice.Children.Add(device);
			AddAutoCreateChildren(device);
			AddAutoChildren(device);

			parentDevice.OnChanged();
			DeviceConfiguration.Update();
			return device;
		}
예제 #3
0
        public StateViewModel(LibraryState libraryState, Driver driver)
        {
            AddFrameCommand = new RelayCommand(OnAddFrame);
            RemoveFrameCommand = new RelayCommand(OnRemoveFrame, CanRemoveFrame);

            State = libraryState;
            Driver = driver;

            Frames = new ObservableCollection<FrameViewModel>(
                State.Frames.Select(frame => new FrameViewModel(frame))
            );
            SelectedFrame = Frames.FirstOrDefault();
        }
예제 #4
0
		public void Initialize(Driver driver)
		{
			_driver = driver;
			Device = new repositoryModuleDevice()
			{
				id = driver.DriverType.ToString()
			};

			CreateChildren();
			CreateStates();
			CreateImages();
			CreateEvents();
			CreateProperties();
			CreateCommands();
		}
예제 #5
0
        public StateViewModel(LibraryState state, Driver parentDriver)
        {
            State = state;
            if (state.Frames == null)
                SetDefaultFrameTo(State);

            ParentDriver = parentDriver;

            FrameViewModels = new ObservableCollection<FrameViewModel>(
                State.Frames.Select(frame => new FrameViewModel(frame))
            );
            SelectedFrameViewModel = FrameViewModels[0];

            AddFrameCommand = new RelayCommand(OnAddFrame);
            RemoveFrameCommand = new RelayCommand(OnRemoveFrame, CanRemoveFrame);
        }
예제 #6
0
파일: TreeItem.cs 프로젝트: hjlfmy/Rubezh
        public void SetDriver(Driver driver)
        {
            _driver = driver;
            Name = _driver.Name;

            ModelInfo = new Assad.modelInfoType()
            {
                name = _driver.Name,
                type1 = "rubezh." + ViewModel.StaticVersion + "." + _driver.UID.ToString(),
                model = "1.0",
                @event = AddEvents().ToArray(),
                command = AddCommands().ToArray(),
                param = AddParameters().ToArray(),
                state = AddStates().ToArray()
            };
        }
예제 #7
0
파일: MPTHelper.cs 프로젝트: hjlfmy/Rubezh
 static void AddControlType(Driver driver, byte no, string propertyName)
 {
     var property = new DriverProperty()
     {
         IsAUParameter = true,
         No = no,
         Name = propertyName,
         Caption = propertyName,
         Default = "1",
         UseMask = true
     };
     ConfigurationDriverHelper.AddPropertyParameter(property, "Состояние цепи не контролируется", 1);
     ConfigurationDriverHelper.AddPropertyParameter(property, "Цепь контролируется только на обрыв", 2);
     ConfigurationDriverHelper.AddPropertyParameter(property, "Цепь контролируется только на короткое замыкание", 3);
     ConfigurationDriverHelper.AddPropertyParameter(property, "Цепь контролируется на короткое замыкание и на обрыв", 4);
     driver.Properties.Add(property);
 }
예제 #8
0
		private static void AddRegime(Driver driver, byte no, string propertyName, string defaultValue)
		{
			var property = new DriverProperty()
			{
				IsAUParameter = true,
				No = no,
				Name = propertyName,
				Caption = propertyName,
				Default = defaultValue,
				MaxBit = 3,
				UseMask = true
			};
			ConfigurationDriverHelper.AddPropertyParameter(property, "Сирена", 1);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Табличка «Уходи»", 2);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Табличка «Не входи»", 3);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Табличка «Автоматика отключена»", 4);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Выход АУП", 5);
			driver.Properties.Add(property);
		}
예제 #9
0
파일: MPTHelper.cs 프로젝트: hjlfmy/Rubezh
 static void AddLogic(Driver driver, byte no, string propertyName)
 {
     var property = new DriverProperty()
     {
         IsAUParameter = true,
         No = no,
         Name = propertyName,
         Caption = propertyName,
         Default = "1",
         MptHighByte = true
     };
     ConfigurationDriverHelper.AddPropertyParameter(property, "1 Не включать", 1);
     ConfigurationDriverHelper.AddPropertyParameter(property, "2 Включить сразу", 2);
     ConfigurationDriverHelper.AddPropertyParameter(property, "3 Включить после паузы", 3);
     ConfigurationDriverHelper.AddPropertyParameter(property, "4 Включить на заданное время", 4);
     ConfigurationDriverHelper.AddPropertyParameter(property, "5 Включить после паузы на заданное время и выключить", 5);
     ConfigurationDriverHelper.AddPropertyParameter(property, "6 Переключать постоянно", 6);
     ConfigurationDriverHelper.AddPropertyParameter(property, "7 Начать переключение после паузы", 7);
     ConfigurationDriverHelper.AddPropertyParameter(property, "8 Переключать заданное время и оставить выключенным", 8);
     ConfigurationDriverHelper.AddPropertyParameter(property, "9 Начать переключение после паузы, переключать заданное время и оставить выключенным", 9);
     ConfigurationDriverHelper.AddPropertyParameter(property, "10 Переключать заданное время и оставить выключенным", 10);
     ConfigurationDriverHelper.AddPropertyParameter(property, "11 Начать переключение после паузы, переключать заданное время и оставить выключенным", 11);
     driver.Properties.Add(property);
 }
예제 #10
0
파일: MPTHelper.cs 프로젝트: hjlfmy/Rubezh
 static void AddDetectorState(Driver driver, byte no, string propertyName, byte offset)
 {
     var property = new DriverProperty()
     {
         No = no,
         Name = propertyName,
         Caption = propertyName,
         Default = "1",
         BitOffset = offset,
         UseMask = true
     };
     ConfigurationDriverHelper.AddPropertyParameter(property, "Замкнутое", 1);
     ConfigurationDriverHelper.AddPropertyParameter(property, "Разомкнутое", 2);
     driver.Properties.Add(property);
 }
예제 #11
0
		public static void CreateImages(Driver driver, string driverName)
		{
			var libraryDevice = ItvManager.DeviceLibraryConfiguration.Devices.FirstOrDefault(x => x.DriverId == driver.UID);
			if (libraryDevice != null)
			{
				foreach (var stateType in Helper.AllStates)
				{
					var state = libraryDevice.States.FirstOrDefault(x => x.StateType == stateType && x.Code == null);
					if (state == null)
						state = libraryDevice.States.FirstOrDefault(x => x.StateType == StateType.No);

					var name = Directory.GetCurrentDirectory() + "/BMP/" + driverName + "." + stateType.ToString() + ".bmp";
					var canvas = ImageHelper.XmlToCanvas(state.Frames[0].Image);

					if (canvas.Children.Count == 0)
					{
						state = libraryDevice.States.FirstOrDefault(x => x.StateType == StateType.No);
						canvas = ImageHelper.XmlToCanvas(state.Frames[0].Image);
					}

					canvas.Background = new SolidColorBrush(Color.FromRgb(0, 128, 128));
					ImageHelper.XAMLToBitmap(canvas, name);
				}
			}
		}
예제 #12
0
		public static Driver Convert(Firesec.Models.Metadata.config coreDriversConfig, drvType innerDriver)
		{
			var driver = new Driver()
			{
				UID = new Guid(innerDriver.id),
				StringUID = innerDriver.id,
				Name = innerDriver.name,
				ShortName = innerDriver.shortName,
				HasAddress = innerDriver.ar_no_addr != "1",
				IsAutoCreate = innerDriver.acr_enabled == "1",
				MinAutoCreateAddress = int.Parse(innerDriver.acr_from),
				MaxAutoCreateAddress = int.Parse(innerDriver.acr_to),
				HasAddressMask = innerDriver.addrMask != null,
				IsAlternativeUSB = innerDriver.altIntf != null,
				ChildAddressMask = innerDriver.childAddrMask,
				IsZoneDevice = ((innerDriver.minZoneCardinality == "0") && (innerDriver.maxZoneCardinality == "0")) == false,
				IsDeviceOnShleif = innerDriver.addrMask != null && (innerDriver.addrMask == "[8(1)-15(2)];[0(1)-7(255)]" || innerDriver.addrMask == "[0(1)-8(30)]")
			};

			var driverData = DriversHelper.DriverDataList.FirstOrDefault(x => x.DriverId == innerDriver.id && x.IgnoreLevel < 2);
			if (driverData != null)
				driver.DriverType = driverData.DriverType;

			if (innerDriver.options != null)
			{
				driver.DisableAutoCreateChildren = innerDriver.options.Contains("DisableAutoCreateChildren");
				driver.IsZoneLogicDevice = innerDriver.options.Contains("ExtendedZoneLogic");
				driver.CanDisable = innerDriver.options.Contains("Ignorable");
				driver.IsPlaceable = innerDriver.options.Contains("Placeable") && driver.DriverType != DriverType.Computer;
				driver.IsOutDevice = innerDriver.options.Contains("OutDevice");
				driver.IgnoreInZoneState = innerDriver.options.Contains("IgnoreInZoneState");
				driver.IsNotValidateZoneAndChildren = innerDriver.options.Contains("NotValidateZoneAndChildren");
				driver.IsSingleInParent = innerDriver.options.Contains("Single");
				driver.IsSingleInZone = innerDriver.options.Contains("SingleInZone");
				driver.CanMonitoringDisable = innerDriver.options.Contains("CannotDisable") == false;

				driver.CanWriteDatabase = innerDriver.options.Contains("DeviceDatabaseWrite");
				driver.CanReadDatabase = innerDriver.options.Contains("DeviceDatabaseRead");
				driver.CanReadJournal = innerDriver.options.Contains("EventSource")
					&& driver.DriverType != DriverType.MS_1
					&& driver.DriverType != DriverType.MS_2
					&& driver.DriverType != DriverType.IndicationBlock
					&& driver.DriverType != DriverType.MS_3
					&& driver.DriverType != DriverType.MS_4
					&& driver.DriverType != DriverType.PDU
					&& driver.DriverType != DriverType.PDU_PT
					&& driver.DriverType != DriverType.UOO_TL;
				driver.CanSynchonize = innerDriver.options.Contains("HasTimer");
				driver.CanReboot = innerDriver.options.Contains("RemoteReload");
				driver.CanGetDescription = innerDriver.options.Contains("DescriptionString");
				driver.CanSetPassword = innerDriver.options.Contains("PasswordManagement");
				driver.CanUpdateSoft = innerDriver.options.Contains("SoftUpdates");
				driver.CanExecuteCustomAdminFunctions = innerDriver.options.Contains("CustomIOCTLFunctions");
			}
			if (driver.DriverType == DriverType.Exit)
				driver.IsPlaceable = false;

			var metadataClass = [email protected](x => x.clsid == innerDriver.clsid);
			if (metadataClass != null)
			{
				driver.DeviceClassName = metadataClass.param.FirstOrDefault(x => x.name == "DeviceClassName").value;
			}
            

			driver.CanEditAddress = true;
			if (innerDriver.ar_no_addr != null)
			{
				if (innerDriver.ar_no_addr == "1")
					driver.CanEditAddress = false;

				if (innerDriver.acr_enabled == "1")
					driver.CanEditAddress = false;
			}

			driver.ShleifCount = 0;
			if (innerDriver.childAddrMask != null)
			{
				switch (innerDriver.childAddrMask)
				{
					case "[8(1)-15(2)];[0(1)-7(255)]":
						driver.ShleifCount = 2;
						break;

					case "[8(1)-15(4)];[0(1)-7(255)]":
						driver.ShleifCount = 4;
						break;

					case "[8(1)-15(10)];[0(1)-7(255)]":
						driver.ShleifCount = 10;
						break;
				}
			}
			if (driver.DriverType == DriverType.BUNS)
				driver.ShleifCount = 2;
			if (driver.DriverType == DriverType.USB_BUNS)
				driver.ShleifCount = 2;

			driver.HasShleif = driver.ShleifCount == 0 ? false : true;

			if (innerDriver.name == "Насосная Станция")
				driver.UseParentAddressSystem = false;
			else
				driver.UseParentAddressSystem = innerDriver.options != null && innerDriver.options.Contains("UseParentAddressSystem");

			driver.IsChildAddressReservedRange = innerDriver.res_addr != null;
			driver.ChildAddressReserveRangeCount = driver.IsChildAddressReservedRange ? int.Parse(innerDriver.res_addr) : 0;

			if (innerDriver.addrMask == "[0(1)-8(8)]")
				driver.IsRangeEnabled = true;
			else
				driver.IsRangeEnabled = innerDriver.ar_enabled == "1";

			if (innerDriver.addrMask == "[0(1)-8(8)]")
				driver.MinAddress = 1;
			else
				driver.MinAddress = int.Parse(innerDriver.ar_from);

			if (innerDriver.addrMask == "[0(1)-8(8)]")
				driver.MaxAddress = 8;
			else
				driver.MaxAddress = int.Parse(innerDriver.ar_to);

			driver.IsBUtton = false;
			switch (driver.DriverType)
			{
				case DriverType.StopButton:
				case DriverType.StartButton:
				case DriverType.AutomaticButton:
				case DriverType.ShuzOffButton:
				case DriverType.ShuzOnButton:
				case DriverType.ShuzUnblockButton:
					driver.IsBUtton = true;
					break;
			}

			driver.Category = (DeviceCategoryType)int.Parse(innerDriver.cat);
			driver.CategoryName = driver.Category.ToDescription();

			driver.DeviceType = DeviceType.FireSecurity;
			if (innerDriver.options != null)
			{
				if (innerDriver.options.Contains("FireOnly"))
					driver.DeviceType = DeviceType.Fire;

				if (innerDriver.options.Contains("SecOnly"))
					driver.DeviceType = DeviceType.Sequrity;

				if (innerDriver.options.Contains("TechOnly"))
					driver.DeviceType = DeviceType.Technoligical;
			}
			driver.DeviceTypeName = driver.DeviceType.ToDescription();

			var driverdata = DriversHelper.DriverDataList.FirstOrDefault(x => (x.DriverId == innerDriver.id));
			if (driverdata != null)
			{
				driver.IsIgnore = driverdata.IgnoreLevel > 1;
				driver.IsAssadIgnore = driverdata.IgnoreLevel > 0;
			}
			else
			{
				return null;
			}

			var allChildren = new List<drvType>();
			foreach (var childDriver in coreDriversConfig.drv)
			{
				var childClass = [email protected](x => x.clsid == childDriver.clsid);
				if (childClass != null && childClass.parent != null && childClass.parent.Any(x => x.clsid == innerDriver.clsid))
				{
					if (childDriver.lim_parent != null && childDriver.lim_parent != innerDriver.id)
						continue;

					allChildren.Add(childDriver);
				}
			}
			try
			{
				driver.Children = new List<Guid>(
					from drvType childInnerDriver in allChildren
					where (DriversHelper.DriverDataList.FirstOrDefault(x => x.DriverId == childInnerDriver.id) != null &&
					DriversHelper.DriverDataList.FirstOrDefault(x => x.DriverId == childInnerDriver.id).IgnoreLevel == 0)
					select new Guid(childInnerDriver.id));
			}
			catch (Exception e)
			{
				Logger.Error(e);
			}

			driver.AvaliableChildren = new List<Guid>(
				from drvType childInnerDriver in allChildren
				where childInnerDriver.acr_enabled != "1"
				select new Guid(childInnerDriver.id));
			if (driver.DisableAutoCreateChildren)
			{
				driver.AutoCreateChildren = new List<Guid>();
			}
			else
			{
				driver.AutoCreateChildren = new List<Guid>(
				from drvType childInnerDriver in allChildren
				where childInnerDriver.acr_enabled == "1"
				select new Guid(childInnerDriver.id));
			}

			driver.CanAddChildren = driver.AvaliableChildren.Count > 0;

			if (innerDriver.child_id != null)
			{
				driver.AutoChild = new Guid(innerDriver.child_id);
				driver.AutoChildCount = int.Parse(innerDriver.child_count);
			}

			driver.CanAutoDetect = allChildren.Any(x => (x.options != null) && (x.options.Contains("CanAutoDetectInstances")));

			driver.Properties = new List<DriverProperty>();
			if (innerDriver.propInfo != null && driver.DriverType != DriverType.PumpStation)
			{
				foreach (var internalProperty in innerDriver.propInfo)
				{
					if ((internalProperty.hidden == "1") && (driver.DriverType != DriverType.UOO_TL))
						continue;
					if (internalProperty.caption == "Заводской номер" || internalProperty.caption == "Версия микропрограммы")
						continue;
					if (internalProperty.name.StartsWith("Config$"))
						continue;
					if (internalProperty.name == "DeviceCountSecDev")
						continue;

					var driverProperty = new DriverProperty()
					{
						Name = internalProperty.name,
						Caption = internalProperty.caption,
						ToolTip = internalProperty.hint,
						Default = internalProperty.@default,
						Visible = internalProperty.hidden == "0" && internalProperty.showOnlyInState == "0",
						IsHidden = internalProperty.hidden == "1",
						BlockName = internalProperty.blockName
					};

					if (internalProperty.name.StartsWith("Control$"))
					{
						//driverProperty.Name = internalProperty.name.Replace("Control$", "");
						driverProperty.IsControl = true;
					}

					driverProperty.Parameters = new List<DriverPropertyParameter>();
					if (internalProperty.param != null)
					{
						foreach (var firesecParameter in internalProperty.param)
						{
							driverProperty.Parameters.Add(new DriverPropertyParameter()
							{
								Name = firesecParameter.name,
								Value = firesecParameter.value
							});
						}
					}

					if (internalProperty.param != null)
					{
						driverProperty.DriverPropertyType = DriverPropertyTypeEnum.EnumType;
					}
					else
					{
						switch (internalProperty.type)
						{
							case "String":
								driverProperty.DriverPropertyType = DriverPropertyTypeEnum.StringType;
								break;

							case "Int":
							case "Double":
								driverProperty.DriverPropertyType = DriverPropertyTypeEnum.IntType;
								break;

							case "Byte":
								driverProperty.DriverPropertyType = DriverPropertyTypeEnum.ByteType;
								break;

							case "Bool":
								driverProperty.DriverPropertyType = DriverPropertyTypeEnum.BoolType;
								break;

							case "Empty":
								driverProperty.DriverPropertyType = DriverPropertyTypeEnum.Empty;
								break;

							default:
								continue;
						}
					}
					driver.Properties.Add(driverProperty);
				}
			}

			driver.Parameters = new List<Parameter>();
			if (innerDriver.paramInfo != null)
			{
				foreach (var innerParameter in innerDriver.paramInfo)
				{
					driver.Parameters.Add(new Parameter()
					{
						Name = innerParameter.name,
						Caption = innerParameter.caption,
						//Visible = innerParameter.hidden == "0" && innerParameter.showOnlyInState == "1"
                        Visible = innerParameter.showOnlyInState == "1"
					});
				}
			}

			driver.States = new List<DriverState>();
			if (innerDriver.state != null)
			{
				var codes = new HashSet<string>();
				foreach (var innerState in innerDriver.state)
				{
					if (codes.Add(innerState.code) == false)
					{
						innerState.code += "_" + Guid.NewGuid().ToString();
					}
					if (innerState.name == null)
						continue;
					if (innerState.code == null)
						continue;
					driver.States.Add(new DriverState()
					{
						Id = innerState.id,
						Name = innerState.name,
						AffectChildren = innerState.affectChildren == "1" ? true : false,
						AffectParent = innerState.AffectedParent == "1" ? true : false,
						StateType = (StateType)int.Parse(innerState.@class),
						IsManualReset = innerState.manualReset == "1" ? true : false,
						CanResetOnPanel = innerState.CanResetOnPanel == "1" ? true : false,
						//IsAutomatic = innerState.type == "Auto" ? true : false,
						IsAutomatic = (innerState.code.Contains("AutoOff") || innerState.code.Contains("Auto_Off") || innerState.code.Contains("Auto_off")),
						Code = innerState.code
					});
				}
			}
			return driver;
		}
예제 #13
0
		private static void AddAM(Driver driver)
		{
			var property1 = new DriverProperty()
			{
				IsAUParameter = true,
				No = 0x81,
				Name = "Тип шлейфа",
				Caption = "Тип шлейфа",
				Default = "0",
				BitOffset = 4,
				UseMask = true
			};
			var property1Parameter1 = new DriverPropertyParameter()
			{
				Name = "Шлейф дымовых датчиков с определением двойной сработки",
				Value = "0"
			};
			var property1Parameter2 = new DriverPropertyParameter()
			{
				Name = "Комбинированный шлейф дымовых и тепловых датчиков без определения двойной сработки тепловых датчиков и с определением двойной сработки дымовых",
				Value = "1"
			};
			var property1Parameter3 = new DriverPropertyParameter()
			{
				Name = "Шлейф тепловых датчиков с определением двойной сработки",
				Value = "2"
			};
			var property1Parameter4 = new DriverPropertyParameter()
			{
				Name = "Комбинированный шлейф дымовых и тепловых датчиков без определения двойной сработки и без контроля короткого замыкания ШС",
				Value = "3"
			};
			
			
			property1.Parameters.Add(property1Parameter1);
			property1.Parameters.Add(property1Parameter2);
			property1.Parameters.Add(property1Parameter3);
			property1.Parameters.Add(property1Parameter4);

			//var property1Parameter6 = new DriverPropertyParameter()
			//{
			//    Name = "Охранная конфигурация",
			//    Value = "6"
			//};
			//var property1Parameter7 = new DriverPropertyParameter()
			//{
			//    Name = "Охранная конфигурация с дополнительным резистором",
			//    Value = "7"
			//};
			//property1.Parameters.Add(property1Parameter6);
			//property1.Parameters.Add(property1Parameter7);
			
			driver.Properties.Add(property1);

			var property2 = new DriverProperty()
			{
				IsAUParameter = true,
				No = 0x81,
				Name = "Тип включения выхода при пожаре",
				Caption = "Тип включения выхода при пожаре",
				Default = "2",
				MaxBit=3,
				UseMask=true
			};
			var property2Parameter1 = new DriverPropertyParameter()
			{
				Name = "Выключено",
				Value = "0"
			};
			var property2Parameter2 = new DriverPropertyParameter()
			{
				Name = "Мерцает",
				Value = "1"
			};
			var property2Parameter3 = new DriverPropertyParameter()
			{
				Name = "Включено",
				Value = "2"
			};
			property2.Parameters.Add(property2Parameter1);
			property2.Parameters.Add(property2Parameter2);
			property2.Parameters.Add(property2Parameter3);
			driver.Properties.Add(property2);
		}
예제 #14
0
		private static void AddLogic(Driver driver, byte no, string propertyName, string defaultValue)
		{
			var property = new DriverProperty()
			{
				IsAUParameter = true,
				No = no,
				Name = propertyName,
				Caption = propertyName,
				Default = defaultValue,
				BitOffset = 4,
				UseMask = true
			};
			ConfigurationDriverHelper.AddPropertyParameter(property, "Не включать", 1);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Включить сразу", 2);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Включить после паузы", 3);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Включить на заданное время", 4);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Включить после паузы на заданное время и выключить", 5);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Переключать постоянно", 6);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Начать переключение после паузы", 7);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Переключать заданное время и оставить включенным", 8);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Начать переключение после паузы, переключать заданное время и оставить включенным", 9);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Переключать заданное время и оставить выключенным", 10);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Начать переключение после паузы, переключать заданное время и оставить выключенным", 11);
			driver.Properties.Add(property);
		}
예제 #15
0
        AlarmType? StateToAlarmType(DeviceDriverState state, Driver driver)
        {
			if (state.DriverState == null)
			{
				return null;
			}
            if (state.DriverState.IsAutomatic && (state.DriverState.Code.Contains("AutoOff") || state.DriverState.Code.Contains("Auto_Off") || state.DriverState.Code.Contains("Auto_off")))
                return AlarmType.Auto;

            AlarmType? alarmType = null;
            switch (state.DriverState.StateType)
            {
                case StateType.Fire:
                    return null;

                case StateType.Attention:
                    if (state.DriverState.CanResetOnPanel == false)
                        return null;
                    alarmType = AlarmType.Attention;
                    break;

                case StateType.Info:
                    if (state.DriverState.CanResetOnPanel == false)
                        return null;
                    alarmType = AlarmType.Info;
                    break;

                case StateType.Off:
                    if (driver.CanDisable == false)
                        return null;
                    alarmType = AlarmType.Off;
                    break;

                case StateType.Failure:
                    alarmType = AlarmType.Failure;
                    break;

                case StateType.Service:
                    alarmType = AlarmType.Service;
                    break;
            }

            return alarmType;
        }
예제 #16
0
		private static void AddDetectorState(Driver driver, byte no, string propertyName, byte offset, byte minBit, byte maxBit, string defaultValue)
		{
			var property = new DriverProperty()
			{
				IsAUParameter = true,
				No = no,
				Name = propertyName,
				Caption = propertyName,
				Default = defaultValue,
				BitOffset = offset,
				MinBit = minBit,
				MaxBit = maxBit,
				UseMask = true
			};
			ConfigurationDriverHelper.AddPropertyParameter(property, "Замкнутое", 1);
			ConfigurationDriverHelper.AddPropertyParameter(property, "Разомкнутое", 2);
			driver.Properties.Add(property);
		}
		public void ChangeDriver(Device device, Driver driver)
		{
			var changeZone = !(device.Driver.IsZoneDevice && driver.IsZoneDevice);
			device.Driver = driver;
			device.DriverUID = driver.UID;
            if (driver.IsRangeEnabled)
                device.IntAddress = driver.MinAddress;
			if (changeZone)
			{
				RemoveDeviceFromZone(device, null);
				SetDeviceZoneLogic(device, new ZoneLogic());
			}
			device.Properties = new List<Property>();
			device.SystemAUProperties = new List<Property>();
			device.DeviceAUProperties = new List<Property>();
			device.OnChanged();
		}
예제 #18
0
        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
                {
                    if (parentDevice.Children.Where(x=>x.Driver.IsAutoCreate == false).ToList().Count > 0)
                        if (((maxAddress + 1) % 256) != 0)
                            maxAddress = maxAddress + 1;
                }
            }

            return maxAddress;
        }
예제 #19
0
		static int GetBestAddress(Driver driver)
		{
			var bestAddress = Addresses.FirstOrDefault();
			foreach (var address in Addresses)
			{
				if (address.IsBuisy)
					continue;

				bool isPrevAddressBuisy = true;
				var prevAddress = Addresses.FirstOrDefault(x => x.Address == address.Address - 1);
				if (prevAddress != null)
					isPrevAddressBuisy = prevAddress.IsBuisy;

				if (!isPrevAddressBuisy)
					continue;

				bool reservedAddressesFree = true;
				for (int i = 0; i < Math.Max(driver.ChildAddressReserveRangeCount, 1); i++)
				{
					var reservedAddress = Addresses.FirstOrDefault(x => x.Address == address.Address + i);
					if (reservedAddress != null)
					{
						if (reservedAddress.IsBuisy)
							reservedAddressesFree = false;
					}
					else
						reservedAddressesFree = false;
				}
				if (!reservedAddressesFree)
					continue;

				if (address.Address > bestAddress.Address)
					bestAddress = address;
			}
			return bestAddress.Address;
		}