public AnyZonesSelectionViewModel(GKDevice device)
		{
			Title = "Выбор зон";
			Device = device;
			ZonesSelectationViewModel = new ZonesSelectationViewModel(device.Zones, true);
			GuardZonesWithFuncSelectationViewModel = new GuardZonesWithFuncSelectationViewModel(device, true);
		}
示例#2
0
		public BasePropertyViewModel(GKDriverProperty driverProperty, GKDevice device)
		{
			DriverProperty = driverProperty;
			IsAUParameter = driverProperty.IsAUParameter;
			Device = device;

			if (!Device.Properties.Any(x => x.Name == driverProperty.Name))
			{
				Save(driverProperty.Default, false);
			}

			if (Device.DeviceProperties == null)
			{
				Device.DeviceProperties = new List<GKProperty>();
			}

			var deviceProperty = Device.DeviceProperties.FirstOrDefault(x => x.Name == driverProperty.Name);
			if (deviceProperty != null)
			{
				double value = deviceProperty.Value;
				if (DriverProperty.Multiplier != 0)
					value /= DriverProperty.Multiplier;
				DeviceAUParameterValue = value.ToString();
			}
			else
				DeviceAUParameterValue = "Неизвестно";

			UpdateDeviceParameterMissmatchType();
		}
示例#3
0
		public static DeviceViewModel AddDevice(GKDevice device, DeviceViewModel parentDeviceViewModel, bool isAddDevice = true, bool isStartList = false)
		{
			var deviceViewModel = new DeviceViewModel(device);
			if (isAddDevice)
			{
				if (isStartList)
					parentDeviceViewModel.AddChildFirst(deviceViewModel);
				else
					parentDeviceViewModel.AddChild(deviceViewModel);
				foreach (var childDevice in device.Children)
				{
					AddDevice(childDevice, deviceViewModel);
				}
			}
			else
			{
				parentDeviceViewModel.InsertChild(deviceViewModel);

				foreach (var childDevice in device.Children)
				{
					AddDevice(childDevice, deviceViewModel, !isAddDevice);
				}
			}
			return deviceViewModel;
		}
示例#4
0
		public GKState(GKDevice device)
			: this()
		{
			Device = device;
			UID = device.UID;
			BaseObjectType = GKBaseObjectType.Device;
		}
		public BaseAUPropertyViewModel(GKDriverProperty driverProperty, GKDevice device)
		{
			DriverProperty = driverProperty;
			Device = device;

			if (!Device.Properties.Any(x => x.Name == driverProperty.Name))
			{
				Save(driverProperty.Default, false);
			}

			if (Device.DeviceProperties == null)
			{
				Device.DeviceProperties = new List<GKProperty>();
			}
			
			var deviceProperty = Device.DeviceProperties.FirstOrDefault(x => x.Name == driverProperty.Name);
			if (deviceProperty != null)
			{
				DeviceAUParameterValue = deviceProperty.Value.ToString();
				//if ((deviceProperty.DriverProperty != null) && (deviceProperty.DriverProperty.DriverPropertyType == XDriverPropertyTypeEnum.EnumType))
					//DeviceAUParameterValue = deviceProperty.DriverProperty.Parameters.FirstOrDefault(x => x.Value == deviceProperty.Value).Name;
			}
			else
				DeviceAUParameterValue = "Неизвестно";

			UpdateDeviceParameterMissmatchType();
		}
示例#6
0
		void CheckDeviceLogicOnGK(GKDevice device)
		{
			var deviceGKDescriptor = GkDatabase.Descriptors.FirstOrDefault(x => x.GKBase == device);
			var deviceKau1Descriptor = Kau1Database.Descriptors.FirstOrDefault(x => x.GKBase == device);
			Assert.IsTrue(deviceGKDescriptor.Formula.FormulaOperations.Count > 1, "На ГК должна присутствовать логика устройства");
			Assert.IsTrue(deviceKau1Descriptor.Formula.FormulaOperations.Count == 1, "На КАУ должна отсутствовать логика устройства");
		}
示例#7
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);
		}
示例#8
0
文件: Helper.cs 项目: xbadcode/Rubezh
		public static Color GetTankColor(GKDevice device)
		{
			Color color = Colors.Black;
			if (device != null)
				color = Colors.LightCyan;
			return color;
		}
		public DeviceSelectationViewModel(GKDevice selectedDevice, IEnumerable<GKDevice> sourceDevices = null)
		{
			Title = "Выбор устройства";
			Devices = new ObservableCollection<GKDevice>(sourceDevices);
			if (selectedDevice != null)
				SelectedDevice = Devices.FirstOrDefault(x => x.UID == selectedDevice.UID);
		}
