Exemplo n.º 1
0
		public DescriptorViewModel(BaseDescriptor descriptor, DescriptorsViewModel descriptorsViewModel)
		{
			NavigateCommand = new RelayCommand(OnNavigate);
			DescriptorsViewModel = descriptorsViewModel;
			Descriptor = descriptor;
			Description = descriptor.XBase.PresentationName;
			switch (descriptor.DescriptorType)
			{
				case DescriptorType.Device:
					ImageSource = descriptor.Device.Driver.ImageSource;
					break;

				case DescriptorType.Zone:
					ImageSource = "/Controls;component/Images/Zone.png";
					break;

				case DescriptorType.Direction:
					ImageSource = "/Controls;component/Images/Blue_Direction.png";
					break;

				case DescriptorType.PumpStation:
					ImageSource = "/Controls;component/Images/BPumpStation.png";
					break;

				case DescriptorType.Delay:
					ImageSource = "/Controls;component/Images/Delay.png";
					break;

				case DescriptorType.Pim:
					ImageSource = "/Controls;component/Images/Pim.png";
					break;
			}

			IsFormulaInvalid = Descriptor.Formula.CalculateStackLevels();
		}
Exemplo n.º 2
0
		public DescriptorViewModel(BaseDescriptor descriptor, DescriptorsViewModel descriptorsViewModel)
		{
			NavigateCommand = new RelayCommand(OnNavigate);
			DescriptorsViewModel = descriptorsViewModel;
			Descriptor = descriptor;
			PresentationName = descriptor.GKBase.PresentationName;
			Description = descriptor.GKBase.Description;
			switch (descriptor.DescriptorType)
			{
				case DescriptorType.Device:
					var device = descriptor.GKBase as GKDevice;
					if (device != null)
					{
						ImageSource = device.Driver.ImageSource;
					}
					break;

				case DescriptorType.Zone:
					ImageSource = "/Controls;component/Images/Zone.png";
					break;

				case DescriptorType.Direction:
					ImageSource = "/Controls;component/Images/Blue_Direction.png";
					break;

				case DescriptorType.PumpStation:
					ImageSource = "/Controls;component/Images/BPumpStation.png";
					break;

				case DescriptorType.MPT:
					ImageSource = "/Controls;component/Images/BMPT.png";
					break;

				case DescriptorType.Delay:
					ImageSource = "/Controls;component/Images/Delay.png";
					break;

				case DescriptorType.Pim:
					ImageSource = "/Controls;component/Images/Pim.png";
					break;

				case DescriptorType.GuardZone:
					ImageSource = "/Controls;component/Images/GuardZone.png";
					break;

				case DescriptorType.Code:
					ImageSource = "/Controls;component/Images/Code.png";
					break;

				case DescriptorType.Door:
					ImageSource = "/Controls;component/Images/Door.png";
					break;
			}

			IsFormulaInvalid = !Descriptor.Formula.CheckStackOverflow();
		}
