public CardReaderViewModel(DescriptorViewModel descriptorViewModel) { Title = "Считывание карт"; EnterCommand = new RelayCommand(OnEnter); DescriptorViewModel = descriptorViewModel; EnterTypes = Enum.GetValues(typeof(GKCodeReaderEnterType)).Cast<GKCodeReaderEnterType>().ToList(); SelectedEnterType = EnterTypes.FirstOrDefault(x => x == GKCodeReaderEnterType.CodeOnly); }
void InitializeDescriptors() { DescriptorsManager.Create(); var gkDatabase = DescriptorsManager.GkDatabases.FirstOrDefault(); Descriptors = new List<DescriptorViewModel>(); if (gkDatabase != null) { foreach (var descriptor in gkDatabase.Descriptors) { var binObjectViewModel = new DescriptorViewModel(descriptor); binObjectViewModel.OnStateChanged = InitIndicatorsStates; Descriptors.Add(binObjectViewModel); } foreach (var kauDatabase in gkDatabase.KauDatabases) { foreach (var descriptor in kauDatabase.Descriptors) { var descriptorViewModel = Descriptors.FirstOrDefault(x => x.GKBase.GKDescriptorNo == descriptor.GKBase.GKDescriptorNo); if (descriptorViewModel != null) { descriptorViewModel.SetKauDescriptor(descriptor); } } } } SelectedDescriptor = Descriptors.FirstOrDefault(); failureIndicator = Descriptors[1]; fire1Indicator = Descriptors[2]; fire2Indicator = Descriptors[3]; attentionIndicator = Descriptors[4]; startIndicator = Descriptors[5]; ignoreIndicator = Descriptors[7]; manualIndicator = Descriptors[8]; suspendIndicator = Descriptors[10]; }
bool ValidateCommand(DescriptorViewModel descriptor, GKStateBit command) { var availableCommands = new List<GKStateBit>(); if (descriptor.HasAutomaticRegime) availableCommands.Add(GKStateBit.SetRegime_Automatic); if (descriptor.HasManualRegime) availableCommands.Add(GKStateBit.SetRegime_Manual); if (descriptor.HasIgnoreRegime) availableCommands.Add(GKStateBit.Ignore); if (descriptor.HasReset || descriptor.HasResetFire) availableCommands.Add(GKStateBit.Reset); if (descriptor.HasSetFireHandDetector || descriptor.HasFire12) availableCommands.Add(GKStateBit.Fire2); if (descriptor.HasSetFireSmoke || descriptor.HasSetFireTemperature || descriptor.HasSetFireTemperatureGradient || descriptor.HasFire12 || descriptor.HasFire1) availableCommands.Add(GKStateBit.Fire1); if (descriptor.HasTest) availableCommands.Add(GKStateBit.Test); if (descriptor.HasTurnOn) { availableCommands.Add(GKStateBit.TurnOn_InManual); availableCommands.Add(GKStateBit.TurnOn_InAutomatic); } if (descriptor.HasTurnOnNow) { availableCommands.Add(GKStateBit.TurnOnNow_InManual); availableCommands.Add(GKStateBit.TurnOnNow_InAutomatic); } if (descriptor.HasTurnOff) { availableCommands.Add(GKStateBit.TurnOff_InManual); availableCommands.Add(GKStateBit.TurnOff_InAutomatic); } if (descriptor.HasTurnOffNow) { availableCommands.Add(GKStateBit.TurnOffNow_InManual); availableCommands.Add(GKStateBit.TurnOffNow_InAutomatic); } if (descriptor.HasAlarm) availableCommands.Add(GKStateBit.Fire1); return availableCommands.Contains(command); }
static Tuple<ImitatorUser, bool> GetUserAccess(uint currentCardNo, FormulaOperation formulaOperation, DescriptorViewModel descriptorViewModel) { var isAccess = false; var level = formulaOperation.FirstOperand; ImitatorUser user = null; var device = descriptorViewModel.GKBase as GKDevice; if (device != null && (device.Driver.IsCardReaderOrCodeReader)) { using (var dbService = new DbService()) { user = dbService.ImitatorUserTraslator.GetByNo(currentCardNo); if (user != null) { if (user.Level >= level) { if (IsInSchedule(dbService, user.ScheduleNo)) isAccess = true; } foreach (var imitatorUserDevice in user.ImitatorUserDevices) { if (imitatorUserDevice.DescriptorNo == formulaOperation.SecondOperand) { if (IsInSchedule(dbService, imitatorUserDevice.ScheduleNo)) isAccess = true; } } } } } return new Tuple<ImitatorUser, bool>(user, isAccess); }
public StateBitViewModel(DescriptorViewModel descriptorViewModel, GKStateBit stateBit, bool isActive = false) { DescriptorViewModel = descriptorViewModel; StateBit = stateBit; _isActive = isActive; }
void ChangeIndicatorStates(DescriptorViewModel indicator, GKStateBit stateBit) { if (activeStateBits.Any(x => x.Item2 == stateBit)) { if (indicator.GetStateBit(GKStateBit.Off)) indicator.TurnOnNowCommand.Execute(); } else { if (indicator.GetStateBit(GKStateBit.On)) indicator.TurnOffNowCommand.Execute(); } }