Пример #1
0
		public static DeviceViewModel AddDevice(GKDevice device, DeviceViewModel parentDeviceViewModel, bool isAddDevice = true, bool isStartList = false)
		{
			var deviceViewModel = new DeviceViewModel(device);
			if (isAddDevice)
			{
				if (isStartList)
					parentDeviceViewModel.AddChildFirst(deviceViewModel);
				else
					parentDeviceViewModel.AddChild(deviceViewModel);
				foreach (var childDevice in device.Children)
				{
					AddDevice(childDevice, deviceViewModel);
				}
			}
			else
			{
				parentDeviceViewModel.InsertChild(deviceViewModel);

				foreach (var childDevice in device.Children)
				{
					AddDevice(childDevice, deviceViewModel, !isAddDevice);
				}
			}
			return deviceViewModel;
		}
Пример #2
0
		public NewDeviceViewModel(DeviceViewModel deviceViewModel)
		{
			Title = "Добавление устройства";

			if (deviceViewModel.Device.Parent != null && deviceViewModel.Device.Parent.DriverType == GKDriverType.GKMirror)
				deviceViewModel = deviceViewModel.Parent;

			ParentDeviceViewModel = deviceViewModel;
			ParentDevice = ParentDeviceViewModel.Device;
			AddedDevices = new List<DeviceViewModel>();
			
			if (ParentDevice.IsConnectedToKAU)
				{
					RealParentDevice = ParentDevice.MVPPartParent ?? ParentDevice.KDPartParent ?? ParentDevice.MRKParent ?? ParentDevice.KAUShleifParent;
					var Drivers = (SortDrivers().Where(x => RealParentDevice.Driver.Children.Contains(x.DriverType)));
					TypedDrivers = new ObservableCollection<NewTypedDeviceViewModel>(Drivers.Select(x => new NewTypedDeviceViewModel(x)));
					SelectedDriver = TypedDrivers.FirstOrDefault();
					MinAddress = 1;
					MaxAddress = 255;
					BuildTree(TypedDrivers);
				}
				else
				{
					var Drivers = (SortDrivers().Where(x => ParentDevice.Driver.Children.Contains(x.DriverType)));
					TypedDrivers = new ObservableCollection<NewTypedDeviceViewModel>(Drivers.Select(x => new NewTypedDeviceViewModel(x)));
					SelectedDriver = TypedDrivers.FirstOrDefault();
					MinAddress = SelectedDriver.Driver.MinAddress;
					MaxAddress = SelectedDriver.Driver.MaxAddress;
				}
			Count = 1;
		}
        public DirectionDeviceSelectationViewModel()
        {
            Title = "Выбор устройства";

            var devices = new HashSet<XDevice>();
            foreach (var device in XManager.DeviceConfiguration.Devices)
            {
                if (device.Driver.IsControlDevice)
                {
                    device.AllParents.ForEach(x => { devices.Add(x); });
                    devices.Add(device);
                }
            }

            Devices = new ObservableCollection<DeviceViewModel>();
            foreach (var device in devices)
            {
                var deviceViewModel = new DeviceViewModel(device, Devices);
                deviceViewModel.IsExpanded = device.Driver.IsControlDevice;
                Devices.Add(deviceViewModel);
            }

            foreach (var device in Devices.Where(x => x.Device.Parent != null))
            {
                var parent = Devices.FirstOrDefault(x => x.Device.UID == device.Device.Parent.UID);
                device.Parent = parent;
                parent.Children.Add(device);
            }

            SelectedDevice = Devices.FirstOrDefault(x => x.HasChildren == false);
        }