Exemplo n.º 3
0
		public DescriptorLogicItem(FormulaOperation formulaOperation, DescriptorsViewModel descriptorsViewModel)
		{
			FormulaOperation = formulaOperation;
			DescriptorsViewModel = descriptorsViewModel;

			FirstOperand = FormulaOperation.FirstOperand.ToString();
			SecondOperand = FormulaOperation.SecondOperand.ToString();

			switch (FormulaOperation.FormulaOperationType)
			{
				case FormulaOperationType.ADD:
				case FormulaOperationType.AND:
				case FormulaOperationType.COM:
				case FormulaOperationType.DUP:
				case FormulaOperationType.END:
				case FormulaOperationType.EQ:
				case FormulaOperationType.GE:
				case FormulaOperationType.GT:
				case FormulaOperationType.LE:
				case FormulaOperationType.LT:
				case FormulaOperationType.MUL:
				case FormulaOperationType.NE:
				case FormulaOperationType.NEG:
				case FormulaOperationType.OR:
				case FormulaOperationType.SUB:
				case FormulaOperationType.XOR:
					FirstOperand = "";
					SecondOperand = "";
					break;

				case FormulaOperationType.CONST:
					FirstOperand = "";
					break;

				default:
					IsBold = true;

					var stateTypeToIconConverter = new XStateTypeToIconConverter();
					StateIcon = (string)stateTypeToIconConverter.Convert((XStateBit)FormulaOperation.FirstOperand, null, null, null);

					var stateTypeToStringConverter = new XStateTypeToStringConverter();
					FirstOperand = (string)stateTypeToStringConverter.Convert((XStateBit)FormulaOperation.FirstOperand, null, null, null);

					var descriptorViewModel = DescriptorsViewModel.Descriptors.FirstOrDefault(x => x.Descriptor.XBase.GKDescriptorNo == FormulaOperation.SecondOperand);
					if (descriptorViewModel != null)
					{
						DescriptorIcon = descriptorViewModel.ImageSource;
						SecondOperand = descriptorViewModel.Descriptor.XBase.PresentationName;
					}
					break;
			}
		}
Exemplo n.º 4
0
		public override void CreateViewModels()
		{
			ServiceFactory.Events.GetEvent<CreateXZoneEvent>().Subscribe(OnCreateXZone);
			ServiceFactory.Events.GetEvent<EditXZoneEvent>().Subscribe(OnEditXZone);
			ServiceFactory.Events.GetEvent<CreateXDirectionEvent>().Subscribe(OnCreateXDirection);
			ServiceFactory.Events.GetEvent<EditXDirectionEvent>().Subscribe(OnEditXDirection);

			DevicesViewModel = new DevicesViewModel();
			ParameterTemplatesViewModel = new ParameterTemplatesViewModel();
			ZonesViewModel = new ZonesViewModel();
			DirectionsViewModel = new DirectionsViewModel();
			PumpStationsViewModel = new PumpStationsViewModel();
			GuardViewModel = new GuardViewModel();
			FiltersViewModel = new FiltersViewModel();
			DeviceLidraryViewModel = new LibraryViewModel();
			InstructionsViewModel = new InstructionsViewModel();
			OPCDevicesViewModel = new OPCDevicesViewModel();
			OPCZonesViewModel = new OPCZonesViewModel();
			OPCDirectionsViewModel = new OPCDirectionsViewModel();
			DiagnosticsViewModel = new DiagnosticsViewModel();
			DescriptorsViewModel = new DescriptorsViewModel();
			_planExtension = new GKPlanExtension(DevicesViewModel, ZonesViewModel, DirectionsViewModel);
		}
