From deba5d7e96f9b891a6f7659a2a7ea73514393c9c Mon Sep 17 00:00:00 2001 From: Angel Ivan Date: Fri, 15 May 2026 10:59:31 -0600 Subject: [PATCH] =?UTF-8?q?Se=20agreg=C3=B3=20un=20timer=20para=20obtener?= =?UTF-8?q?=20el=20tiempo=20de=20ejecuci=C3=B3n=20del=20programa.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BackupCognex/Program.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/BackupCognex/Program.cs b/BackupCognex/Program.cs index 4cc9d6a..efe79a1 100644 --- a/BackupCognex/Program.cs +++ b/BackupCognex/Program.cs @@ -1,4 +1,6 @@ using System; +using System; +using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Threading; @@ -8,6 +10,9 @@ class Program { static void Main(string[] args) { + // Iniciar cronómetro para medir tiempo de ejecución + Stopwatch timer = Stopwatch.StartNew(); + // 1. Leer configuración desde config.txt string exeDirectory = AppDomain.CurrentDomain.BaseDirectory; string configDirectory = "C:\\Jabil DM Config Station\\Files\\"; @@ -107,14 +112,18 @@ class Program } catch (Cognex.DataMan.SDK.UnknownErrorException ex) { + timer.Stop(); Console.WriteLine("\n[ERROR COGNEX] El lector rechazó la operación."); Console.WriteLine("Comando que falló: " + ex.Command); Console.WriteLine("Detalle: " + ex.Message); + Console.WriteLine($"Tiempo transcurrido: {timer.Elapsed.TotalSeconds:F2} segundos"); ActualizarEstadoLabVIEW(2, exeDirectory, labviewFolder); // Error } catch (Exception ex) { + timer.Stop(); Console.WriteLine("\n[ERROR GENERAL]: " + ex.Message); + Console.WriteLine($"Tiempo transcurrido: {timer.Elapsed.TotalSeconds:F2} segundos"); ActualizarEstadoLabVIEW(2, exeDirectory, labviewFolder); // Error } finally @@ -134,6 +143,16 @@ class Program catch { Console.WriteLine("Aviso: No se pudieron eliminar algunos archivos temporales."); } } + Console.WriteLine("\nEsperando 30 segundos hasta que se reinicie el lector"); + Thread.Sleep(30000); + + timer.Stop(); + TimeSpan tiempoTotal = timer.Elapsed; + Console.WriteLine($"\n================================================"); + Console.WriteLine($"Tiempo total de ejecución: {tiempoTotal.TotalSeconds:F2} segundos"); + Console.WriteLine($"Desglose: {tiempoTotal.Hours}h {tiempoTotal.Minutes}m {tiempoTotal.Seconds}s {tiempoTotal.Milliseconds}ms"); + Console.WriteLine($"================================================"); + Console.WriteLine("\nLa aplicación se cerrará automáticamente en 5 segundos..."); Thread.Sleep(5000); }