Пример #4
0
		public NewDeviceViewModel(DeviceViewModel deviceViewModel)
			: base(deviceViewModel)
		{
			var sortedDrivers = SortDrivers();
			foreach (var driver in sortedDrivers)
			{
				if (driver.DriverType == XDriverType.AMP_1)
					continue;
				if (ParentDevice.Driver.Children.Contains(driver.DriverType))
					Drivers.Add(driver);
			}

			var driverType = deviceViewModel.Driver.DriverType;
			if (driverType == XDriverType.MPT || driverType == XDriverType.MRO_2)
			{
				Drivers = new ObservableCollection<XDriver>(
					from XDriver driver in sortedDrivers
					where driver.DriverType == driverType
					select driver);
			}

			var parentShleif = ParentDevice;
			if (ParentDevice.DriverType == XDriverType.MPT || ParentDevice.DriverType == XDriverType.MRO_2)
				parentShleif = ParentDevice.Parent;

			SelectedDriver = Drivers.FirstOrDefault();
		}
Пример #5
0
		public NewDeviceViewModelBase(DeviceViewModel deviceViewModel)
		{
			Title = "Новое устройство";
			ParentDeviceViewModel = deviceViewModel;
			ParentDevice = ParentDeviceViewModel.Device;
			Drivers = new ObservableCollection<XDriver>();
			AvailableShleifs = new ObservableCollection<byte>();
			Count = 1;
		}
Пример #6
0
		DeviceViewModel AddDeviceInternal(GKDevice device, DeviceViewModel parentDeviceViewModel)
		{
			var deviceViewModel = new DeviceViewModel(device);
			if (parentDeviceViewModel != null)
				parentDeviceViewModel.AddChild(deviceViewModel);

			foreach (var childDevice in device.Children)
				AddDeviceInternal(childDevice, deviceViewModel);
			return deviceViewModel;
		}
		private DeviceViewModel AddDeviceInternal(XDevice device, DeviceViewModel parentDeviceViewModel)
		{
			var deviceViewModel = new DeviceViewModel(device);
			if (parentDeviceViewModel != null)
				parentDeviceViewModel.AddChild(deviceViewModel);

			foreach (var childDevice in device.Children)
				AddDeviceInternal(childDevice, deviceViewModel);
			if (device.UID == _elementXDevice.XDeviceUID)
				SelectedDevice = deviceViewModel;
			return deviceViewModel;
		}
		public DeviceParameterViewModel(XDevice device)
		{
			Device = device;
			DeviceViewModel = new DeviceViewModel(device);

			Smokiness = " - ";
			Temperature = " - ";
			Dustinness = " - ";
			LastServiceTime = " - ";
			Resistance = " - ";
			AUParameterValues = new ObservableCollection<MeasureParameterViewModel>();
		}
Пример #9
0
        public NewDeviceViewModel(DeviceViewModel parent)
        {
            Title = "Новое устройство";
            _parentDeviceViewModel = parent;
            _parent = _parentDeviceViewModel.Device;

            Drivers = new List<XDriver>(
                from XDriver driver in XManager.DriversConfiguration.Drivers
                       where _parent.Driver.Children.Contains(driver.DriverType)
                       select driver);

            SelectedDriver = Drivers.FirstOrDefault();
        }
Пример #10
0
		public RSR2NewDeviceViewModel(DeviceViewModel deviceViewModel)
			: base(deviceViewModel)
		{
			RealParentDevice = ParentDevice.KAURSR2ShleifParent;

			var sortedDrivers = SortDrivers();
			foreach (var driver in sortedDrivers)
			{
				if (RealParentDevice.Driver.Children.Contains(driver.DriverType))
					Drivers.Add(driver);
			}

			SelectedDriver = Drivers.FirstOrDefault();
		}
Пример #11
0
		public DevicesListViewModel()
		{
			Title = "Список устройств";
			Devices = new ObservableCollection<DeviceViewModel>();
			foreach (var device in GKManager.Devices)
			{
				if (device.IsRealDevice)
				{
					var deviceViewModel = new DeviceViewModel(device);
					deviceViewModel.CanUpdateDescriptorName = true;
					deviceViewModel.UpdateDescriptorName();
					Devices.Add(deviceViewModel);
				}
			}
			SelectedDevice = Devices.FirstOrDefault();
		}
