/// <summary> /// Metodo encargado para obtener la informacion de los tanques del varillaje. /// </summary> /// <param name="host"></param> /// <param name="posId"></param> /// <param name="maquina"></param> /// <returns IEnumerable<TankInfo>></returns> public IList <TankGauge> GetTanksGaugeDataDOMS(string host, string posId, string maquina) { try { _DOMSSemaphore.Wait(); Logger.Log("Entrada", new { host, posId, maquina }); var ret = new List <TankGauge>(); // BLOQUE CRITICO _connectToDOMS(host, posId, maquina); Logger.Log("Llamada Forecourt.EventsDisabled"); Forecourt.EventsDisabled = false; TankGaugeCollection tgcSondaa = GetTankGaugeCollection(); Logger.Log("Llamada IFCConfig.TankGauges con exito", tgcSondaa); if (tgcSondaa.Count > 0) { foreach (PSS_Forecourt_Lib.TankGauge tankInfo in tgcSondaa) { var tank = new TankGauge { Id = Convert.ToInt32(tankInfo.Id), DataCollection = new List <TankGaugeData>(tankInfo.DataCollection.Count) }; TankGaugeDataCollection tankGaugeDataCollection = GetTankGaugeDataCollection(tankInfo); Logger.Log("Llamada TankGaugeDataCollection con exito.", tankGaugeDataCollection); foreach (PSS_Forecourt_Lib.TankGaugeData tgdData in tankGaugeDataCollection) { tank.DataCollection.Add(new TankGaugeData { Data = tgdData.Data, TankDataId = (TankDataId)tgdData.TankDataId }); } ret.Add(tank); } } Logger.Log("Salida", ret); return(ret); } catch (Exception e) { Logger.LogException(e); throw; } finally { _performDisconnect(); _DOMSSemaphore.Release(); } }
/// <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"); }