Exemple #1
0
        /// <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();
            }
        }
Exemple #2
0
        public string fnGetAlarm(string pstrHost, string pbytPosId, string pscompany, string pstoreID, string psUserID, string pstrMaquina, Forecourt fc0, IFCConfig ifc0)
        {
            AlarmTank           objAlarmTank = null;
            List <AlarmTank>    lstAlarmTank = null;
            TankGaugeCollection tgcSondaa    = null;
            string       json           = "";
            string       strFechaIso    = "";
            TgMainStates tmsMainState   = 0;
            byte         bytStatus      = 0;
            int          intAlarmStatus = 0;

            try
            {
                Thread.Sleep(5000);
                fc0.EventsDisabled = false;
                tgcSondaa          = (TankGaugeCollection)ifc0.TankGauges;

                if (tgcSondaa.Count > 0)
                {
                    lstAlarmTank = new List <AlarmTank>();
                    strFechaIso  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                    foreach (PSS_Forecourt_Lib.TankGauge tgesondaa2 in tgcSondaa)
                    {
                        tgesondaa2.GetStatus(out tmsMainState, out bytStatus, out intAlarmStatus);

                        if (Convert.ToByte(TgStatusBits.TGS_ALARM) == bytStatus)
                        {
                            objAlarmTank             = new AlarmTank();
                            objAlarmTank.Ncompany    = pscompany;
                            objAlarmTank.StoreID     = pstoreID;
                            objAlarmTank.Date        = strFechaIso;
                            objAlarmTank.UserID      = psUserID;
                            objAlarmTank.TgID        = tgesondaa2.Id;
                            objAlarmTank.bitAlarm    = bytStatus;
                            objAlarmTank.AlarmStatus = intAlarmStatus;
                            lstAlarmTank.Add(objAlarmTank);
                        }
                    }
                    json = TransformJson(lstAlarmTank);
                }
                else
                {
                    json = "";
                }

                return(json);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// Obtiene los TankGauges desde IFC.
        /// 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 TankGaugeCollection GetTankGaugeCollection()
        {
            for (int i = 0; i < Configuration.MaxAttemptsToReadTankGauges; i++)
            {
                Logger.Log($"Intento {i + 1} de lectura TankGauge");
                TankGaugeCollection ret = IFCConfig.TankGauges;
                if (ret.Count > 0)
                {
                    return(ret);
                }
                Logger.Log($"Intento {i + 1} de lectura TankGauge con resultado vacio. Paramos hilo {Configuration.SleepingMillisecondsBetweenAttemptsToReadTankGauges} ms");

                System.Threading.Thread.CurrentThread.Join(Configuration.SleepingMillisecondsBetweenAttemptsToReadTankGauges);
            }
            throw new InvalidOperationException($"No se ha recuperado TankGauges tras {Configuration.MaxAttemptsToReadTankGauges} intentos");
        }