/// <summary> /// Obtiene TankGaugeDataCollection desde informacion de tankGauge /// Debe llamarse desde bloque critico /// Realizara una serie de intentos para obtener la lectura, si no lo consigue fallará /// </summary> /// <param name="tankInfo"></param> /// <returns></returns> private TankGaugeDataCollection GetTankGaugeDataCollection(PSS_Forecourt_Lib.TankGauge tankInfo) { for (int i = 0; i < Configuration.MaxAttemptsToReadTankGaugeData; i++) { Logger.Log($"Intento {i + 1} de lectura TankGaugeDataCollection"); TankGaugeDataCollection ret = tankInfo.DataCollection; if (ret.Count > 0) { return(ret); } Logger.Log($"Intento {i + 1} de lectura TankGaugeDataCollection con resultado vacio. Paramos hilo {Configuration.SleepingMillisecondsBetweenAttemptsToReadTankGaugeData} ms"); System.Threading.Thread.CurrentThread.Join(Configuration.SleepingMillisecondsBetweenAttemptsToReadTankGaugeData); } throw new InvalidOperationException($"No se ha recuperado TankGaugeDataCollection tras {Configuration.MaxAttemptsToReadTankGaugeData} intentos"); }
/// <summary> /// Obtiene GetDeliveryData desde TankGauge. /// Se debe llamar desde un bloque critico. /// Realizara una serie de intentos para obtener la lectura, si no lo consigue fallará /// </summary> /// <returns></returns> private GetDeliveryDataResponse GetDeliveryData(PSS_Forecourt_Lib.TankGauge tankInfo, byte bytPosId) { for (int i = 0; i < Configuration.MaxAttemptsToReadDeliveryData; i++) { Logger.Log($"Intento {i + 1} de lectura DeliveryData"); DeliveryDataCollection ddcDelivery = tankInfo.GetDeliveryData(bytPosId, out byte byNroReport); if (ddcDelivery != null && ddcDelivery.Count > 0) { return(new GetDeliveryDataResponse { ByNroReport = byNroReport, DeliveryDataCollection = ddcDelivery }); } Logger.Log($"Intento {i + 1} de lectura DeliveryData con resultado vacio. Paramos hilo {Configuration.SleepingMillisecondsBetweenAttempsToReadDeliveryData} ms"); System.Threading.Thread.CurrentThread.Join(Configuration.SleepingMillisecondsBetweenAttempsToReadDeliveryData); } throw new InvalidOperationException($"No se ha recuperado DeliveryData tras {Configuration.MaxAttemptsToReadDeliveryData} intentos"); }