コード例 #1
0
ファイル: DeviceViewModel.cs プロジェクト: saeednazari/Rubezh
 void OnDeviceStateChanged(DeviceState deviceState)
 {
     if (DeviceState == deviceState)
     {
         StateType = DeviceState.StateType;
     }
 }
コード例 #2
0
		public DeviceDetailsViewModel(Device device)
		{
			ExecuteCommand = new RelayCommand(OnExecute);
			DeviceCommands = new List<DeviceCommandViewModel>();
			Device = device;
			DeviceState = Device.DeviceState;
			DeviceState.StateChanged += new Action(OnStateChanged);
			DeviceState.ParametersChanged += new Action(OnParametersChanged);
			OnStateChanged();

			Title = Device.DottedPresentationAddressAndName;
			TopMost = true;

			var tableNo = MetadataHelper.GetDeviceTableNo(device);
			var metadataDeviceCommands = MetadataHelper.Metadata.devicePropInfos.Where(x => x.tableType == tableNo);
			foreach (var metadataDeviceCommand in metadataDeviceCommands)
			{
				var deviceCommandViewModel = new DeviceCommandViewModel()
				{
					Name = metadataDeviceCommand.name,
					Caption = metadataDeviceCommand.caption,
				};
				DeviceCommands.Add(deviceCommandViewModel);
			}
			SelectedDeviceCommand = DeviceCommands.FirstOrDefault();
		}
コード例 #3
0
ファイル: DeviceViewModel.cs プロジェクト: hjlfmy/Rubezh
 public DeviceViewModel(DeviceState deviceState)
 {
     DeviceState = deviceState;
     _stateType = deviceState.StateType;
     FiresecCallbackService.DeviceStateChangedEvent += new Action<Guid>(OnDeviceStateChangedEvent);
     Name = DeviceState.Device.Driver.ShortName + " - " + DeviceState.Device.DottedAddress;
 }
コード例 #4
0
		public static bool CanDisable(DeviceState deviceState)
		{
			try
			{
				if ((deviceState != null) && (deviceState.Device.Driver.CanDisable))
				{
					if (deviceState.IsDisabled)
						return CheckPermission(PermissionType.Oper_RemoveFromIgnoreList);
					return CheckPermission(PermissionType.Oper_AddToIgnoreList);
				}
				return false;
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecManager.CanDisable");
				return false;
			}
		}