Пример #12
0
		public void Update()
		{
			PumpDevices = new ObservableCollection<DeviceViewModel>();
			PumpStation.NSDevices = new List<XDevice>();
			foreach (var deviceUID in PumpStation.NSDeviceUIDs)
			{
				var device = XManager.Devices.FirstOrDefault(x => x.UID == deviceUID);
				if (device != null)
				{
					PumpStation.NSDevices.Add(device);
					var deviceViewModel = new DeviceViewModel(device);
					PumpDevices.Add(deviceViewModel);
				}
			}
			OnPropertyChanged("PumpStation");
		}
Пример #13
0
		public DeviceParameterViewModel(GKDevice device)
		{
			Device = device;
			DeviceViewModel = new DeviceViewModel(device);

			AUParameterValues = new ObservableCollection<MeasureParameterViewModel>();
			foreach (var measureParameter in device.Driver.MeasureParameters.Where(x => !x.IsNotVisible))
			{
				var measureParameterViewModel = new MeasureParameterViewModel();
				measureParameterViewModel.Device = device;
				measureParameterViewModel.Name = measureParameter.Name;
				measureParameterViewModel.DriverParameter = measureParameter;
				AUParameterValues.Add(measureParameterViewModel);
			}

			device.State.MeasureParametersChanged += new Action(OnMeasureParametersChanged);
		}
Пример #14
0
		public void Update()
		{
			PumpDevices = new ObservableCollection<DeviceViewModel>();
			PumpStation.NSDevices = new List<GKDevice>();
			foreach (var deviceUID in PumpStation.NSDeviceUIDs)
			{
				var device = GKManager.Devices.FirstOrDefault(x => x.UID == deviceUID);
				if (device != null)
				{
					device.Logic = new GKLogic();
					PumpStation.NSDevices.Add(device);
					var deviceViewModel = new DeviceViewModel(device);
					PumpDevices.Add(deviceViewModel);
					device.OnChanged();
				}
			}
			OnPropertyChanged(() => PumpStation);
			OnPropertyChanged(() => StartPresentationName);
			OnPropertyChanged(() => StopPresentationName);
			OnPropertyChanged(() => AutomaticOffPresentationName);
			UpdateVisualizationState();
		}
Пример #15
0
		public static DeviceViewModel AddDevice(XDevice device, DeviceViewModel parentDeviceViewModel)
		{
			var deviceViewModel = new DeviceViewModel(device);
			parentDeviceViewModel.AddChild(deviceViewModel);

			foreach (var childDevice in device.Children)
			{
				AddDevice(childDevice, deviceViewModel);
			}

			if (device.Driver.IsGroupDevice)
			{
				var driver = XManager.Drivers.FirstOrDefault(x => x.DriverType == device.Driver.GroupDeviceChildType);

				for (byte i = 0; i < device.Driver.GroupDeviceChildrenCount; i++)
				{
					var autoDevice = XManager.AddChild(device, driver, (byte)(device.IntAddress + i));
					AddDevice(autoDevice, deviceViewModel);
				}
			}
			return deviceViewModel;
		}
Пример #16
0
		DeviceViewModel AddDeviceInternal(GKDevice device, DeviceViewModel parentDeviceViewModel)
		{
			if (device.DriverType == GKDriverType.RSR2_MVP)
				foreach (var autoCreateDriverType in device.Driver.AutoCreateChildren)
				{
					var autoCreateDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == autoCreateDriverType);
					for (byte i = autoCreateDriver.MinAddress; i <= autoCreateDriver.MaxAddress; i++)
					{
						GKManager.AddDevice(device, autoCreateDriver, i);
					}
				}
			var deviceViewModel = new DeviceViewModel(device);
			if (parentDeviceViewModel != null)
				parentDeviceViewModel.AddChild(deviceViewModel);

			foreach (var childDevice in device.Children)
				AddDeviceInternal(childDevice, deviceViewModel);

			if (deviceViewModel.Device.DriverType == GKDriverType.RSR2_KAU_Shleif)
				deviceViewModel.ExpandToThis();

			return deviceViewModel;
		}
