Exemplo n.º 1
0
        public DirectionDetailsViewModel(XDirection direction = null)
        {
            if (direction == null)
            {
                Title = "Создание новоого направления";

                XDirection = new XDirection()
                {
                    Name = "Новое направление",
                    No = 1
                };
                if (XManager.DeviceConfiguration.Directions.Count != 0)
                    XDirection.No = (ushort)(XManager.DeviceConfiguration.Directions.Select(x => x.No).Max() + 1);
            }
            else
            {
                Title = string.Format("Свойства направления: {0}", direction.PresentationName);
                XDirection = direction;
            }
            if (XDirection.DirectionDevices.Count == 0)
            {
                var directionDevice = new DirectionDevice();
                XDirection.DirectionDevices.Add(directionDevice);
            }
            CopyProperties();
            DirectionDevicesViewModel = new DirectionDevicesViewModel(XDirection);
        }
Exemplo n.º 2
0
		public DirectionDescriptor(XDirection direction)
		{
			DatabaseType = DatabaseType.Gk;
			DescriptorType = DescriptorType.Direction;
			Direction = direction;
			Build();
		}
Exemplo n.º 3
0
 public DirectionBinaryObject(XDirection direction, DatabaseType databaseType)
 {
     DatabaseType = databaseType;
     ObjectType = ObjectType.Direction;
     Direction = direction;
     Build();
 }
Exemplo n.º 4
0
		public DirectionViewModel(XDirection direction)
		{
			Direction = direction;
			Zones = new ObservableCollection<DirectionZoneViewModel>();
			Devices = new ObservableCollection<DirectionDeviceViewModel>();
			OutputDevices = new ObservableCollection<DeviceViewModel>();
			Update();
		}
Exemplo n.º 5
0
		public DirectionViewModel(XDirection direction)
		{
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);
			Direction = direction;
			State.StateChanged += new System.Action(OnStateChanged);
			OnStateChanged();
		}
Exemplo n.º 6
0
		public ObjectViewModel(XDirection direction)
		{
			Direction = direction;
			Name = direction.PresentationName;
			ImageSource = "/Controls;component/Images/Blue_Direction.png";
			Address = "";
			PresentationZone = "";
			ObjectType = ObjectType.Zone;
		}
Exemplo n.º 7
0
		public InstructionViewModel(XDevice device, XZone zone, XDirection direction, XAlarmType alarmType)
		{
			
			AlarmType = alarmType;

			Instruction = FindInstruction(device, zone, direction);
			Title = Instruction != null ? Instruction.Name : "";
			HasContent = Instruction != null;
			
		}
Exemplo n.º 8
0
 static bool ValidateEmptyDirection(XDirection direction)
 {
     var count = direction.InputZones.Count + direction.InputDevices.Count + direction.OutputDevices.Count;
     if (count == 0)
     {
         Errors.Add(new DirectionValidationError(direction, "В направлении отсутствуют входные или выходные объекты", ValidationErrorLevel.CannotWrite));
         return false;
     }
     return true;
 }
Exemplo n.º 9
0
 static void ValidateEmptyZoneInDirection(XDirection direction)
 {
     foreach (var zone in direction.InputZones)
     {
         if (zone.Devices.Count == 0)
         {
             Errors.Add(new DirectionValidationError(direction, "В направление входит пустая зона " + zone.PresentationName, ValidationErrorLevel.CannotWrite));
         }
     }
 }
Exemplo n.º 10
0
		public static bool CanShowDirection(XDirection direction)
		{
			foreach (var plan in FiresecManager.PlansConfiguration.AllPlans)
			{
				if (plan.ElementRectangleXDirections.Any(x => x.DirectionUID == direction.UID))
					return true;
				if (plan.ElementPolygonXDirections.Any(x => x.DirectionUID == direction.UID))
					return true;
			}
			return false;
		}
Exemplo n.º 11
0
        static void ValidateDifferentGK(XDirection direction)
        {
            var devices = new List<XDevice>();
            devices.AddRange(direction.InputDevices);
            devices.AddRange(direction.OutputDevices);
            foreach (var zone in direction.InputZones)
            {
                devices.AddRange(zone.Devices);
            }

            if (AreDevicesInSameGK(devices))
                Errors.Add(new DirectionValidationError(direction, "Направление содержит объекты устройства разных ГК", ValidationErrorLevel.CannotWrite));
        }
