Ejemplo n.º 1
0
		public static void AddCodeReaderLogic(FormulaBuilder formula, GKCodeReaderSettingsPart settingsPart, GKDevice device)
		{
			var stateBit = CodeReaderEnterTypeToStateBit(settingsPart.CodeReaderEnterType);
			formula.AddGetBit(stateBit, device);
			formula.Add(FormulaOperationType.BR, 2, 2);
			formula.Add(FormulaOperationType.CONST);
			var gotoFormulaOperation = formula.Add(FormulaOperationType.BR, 0, 0);
			var formulaNo = formula.FormulaOperations.Count;

			var codeIndex = 0;
			foreach (var codeUID in settingsPart.CodeUIDs)
			{
				var code = GKManager.DeviceConfiguration.Codes.FirstOrDefault(x => x.UID == codeUID);
				formula.AddWithGKBase(FormulaOperationType.KOD, 0, device);
				formula.AddWithGKBase(FormulaOperationType.CMPKOD, 1, code);
				if (codeIndex > 0)
				{
					formula.Add(FormulaOperationType.OR);
				}
				codeIndex++;
			}
			if (settingsPart.AccessLevel > 0)
			{
				formula.AddWithGKBase(FormulaOperationType.ACS, (byte)settingsPart.AccessLevel, device);
				if (codeIndex > 0)
				{
					formula.Add(FormulaOperationType.OR);
				}
			}

			gotoFormulaOperation.SecondOperand = (ushort)(formula.FormulaOperations.Count - formulaNo);
		}
Ejemplo n.º 2
0
		public GKCodeReaderSettingsPart GetCodeReaderSettingsPart()
		{
			var codeReaderSettingsPart = new GKCodeReaderSettingsPart();
			codeReaderSettingsPart.CodeReaderEnterType = SelectedEnterType;
			codeReaderSettingsPart.AccessLevel = AccessLevel;
			codeReaderSettingsPart.CodeUIDs = (from code in Codes select code.UID).ToList();
			return codeReaderSettingsPart;
		}
Ejemplo n.º 3
0
		public GKCodeReaderSettings()
		{
			SetGuardSettings = new GKCodeReaderSettingsPart();
			ResetGuardSettings = new GKCodeReaderSettingsPart();
			ChangeGuardSettings = new GKCodeReaderSettingsPart();
			AlarmSettings = new GKCodeReaderSettingsPart();
			MPTSettings = new GKCodeReaderSettingsPart();

			SetGuardSettings.CodeReaderEnterType = GKCodeReaderEnterType.CodeAndOne;
			ResetGuardSettings.CodeReaderEnterType = GKCodeReaderEnterType.CodeAndTwo;
			MPTSettings.CodeReaderEnterType = GKCodeReaderEnterType.CodeOnly;
		}
Ejemplo n.º 4
0
		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);
					}
				}
			}
		}
Ejemplo n.º 5
0
		public CodeReaderSettingsViewModel(GKCodeReaderSettingsPart codeReaderSettingsPart)
		{
			SelectCodeCommand = new RelayCommand(OnSelectCode);
			CodeReaderSettingsPart = codeReaderSettingsPart;
			EnterTypes = Enum.GetValues(typeof(GKCodeReaderEnterType)).Cast<GKCodeReaderEnterType>().ToList();
			SelectedEnterType = EnterTypes.FirstOrDefault(x => x == codeReaderSettingsPart.CodeReaderEnterType);
			AccessLevel = CodeReaderSettingsPart.AccessLevel;
			Codes = new List<GKCode>();
			foreach (var codeUID in codeReaderSettingsPart.CodeUIDs)
			{
				var code = GKManager.DeviceConfiguration.Codes.FirstOrDefault(x => x.UID == codeUID);
				if (code != null)
				{
					Codes.Add(code);
				}
			}
		}
		public void InvalidateGKCodeReaderSettingsPart(GKCodeReaderSettingsPart codeReaderSettingsPart)
		{
			var codeUIDs = new List<Guid>();
			foreach (var codeUID in codeReaderSettingsPart.CodeUIDs)
			{
				var code = Codes.FirstOrDefault(x => x.UID == codeUID);
				if (code != null)
				{
					codeUIDs.Add(codeUID);
				}
			}
			codeReaderSettingsPart.CodeUIDs = codeUIDs;
		}