示例#10
0
		public DeviceGuardZoneViewModel(GKDeviceGuardZone deviceGuardZone, GKDevice device)
		{
			DeviceGuardZone = deviceGuardZone;
			if (device != null)
				IsCodeReader = device.Driver.IsCardReaderOrCodeReader;
			No = deviceGuardZone.GuardZone.No;
			Name = deviceGuardZone.GuardZone.Name;
			Description = deviceGuardZone.GuardZone.Description;
			ActionTypes = new ObservableCollection<GKGuardZoneDeviceActionType>();
			if (device != null)
			switch (device.DriverType)
			{
				case GKDriverType.RSR2_GuardDetector:
				case GKDriverType.RSR2_GuardDetectorSound:
				case GKDriverType.RSR2_HandGuardDetector:
					ActionTypes.Add(GKGuardZoneDeviceActionType.SetAlarm);
					break;

				case GKDriverType.RSR2_AM_1:
				case GKDriverType.RSR2_MAP4:
					ActionTypes.Add(GKGuardZoneDeviceActionType.SetGuard);
					ActionTypes.Add(GKGuardZoneDeviceActionType.ResetGuard);
					ActionTypes.Add(GKGuardZoneDeviceActionType.ChangeGuard);
					ActionTypes.Add(GKGuardZoneDeviceActionType.SetAlarm);
					break;
			}
			if (deviceGuardZone.ActionType == null || !ActionTypes.Contains(deviceGuardZone.ActionType.Value))
				SelectedActionType = ActionTypes.FirstOrDefault();
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);
		}
		public DeviceExecutableCommandViewModel(GKDevice device, GKStateBit stateType)
		{
			ExecuteControlCommand = new RelayCommand(OnExecuteControl);
			Device = device;
			StateBit = stateType;
			Name = ((GKStateBit)stateType).ToDescription();
			if (Device.DriverType == GKDriverType.RSR2_Valve_DU || Device.DriverType == GKDriverType.RSR2_Valve_KV || Device.DriverType == GKDriverType.RSR2_Valve_KVMV)
			{
				switch (stateType)
				{
					case GKStateBit.TurnOn_InManual:
						Name = "Открыть";
						break;
					case GKStateBit.TurnOnNow_InManual:
						Name = "Открыть немедленно";
						break;
					case GKStateBit.TurnOff_InManual:
						Name = "Закрыть";
						break;
					case GKStateBit.Stop_InManual:
						Name = "Остановить";
						break;
				}
			}
		}
示例#12
0
		bool GetDescriptorInfo(GKDevice kauDevice, int descriptorAdderss)
		{
			var descriptorAdderssesBytes = new List<byte>(BitConverter.GetBytes(descriptorAdderss));
			var data = new List<byte>(descriptorAdderssesBytes);
			var sendResult = SendManager.Send(kauDevice, 4, 31, 256, data);
			var bytes = sendResult.Bytes;
			if (bytes.Count != 256)
			{
				Error = "Длина дескриптора не соответствует нужному значению";
				return false;
			}
			var deviceType = BytesHelper.SubstructShort(bytes, 0);
			var address = BytesHelper.SubstructShort(bytes, 2);
			int shleifNo = (byte)(address / 256 + 1);
			var device = new GKDevice();
			device.Driver = GKManager.Drivers.FirstOrDefault(x => x.DriverTypeNo == deviceType);
			if ((1 <= shleifNo && shleifNo <= 8) && (address != 0))
			{
				device.DriverUID = device.Driver.UID;
				var shleif = KauDevice.Children.FirstOrDefault(x => (x.DriverType == GKDriverType.RSR2_KAU_Shleif) && x.IntAddress == shleifNo);
				shleif.Children.Add(device);
				device.IntAddress = (byte)(address % 256);
				return true;
			}
			device.Driver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.KAUIndicator);
			device.DriverUID = device.Driver.UID;
			device.IntAddress = 1;
			KauDevice.Children.Add(device);
			return true;
		}