コード例 #5
0
		public static void ChangeDisabled(DeviceState deviceState)
		{
			try
			{
				if ((deviceState != null) && (CanDisable(deviceState)))
				{
					if (deviceState.IsDisabled)
					{
						RemoveFromIgnoreList(new List<Device>() { deviceState.Device });
					}
					else
					{
						AddToIgnoreList(new List<Device>() { deviceState.Device });
					}
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecManager.ChangeDisabled");
			}
		}
コード例 #6
0
ファイル: DeviceViewModel.cs プロジェクト: saeednazari/Rubezh
        public DeviceViewModel(DeviceState deviceState)
        {
            DeviceState = deviceState;
			Name = DeviceState.Device.DottedPresentationAddressAndName;
            Level = DeviceState.Device.AllParents.Count;
            ImageSource = DeviceState.Device.Driver.ImageSource;

            DriverStates = new List<DeviceStateViewModel>();
            foreach (var driverState in from x in DeviceState.Device.Driver.States orderby x.StateType select x)
            {
                if (!string.IsNullOrEmpty(driverState.Name))
                {
                    var deviceStateViewModel = new DeviceStateViewModel(driverState);
                    DriverStates.Add(deviceStateViewModel);
                }
            }

            foreach (var deviceDriverState in deviceState.ThreadSafeStates)
            {
                var state = DriverStates.FirstOrDefault(x => x.DriverState.Code == deviceDriverState.DriverState.Code);
                state._isActive = true;
            }
        }
コード例 #7
0
		public void CreateStates()
		{
			foreach (var device in DeviceConfiguration.Devices)
			{
				var deviceState = new DeviceState()
				{
					Device = device
				};
				foreach (var parameter in device.Driver.Parameters)
					deviceState.Parameters.Add(parameter.Copy());
				device.DeviceState = deviceState;
			}

			foreach (var zone in DeviceConfiguration.Zones)
			{
				var zoneState = new ZoneState()
				{
					Zone = zone,
				};
				zone.ZoneState = zoneState;
			}
		}
コード例 #8
0
ファイル: FiresecManager.cs プロジェクト: hjlfmy/Rubezh
        public void ConvertStates()
        {
            ConfigurationCash.DeviceConfigurationStates = new DeviceConfigurationStates();
            if (ConfigurationCash.DeviceConfiguration.Devices.IsNotNullOrEmpty())
            {
                foreach (var device in ConfigurationCash.DeviceConfiguration.Devices)
                {
                    var deviceState = new DeviceState()
                    {
                        UID = device.UID,
                        PlaceInTree = device.PlaceInTree,
                        Device = device
                    };

                    foreach (var parameter in device.Driver.Parameters)
                        deviceState.Parameters.Add(parameter.Copy());

                    ConfigurationCash.DeviceConfigurationStates.DeviceStates.Add(deviceState);
                }
            }

            foreach (var zone in ConfigurationCash.DeviceConfiguration.Zones)
            {
                ConfigurationCash.DeviceConfigurationStates.ZoneStates.Add(new ZoneState() { No = zone.No });
            }
            if (Watcher != null)
            {
                Watcher.Ignore = true;
                Watcher.DoNotCallback = true;
                try
                {
                    Watcher.OnStateChanged();
                    Watcher.OnParametersChanged();
                }
                catch { }
                Watcher.DoNotCallback = false;
                Watcher.Ignore = false;
            }
        }
コード例 #9
0
		private static Brush GetDynamicBrush(Dictionary<StateType, Dictionary<string, Brush>> map, DeviceState deviceState)
		{
			var brushes = map.ContainsKey(deviceState.StateType) ? map[deviceState.StateType] : null;
			var brush = brushes != null && brushes.ContainsKey(string.Empty) ? brushes[string.Empty] : null;
			if (brushes != null)
				foreach (var state in deviceState.ThreadSafeStates)
					if (state.DriverState.StateType == deviceState.StateType && brushes.ContainsKey(state.DriverState.Code))
					{
						brush = brushes[state.DriverState.Code];
						break;
					}
			if (brush == null && brushes != null)
				brush = brushes.ContainsKey(string.Empty) ? brushes[string.Empty] : null;
			if (brush == null && map.ContainsKey(StateType.No))
			{
				brushes = map[StateType.No];
				foreach (var state in deviceState.ThreadSafeStates)
					if (state.DriverState.StateType == deviceState.StateType && brushes.ContainsKey(state.DriverState.Code))
					{
						brush = brushes[state.DriverState.Code];
						break;
					}
				if (brush == null && brushes != null)
					brush = brushes.ContainsKey(string.Empty) ? brushes[string.Empty] : null;
			}
			return brush;
		}
コード例 #10
0
		private static Brush GetDynamicBrush(Guid guid, string presenterKey, DeviceState deviceState)
		{
			Brush brush = null;
			try
			{
				if (_dynamicBrushes.ContainsKey(guid))
				{
					if (!string.IsNullOrEmpty(presenterKey) && _dynamicBrushes[guid].ContainsKey(presenterKey))
						brush = GetDynamicBrush(_dynamicBrushes[guid][presenterKey], deviceState);
					if (brush == null)
						brush = GetDynamicBrush(_dynamicBrushes[guid][string.Empty], deviceState);
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "DevicePictureCache.GetDynamicBrush(Guid guid, DeviceState deviceState)");
			}
			return brush ?? EmptyBrush;
		}