Exemplo n.º 5
0
		public override void CreateViewModels()
		{
			ServiceFactory.Events.GetEvent<SelectGKZoneEvent>().Subscribe(OnSelectGKZone);
			ServiceFactory.Events.GetEvent<SelectGKZonesEvent>().Subscribe(OnSelectGKZones);
			ServiceFactory.Events.GetEvent<SelectGKGuardZoneEvent>().Subscribe(OnSelectGKGuardZone);
			ServiceFactory.Events.GetEvent<SelectGKGuardZonesEvent>().Subscribe(OnSelectGKGuardZones);
			ServiceFactory.Events.GetEvent<SelectGKDelayEvent>().Subscribe(OnSelectGKDelay);
			ServiceFactory.Events.GetEvent<SelectGKDelaysEvent>().Subscribe(OnSelectGKDelays);
			ServiceFactory.Events.GetEvent<SelectGKDirectionEvent>().Subscribe(OnSelectGKDirection);
			ServiceFactory.Events.GetEvent<SelectGKDirectionsEvent>().Subscribe(OnSelectGKDirections);
			ServiceFactory.Events.GetEvent<SelectGKMPTEvent>().Subscribe(OnSelectGKMPT);
			ServiceFactory.Events.GetEvent<SelectGKMPTsEvent>().Subscribe(OnSelectGKMPTs);
			ServiceFactory.Events.GetEvent<SelectGKDoorEvent>().Subscribe(OnSelectGKDoor);
			ServiceFactory.Events.GetEvent<SelectGKDoorsEvent>().Subscribe(OnSelectGKDoors);
			ServiceFactory.Events.GetEvent<SelectGKDeviceEvent>().Subscribe(OnSelectGKDevice);
			ServiceFactory.Events.GetEvent<SelectGKDevicesEvent>().Subscribe(OnSelectGKDevices);
			ServiceFactory.Events.GetEvent<SelectGKPumpStationEvent>().Subscribe(OnSelectGKPumpStation);
			ServiceFactory.Events.GetEvent<SelectGKPumpStationsEvent>().Subscribe(OnSelectGKPumpStations);

			DevicesViewModel = new DevicesViewModel();
			ParameterTemplatesViewModel = new ParameterTemplatesViewModel();
			ZonesViewModel = new ZonesViewModel();
			DirectionsViewModel = new DirectionsViewModel();
			DelaysViewModel = new DelaysViewModel();
			PumpStationsViewModel = new PumpStationsViewModel();
			MPTsViewModel = new MPTsViewModel();
			CodesViewModel = new CodesViewModel();
			GuardZonesViewModel = new GuardZonesViewModel();
			DoorsViewModel = new DoorsViewModel();
			SKDZonesViewModel = new SKDZonesViewModel();
			DeviceLidraryViewModel = new LibraryViewModel();
			OPCViewModel = new OPCsViewModel();
			DescriptorsViewModel = new DescriptorsViewModel();
			DiagnosticsViewModel = new DiagnosticsViewModel();
			_planExtension = new GKPlanExtension();
		}
Exemplo n.º 6
0
		public DescriptorsMenuViewModel(DescriptorsViewModel context)
		{
			Context = context;
		}
