public GuardZone(GKGuardZone guardZone) : base(guardZone) { No = guardZone.No; GKDescriptorNo = guardZone.GKDescriptorNo; Name = guardZone.Name; AlarmDelay = guardZone.AlarmDelay; ResetDelay = guardZone.ResetDelay; SetDelay = guardZone.SetDelay; State = GuardZoneStateClassToStringConverter.Converter(guardZone.State.StateClass); // guardZone.State.StateClass.ToDescription(); StateIcon = guardZone.State.StateClass.ToString(); StateClasses = guardZone.State.StateClasses.Select(x => new StateClass{ Name = GuardZoneStateClassToStringConverter.Converter(x), IconData = x.ToString() }).ToList(); StateColor = "'#" + new XStateClassToColorConverter2().Convert(guardZone.State.StateClass, null, null, null).ToString().Substring(3) + "'"; HasOnDelay = guardZone.State.StateClasses.Contains(XStateClass.TurningOn) && guardZone.State.OnDelay > 0; OnDelay = HasOnDelay? guardZone.State.OnDelay.ToString(): String.Empty; HasOffDelay = guardZone.State.StateClasses.Contains(XStateClass.TurningOff) && guardZone.State.OnDelay > 0; OffDelay = HasOffDelay? guardZone.State.OffDelay.ToString(): String.Empty; HasHoldDelay = guardZone.State.StateClasses.Contains(XStateClass.Attention) && guardZone.State.OffDelay > 0; HoldDelay = HasHoldDelay ? guardZone.State.OffDelay.ToString() : String.Empty; var controlRegime = guardZone.State.StateClasses.Contains(XStateClass.Ignore) ? DeviceControlRegime.Ignore : !guardZone.State.StateClasses.Contains(XStateClass.AutoOff) ? DeviceControlRegime.Automatic : DeviceControlRegime.Manual; //ControlRegimeIcon = "data:image/gif;base64," + InternalConverter.GetImageResource(((string)new DeviceControlRegimeToIconConverter().Convert(controlRegime)) ?? string.Empty).Item1; ControlRegimeName = controlRegime.ToDescription(); ControlRegimeIcon = (new DeviceControlRegimeToIconConverter()).Convert(controlRegime); CanSetAutomaticState = (controlRegime != DeviceControlRegime.Automatic); CanSetManualState = (controlRegime != DeviceControlRegime.Manual); CanSetIgnoreState = (controlRegime != DeviceControlRegime.Ignore); IsControlRegime = (controlRegime == DeviceControlRegime.Manual); }
/// <summary> /// Валидация того, что охранная зона содержит подключенные устройства /// </summary> /// <param name="guardZone"></param> void ValidateGuardZoneHasNoDevices(GKGuardZone guardZone) { if (guardZone.GuardZoneDevices.Count == 0) { AddError(guardZone, "К зоне не подключено ни одного устройства", ValidationErrorLevel.CannotWrite); } }
public GuardZoneDescriptor(GKGuardZone zone) : base(zone) { DescriptorType = DescriptorType.GuardZone; GuardZone = zone; SetGuardDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.SetGuard, false).Select(x => x.Device); ResetGuardDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ResetGuard, false).Select(x => x.Device); SetAlarmDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.SetAlarm, false).Select(x => x.Device); SetGuardPimDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.SetGuard, true); ResetGuardPimDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ResetGuard, true); ChangeGuardPimDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ChangeGuard, true).ToList(); ChangeGuardPimDevices.AddRange(DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ChangeGuard, false).ToList()); SetAlarmPimDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.SetAlarm, true); if (GuardZone.GuardZoneDevices.FindAll(x => x.ActionType == GKGuardZoneDeviceActionType.ChangeGuard || x.Device.Driver.IsCardReaderOrCodeReader).Count > 0) { UsePim = true; GuardZonePimDescriptor = new GuardZonePimDescriptor(GuardZone); GuardZoneChangePimDescriptor = new GuardZoneChangePimDescriptor(GuardZone); GuardZone.LinkToDescriptor(GuardZone.ChangePim); GuardZone.LinkToDescriptor(GuardZone.Pim); } else GuardZone.LinkToDescriptor(GuardZone); }
public void InitializeAvailableDevices(GKGuardZone zone) { AvailableDevices = new ObservableCollection<GuardZoneDeviceViewModel>(); foreach (var device in GKManager.Devices) { if (device.Driver.HasGuardZone && !zone.GuardZoneDevices.Any(x => x.DeviceUID == device.UID)) { if (device.GuardZones.Count > 0 || (device.IsInMPT && !GlobalSettingsHelper.GlobalSettings.ShowMPTsDevices) || (device.ZoneUIDs.Count > 0 && !GlobalSettingsHelper.GlobalSettings.ShowZonesDevices) || (device.Door != null && !GlobalSettingsHelper.GlobalSettings.ShowDoorsDevices)) continue; var guardZoneDevice = new GKGuardZoneDevice { DeviceUID = device.UID, Device = device }; var deviceViewModel = new GuardZoneDeviceViewModel(guardZoneDevice); AvailableDevices.Add(deviceViewModel); } } OnPropertyChanged(() => AvailableDevices); SelectedAvailableDevice = AvailableDevices.FirstOrDefault(); }
public static GKDevice CopyDevice(GKDevice deviceFrom, GKDevice deviceTo) { deviceTo.DriverUID = deviceFrom.DriverUID; deviceTo.Driver = deviceFrom.Driver; deviceTo.IntAddress = deviceFrom.IntAddress; deviceTo.Description = deviceFrom.Description; deviceTo.ProjectAddress = deviceFrom.ProjectAddress; deviceTo.PredefinedName = deviceFrom.PredefinedName; deviceTo.InputDependentElements = deviceFrom.InputDependentElements; deviceTo.OutputDependentElements = deviceFrom.OutputDependentElements; deviceTo.Properties = new List<GKProperty>(); foreach (var property in deviceFrom.Properties) { deviceTo.Properties.Add(new GKProperty() { Name = property.Name, Value = property.Value, DriverProperty = property.DriverProperty, StringValue = property.StringValue, }); } deviceTo.ZoneUIDs = deviceFrom.ZoneUIDs.ToList(); deviceTo.Logic.OnClausesGroup = deviceFrom.Logic.OnClausesGroup.Clone(); deviceTo.Logic.OffClausesGroup = deviceFrom.Logic.OffClausesGroup.Clone(); deviceTo.Logic.StopClausesGroup = deviceFrom.Logic.StopClausesGroup.Clone(); deviceTo.Logic.OnNowClausesGroup = deviceFrom.Logic.OnNowClausesGroup.Clone(); deviceTo.Logic.OffNowClausesGroup = deviceFrom.Logic.OffNowClausesGroup.Clone(); deviceTo.Children = new List<GKDevice>(); foreach (var childDevice in deviceFrom.Children) { var newChildDevice = CopyDevice(childDevice, false, true); newChildDevice.Parent = deviceTo; deviceTo.Children.Add(newChildDevice); } var newGuardZone = new List<GKGuardZone>(); foreach (var zone in deviceFrom.GuardZones) { var guardZoneDevice = zone.GuardZoneDevices.FirstOrDefault(x => x.DeviceUID == deviceFrom.UID); if (guardZoneDevice != null) { var newZone = new GKGuardZone { UID = zone.UID }; var GuardZoneDevice = new GKGuardZoneDevice() { DeviceUID = deviceTo.UID, Device = deviceTo, ActionType = guardZoneDevice.ActionType, CodeReaderSettings = guardZoneDevice.CodeReaderSettings, }; newZone.GuardZoneDevices.Add(GuardZoneDevice); newGuardZone.Add(newZone); } } deviceTo.GuardZones = new List<GKGuardZone>(newGuardZone); return deviceTo; }
public GuardZonePropertiesViewModel(GKGuardZone guardZone) { Title = "Параметры охранной зоны"; GuardZone = guardZone; SetDelay = GuardZone.SetDelay; ResetDelay = GuardZone.ResetDelay; AlarmDelay = GuardZone.AlarmDelay; }
public GuardZoneChangePimDescriptor(GKGuardZone guardZone) : base(guardZone.ChangePim) { GuardZone = guardZone; SetGuardDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.SetGuard, true); ResetGuardDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ResetGuard, true); ChangeGuardDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ChangeGuard, true).ToList(); ChangeGuardDevices.AddRange(DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.ChangeGuard, false).ToList()); SetAlarmDevices = DescriptorHelper.GetGuardZoneDevices(GuardZone, GKGuardZoneDeviceActionType.SetAlarm, true); }
public GuardZoneSelectionViewModel(GKGuardZone guardZone) { Title = "Выбор охранной зоны"; Zones = new ObservableCollection<ZoneViewModel>(); GKManager.GuardZones.ForEach(x => Zones.Add(new ZoneViewModel(x))); if (guardZone != null) SelectedZone = Zones.FirstOrDefault(x => x.GuardZone.UID == guardZone.UID); if (SelectedZone == null) SelectedZone = Zones.FirstOrDefault(); }
public void TestGuardZone_WithAlarmDevice() { var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1); var guardZone = new GKGuardZone(); guardZone.GuardZoneDevices.Add(new GKGuardZoneDevice() { ActionType = GKGuardZoneDeviceActionType.SetAlarm, DeviceUID = device1.UID }); GKManager.GuardZones.Add(guardZone); Compile(); CheckObjectLogicOnKau(guardZone); }
public void RemoveDeviceTestGuardZone() { var device = AddDevice(kauDevice11, GKDriverType.RSR2_GuardDetector); var guardZone = new GKGuardZone(); var guardZoneDevice = new GKGuardZoneDevice {Device = device,DeviceUID = device.UID }; GKManager.AddGuardZone(guardZone); #region forzone // проверка добавления устройства в зону GKManager.AddDeviceToGuardZone(guardZone, guardZoneDevice); Assert.IsTrue(device.GuardZones.Contains(guardZone)); Assert.IsTrue(guardZone.GuardZoneDevices.Any(x => x.DeviceUID == device.UID)); Assert.IsTrue(device.InputDependentElements.Contains(guardZone)); Assert.IsTrue(guardZone.OutputDependentElements.Contains(device)); GKManager.RemoveDeviceFromGuardZone(device, guardZone); Assert.IsFalse(guardZone.GuardZoneDevices.Any(x => x.Device.UID == device.UID)); Assert.IsFalse(device.GuardZones.Contains(guardZone)); Assert.IsFalse(device.InputDependentElements.Contains(guardZone)); Assert.IsFalse(guardZone.OutputDependentElements.Contains(device)); #endregion #region fordevice // проверка добавления зоны в устройства GKManager.ChangeDeviceGuardZones(device, new List<GKDeviceGuardZone>() {new GKDeviceGuardZone{GuardZone = guardZone, GuardZoneUID = guardZone.UID}}); Assert.IsTrue(device.GuardZones.Contains(guardZone)); Assert.IsTrue(guardZone.GuardZoneDevices.Any(x => x.DeviceUID == device.UID)); Assert.IsTrue(device.InputDependentElements.Contains(guardZone)); Assert.IsTrue(guardZone.OutputDependentElements.Contains(device)); var guardZone_2 = new GKGuardZone(); GKManager.AddGuardZone(guardZone_2); GKManager.ChangeDeviceGuardZones(device, new List<GKDeviceGuardZone>() { new GKDeviceGuardZone { GuardZone = guardZone_2, GuardZoneUID = guardZone_2.UID }}); Assert.IsTrue(device.GuardZones.Contains(guardZone_2)); Assert.IsTrue(guardZone_2.GuardZoneDevices.Any(x => x.DeviceUID == device.UID)); Assert.IsTrue(device.InputDependentElements.Contains(guardZone_2)); Assert.IsTrue(guardZone_2.OutputDependentElements.Contains(device)); Assert.IsFalse(device.GuardZones.Contains(guardZone)); Assert.IsFalse(guardZone.GuardZoneDevices.Any(x => x.DeviceUID == device.UID)); Assert.IsFalse(device.InputDependentElements.Contains(guardZone)); Assert.IsFalse(guardZone.OutputDependentElements.Contains(device)); #endregion //удалениy зоны GKManager.AddDeviceToGuardZone(guardZone, guardZoneDevice); GKManager.RemoveGuardZone(guardZone); Assert.IsFalse(device.GuardZones.Any(x => x.UID == guardZone.UID)); Assert.IsFalse(device.InputDependentElements.Any(x => x.UID == guardZone.UID)); // удаление устройства GKManager.ChangeDeviceGuardZones(device, new List<GKDeviceGuardZone>() { new GKDeviceGuardZone { GuardZone = guardZone_2, GuardZoneUID = guardZone_2.UID } }); GKManager.RemoveDevice(device); Assert.IsFalse(guardZone_2.GuardZoneDevices.Any(x => x.DeviceUID == device.UID)); Assert.IsFalse(guardZone_2.OutputDependentElements.Any(x => x.UID == device.UID)); }
public static void AddDeviceToGuardZone(GKGuardZone guardZone, GKGuardZoneDevice guardZoneDevice) { var device = guardZoneDevice.Device; guardZone.GuardZoneDevices.Add(guardZoneDevice); if (!device.GuardZones.Contains(guardZone)) device.GuardZones.Add(guardZone); if (!device.InputDependentElements.Contains(guardZone)) device.InputDependentElements.Add(guardZone); if (!guardZone.OutputDependentElements.Contains(device)) guardZone.OutputDependentElements.Add(device); guardZone.OnChanged(); device.OnChanged(); }
public void TestGuardZone_WithChangeDevice() { var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1); var guardZone = new GKGuardZone(); guardZone.GuardZoneDevices.Add(new GKGuardZoneDevice() { ActionType = GKGuardZoneDeviceActionType.ChangeGuard, DeviceUID = device1.UID }); GKManager.GuardZones.Add(guardZone); Compile(); CheckObjectLogicOnKau(guardZone); var pimGKDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase is GKPim); var pimKauDescriptor = Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase is GKPim); Assert.IsTrue(pimGKDescriptor.Formula.FormulaOperations.Count == 1, "На ГК должна отсутствовать логика ПИМ"); Assert.IsTrue(pimKauDescriptor.Formula.FormulaOperations.Count > 1, "На КАУ должна присутствовать логика ПИМ"); }
void ValidationGuardSettings(GKCodeReaderSettingsPart codeReaderSettingsPart, HashSet<Tuple<Guid, GKCodeReaderEnterType>> hashSet, GKGuardZone guardZone, string name) { if (codeReaderSettingsPart.CodeReaderEnterType != GKCodeReaderEnterType.None) { foreach (var codeUID in codeReaderSettingsPart.CodeUIDs) { if (!hashSet.Add(new Tuple<Guid, GKCodeReaderEnterType>(codeUID, codeReaderSettingsPart.CodeReaderEnterType))) { var code = GKManager.DeviceConfiguration.Codes.FirstOrDefault(x => x.UID == codeUID); if (code != null) AddError(guardZone, "Дублируется комманда " + codeReaderSettingsPart.CodeReaderEnterType.ToDescription() + " в устройстве " + name + " для кода " + code.PresentationName, ValidationErrorLevel.CannotWrite); } } } }
/// <summary> /// Удаление охранной зоны /// </summary> /// <param name="guardZone"></param> public static void RemoveGuardZone(GKGuardZone guardZone) { GuardZones.Remove(guardZone); guardZone.OnChanged(); guardZone.OutputDependentElements.ForEach(x => { x.InputDependentElements.Remove(guardZone); if (x is GKDevice) { x.Invalidate(DeviceConfiguration); x.OnChanged(); } x.UpdateLogic(DeviceConfiguration); x.OnChanged(); }); }
public static IEnumerable<GKGuardZoneDevice> GetGuardZoneDevices(GKGuardZone guardZone, GKGuardZoneDeviceActionType actionType, bool IsCardOrCodeReader) { if (!IsCardOrCodeReader) return guardZone.GuardZoneDevices.FindAll(x => x.ActionType == actionType && !x.Device.Driver.IsCardReaderOrCodeReader); if (actionType == GKGuardZoneDeviceActionType.SetGuard) return guardZone.GuardZoneDevices.FindAll(x => x.CodeReaderSettings.SetGuardSettings.CanBeUsed); if (actionType == GKGuardZoneDeviceActionType.ResetGuard) return guardZone.GuardZoneDevices.FindAll(x => x.CodeReaderSettings.ResetGuardSettings.CanBeUsed); if (actionType == GKGuardZoneDeviceActionType.ChangeGuard) return guardZone.GuardZoneDevices.FindAll(x => x.CodeReaderSettings.ChangeGuardSettings.CanBeUsed); if (actionType == GKGuardZoneDeviceActionType.SetAlarm) return guardZone.GuardZoneDevices.FindAll(x => x.CodeReaderSettings.AlarmSettings.CanBeUsed); return new List<GKGuardZoneDevice>(); }
public void TestGuardZoneInMultiGk() { var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_GuardDetector); var device2 = AddDevice(kauDevice21, GKDriverType.RSR2_GuardDetector); var guardZoneDevice1 = new GKGuardZoneDevice {Device = device1, DeviceUID = device1.UID}; var guardZoneDevice2 = new GKGuardZoneDevice {Device = device2, DeviceUID = device2.UID}; var guardZone = new GKGuardZone(); GKManager.GuardZones.Add(guardZone); guardZone.GuardZoneDevices.Add(guardZoneDevice1); guardZone.GuardZoneDevices.Add(guardZoneDevice2); GKManager.AddDeviceToGuardZone(guardZone, guardZoneDevice1); GKManager.AddDeviceToGuardZone(guardZone, guardZoneDevice2); var validator = new Validator(); var errors = validator.Validate(); Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Содержится в нескольких ГК")); }
//RG-1109 (Валидация настройки контроллера Wiegand при одновременном участии в ТД и в ОЗ) public void TestCardReader() { var rK = AddDevice(kauDevice11, GKDriverType.RK_RM); var cardReader = AddDevice(kauDevice11, GKDriverType.RSR2_CardReader); var codeReader = AddDevice(kauDevice11, GKDriverType.RSR2_CodeReader); var lockDevice = new GKGuardZoneDevice { DeviceUID = codeReader.UID, Device = codeReader }; var enterDevice = new GKGuardZoneDevice { DeviceUID = cardReader.UID, Device = cardReader }; var zone = new GKGuardZone { No = 1, Name = "Охранная зона" }; var door = new GKDoor { No = 1, Name = "Точка доступа", DoorType = GKDoorType.TwoWay, EnterDevice = cardReader, EnterDeviceUID = cardReader.UID, ExitDevice = codeReader, ExitDeviceUID = codeReader.UID, LockDevice = rK, LockDeviceUID = codeReader.UID }; GKManager.AddGuardZone(zone); GKManager.AddDeviceToGuardZone(zone, lockDevice); GKManager.AddDeviceToGuardZone(zone, enterDevice); GKManager.AddDoor(door); enterDevice.CodeReaderSettings.SetGuardSettings = new GKCodeReaderSettingsPart { CodeReaderEnterType = GKCodeReaderEnterType.CodeOnly }; var errors = Validate(); Assert.IsTrue(errors.Any(x => x.ErrorLevel == ValidationErrorLevel.CannotWrite && x.Error == "Котроллер Wiegand используется в точке доступа, не должно быть настроенных кодов с методом ввода *КОД# ")); }
public GuardZoneDetailsViewModel(GKGuardZone zone) { 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); TurnOffNowCommand = new RelayCommand(OnTurnOffNow); ResetCommand = new RelayCommand(OnReset, CanReset); Zone = zone; Title = Zone.PresentationName; State.StateChanged += new Action(OnStateChanged); PlanLinks = new PlanLinksViewModel(Zone); }
/* RG-1223 (Сброс зоны не должен сбрасывать тревогу, если тревожный датчик в сработке1, тест с контроллером Wiegand)*/ public void TestGuardZoneFire1AfterResetCaseWithCardReader() { var device1 = AddDevice(kauDevice11, GKDriverType.RSR2_CardReader); var cardReader = AddGuardZoneDevice(device1); var device2 = AddDevice(kauDevice11, GKDriverType.RSR2_AM_1); var aM = AddGuardZoneDevice(device2); aM.ActionType = GKGuardZoneDeviceActionType.SetAlarm; var device3 = AddDevice(kauDevice11, GKDriverType.RSR2_GuardDetector); var guardDetector = AddGuardZoneDevice(device3); guardDetector.ActionType = GKGuardZoneDeviceActionType.SetAlarm; var zone = new GKGuardZone {Name = "Охранная зона", No = 1}; GKManager.AddGuardZone(zone); GKManager.AddDeviceToGuardZone(zone, aM); GKManager.AddDeviceToGuardZone(zone, cardReader); GKManager.AddDeviceToGuardZone(zone, guardDetector); SetConfigAndRestartImitator(); WaitWhileState(zone, XStateClass.Off, 10000, "Ждем норму в охранной зоне"); Assert.IsTrue(zone.State.StateClass == XStateClass.Off, "Проверка того, что зона снята с охраны"); Assert.IsTrue(device3.State.StateClass == XStateClass.Off, "Проверка того, что датчик выключен"); ConrtolGKBase(zone, GKStateBit.TurnOn_InAutomatic, "Постановка зоны на охрану"); WaitWhileState(zone, XStateClass.On, 3000, "Ждем пока зона не встанет на охрану"); Assert.IsTrue(zone.State.StateClass == XStateClass.On, "Проверка того, что зона установилась на охрану"); ConrtolGKBase(device3, GKStateBit.Fire1, "Сработка тревоги у датчика"); WaitWhileState(zone, XStateClass.Fire1, 10000, "Ждем пока зона не перейдёт в тревогу"); Assert.IsTrue(zone.State.StateClasses.Contains(XStateClass.Fire1), "Проверка того, что зона перешла в тревогу"); Assert.IsTrue(zone.State.StateClasses.Contains(XStateClass.On), "Проверка того, что зона на охране"); CheckTime(() => Thread.Sleep(1000), "Ждем 1 секунду"); Assert.IsTrue(device3.State.StateClass == XStateClass.Fire1, "Проверка того, что датчик ещё в тревоге"); CheckJournal(5, JournalItem(zone, JournalEventNameType.На_охране), JournalItem(device3, JournalEventNameType.Включено), JournalItem(device3, JournalEventNameType.Сработка_1), JournalItem(zone, JournalEventNameType.Внимание), JournalItem(zone, JournalEventNameType.Тревога)); ConrtolGKBase(zone, GKStateBit.Reset, "Cброс зоны"); WaitWhileOneOfStates(zone, XStateClass.Fire1, 10000, "Ждем пока зона не перейдёт в тревогу"); Assert.IsTrue(zone.State.StateClasses.Contains(XStateClass.Fire1), "Проверка того, что зона перешла в тревогу"); Assert.IsTrue(zone.State.StateClasses.Contains(XStateClass.On), "Проверка того, что зона на охране"); Thread.Sleep(6000); CheckJournal(3, JournalItem(zone, JournalEventNameType.Норма), JournalItem(zone, JournalEventNameType.Внимание), JournalItem(zone, JournalEventNameType.Тревога)); }
public void Initialize(GKGuardZone zone) { Zone = zone; Devices = new ObservableCollection<GuardZoneDeviceViewModel>(); foreach (var device in GKManager.Devices) { if (device.DriverType == GKDriverType.RSR2_GuardDetector || device.DriverType == GKDriverType.RSR2_GuardDetectorSound || device.DriverType == GKDriverType.RSR2_HandGuardDetector || device.DriverType == GKDriverType.RSR2_AM_1 || device.DriverType == GKDriverType.RSR2_MAP4 || device.Driver.IsCardReaderOrCodeReader) { var guardZoneDevice = Zone.GuardZoneDevices.FirstOrDefault(x => x.DeviceUID == device.UID); if (guardZoneDevice != null) { var deviceViewModel = new GuardZoneDeviceViewModel(guardZoneDevice); Devices.Add(deviceViewModel); } } } OnPropertyChanged(() => Devices); SelectedDevice = Devices.FirstOrDefault(); }
public GuardZoneDetailsViewModel(GKGuardZone zone = null) { ReadPropertiesCommand = new RelayCommand(OnReadProperties); WritePropertiesCommand = new RelayCommand(OnWriteProperties); ResetPropertiesCommand = new RelayCommand(OnResetProperties); if (zone == null) { IsEdit = false; Title = "Создание новой зоны"; Zone = new GKGuardZone() { Name = "Новая зона", No = 1 }; if (GKManager.DeviceConfiguration.GuardZones.Count != 0) Zone.No = (GKManager.DeviceConfiguration.GuardZones.Select(x => x.No).Max() + 1); } else { IsEdit = true; Title = string.Format("Свойства зоны: {0}", zone.PresentationName); Zone = zone; } CopyProperties(); var availableNames = new HashSet<string>(); var availableDescription = new HashSet<string>(); foreach (var existingZone in GKManager.DeviceConfiguration.GuardZones) { availableNames.Add(existingZone.Name); availableDescription.Add(existingZone.Description); } AvailableNames = new ObservableCollection<string>(availableNames); AvailableDescription = new ObservableCollection<string>(availableDescription); }
public void TestGuardZone() { var cardReaderDevice = AddDevice(kauDevice, GKDriverType.RSR2_CardReader); var guardZoneDevice = new GKGuardZoneDevice(); guardZoneDevice.Device = cardReaderDevice; guardZoneDevice.DeviceUID = cardReaderDevice.UID; guardZoneDevice.CodeReaderSettings = new GKCodeReaderSettings(); guardZoneDevice.CodeReaderSettings.ChangeGuardSettings = new GKCodeReaderSettingsPart(); var code = new GKCode(); GKManager.DeviceConfiguration.Codes.Add(code); guardZoneDevice.CodeReaderSettings.ChangeGuardSettings.CodeUIDs.Add(code.UID); guardZoneDevice.ActionType = GKGuardZoneDeviceActionType.ChangeGuard; guardZoneDevice.CodeReaderSettings.ChangeGuardSettings.CodeReaderEnterType = GKCodeReaderEnterType.CodeAndOne; var guardZone = new GKGuardZone(); GKManager.AddGuardZone(guardZone); GKManager.AddDeviceToGuardZone(guardZone, guardZoneDevice); Test(guardZone, GKDriverType.GuardZonesMirror); CheckObjectOnGK(code); Assert.IsNotNull(guardZone.Pim); CheckObjectOnGK(guardZone.Pim); }
public GuardZoneViewModel(GKGuardZone zone) { Zone = zone; zone.PlanElementUIDsChanged += UpdateVisualizationState; Update(); }
public GuardZonePimDescriptor(GKGuardZone pimGuardZone) : base(pimGuardZone.Pim) { PimGuardZone = pimGuardZone; Pim.LinkToDescriptor(PimGuardZone); }
public ZoneViewModel(GKGuardZone guardZone) { GuardZone = guardZone; }
/// <summary> /// Изменение охранной зоны /// </summary> /// <param name="guardZone"></param> public static void EditGuardZone(GKGuardZone guardZone) { guardZone.InputDependentElements.ForEach(x => x.OnChanged()); guardZone.OutputDependentElements.ForEach(x => x.OnChanged()); guardZone.OnChanged(); }
public void Reset() { if (GkEntity.ObjectType == GKBaseObjectType.Zone) { var zone = new GKZone { UID = GkEntity.UID }; switch (AlarmType) { case GKAlarmType.Fire1: ClientManager.RubezhService.GKResetFire1(zone); break; case GKAlarmType.Fire2: ClientManager.RubezhService.GKResetFire2(zone); break; } } if (GkEntity.ObjectType == GKBaseObjectType.GuardZone) { var guardZone = new GKGuardZone { UID = GkEntity.UID }; switch (AlarmType) { case GKAlarmType.GuardAlarm: ClientManager.RubezhService.GKReset(guardZone); break; } } if (GkEntity.ObjectType == GKBaseObjectType.Device) { var device = new GKDevice { UID = GkEntity.UID }; ClientManager.RubezhService.GKReset(device); } if (GkEntity.ObjectType == GKBaseObjectType.Door) { var door = new GKDoor { UID = GkEntity.UID }; switch (AlarmType) { case GKAlarmType.GuardAlarm: ClientManager.RubezhService.GKReset(door); break; } } }
/// <summary> /// Добавление охранной зоны /// </summary> /// <param name="guardZone"></param> public static void AddGuardZone(GKGuardZone guardZone) { GuardZones.Add(guardZone); }
public ObjectViewModel(GKGuardZone guardZone) { GuardZone = guardZone; Name = guardZone.PresentationName; ImageSource = "/Controls;component/Images/GuardZone.png"; Address = ""; PresentationZoneOrLogic = ""; ObjectType = ObjectType.GuardZone; SortingName = "g " + guardZone.No; }
public void GuardZoneUpdate(GKGuardZone guardZone) { var _guardZone = new GuardZone(guardZone); Clients.All.guardZoneUpdate(_guardZone); }