コード例 #1
0
		public CodeDetailsViewModel(GKCode code = null)
		{
			ReadPropertiesCommand = new RelayCommand(OnReadProperties);
			WritePropertiesCommand = new RelayCommand(OnWriteProperties);

			if (code == null)
			{
				IsEdit = false;
				Title = "Создать код";
				Code = new GKCode()
				{
					Name = "Новый код",
					No = 1
				};
				if (GKManager.DeviceConfiguration.Codes.Count != 0)
					Code.No = (GKManager.DeviceConfiguration.Codes.Select(x => x.No).Max() + 1);
			}
			else
			{
				IsEdit = true;
				Title = "Редактировать код";
				Code = code;
			}

			CopyProperies();
		}
コード例 #2
0
		public void TestMPTWithCodesOnKau()
		{
			var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_HandDetector);
			var device2 = AddDevice(kauDevice1, GKDriverType.RSR2_CodeReader);
			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			var mpt = new GKMPT();
			var clause = new GKClause()
			{
				ClauseOperationType = ClauseOperationType.AllDevices,
				StateType = GKStateBit.Failure,
				DeviceUIDs = { device1.UID }
			};
			mpt.MptLogic.OnClausesGroup.Clauses.Add(clause);
			mpt.MPTDevices.Add(new GKMPTDevice() { MPTDeviceType = GKMPTDeviceType.HandStart, DeviceUID = device2.UID, CodeReaderSettings = new GKCodeReaderSettings() { MPTSettings = new GKCodeReaderSettingsPart() { CodeUIDs = {code.UID}} } });
			GKManager.MPTs.Add(mpt);
			Compile();

			CheckObjectLogicOnKau(mpt);
			Assert.IsNotNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == code));
		}
コード例 #3
0
ファイル: ObjectViewModel.cs プロジェクト: xbadcode/Rubezh
		public ObjectViewModel(GKCode code)
		{
			Code = code;
			Name = code.PresentationName;
			ImageSource = "/Controls;component/Images/Code.png";
			Address = "";
			PresentationZoneOrLogic = "";
			ObjectType = ObjectType.Code;
			SortingName = "h " + code.No;
		}
コード例 #4
0
		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);
		}
コード例 #5
0
		public CodePropertiesViewModel(GKCode code)
		{
			Title = "Параметры кода";
			Code = code;
			Password = Code.Password;
		}
