コード例 #1
0
ファイル: FiresecDriver.cs プロジェクト: saeednazari/Rubezh
		public OperationResult<bool> Connect(FSAgent fsAgent, bool isPing)
		{
			try
			{
				FiresecSerializedClient = new FiresecSerializedClient();
				FiresecSerializedClient.FSAgent = fsAgent;
				FiresecSerializedClient.SubscribeFsAgentEvents();

                ConfigurationConverter = new ConfigurationConverter(FiresecSerializedClient);
				var result = ConfigurationConverter.ConvertMetadataFromFiresec();
                if (!result.HasError)
                {
                    ConfigurationCash.DriversConfiguration = result.Result;
                    return new OperationResult<bool>() { Result = true };
                }
                else
                {
					return new OperationResult<bool>(result.Error);
                }
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecDriver.Synchronyze");
                LoadingErrorManager.Add(e);
                return new OperationResult<bool>(e.Message);
			}
		}
コード例 #2
0
		public FiresecDriver(int lastJournalNo, string FS_Address, int FS_Port, string FS_Login, string FS_Password, bool isPing)
		{
			LoadingErrors = new StringBuilder();
			try
			{
				FiresecSerializedClient = new FiresecSerializedClient();
				FiresecSerializedClient.Connect(FS_Address, FS_Port, FS_Login, FS_Password, isPing);
				ConfigurationConverter = new ConfigurationConverter()
				{
					FiresecSerializedClient = FiresecSerializedClient
				};
				ConfigurationConverter.ConvertMetadataFromFiresec();
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecDriver.Synchronyze");
				FiresecDriver.LoadingErrors.Append(e.Message);
			}
		}
コード例 #3
0
		public OperationResult<DeviceConfiguration> DeviceReadConfiguration(DeviceConfiguration deviceConfiguration, Guid deviceUID)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, false);
			var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
			var result = FiresecSerializedClient.DeviceReadConfig(firesecConfiguration, device.GetPlaceInTree());

			var operationResult = new OperationResult<DeviceConfiguration>()
			{
				HasError = result.HasError,
				Error = result.Error
			};
			if (operationResult.HasError)
				return operationResult;

			if (result.Result == null)
				return new OperationResult<DeviceConfiguration>("Ошибка. Получена пустая конфигурация");

			var configurationManager = new ConfigurationConverter();
			operationResult.Result = configurationManager.ConvertOnlyDevices(result.Result);
			return operationResult;
		}
コード例 #4
0
ファイル: FiresecDriver.cs プロジェクト: saeednazari/Rubezh
		public OperationResult<DeviceConfiguration> DeviceAutoDetectChildren(DeviceConfiguration deviceConfiguration, Guid deviceUID, bool fastSearch)
		{
			var firesecConfiguration = ConvertBack(deviceConfiguration, false);
			var device = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
			var result = FiresecSerializedClient.DeviceAutoDetectChildren(firesecConfiguration, device.GetPlaceInTree(), fastSearch);

			var operationResult = new OperationResult<DeviceConfiguration>()
			{
				HasError = result.HasError,
				Error = result.Error
			};
			if (operationResult.HasError)
				return operationResult;

			if (result.Result == null)
				return new OperationResult<DeviceConfiguration>();

            var configurationConverter = new ConfigurationConverter(FiresecSerializedClient);
			operationResult.Result = configurationConverter.ConvertOnlyDevices(result.Result);
			return operationResult;
		}