Exemplo n.º 12
0
        XInstruction FindInstruction(XDevice device, XZone zone, XDirection direction)
		{
			var availableStateTypeInstructions = XManager.DeviceConfiguration.Instructions.FindAll(x => x.AlarmType == AlarmType);

			if (device != null)
			{
				foreach (var instruction in availableStateTypeInstructions)
				{
					if (instruction.Devices.Contains(device.UID))
					{
						return instruction;
					}
				}
			}

			if (zone != null)
			{
				foreach (var instruction in availableStateTypeInstructions)
				{
					if (instruction.ZoneUIDs.Contains(zone.UID))
					{
						return instruction;
					}
				}
			}

            if (direction != null)
            {
                foreach (var instruction in availableStateTypeInstructions)
                {
                    if (instruction.Directions == null)
                        break;
                    if (instruction.Directions.Contains(direction.UID))
                    {
                        return instruction;
                    }
                }
            }

			foreach (var instruction in availableStateTypeInstructions)
			{
				if (instruction.InstructionType == XInstructionType.General)
				{
					return instruction;
				}
			}

			return null;
		}
Exemplo n.º 13
0
        public DirectionDevicesViewModel(XDirection direction)
        {
            AddCommand = new RelayCommand(OnAdd);
            RemoveCommand = new RelayCommand<DirectionDeviceViewModel>(OnRemove);

            Direction = direction;

            DirectionDevices = new ObservableCollection<DirectionDeviceViewModel>();
            if (direction.DirectionDevices == null)
                direction.DirectionDevices = new List<DirectionDevice>();
            foreach (var directionDevice in direction.DirectionDevices)
            {
                var directionDeviceViewModel = new DirectionDeviceViewModel(directionDevice);
                DirectionDevices.Add(directionDeviceViewModel);
            }
        }
Exemplo n.º 14
0
		public XDirectionPainter(PresenterItem presenterItem)
			: base(presenterItem.Element)
		{
			_textDrawing = null;
			_scaleTransform = new ScaleTransform();
			_contextMenu = null;
			_presenterItem = presenterItem;
			_presenterItem.ShowBorderOnMouseOver = true;
			_presenterItem.ContextMenuProvider = CreateContextMenu;
			_direction = Helper.GetXDirection((IElementDirection)_presenterItem.Element);
			_showText = _direction != null && _presenterItem.Element is ElementRectangleXDirection;
			if (_direction != null)
				_direction.State.StateChanged += OnPropertyChanged;
			_presenterItem.Cursor = Cursors.Hand;
			_presenterItem.ClickEvent += (s, e) => OnShowProperties();
			UpdateTooltip();
		}
Exemplo n.º 15
0
		public DirectionDetailsViewModel(XDirection direction)
		{
			Direction = direction;
			State.StateChanged += new Action(OnStateChanged);
			InitializePlans();

			ShowCommand = new RelayCommand(OnShow);
			ShowJournalCommand = new RelayCommand(OnShowJournal);
			SetAutomaticStateCommand = new RelayCommand(OnSetAutomaticState, CanSetAutomaticState);
			SetManualStateCommand = new RelayCommand(OnSetManualState, CanSetManualState);
			SetIgnoreStateCommand = new RelayCommand(OnSetIgnoreState, CanSetIgnoreState);
			TurnOnCommand = new RelayCommand(OnTurnOn);
			TurnOnNowCommand = new RelayCommand(OnTurnOnNow);
			TurnOffCommand = new RelayCommand(OnTurnOff);
			ForbidStartCommand = new RelayCommand(OnForbidStart);

			Title = Direction.PresentationName;
			TopMost = true;
		}
Exemplo n.º 16
0
        public DirectionViewModel(XDirection direction)
        {
            AddZoneCommand = new RelayCommand(OnAddZone, CanAdd);
            RemoveZoneCommand = new RelayCommand(OnRemoveZone, CanRemove);

            Direction = direction;

            Zones = new ObservableCollection<ZoneViewModel>();
            SourceZones = new ObservableCollection<ZoneViewModel>();

            foreach (var zone in XManager.DeviceConfiguration.Zones)
            {
                var zoneViewModel = new ZoneViewModel(zone);
                if (Direction.Zones.Contains(zone.UID))
                    Zones.Add(zoneViewModel);
                else
                    SourceZones.Add(zoneViewModel);
            }

            SelectedZone = Zones.FirstOrDefault();
            SelectedSourceZone = SourceZones.FirstOrDefault();
        }
Exemplo n.º 17
0
		public DirectionDetailsViewModel(XDirection direction = null)
		{
			WritePropertiesCommand = new RelayCommand(OnWriteProperties);
			ReadPropertiesCommand = new RelayCommand(OnReadProperties);
			ResetPropertiesCommand = new RelayCommand(OnResetProperties);
			DelayRegimes = Enum.GetValues(typeof(DelayRegime)).Cast<DelayRegime>().ToList();

			if (direction == null)
			{
				Title = "Создание новоого направления";

				Direction = new XDirection()
				{
					Name = "Новое направление",
					No = 1
				};
				if (XManager.Directions.Count != 0)
					Direction.No = (ushort)(XManager.Directions.Select(x => x.No).Max() + 1);
			}
			else
			{
				Title = string.Format("Свойства направления: {0}", direction.PresentationName);
				Direction = direction;
			}
			CopyProperties();

			var availableNames = new HashSet<string>();
			var availableDescription = new HashSet<string>();
			foreach (var existingDirection in XManager.Directions)
			{
				availableNames.Add(existingDirection.Name);
				availableDescription.Add(existingDirection.Description);
			}
			AvailableNames = new ObservableCollection<string>(availableNames);
			AvailableDescription = new ObservableCollection<string>(availableDescription);
		}