コード例 #6
0
		bool Parse(List<byte> bytes, int descriptorNo)
		{
			var internalType = BytesHelper.SubstructShort(bytes, 0);
			var controllerAdress = BytesHelper.SubstructShort(bytes, 2);
			var adressOnController = BytesHelper.SubstructShort(bytes, 4);
			var physicalAdress = BytesHelper.SubstructShort(bytes, 6);
			if (internalType == 0)
				return true;
			var description = BytesHelper.BytesToStringDescription(bytes);
			var driver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == internalType);
			if (driver != null)
			{
				if (driver.DriverType == GKDriverType.GK && descriptorNo > 1)
				{
					if (bytes.Count <= 0x3a)
					{
						driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.GKMirror);
					}
					else if (bytes[0x3a] == 1)
					{
						driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU);
					}
				}

				var shleifNo = (byte)(physicalAdress / 256) + 1;
				var device = new GKDevice
				{
					Driver = driver,
					DriverUID = driver.UID,
					IntAddress = (byte)(physicalAdress % 256),
				};
				if (driver.DriverType == GKDriverType.GK)
				{
					device.Properties.Add(new GKProperty { Name = "IPAddress", StringValue = IpAddress });
					ControllerDevices.Add(controllerAdress, device);
					DeviceConfiguration.RootDevice.Children.Add(device);
					GkDevice = device;
				}
				if (driver.IsKau)
				{
					device.IntAddress = (byte)(controllerAdress % 256);
					var modeProperty = new GKProperty
					{
						Name = "Mode",
						Value = (byte)(controllerAdress / 256)
					};
					device.DeviceProperties.Add(modeProperty);
					ControllerDevices.Add(controllerAdress, device);
					GkDevice.Children.Add(device);
					for (int i = 0; i < 8; i++)
					{
						var shleif = new GKDevice();
						shleif.Driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif);
						shleif.DriverUID = shleif.Driver.UID;
						shleif.IntAddress = (byte)(i + 1);
						device.Children.Add(shleif);
					}
				}

				if (driver.DriverType == GKDriverType.GKMirror)
				{
					device.IntAddress = (byte)(controllerAdress % 256);
					var modeProperty = new GKProperty
					{
						Name = "Mode",
						Value = (byte)(controllerAdress / 256)
					};
					device.DeviceProperties.Add(modeProperty);
					ControllerDevices.Add(controllerAdress, device);
					GkDevice.Children.Add(device);
				}

				if (driver.DriverType != GKDriverType.GK && !driver.IsKau && driver.DriverType != GKDriverType.GKMirror && driver.DriverType != GKDriverType.System)
				{
					var controllerDevice = ControllerDevices.FirstOrDefault(x => x.Key == controllerAdress);
					if (controllerDevice.Value != null)
					{
						if (driver.DriverType == GKDriverType.GKIndicator && controllerDevice.Value.Driver.IsKau)
						{
							device.Driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.KAUIndicator);
							device.DriverUID = device.Driver.UID;
						}
						if (1 <= shleifNo && shleifNo <= 8 && physicalAdress != 0)
						{
							var shleif = controllerDevice.Value.Children.FirstOrDefault(x => (x.DriverType == GKDriverType.RSR2_KAU_Shleif) && x.IntAddress == shleifNo);
							shleif.Children.Add(device);
						}
						else
						{
							if (controllerDevice.Value.Driver.DriverType == GKDriverType.GK)
								device.IntAddress = (byte)(controllerDevice.Value.Children.Count(x => !x.Driver.HasAddress) + 2);
							else
								device.IntAddress = (byte)(controllerDevice.Value.Children.Count(x => !x.Driver.HasAddress) + 1);
							controllerDevice.Value.Children.Add(device);
						}
					}
				}
				return true;
			}

			if (internalType == 0x100 || internalType == 0x106 || internalType == 0x108 || internalType == 0x109 || internalType == 0x104)
			{
				var isMPT = false;
				var isPumpStation = false;
				ushort no = 0;

				try
				{
					if (description.StartsWith("MПТ."))
					{
						isMPT = true;
					}
					else
					{
						if (description[0] == '0')
							isPumpStation = true;
						no = (ushort)Int32.Parse(description.Substring(0, description.IndexOf(".")));
					}
					description = description.Substring(description.IndexOf(".") + 1);
				}
				catch
				{
					Error = "Невозможно получить номер объекта с дескриптором " + descriptorNo;
					return false;
				}

				if (internalType == 0x100)
				{
					var zone = new GKZone
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Zones.Add(zone);
					return true;
				}
				if (internalType == 0x106)
				{
					if (isPumpStation)
					{
						var pumpStation = new GKPumpStation()
						{
							Name = description,
							No = no,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.PumpStations.Add(pumpStation);
					}
					else if (isMPT)
					{
						var mpt = new GKMPT()
						{
							Name = description,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.MPTs.Add(mpt);
					}
					else
					{
						var direction = new GKDirection
						{
							Name = description,
							No = no,
							GkDatabaseParent = GkDevice
						};
						DeviceConfiguration.Directions.Add(direction);
					}
					return true;
				}
				if (internalType == 0x108)
				{
					var guardZone = new GKGuardZone
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.GuardZones.Add(guardZone);
					return true;
				}
				if (internalType == 0x109)
				{
					var code = new GKCode
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Codes.Add(code);
					return true;
				}
				if (internalType == 0x104)
				{
					var door = new GKDoor
					{
						Name = description,
						No = no,
						GkDatabaseParent = GkDevice
					};
					DeviceConfiguration.Doors.Add(door);
					return true;
				}
			}
			return true;
		}
コード例 #7
0
		public void TestEmptyObjects()
		{
			var zone = new GKZone();
			GKManager.Zones.Add(zone);

			var direction = new GKDirection();
			GKManager.Directions.Add(direction);

			var delay = new GKDelay();
			GKManager.Delays.Add(delay);

			var guardZone = new GKGuardZone();
			GKManager.GuardZones.Add(guardZone);

			var pumpStation = new GKPumpStation();
			GKManager.PumpStations.Add(pumpStation);

			var mpt = new GKMPT();
			GKManager.MPTs.Add(mpt);

			var door = new GKDoor();
			GKManager.Doors.Add(door);

			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			Compile();

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == zone));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == zone));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == zone));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == direction));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == direction));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == direction));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == delay));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == delay));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == delay));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == guardZone));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == guardZone));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == guardZone));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == pumpStation));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == pumpStation));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == pumpStation));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == mpt));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == mpt));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == mpt));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == door));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == door));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == door));

			Assert.IsNull(Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == code));
			Assert.IsNull(Kau2Database.Descriptors.FirstOrDefault(x => x.GKBase == code));
			Assert.IsNull(GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == code));
		}