示例#13
0
		GKDevice CreateDevice(GKDriverType deviceDriverType)
		{
			var deviceDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == deviceDriverType);
			var device = new GKDevice { DriverUID = deviceDriver.UID };
			AlsDevice.Children.Add(device);
			return device;
		}
		public DevicePropertiesViewModel(GKDevice device)
		{
			Title = "Параметры устройства";
			Device = device;

			ShortProperties = new List<ShortPropertyViewModel>();
			BoolProperties = new List<BoolPropertyViewModel>();
			EnumProperties = new List<EnumPropertyViewModel>();
			if (Device != null)
			{
				if (Device.PredefinedName == "Тест")
				{
					return;
				}
				foreach (var driverProperty in Device.Driver.Properties.Where(x => x.IsAUParameter && !x.CanNotEdit))
				{
					switch (driverProperty.DriverPropertyType)
					{
						case GKDriverPropertyTypeEnum.IntType:
							ShortProperties.Add(new ShortPropertyViewModel(driverProperty, Device));
							break;
						case GKDriverPropertyTypeEnum.BoolType:
							BoolProperties.Add(new BoolPropertyViewModel(driverProperty, Device));
							break;
						case GKDriverPropertyTypeEnum.EnumType:
							EnumProperties.Add(new EnumPropertyViewModel(driverProperty, Device));
							break;
					}
				}
			}
		}
示例#15
0
		public void CreateConfiguration()
		{
			GKManager.DeviceLibraryConfiguration = new GKDeviceLibraryConfiguration();
			GKManager.DeviceConfiguration = new GKDeviceConfiguration();
			var systemDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.System);
			Assert.IsNotNull(systemDriver);
			var systemDevice = GKManager.DeviceConfiguration.RootDevice = new GKDevice { Driver = systemDriver, DriverUID = systemDriver.UID };
			gkDevice1 = GKManager.AddDevice(systemDevice, GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.GK), 0);
			kauDevice11 = GKManager.AddDevice(gkDevice1, GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU), 1);
			kauDevice12 = GKManager.AddDevice(gkDevice1, GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU), 2);

			gkDevice2 = GKManager.AddDevice(systemDevice, GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.GK), 0);
			kauDevice21 = GKManager.AddDevice(gkDevice2, GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU), 1);
			kauDevice22 = GKManager.AddDevice(gkDevice2, GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.RSR2_KAU), 2);

			GKManager.UpdateConfiguration();
			ClientManager.PlansConfiguration = new PlansConfiguration();
			ClientManager.PlansConfiguration.AllPlans = new List<Plan>();

			ServiceFactory.Initialize(null, null);
			ServiceFactory.ResourceService = new MockResourceService();
			ServiceFactory.DialogService = MockDialogService = new MockDialogService();
			ServiceFactory.MessageBoxService = MockMessageBoxService = new MockMessageBoxService();
			ServiceFactory.MenuService = new MenuService(x => { ;});
			ServiceFactory.RibbonService = new MockRibbonService();

			CreateGroupControllerModule();
		}
		public ConfigurationCompareViewModel(GKDeviceConfiguration localConfiguration, GKDeviceConfiguration remoteConfiguration, GKDevice device, string configFileName = "")
		{
			Title = "Сравнение конфигураций " + device.PresentationName;
			ChangeCurrentGkCommand = new RelayCommand(OnChangeCurrentGk);
			LoadConfigurationFromFileCommand = new RelayCommand(OnLoadConfigurationFromFile);
			NextDifferenceCommand = new RelayCommand(OnNextDifference, CanNextDifference);
			PreviousDifferenceCommand = new RelayCommand(OnPreviousDifference, CanPreviousDifference);

			ConfigFileName = configFileName;
			ConfigFromFile = CanChangeOrOpenConfiguration = !string.IsNullOrEmpty(configFileName);

			var remoteConfig = new ZipFile(ConfigFileName);
			OnlyGKDeviceConfiguration = remoteConfig.Entries.Count == 1;

			LocalConfiguration = localConfiguration;
			RemoteConfiguration = remoteConfiguration;
			RemoteConfiguration.Update();
			RemoteConfiguration.UpdateConfiguration();

			LocalDevice = localConfiguration.Devices.FirstOrDefault(x => x.DriverType == device.DriverType && x.Address == device.Address);
			RemoteDevice = remoteConfiguration.Devices.FirstOrDefault(x => x.DriverType == device.DriverType && x.Address == device.Address);
			if (RemoteDevice == null)
			{
				Error = "ГК в удаленной конфигурации имеет невалидный IP адрес";
				return;
			}
			LocalObjectsViewModel = new ObjectsListViewModel(LocalDevice, localConfiguration);
			RemoteObjectsViewModel = new ObjectsListViewModel(RemoteDevice, remoteConfiguration);
			CompareObjectLists();
			InitializeMismatchedIndexes();
		}
示例#17
0
		public UpdatableDeviceViewModel(GKDevice device)
		{
			Device = device;
			Name = device.ShortName;
			Address = device.DottedPresentationAddress;
			ImageSource = device.Driver.ImageSource;
		}