Exemplo n.º 7
0
		public DescriptorLogicItem(FormulaOperation formulaOperation, DescriptorsViewModel descriptorsViewModel, BaseDescriptor descriptor)
		{
			FormulaOperation = formulaOperation;
			DescriptorsViewModel = descriptorsViewModel;
			FirstOperand = FormulaOperation.FirstOperand.ToString();
			FirstOperandByte = FormulaOperation.FirstOperand;
			SecondOperand = FormulaOperation.SecondOperand.ToString();
			Descriptor = descriptor;

			switch (FormulaOperation.FormulaOperationType)
			{
				case FormulaOperationType.ADD:
				case FormulaOperationType.AND:
				case FormulaOperationType.COM:
				case FormulaOperationType.DUP:
				case FormulaOperationType.END:
				case FormulaOperationType.EQ:
				case FormulaOperationType.GE:
				case FormulaOperationType.GT:
				case FormulaOperationType.LE:
				case FormulaOperationType.LT:
				case FormulaOperationType.MUL:
				case FormulaOperationType.NE:
				case FormulaOperationType.NEG:
				case FormulaOperationType.OR:
				case FormulaOperationType.SUB:
				case FormulaOperationType.XOR:
				case FormulaOperationType.EXIT:
				case FormulaOperationType.PUTP:
					FirstOperand = "";
					SecondOperand = "";
					break;

				case FormulaOperationType.CONST:
				case FormulaOperationType.TSTP:
					FirstOperand = "";
					break;

				case FormulaOperationType.PUTMEMB:
				case FormulaOperationType.GETMEMB:
					FirstOperand = "";
					var descriptorViewModel = DescriptorsViewModel.Descriptors.FirstOrDefault(x => ((x.Descriptor.DatabaseType == GKProcessor.DatabaseType.Gk && x.Descriptor.GKBase.GKDescriptorNo == FormulaOperation.SecondOperand) || (x.Descriptor.DatabaseType == GKProcessor.DatabaseType.Kau && x.Descriptor.GKBase.KAUDescriptorNo == FormulaOperation.SecondOperand)));
					if (descriptorViewModel != null)
					{
						DescriptorIcon = descriptorViewModel.ImageSource;
						SecondOperand = descriptorViewModel.Descriptor.GKBase.PresentationName;
					}
					else
					{
						SecondOperand = "<Не найдено в конфигурации>";
						Error = "Отсутствует ссылка на объект логики";
					}
					break;

				case FormulaOperationType.BR:
					break;

				case FormulaOperationType.GETWORD:
				case FormulaOperationType.PUTWORD:
					FirstOperand = FormulaOperation.FirstOperand == 1 ? "старшее слово" : "младшее слово";
					descriptorViewModel = DescriptorsViewModel.Descriptors.FirstOrDefault(x => ((x.Descriptor.DatabaseType == GKProcessor.DatabaseType.Gk && x.Descriptor.GKBase.GKDescriptorNo == FormulaOperation.SecondOperand) || (x.Descriptor.DatabaseType == GKProcessor.DatabaseType.Kau && x.Descriptor.GKBase.KAUDescriptorNo == FormulaOperation.SecondOperand)));
					if (descriptorViewModel != null)
					{
						DescriptorIcon = descriptorViewModel.ImageSource;
						SecondOperand = descriptorViewModel.Descriptor.GKBase.PresentationName;
					}
					else
					{
						SecondOperand = "<Не найдено в конфигурации>";
						Error = "Отсутствует ссылка на объект логики";
					}
					break;

				default:
					IsBold = true;

					var stateTypeToIconConverter = new XStateTypeToIconConverter();
					StateIcon = (string)stateTypeToIconConverter.Convert((GKStateBit)FormulaOperation.FirstOperand, null, null, null);

					var stateTypeToStringConverter = new EnumToDescriptionConverter();
					FirstOperand = (string)stateTypeToStringConverter.Convert((GKStateBit)FormulaOperation.FirstOperand, null, null, null);

					descriptorViewModel = DescriptorsViewModel.Descriptors.FirstOrDefault(x => ((x.Descriptor.DatabaseType == GKProcessor.DatabaseType.Gk && x.Descriptor.GKBase.GKDescriptorNo == FormulaOperation.SecondOperand) || (x.Descriptor.DatabaseType == GKProcessor.DatabaseType.Kau && x.Descriptor.GKBase.KAUDescriptorNo == FormulaOperation.SecondOperand)));
					if (descriptorViewModel != null)
					{
						DescriptorIcon = descriptorViewModel.ImageSource;
						SecondOperand = descriptorViewModel.Descriptor.GKBase.PresentationName;
					}
					else
					{
						SecondOperand = "<Не найдено в конфигурации>";
						Error = "Отсутствует ссылка на объект логики";
					}
					break;
			}

			if (FormulaOperation.FormulaOperationType == FormulaOperationType.KOD)
			{
				StateIcon = null;
				FirstOperand = "";
			}
			if (FormulaOperation.FormulaOperationType == FormulaOperationType.CMPKOD)
			{
				StateIcon = null;
				if (FormulaOperation.FirstOperand == 1)
					FirstOperand = "Если равно";
				if (FormulaOperation.FirstOperand == 2)
					FirstOperand = "Если не равно";
			}
			if (FormulaOperation.FormulaOperationType == FormulaOperationType.ACS)
			{
				FirstOperand = FormulaOperation.FirstOperand.ToString();
			}
			if (FormulaOperation.FormulaOperationType == FormulaOperationType.ACSP)
			{
				FirstOperand = FormulaOperation.FirstOperand.ToString();
			}
			if (FormulaOperation.FormulaOperationType == FormulaOperationType.BR)
			{
				StateIcon = null;
				DescriptorIcon = null;
				switch(FormulaOperation.FirstOperand)
				{
					case 0:
						FirstOperand = "Безусловный переход";
						break;

					case 1:
						FirstOperand = "Переход, если в стеке 0";
						break;

					case 2:
						FirstOperand = "Переход, если в стеке не 0";
						break;
				}
				SecondOperand = FormulaOperation.SecondOperand.ToString();
			}
		}