Пример #17
0
		public void InitializeDependences()
		{
			Zones.Clear();
			foreach (var directionZone in Direction.DirectionZones)
			{
				var directionZoneViewModel = new DirectionZoneViewModel(directionZone);
				Zones.Add(directionZoneViewModel);
			}

			Devices.Clear();
			foreach (var directionDevice in Direction.DirectionDevices)
			{
				var directionDeviceViewModel = new DirectionDeviceViewModel(directionDevice);
				Devices.Add(directionDeviceViewModel);
			}

			OutputDevices.Clear();
			foreach (var outputDevice in Direction.OutputDevices)
			{
				var deviceViewModel = new DeviceViewModel(outputDevice);
				OutputDevices.Add(deviceViewModel);
			}
		}
Пример #18
0
		public void DeletePumpDevice()
		{
			if (SelectedPumpDevice != null)
			{
				var device = SelectedPumpDevice.Device;
				PumpStation.NSDeviceUIDs.Remove(SelectedPumpDevice.Device.UID);
				SelectedPumpDevice.Device.OutputDependentElements.Remove(PumpStation);
				PumpStation.InputDependentElements.Remove(SelectedPumpDevice.Device);
				Update();
				device.NSLogic = new GKLogic();
				device.OnChanged();
				ServiceFactory.SaveService.GKChanged = true;
			}
			SelectedPumpDevice = null;
		}
Пример #19
0
		public void DeletePumpDevice()
		{
			if (SelectedPumpDevice != null)
			{
				PumpStation.NSDeviceUIDs.Remove(SelectedPumpDevice.Device.UID);
				Update();
				ServiceFactory.SaveService.GKChanged = true;
			}
			SelectedPumpDevice = null;
		}
Пример #20
0
        public void Initialize(XZone zone)
        {
            Zone = zone;

            var devices = new HashSet<XDevice>();
            var availableDevices = new HashSet<XDevice>();

            foreach (var device in XManager.DeviceConfiguration.Devices)
            {
                if (!device.Driver.HasZone)
                    continue;

                if (Zone.DeviceUIDs.Contains(device.UID))
                {
                    device.AllParents.ForEach(x => { devices.Add(x); });
                    devices.Add(device);
                }
                else
                {
                    if (device.Zones.Count == 0)
                    {
                        device.AllParents.ForEach(x => { availableDevices.Add(x); });
                        availableDevices.Add(device);
                    }
                }
            }

            Devices.Clear();
            foreach (var device in devices)
            {
                var deviceViewModel = new DeviceViewModel(device, Devices)
                {
                    IsExpanded = true,
                    IsBold = Zone.DeviceUIDs.Contains(device.UID)
                    //IsBold = device.Zones.Contains(Zone.No)
                };
                Devices.Add(deviceViewModel);
            }

            foreach (var device in Devices.Where(x => x.Device.Parent != null))
            {
                var parent = Devices.FirstOrDefault(x => x.Device.UID == device.Device.Parent.UID);
                device.Parent = parent;
                parent.Children.Add(device);
            }

            AvailableDevices.Clear();
            foreach (var device in availableDevices)
            {
                if ((device.Driver.DriverType == XDriverType.GKIndicator) ||
                    (device.Driver.DriverType == XDriverType.GKLine) ||
                    (device.Driver.DriverType == XDriverType.GKRele) ||
                    (device.Driver.DriverType == XDriverType.KAUIndicator))
                    continue;

                var deviceViewModel = new DeviceViewModel(device, AvailableDevices)
                {
                    IsExpanded = true,
                    IsBold = device.Driver.HasZone
                };

                AvailableDevices.Add(deviceViewModel);
            }

            foreach (var device in AvailableDevices.Where(x => x.Device.Parent != null))
            {
                var parent = AvailableDevices.FirstOrDefault(x => x.Device.UID == device.Device.Parent.UID);
                device.Parent = parent;
                parent.Children.Add(device);
            }

            OnPropertyChanged("Devices");

            SelectedDevice = Devices.LastOrDefault();
            SelectedAvailableDevice = AvailableDevices.LastOrDefault(); ;
        }
Пример #21
0
 public void Clear()
 {
     Devices.Clear();
     AvailableDevices.Clear();
     SelectedDevice = null;
     SelectedAvailableDevice = null;
 }