Exemplo n.º 18
0
		public static Color GetXDirectionColor(XDirection direction)
		{
			Color color = Colors.Black;
			if (direction != null)
				color = Colors.LightBlue;
			return color;
		}
Exemplo n.º 19
0
		public static void SetXDirection(IElementDirection element, XDirection xdirection)
		{
			ResetXDirection(element);
			element.DirectionUID = xdirection == null ? Guid.Empty : xdirection.UID;
			element.BackgroundColor = GetXDirectionColor(xdirection);
			if (xdirection != null)
				xdirection.PlanElementUIDs.Add(element.UID);
		}
Exemplo n.º 20
0
		public XDirectionState(XDirection direction)
		{
			Direction = direction;
		}
Exemplo n.º 21
0
		public static void ShowDirection(XDirection direction)
		{
			ServiceFactory.Events.GetEvent<ShowXDirectionOnPlanEvent>().Publish(direction);
		}
Exemplo n.º 22
0
		public static void ChangeDirectionDevices(XDirection direction, List<XDevice> devices)
		{
			foreach (var device in direction.InputDevices)
            {
                device.Directions.Remove(direction);
                device.OnChanged();
            }
            direction.InputDevices.Clear();
            var oldDirectionDevices = new List<XDirectionDevice>(direction.DirectionDevices);
            direction.DirectionDevices.Clear();
            foreach (var device in devices)
            {
                var directionDevice = new XDirectionDevice()
                {
                    DeviceUID = device.UID,
                    Device = device
                };
				if(device.Driver.AvailableStateBits.Contains(XStateBit.Fire1))
				{
					directionDevice.StateBit = XStateBit.Fire1;
				}
				else if (device.Driver.AvailableStateBits.Contains(XStateBit.Fire2))
				{
					directionDevice.StateBit = XStateBit.Fire2;
				}
				else if (device.Driver.AvailableStateBits.Contains(XStateBit.On))
				{
					directionDevice.StateBit = XStateBit.On;
				}
                var existingDirectionDevice = oldDirectionDevices.FirstOrDefault(x => x.Device == device);
                if (existingDirectionDevice != null)
                {
                    directionDevice.StateBit = existingDirectionDevice.StateBit;
                }
                direction.DirectionDevices.Add(directionDevice);
                direction.InputDevices.Add(device);
				device.Directions.Add(direction);
                device.OnChanged();
            }
			direction.OnChanged();
		}
Exemplo n.º 23
0
		public static void ChangeDirectionZones(XDirection direction, List<XZone> zones)
		{
			foreach (var zone in direction.InputZones)
			{
				zone.Directions.Remove(direction);
				zone.OnChanged();
			}
			direction.InputZones.Clear();
            var oldDirectionZones = new List<XDirectionZone>(direction.DirectionZones);
            direction.DirectionZones.Clear();
            foreach (var zone in zones)
            {
                direction.InputZones.Add(zone);
                var directionZone = new XDirectionZone()
                {
                    ZoneUID = zone.UID,
                    Zone = zone
                };
                var existingDirectionZone = oldDirectionZones.FirstOrDefault(x => x.Zone == zone);
                if (existingDirectionZone != null)
                {
                    directionZone.StateBit = existingDirectionZone.StateBit;
                }
                direction.DirectionZones.Add(directionZone);
                zone.Directions.Add(direction);
                zone.OnChanged();
            }
			direction.OnChanged();
		}
Exemplo n.º 24
0
		public DirectionTooltipViewModel(XDirection direction)
		{
			Direction = direction;
			State = direction.State;
		}
Exemplo n.º 25
0
		public static string GetXDirectionTitle(XDirection xdirection)
		{
			return xdirection == null ? "Несвязанное направление" : xdirection.PresentationName;
		}
Exemplo n.º 26
0
		public Alarm(XAlarmType alarmType, XDirection direction)
		{
			AlarmType = alarmType;
			Direction = direction;
		}
