Ejemplo n.º 1
0
        public void AssadExecuteCommand(Assad.MHdeviceControlType controlType)
        {
            var assadDevice = Configuration.Devices.First(x => x.DeviceId == controlType.deviceId);
            string commandName = controlType.cmdId;
            if (commandName == "Обновить")
            {
                var cPqueryConfigurationType = new Assad.CPqueryConfigurationType();
                NetManager.Send(cPqueryConfigurationType, null);
            }
            else
            {
                var device = FiresecManager.Devices.FirstOrDefault(x => x.PathId == assadDevice.Id);
                if (device != null)
                {
                    if (commandName.StartsWith("Сброс "))
                    {
                        commandName = commandName.Replace("Сброс ", "");

                        if (device.Driver.DriverType == DriverType.Computer)
                        {
                            foreach (var resetDevice in FiresecManager.Devices)
                            {
                                if (resetDevice.Driver.States.Any(x => ((x.Name == commandName) && (x.IsManualReset))))
                                {
                                    var resetItem = new ResetItem();
                                    resetItem.DeviceUID = resetDevice.UID;
                                    resetItem.StateNames = new List<string>() { commandName };
                                    FiresecManager.FiresecService.ResetStates(new List<ResetItem>() { resetItem });
                                }
                            }
                        }
                        else
                        {
                            var resetItem = new ResetItem();
                            resetItem.DeviceUID = device.UID;
                            resetItem.StateNames = new List<string>() { commandName };
                            FiresecManager.FiresecService.ResetStates(new List<ResetItem>() { resetItem });
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
		public static void ResetAllStates()
		{
			try
			{
				var resetItems = new List<ResetItem>();
				foreach (var device in Devices)
				{
					foreach (var deviceDriverState in device.DeviceState.ThreadSafeStates)
					{
						if (deviceDriverState.DriverState.IsManualReset)
						{
							var resetItem = new ResetItem()
							{
								DeviceState = device.DeviceState
							};
							resetItem.States.Add(deviceDriverState);

							var existringResetItem = resetItems.FirstOrDefault(x => x.DeviceState == resetItem.DeviceState);
							if (existringResetItem != null)
							{
								foreach (var driverState in resetItem.States)
								{
									if (existringResetItem.States.Any(x => x.DriverState.Code == driverState.DriverState.Code) == false)
										existringResetItem.States.Add(driverState);
								}
							}
							else
							{
								resetItems.Add(resetItem);
							}
						}
					}
				}

				FiresecManager.ResetStates(resetItems);
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecManager.ResetAllStates");
			}
		}
Ejemplo n.º 3
0
		public void ResetAllStates(string deviceId)
		{
			var assadDevice = Configuration.Devices.First(x => x.DeviceId == deviceId);
			var device = FiresecManager.Devices.FirstOrDefault(x => x.PathId == assadDevice.Id);
			if (device != null)
			{
				foreach (var state in device.Driver.States)
				{
					if (state.IsManualReset)
					{
						var resetItem = new ResetItem();
						resetItem.DeviceState = device.DeviceState;
						var deviceDriverState = device.DeviceState.States.FirstOrDefault(x => x.DriverState.Name == state.Name);
						if (deviceDriverState != null)
						{
							resetItem.States = new List<DeviceDriverState>() { deviceDriverState };
							FiresecManager.FiresecDriver.ResetStates(new List<ResetItem>() { resetItem });
						}
					}
				}
			}
		}
Ejemplo n.º 4
0
		ResetItem GetDeviceResetItem(Device device)
		{
			if (device == null)
				return null;

			DeviceState parentDeviceState;
			if (device.ParentPanel != null)
				parentDeviceState = device.ParentPanel.DeviceState;
			else
				parentDeviceState = device.Parent.DeviceState;

			var resetItem = new ResetItem();

			switch (AlarmType)
			{
				case AlarmType.Guard:
				case AlarmType.Fire:
				case AlarmType.Attention:
				case AlarmType.Info:
				case AlarmType.Failure:
					resetItem.DeviceState = parentDeviceState;
					foreach (var state in parentDeviceState.ThreadSafeStates)
					{
						if (state.DriverState.StateType == EnumsConverter.AlarmTypeToStateType(AlarmType) && state.DriverState.IsManualReset)
							resetItem.States.Add(state);
					}
					break;

				case AlarmType.Service:
					resetItem.DeviceState = device.DeviceState;
					foreach (var state in device.DeviceState.ThreadSafeStates)
					{
						if (state.DriverState.IsManualReset)
							resetItem.States.Add(state);
					}
					break;

				case AlarmType.Auto:
				case AlarmType.Off:
					break;
			}

			if (resetItem.States.Count > 0)
				return resetItem;
			return null;
		}
Ejemplo n.º 5
0
        ResetItem GetDeviceResetItem()
        {
            var device = FiresecManager.Devices.FirstOrDefault(x => x.UID == DeviceUID);
            DeviceState parentDeviceState;
            if (device.ParentPanel != null)
                parentDeviceState = FiresecManager.DeviceStates.DeviceStates.FirstOrDefault(x => x.UID == device.ParentPanel.UID);
            else
                parentDeviceState = FiresecManager.DeviceStates.DeviceStates.FirstOrDefault(x => x.UID == device.Parent.UID);

            var resetItem = new ResetItem();

            switch (AlarmType)
            {
                case AlarmType.Fire:
                case AlarmType.Attention:
                case AlarmType.Info:
                case AlarmType.Failure:
                    resetItem.DeviceUID = parentDeviceState.UID;
                    foreach (var state in parentDeviceState.States)
                    {
                        if (state.DriverState.StateType == EnumsConverter.AlarmTypeToStateType(AlarmType) && state.DriverState.IsManualReset)
                            resetItem.StateNames.Add(state.DriverState.Name);
                    }
                    break;

                case AlarmType.Service:
                    resetItem.DeviceUID = device.UID;
                    var deviceState = FiresecManager.DeviceStates.DeviceStates.FirstOrDefault(x => x.UID == device.UID);
                    foreach (var state in deviceState.States)
                    {
                        if (state.DriverState.IsManualReset)
                            resetItem.StateNames.Add(state.DriverState.Name);
                    }
                    break;

                case AlarmType.Auto:
                case AlarmType.Off:
                    break;
            }

            if (resetItem.StateNames.Count > 0)
                return resetItem;
            return null;
        }