コード例 #8
0
		/// <summary>
		/// Если в охранной зоне учавствует контроллер Wiegand или кодонаборник и у них настроены и код и уровень доступа, то такая зона должна попасть на ГК
		/// и логика всех устройств, учавствующих в зоне, должна также попасть на ГК
		/// </summary>
		/// <param name="driverType"></param>
		void TestGuardZoneWithCodesAndLevelsOnGK(GKDriverType driverType)
		{
			var device1 = AddDevice(kauDevice1, driverType);
			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			var guardZone = new GKGuardZone();
			guardZone.GuardZoneDevices.Add(new GKGuardZoneDevice() { DeviceUID = device1.UID, CodeReaderSettings = new GKCodeReaderSettings() { SetGuardSettings = new GKCodeReaderSettingsPart() { CodeReaderEnterType = GKCodeReaderEnterType.CodeAndOne, CodeUIDs = { code.UID }, AccessLevel = 1 } } });
			GKManager.GuardZones.Add(guardZone);
			Compile();

			CheckObjectLogicOnGK(guardZone);
		}
コード例 #9
0
		/// <summary>
		/// Если в охранноую зону входит контроллер Wiegand или кодонаборник, а у кодонаборника указан только код и не указан уровень, то такая зона и само устройство
		/// должны попасть на КАУ
		/// </summary>
		void TestGuardZoneWithCodesOnKau(GKDriverType driverType)
		{
			var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_CodeReader);
			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			var guardZone = new GKGuardZone();
			var guardZoneDevice = new GKGuardZoneDevice
			{
				DeviceUID = device1.UID,
				CodeReaderSettings = new GKCodeReaderSettings
				{
					SetGuardSettings = new GKCodeReaderSettingsPart {CodeReaderEnterType = GKCodeReaderEnterType.CodeAndOne, CodeUIDs = {code.UID}}
				}
			};
			GKManager.AddDeviceToGuardZone(guardZone, guardZoneDevice);
			GKManager.GuardZones.Add(guardZone);
			Compile();

			CheckObjectLogicOnKau(guardZone);
		}
コード例 #10
0
		public void TestGuardZoneWithCodeReaderOnGK()
		{
			var device1 = AddDevice(kauDevice1, GKDriverType.RSR2_AM_1);
			var device2 = AddDevice(kauDevice2, GKDriverType.RSR2_CodeReader);
			var code = new GKCode();
			GKManager.DeviceConfiguration.Codes.Add(code);
			var guardZone = new GKGuardZone();
			guardZone.GuardZoneDevices.Add(new GKGuardZoneDevice() { ActionType = GKGuardZoneDeviceActionType.SetGuard, DeviceUID = device1.UID });
			guardZone.GuardZoneDevices.Add(new GKGuardZoneDevice() { DeviceUID = device2.UID, CodeReaderSettings = new GKCodeReaderSettings() { SetGuardSettings = new GKCodeReaderSettingsPart() { CodeReaderEnterType = GKCodeReaderEnterType.CodeAndOne, CodeUIDs = { code.UID } } } });
			GKManager.GuardZones.Add(guardZone);
			Compile();

			CheckObjectLogicOnGK(guardZone);
		}
コード例 #11
0
ファイル: CodeViewModel.cs プロジェクト: xbadcode/Rubezh
		public CodeViewModel(GKCode code)
		{
			Code = code;
		}
コード例 #12
0
ファイル: CodeDescriptor.cs プロジェクト: xbadcode/Rubezh
		public CodeDescriptor(GKCode code)
			: base(code)
		{
			DescriptorType = DescriptorType.Code;
			Code = code;
		}
コード例 #13
0
ファイル: GKState.cs プロジェクト: xbadcode/Rubezh
		public GKState(GKCode code)
			: this()
		{
			Code = code;
			UID = code.UID;
			BaseObjectType = GKBaseObjectType.Code;
		}