Exemple #1
0
		public static List<CurrentConsumption> GetKAUMeasure(GKDevice device, int? alsIntAddress = null)
		{
			var result = SendManager.Send(device.GkDatabaseParent, 2, 20, 16, BytesHelper.ShortToBytes(device.GKDescriptorNo));
			var alsCurrents = new List<CurrentConsumption>();
			if (!result.HasError && result.Bytes.Count == 16)
			{
				foreach (var alsDevice in device.Children.Where(x => x.DriverType == GKDriverType.RSR2_KAU_Shleif && (alsIntAddress == null || x.IntAddress == alsIntAddress)))
				{
					var current = (double)BytesHelper.SubstructShort(result.Bytes, (alsDevice.IntAddress - 1) * 2) * 300 / 4096;
					var alsCurrent = new CurrentConsumption();
					alsCurrent.AlsUID = alsDevice.UID;
					alsCurrent.Current = (int)current;
					alsCurrent.DateTime = DateTime.Now;
					alsCurrents.Add(alsCurrent);
				}
			}
			return alsCurrents;
		}
		public OperationResult<bool> SaveCurrentConsumption(Guid clientUID, CurrentConsumption item)
		{
			return SafeOperationCall(clientUID, () => RubezhService.SaveCurrentConsumption(clientUID, item), "SaveCurrentConsumption");
		}
		public OperationResult<bool> SaveCurrentConsumption(CurrentConsumption item)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.SaveCurrentConsumption(RubezhServiceFactory.UID, item);
			}, "SaveCurrentConsumption");
		}
Exemple #4
0
		public OperationResult<bool> SaveCurrentConsumption(Guid clientUID, CurrentConsumption item)
		{
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				return databaseService.CurrentConsumptionTranslator.Save(item);
			}
		}