示例#18
0
		public GKDeviceInternalState(GKDevice device)
		{
			Device = device;

			if (device.DriverType == GKDriverType.System || device.DriverType == GKDriverType.RSR2_MVP_Part || device.DriverType == GKDriverType.RSR2_KDKR_Part)
				IsInitialState = false;
		}
示例#19
0
		public DoorDevice(GKDevice device)
		{
				UID = device.UID;
				Name = device.PresentationName;
				ImageSource = device.ImageSource.Replace("/Controls;component/", "");
				StateIcon = device.State.StateClass.ToString();
		}
示例#20
0
		void AddDevice(GKDevice device)
		{
			if (!Devices.Contains(device))
			{
				Devices.Add(device);
			}
		}
示例#21
0
		bool GetDescriptorAddresses(GKDevice device)
		{
			descriptorAddresses = new List<int>();
			var startaddress = 0x078000;
			while (true)
			{
				byte[] startAddressBytes = BitConverter.GetBytes(startaddress);
				startaddress += 256;

				var data = new List<byte>(startAddressBytes);
				var sendResult = SendManager.Send(device, 4, 31, 256, data);
				if (sendResult.Bytes.Count != 256)
				{
					Error = "Не удалось распознать дескриптор";
					return false;
				}
				for (int i = 0; i < 256 / 4; i++)
				{
					var descriptorAddress = BytesHelper.SubstructInt(sendResult.Bytes, i * 4);
					if (descriptorAddress == -1)
					{
						return true;
					}
					descriptorAddresses.Add(descriptorAddress);
				}
			}
		}
示例#22
0
		override public bool ReadConfiguration(GKDevice mirrorDevice, Guid clientUID)
		{
			MirrorDevice = (GKDevice)mirrorDevice.Clone();
			MirrorDevice.Children = new List<GKDevice>();

			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + mirrorDevice.PresentationName, "Проверка связи", 2, true, GKProgressClientType.Administrator);
			var result = DeviceBytesHelper.Ping(mirrorDevice);
			if (result.HasError)
			{
				Error = "Устройство " + mirrorDevice.PresentationName + " недоступно";
				return false;
			}

			DeviceConfiguration = new GKDeviceConfiguration { RootDevice = MirrorDevice };
			GKProcessorManager.DoProgress("Перевод ПМФ в технологический режим", progressCallback);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(mirrorDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести " + mirrorDevice.PresentationName + " в технологический режим";
				GKProcessorManager.StopProgress(progressCallback);
				return false;
			}

			ReadConfiguration(mirrorDevice);

			GKProcessorManager.DoProgress("Перевод ПМФ в рабочий режим", progressCallback);
			if (!DeviceBytesHelper.GoToWorkingRegime(mirrorDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести  " + mirrorDevice.PresentationName + " в рабочий режим в заданное время";
			}
			GKProcessorManager.StopProgress(progressCallback);
			return Error == null;
		}
示例#23
0
		/// <summary>
		/// Перезаписать вае графики конкретного ГК
		/// </summary>
		/// <param name="device"></param>
		/// <returns></returns>
		public static OperationResult<bool> RewriteAllSchedules(GKDevice device, Guid clientUID)
		{
			var progressCallback = GKProcessorManager.StartProgress("Перезапись графиков в " + device.PresentationName, "Стирание графиков", 1, false, GKProgressClientType.Administrator, clientUID);
			var removeResult = RemoveAllSchedules(device);
			if (removeResult.HasError)
				return OperationResult<bool>.FromError(removeResult.Errors);

			var schedules = new List<GKSchedule>();
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				var schedulesResult = databaseService.GKScheduleTranslator.Get();
				if (schedulesResult.HasError)
					return OperationResult<bool>.FromError(schedulesResult.Errors);
				schedules = schedulesResult.Result;
			}

			progressCallback = GKProcessorManager.StartProgress("Запись графиков в " + device.PresentationName, "", schedules.Count + 1, false, GKProgressClientType.Administrator, clientUID);
			var emptySchedule = new GKSchedule();
			emptySchedule.Name = "Никогда";
			var setResult = GKSetSchedule(device, emptySchedule);
			if (setResult.HasError)
				return OperationResult<bool>.FromError(setResult.Errors);
			GKProcessorManager.DoProgress("Запись пустого графика ", progressCallback, clientUID);
			int i = 1;
			foreach (var schedule in schedules)
			{
				setResult = GKSetSchedule(device, schedule);
				if (setResult.HasError)
					return OperationResult<bool>.FromError(setResult.Errors);
				GKProcessorManager.DoProgress("Запись графика " + i, progressCallback, clientUID);
				i++;
			}
			GKProcessorManager.StopProgress(progressCallback, clientUID);
			return new OperationResult<bool>(true);
		}
