public static LEDProperties ConvertBack(IndicatorLogic indicatorLogic)
        {
            var lEDProperties = new LEDProperties();

            switch (indicatorLogic.IndicatorLogicType)
            {
                case IndicatorLogicType.Zone:
                    lEDProperties.type = "0";
                    lEDProperties.device = null;
                    lEDProperties.zone = indicatorLogic.Zones.Select(x => x.ToString()).ToArray();
                    break;

                case IndicatorLogicType.Device:
                    lEDProperties.type = "1";
                    lEDProperties.zone = null;
                    lEDProperties.device = new deviceType[1];
                    lEDProperties.device[0] = new deviceType()
                    {
                        UID = GuidHelper.ToString(indicatorLogic.DeviceUID),
                        state1 = ((int)indicatorLogic.OnColor).ToString(),
                        state2 = ((int)indicatorLogic.OffColor).ToString(),
                        state3 = ((int)indicatorLogic.FailureColor).ToString(),
                        state4 = ((int)indicatorLogic.ConnectionColor).ToString()
                    };
                    break;
            }

            return lEDProperties;
        }
        public static IndicatorLogic Convert(DeviceConfiguration deviceConfiguration, LEDProperties lEDProperties)
		{
			var indicatorLogic = new IndicatorLogic();

			switch (lEDProperties.type)
			{
				case "0":
					indicatorLogic.IndicatorLogicType = IndicatorLogicType.Zone;
					break;

				case "1":
					indicatorLogic.IndicatorLogicType = IndicatorLogicType.Device;
					break;
			}

			if (lEDProperties.zone != null)
			{
				foreach (var item in lEDProperties.zone)
				{
                    if (string.IsNullOrWhiteSpace(item) == false)
                    {
                        int zoneNo = int.Parse(item);
                        var zone = deviceConfiguration.Zones.FirstOrDefault(x => x.No == zoneNo);
                        if (zone != null)
                        {
                            indicatorLogic.ZoneUIDs.Add(zone.UID);
                        }
                    }
				}
			}

			if (lEDProperties.device != null && lEDProperties.device.Count() > 0)
			{
				var indicatorDevice = lEDProperties.device[0];
				indicatorLogic.DeviceUID = GuidHelper.ToGuid(indicatorDevice.UID);
				indicatorLogic.OnColor = StringToIndicatorColorType(indicatorDevice.state1);
				indicatorLogic.OffColor = StringToIndicatorColorType(indicatorDevice.state2);
				indicatorLogic.FailureColor = StringToIndicatorColorType(indicatorDevice.state3);
				indicatorLogic.ConnectionColor = StringToIndicatorColorType(indicatorDevice.state4);
			}

			return indicatorLogic;
		}
Beispiel #3
0
		public Device()
		{
			UID = Guid.NewGuid();
			Children = new List<Device>();
			Properties = new List<Property>();
			SystemAUProperties = new List<Property>();
			DeviceAUProperties = new List<Property>();
			IndicatorLogic = new IndicatorLogic();
			PDUGroupLogic = new PDUGroupLogic();
			PlanElementUIDs = new List<Guid>();
			ZoneLogic = new ZoneLogic();
			IsRmAlarmDevice = false;
			IsNotUsed = false;
			AllowMultipleVizualization = false;

			ShapeIds = new List<string>();
			ZonesInLogic = new List<Zone>();
			DependentDevices = new List<Device>();
			DeviceConfiguration = new DeviceConfiguration();
			StateWordBytes = new List<byte>();
			RawParametersBytes = new List<byte>();
		}
        public static IndicatorLogic Convert(LEDProperties lEDProperties)
        {
            var indicatorLogic = new IndicatorLogic();

            switch (lEDProperties.type)
            {
                case "0":
                    indicatorLogic.IndicatorLogicType = IndicatorLogicType.Zone;
                    break;

                case "1":
                    indicatorLogic.IndicatorLogicType = IndicatorLogicType.Device;
                    break;
            }

            if (lEDProperties.zone != null)
            {
                foreach (var item in lEDProperties.zone)
                {
                    if (string.IsNullOrWhiteSpace(item) == false)
                        indicatorLogic.Zones.Add(int.Parse(item));
                }
            }

            if (lEDProperties.device != null && lEDProperties.device.Count() > 0)
            {
                var indicatorDevice = lEDProperties.device[0];
                indicatorLogic.DeviceUID = GuidHelper.ToGuid(indicatorDevice.UID);
                indicatorLogic.OnColor = (IndicatorColorType)int.Parse(indicatorDevice.state1);
                indicatorLogic.OffColor = (IndicatorColorType)int.Parse(indicatorDevice.state2);
                indicatorLogic.FailureColor = (IndicatorColorType)int.Parse(indicatorDevice.state3);
                indicatorLogic.ConnectionColor = (IndicatorColorType)int.Parse(indicatorDevice.state4);
            }

            return indicatorLogic;
        }
 public void SetIndicatorLogic(Device device, IndicatorLogic indicatorLogic)
 {
     foreach (var zone in device.IndicatorLogic.Zones)
         zone.IndicatorsInZone.Remove(device);
     device.IndicatorLogic = indicatorLogic;
     DeviceConfiguration.InvalidateIndicator(device);
     DeviceConfiguration.UpdateOneDeviceCrossReferences(device);
     device.OnChanged();
 }
		protected override bool Save()
		{
			var indicatorLogic = new IndicatorLogic();
			if (IsZone)
			{
				indicatorLogic.IndicatorLogicType = IndicatorLogicType.Zone;
				indicatorLogic.ZoneUIDs = Zones;
			}
			else if (IsDevice)
			{
				indicatorLogic.IndicatorLogicType = IndicatorLogicType.Device;
				indicatorLogic.Device = SelectedDevice;
				indicatorLogic.DeviceUID = (SelectedDevice == null) ? Guid.Empty : SelectedDevice.UID;
				indicatorLogic.OnColor = OnColor;
				indicatorLogic.OffColor = OffColor;
				indicatorLogic.FailureColor = FailureColor;
				indicatorLogic.ConnectionColor = ConnectionColor;

				if (indicatorLogic.Device != null && indicatorLogic.Device.Driver.IsPump())
				{
					if (Device.IntAddress > 10)
					{
						MessageBoxService.ShowError("Размещать устройства данного типа можно только на индикаторах с адресом меньше 11");
						return false;
					}
					if (MessageBoxService.ShowQuestion("Разместить устройство на нескольких индикаторах?") != System.Windows.MessageBoxResult.Yes)
						return false;

					for (int i = 1; i < 5; i++)
					{
						var nextIndicatorDevice = Device.Parent.Children[Device.IntAddress + i * 10 - 1];
						var nextIndicatorLogic = new IndicatorLogic()
						{
							IndicatorLogicType = IndicatorLogicType.Device,
							Device = Device,
							DeviceUID = Device.UID
						};
						FiresecManager.FiresecConfiguration.SetIndicatorLogic(nextIndicatorDevice, nextIndicatorLogic);
					}
				}
			}
			FiresecManager.FiresecConfiguration.SetIndicatorLogic(Device, indicatorLogic);
			ValidateMissingPumpDevices();
			RegistrySettingsHelper.SetInt("FireAdministrator.Indicator.IndicatorLogicType", (int)indicatorLogic.IndicatorLogicType);
			return base.Save();
		}