public static Boolean fnIniciarLectorSonda(string bytPosID, string strHost, out Forecourt fc, out IFCConfig ifc, string idmaquina) { fc = new Forecourt(); ifc = null; //fc.TankGaugeCfgChanged += new _IForecourtEvents_TankGaugeCfgChangedEventHandler(FC_TankGaugeCfgChanged); string logon = "POS,UNSO_FPSTA_2,APPL_ID=" + idmaquina; fc.PosId = Convert.ToByte(bytPosID); fc.HostName = strHost; fc.Disconnect(); string strEstadoSonda = "Initialize"; fc.Initialize(); strEstadoSonda = "Logon"; ifc = (IFCConfig)fc; int cnt = 0; bool auxLogon = false; FcLogonParms objParametro = new FcLogonParms(); do { cnt++; try { objParametro.EnableFcEvent(FcEvents.xxxxCfgChanged); fc.FcLogon2(logon, objParametro); auxLogon = true; } catch { if (cnt == 3) { throw new Exception("Intento de Conexión 3 veces fallida" + strEstadoSonda); } Thread.Sleep(1000); // Pausa de 1 segundo para reintentar el Logon } } while ((cnt < 3) && !auxLogon); return(auxLogon); }
static void Main(string[] args) { //Conexión de prueba Forecourt fc = new Forecourt(); fc.PosId = 60; fc.HostName = "83.56.16.44"; FcLogonParms fcLogonParams = new FcLogonParms(); fc.Disconnect(); fc.Initialize(); IDomsPos idp = (IDomsPos)fc; fcLogonParams.EnableFcEvent(FcEvents.xxxxCfgChanged); fcLogonParams.EnableFcEvent(FcEvents.TankGaugeStatusChanged); fc.FcLogon2("POS,UNSO_TGSTA_2,RI,APPL_ID=SvcTPVCOFO", fcLogonParams); //Llamar a método estático desde libreria DOMSLibrary string path = Assembly.GetExecutingAssembly().Location; path = path.Substring(0, (path.Length - 16)); string lib = "DOMSLibrary"; Assembly ass = Assembly.LoadFile(path + "Lib\\" + lib + ".dll");//Ruta de DOMSLibrary.dll Type tipo = ass.GetType(lib + ".DOMSTankGaugeAlarms"); MethodInfo metodo = tipo.GetMethod("GetTankGaugeAlarmTxt"); //Ejecutar el metodo y guardar el retorno string resultado = metodo.Invoke(null, new object[] { idp, (byte)3 }).ToString(); Console.WriteLine("TEST20180618: " + resultado); Console.WriteLine("\nA la espera.\nPulse Esc para salir...\n"); while (Console.ReadKey().Key != ConsoleKey.Escape) { ; } }
/// <summary> /// PRECONDITION: LLAMAR DENTRO DE BLOQUE CRITICO /// </summary> private void _performDisconnect() { Logger.Log("Llamada Forecourt.Disconnect"); Forecourt.Disconnect(); Logger.Log("Llamada Forecourt.Disconnect con exito"); }