示例#24
0
		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;
		}
示例#25
0
		public void WriteFileToGK(GKDevice gkControllerDevice, Guid clientUID)
		{
			using (var gkLifecycleManager = new GKLifecycleManager(gkControllerDevice, "Запись файла в ГК"))
			{
				gkLifecycleManager.AddItem("Формирование хэша");
				var gkFileInfo = new GKFileInfo();
				gkFileInfo.Initialize(gkControllerDevice);
				var bytesList = new List<byte>();
				bytesList.AddRange(gkFileInfo.InfoBlock);
				bytesList.AddRange(gkFileInfo.FileBytes);

				gkLifecycleManager.AddItem("Перевод в режим записи файла");
				var sendResult = SendManager.Send(gkControllerDevice, 0, 21, 0);
				if (sendResult.HasError)
				{
					Error = "Невозможно начать процедуру записи ";
					gkLifecycleManager.AddItem("Ошибка");
					return;
				}

				var progressCallback = GKProcessorManager.StartProgress("Запись файла в " + gkControllerDevice.PresentationName, null, bytesList.Count / 256, false, GKProgressClientType.Administrator, clientUID);
				for (var i = 0; i < bytesList.Count; i += 256)
				{
					gkLifecycleManager.Progress(i + 1, bytesList.Count);
					GKProcessorManager.DoProgress("Запись блока данных " + i + 1, progressCallback, clientUID);

					var bytesBlock = BitConverter.GetBytes((uint)(i / 256 + 1)).ToList();
					bytesBlock.AddRange(bytesList.GetRange(i, Math.Min(256, bytesList.Count - i)));
					for (int j = 0; j < 10; j++)
					{
						sendResult = SendManager.Send(gkControllerDevice, (ushort)bytesBlock.Count(), 22, 0, bytesBlock);
						var result = sendResult.Bytes.Count > 0 && sendResult.Bytes[0] == 1;
						if (!sendResult.HasError && result)
							break;
						if (j == 9)
						{
							Error = "Невозможно записать блок данных " + i;
							gkLifecycleManager.AddItem("Ошибка");
							return;
						}
					}
				}
				gkLifecycleManager.AddItem("Запись последнего блока данных");
				var endBlock = BitConverter.GetBytes((uint)(bytesList.Count() / 256 + 1)).ToList();
				sendResult = SendManager.Send(gkControllerDevice, 0, 22, 0, endBlock);
				var endResult = sendResult.Bytes.Count > 0 && sendResult.Bytes[0] == 0;
				if (sendResult.HasError || !endResult)
				{
					Error = "Невозможно завершить запись файла ";
					gkLifecycleManager.AddItem("Ошибка");
				}
				var sendResultRead = SendManager.Send(gkControllerDevice, 4, 23, 256, new List<byte>(BitConverter.GetBytes(1)));
				if (!gkFileInfo.InfoBlock.SequenceEqual(sendResultRead.Bytes))
				{
					Error = "Не удалось корректно записать информационный блок ";
					gkLifecycleManager.AddItem("Ошибка");
				}
			}
		}
示例#26
0
		public OperationResult<GKDevice> GKAutoSearch(GKDevice device)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(120));
				using (rubezhService as IDisposable)
					return rubezhService.GKAutoSearch(RubezhServiceFactory.UID, device.UID);
			}, "GKAutoSearch");
		}
示例#27
0
		public OperationResult<bool> GKReadConfigurationFromGKFile(GKDevice device)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(30));
				using (rubezhService as IDisposable)
					return rubezhService.GKReadConfigurationFromGKFile(RubezhServiceFactory.UID, device.UID);
			}, "GKReadConfigurationFromGKFile");
		}
示例#28
0
		public OperationResult<bool> GKSyncronyseTime(GKDevice device)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.GKSyncronyseTime(RubezhServiceFactory.UID, device.UID);
			}, "GKSyncronyseTime");
		}
示例#29
0
		public OperationResult<bool> GKUpdateFirmware(GKDevice device, List<byte> firmwareBytes)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(30));
				using (rubezhService as IDisposable)
					return rubezhService.GKUpdateFirmware(RubezhServiceFactory.UID, device.UID, firmwareBytes);
			}, "GKUpdateFirmware");
		}
		public StringAUPropertyViewModel(GKDriverProperty driverProperty, GKDevice device)
			: base(driverProperty, device)
		{
			var property = device.Properties.FirstOrDefault(x => x.Name == driverProperty.Name);
			if (property != null)
				_text = Convert.ToString(property.Value);
			else
				_text = Convert.ToString(driverProperty.Default);
		}