Exemplo n.º 27
0
		bool Parse(List<byte> bytes, int descriptorNo)
		 {
			var internalType = BytesHelper.SubstructShort(bytes, 0);
			var controllerAdress = BytesHelper.SubstructShort(bytes, 2);
			var adressOnController = BytesHelper.SubstructShort(bytes, 4);
			var physicalAdress = BytesHelper.SubstructShort(bytes, 6);
			if(internalType == 0)
				return true;
			var description = BytesHelper.BytesToStringDescription(bytes);
			var driver = XManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == internalType);
			if (internalType == 0x70)
			{
				if (description[0] == 'П')
					driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.FirePump);
				if (description[0] == 'Ж')
					driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.JockeyPump);
				if (description[0] == 'Д')
					driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.DrainagePump);
			}
			if (driver != null)
			{
				if (driver.DriverType == XDriverType.GK && descriptorNo > 1)
				{
					driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.KAU);
					if (bytes[0x3a] == 1)
					{
						driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.RSR2_KAU);
					}
				}
				if (driver.DriverType == XDriverType.GKIndicator && descriptorNo > 14)
					driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.KAUIndicator);

				var shleifNo = (byte)(physicalAdress / 256) + 1;
				var device = new XDevice
				{
					Driver = driver,
					DriverUID = driver.UID,
					IntAddress = (byte)(physicalAdress % 256),
				};
				if (driver.DriverType == XDriverType.GK)
				{
					device.Properties.Add(new XProperty{Name = "IPAddress",StringValue = IpAddress});
					ControllerDevices.Add(controllerAdress, device);
					DeviceConfiguration.RootDevice.Children.Add(device);
					GkDevice = device;
				}
				if (driver.IsKauOrRSR2Kau)
				{
					device.IntAddress = (byte)(controllerAdress % 256);
					var modeProperty = new XProperty
					{
						Name = "Mode",
						Value = (byte)(controllerAdress / 256)
					};
					device.DeviceProperties.Add(modeProperty);
					ControllerDevices.Add(controllerAdress, device);
					GkDevice.Children.Add(device);
					for (int i = 0; i < 8; i++)
					{
						var shleif = new XDevice();
						shleif.Driver = driver.DriverType == XDriverType.KAU ? XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.KAU_Shleif) : XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.RSR2_KAU_Shleif);
						shleif.DriverUID = shleif.Driver.UID;
						shleif.IntAddress = (byte)(i + 1);
						device.Children.Add(shleif);
					}
				}
				if (driver.DriverType != XDriverType.GK && !driver.IsKauOrRSR2Kau && driver.DriverType != XDriverType.System)
				{
					var controllerDevice = ControllerDevices.FirstOrDefault(x => x.Key == controllerAdress);
					if (controllerDevice.Value != null)
					{
						if(1 <= shleifNo && shleifNo <= 8 && physicalAdress != 0)
						{
							var shleif = controllerDevice.Value.Children.FirstOrDefault(x => (x.DriverType == XDriverType.KAU_Shleif || x.DriverType == XDriverType.RSR2_KAU_Shleif) && x.IntAddress == shleifNo);
							shleif.Children.Add(device);
						}
						else
						{
							if (controllerDevice.Value.Driver.DriverType == XDriverType.GK)
								device.IntAddress = (byte) (controllerDevice.Value.Children.Where(x => !x.Driver.HasAddress).Count() + 2);
							else
								device.IntAddress = (byte)(controllerDevice.Value.Children.Where(x => !x.Driver.HasAddress).Count() + 1);
							controllerDevice.Value.Children.Add(device);
						}
					}
				}
				return true;
			}

			if(internalType == 0x100 || internalType == 0x106)
			{
				var isPumpStation = false;
				ushort no;
				try
				{
					if (description[0] == '0')
						isPumpStation = true;
					no = (ushort)Int32.Parse(description.Substring(0, description.IndexOf(".")));
					description = description.Substring(description.IndexOf(".") + 1);
				}
				catch
				{
					Error = "Невозможно получить номер объекта с дескриптором " + descriptorNo;
					return false;
				}

				if (internalType == 0x100)
				{
					var zone = new XZone
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Zones.Add(zone);
					return true;
				}
				if (internalType == 0x106)
				{
					if (isPumpStation)
					{
						var pumpStation = new XPumpStation()
						{
							Name = description,
							No = no,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.PumpStations.Add(pumpStation);
					}
					else
					{
						var direction = new XDirection
						{
							Name = description,
							No = no,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.Directions.Add(direction);
					}
					return true;
				}
			}
			return true;
		}
Exemplo n.º 28
0
		public static void AddDirection(XDirection direction)
		{
			Directions.Add(direction);
		}
Exemplo n.º 29
0
		public ArchiveDirectionViewModel(XDirection direction)
		{
			Direction = direction;
			Name = direction.PresentationName;
		}
Exemplo n.º 30
0
		public static void RemoveDirection(XDirection direction)
		{
			foreach (var zone in direction.InputZones)
			{
				zone.Directions.Remove(direction);
				zone.OnChanged();
			}
			Directions.Remove(direction);
			direction.OnChanged();
		}