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); }