private void flushEmptyMinute(DateTime oDateNow, int nMinute, int nLine)
        {
            string sPathFilename     = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";
            string sPathFilenameCopy = Program.FOLDER_DESTINY_COPY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";
            int    nRowStart         = 4;

            if (File.Exists(sPathFilename))
            {
                Microsoft.Office.Interop.Excel.Application oExcelApplication = new Microsoft.Office.Interop.Excel.Application();
                oExcelApplication.Visible = false;

                Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks;
                Microsoft.Office.Interop.Excel.Workbook  oExcelWorkBook  = oExcelWorkBooks.Open(sPathFilename);

                for (int i = 1; i <= Program.nNumElements; i++)
                {
                    if ((Program.bShowLog) && (Program.bShowVerboseLog))
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Volcando la fecha y la hora al Fichero Excel del contaminante " + i.ToString() + " la línea " + nLine, false);
                    }

                    Microsoft.Office.Interop.Excel.Worksheet oWorkSheet = oExcelWorkBook.Worksheets[(i + 1)];
                    oWorkSheet.Cells[(nMinute + nRowStart + 1).ToString(), "A"] = "'" + oDateNow.Day.ToString().PadLeft(2, '0') + "/" + oDateNow.Month.ToString().PadLeft(2, '0') + "/" + oDateNow.Year + " " + oDateNow.Hour.ToString().PadLeft(2, '0') + ":" + nMinute.ToString().PadLeft(2, '0') + ":00";
                    nullExcelObject(oWorkSheet);

                    if ((Program.bShowLog) && (Program.bShowVerboseLog))
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Fecha y hora volcandos al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " de forma correcta", false);
                    }
                }

                try {
                    oExcelWorkBook.Save();
                    Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos salvados al Fichero Excel de la línea " + nLine + " de forma correcta", false);

                    if (nMinute == 59)
                    {
                        if (File.Exists(sPathFilenameCopy))
                        {
                            File.Delete(sPathFilenameCopy);
                        }
                        oExcelWorkBook.SaveAs(sPathFilenameCopy, XlFileFormat.xlExcel5);

                        if (Program.bShowLog)
                        {
                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Copia del Fichero Excel de la línea " + nLine + " realizada correctamente", false);
                        }
                    }
                } catch (Exception) {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error salvando los datos del Fichero Excel de la línea " + nLine, false);
                    }
                }

                oExcelWorkBook.Close(false);
                nullExcelObject(oExcelWorkBook);

                oExcelWorkBooks.Close();
                nullExcelObject(oExcelWorkBooks);

                oExcelApplication.Application.Quit();
                nullExcelObject(oExcelApplication);

                killExcelProcesses();

                FileFormatXEAC oFileFormatXEAC = new FileFormatXEAC();
                if (oFileFormatXEAC.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1)))
                {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC", false);
                    }
                }
                oFileFormatXEAC = null;

                FileFormatXEACReports oFileFormatXEACReports = new FileFormatXEACReports();
                if (oFileFormatXEACReports.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1)))
                {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC - Reports", false);
                    }
                }
                oFileFormatXEACReports = null;
            }
        }
        private void cleanOPCReaderValues(DateTime oDateNow, int nMinute, int nLine)
        {
            string sPathFilename     = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";
            string sPathFilenameCopy = Program.FOLDER_DESTINY_COPY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";

            if (File.Exists(sPathFilename))
            {
                Microsoft.Office.Interop.Excel.Application oExcelApplication = new Microsoft.Office.Interop.Excel.Application();
                oExcelApplication.Visible = false;

                Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks;
                Microsoft.Office.Interop.Excel.Workbook  oExcelWorkBook  = oExcelWorkBooks.Open(sPathFilename);

                for (int i = 1; i <= Program.nNumElements; i++)
                {
                    if ((Program.bShowLog) && (Program.bShowVerboseLog))
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Volcando datos al Fichero Excel del contaminante " + i.ToString() + " la línea " + nLine + " {" + Program.oBeforeElementsValues[i - 1].getDirtyValue().ToString() + ", " + Program.oBeforeElementsValues[i - 1].getRealValue().ToString() + ", " + Program.oBeforeElementsValues[i - 1].getType() + "}", false);
                    }

                    ElementValue oElementValue = new ElementValue(Program.oBeforeElementsValues[i - 1].getDirtyValue(), Program.oBeforeElementsValues[i - 1].getRealValue(), Program.oBeforeElementsValues[i - 1].getType(), Program.oBeforeElementsValues[i - 1].getQAL2Min(), Program.oBeforeElementsValues[i - 1].getQAL2Max(), Program.oBeforeElementsValues[i - 1].getQAL2A(), Program.oBeforeElementsValues[i - 1].getQAL2B());
                    Microsoft.Office.Interop.Excel.Worksheet oWorkSheet = oExcelWorkBook.Worksheets[(i + 1)];
                    flushMinuteValue(oWorkSheet, oDateNow, nMinute, oElementValue, (i - 1));
                    oElementValue = null;
                    nullExcelObject(oWorkSheet);

                    if ((Program.bShowLog) && (Program.bShowVerboseLog))
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos volcados al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " de forma correcta", false);
                    }
                }

                try {
                    oExcelWorkBook.Save();
                    Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos salvados al Fichero Excel de la línea " + nLine + " de forma correcta", false);

                    if (nMinute == 59)
                    {
                        if (File.Exists(sPathFilenameCopy))
                        {
                            File.Delete(sPathFilenameCopy);
                        }
                        oExcelWorkBook.SaveAs(sPathFilenameCopy, XlFileFormat.xlExcel5);

                        if (Program.bShowLog)
                        {
                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Copia del Fichero Excel de la línea " + nLine + " realizada correctamente", false);
                        }
                    }
                } catch (Exception) {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error salvando los datos del Fichero Excel de la línea " + nLine, false);
                    }
                }

                oExcelWorkBook.Close(false);
                nullExcelObject(oExcelWorkBook);

                oExcelWorkBooks.Close();
                nullExcelObject(oExcelWorkBooks);

                oExcelApplication.Application.Quit();
                nullExcelObject(oExcelApplication);

                killExcelProcesses();

                FileFormatXEAC oFileFormatXEAC = new FileFormatXEAC();
                if (oFileFormatXEAC.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1)))
                {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC", false);
                    }
                }
                oFileFormatXEAC = null;

                FileFormatXEACReports oFileFormatXEACReports = new FileFormatXEACReports();
                if (oFileFormatXEACReports.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1)))
                {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC - Reports", false);
                    }
                }
                oFileFormatXEACReports = null;
            }
        }
        private void timerHandler(object source, ElapsedEventArgs e)
        {
            DateTime oDateNow = DateTime.Now;
            int      nMinute  = oDateNow.Minute;

            lock (oThreadLockResource) {
                Microsoft.Office.Interop.Excel.Application oExcelApplication = null;
                Microsoft.Office.Interop.Excel.Workbook    oExcelWorkBook    = null;
                HashSet <TagItem> oHashSetTagsValues = null;

                try {
                    try {
                        if (nMinute == 0)
                        {
                            string sLogFile = Program.FOLDER_FILE_LOG + "EmissionsExcel_log_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + ".txt";

                            if (!File.Exists(sLogFile))
                            {
                                if (Program.bShowLog)
                                {
                                    if (Program.oLogFile != null)
                                    {
                                        Program.oLogFile.Flush();
                                        Program.oLogFile.Close();
                                    }

                                    Program.oLogFile = File.AppendText(sLogFile);

                                    DateTime oDateTimeBefore = oDateNow.AddDays(-1);
                                    string   sLogFileBefore  = Program.FOLDER_FILE_LOG + "EmissionsExcel_log_" + oDateTimeBefore.Year.ToString() + oDateTimeBefore.Month.ToString().PadLeft(2, '0') + oDateTimeBefore.Day.ToString().PadLeft(2, '0') + ".txt";

                                    if (File.Exists(sLogFileBefore))
                                    {
                                        File.Move(sLogFileBefore, Program.FOLDER_FILE_LOG_HISTORY + "EmissionsExcel_log_" + oDateTimeBefore.Year.ToString() + oDateTimeBefore.Month.ToString().PadLeft(2, '0') + oDateTimeBefore.Day.ToString().PadLeft(2, '0') + ".txt");
                                    }
                                }
                            }
                        }
                    } catch (Exception) { }

                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{TIMERHANDLER_START:OK} Llamada al evento {timerHandler} al segundo " + oDateNow.Second, true);
                    }

                    if (nMinute != Program.nLastMinute)
                    {
                        Program.nLastMinute = nMinute;
                        if (Program.bShowLog)
                        {
                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Creando valores de los contaminantes sobre el minuto " + oDateNow.Minute, false);
                        }

                        for (int nLine = 1; nLine <= Program.nNumLines; nLine++)
                        {
                            string sPathFilename = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";
                            if ((!File.Exists(sPathFilename)) || ((File.Exists(sPathFilename)) && (nMinute == 0)))
                            {
                                if ((File.Exists(sPathFilename)) && (nMinute == 0))
                                {
                                    File.Delete(sPathFilename);
                                }

                                oExcelApplication         = new Microsoft.Office.Interop.Excel.Application();
                                oExcelApplication.Visible = false;

                                Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks;
                                oExcelWorkBook = oExcelWorkBooks.Add();
                                createSheets(oExcelApplication, oDateNow);
                                removeDefaultSheets(oExcelApplication);

                                oExcelWorkBook.SaveAs(sPathFilename, XlFileFormat.xlExcel5);
                                oExcelWorkBook.Close(false);
                                nullExcelObject(oExcelWorkBook);

                                oExcelWorkBooks.Close();
                                nullExcelObject(oExcelWorkBooks);

                                oExcelApplication.Application.Quit();
                                nullExcelObject(oExcelApplication);

                                killExcelProcesses();
                            }
                        }

                        oHashSetTagsValues = TryExecuteSyncRead(Program.nTimeoutOPCRead);

                        if ((oHashSetTagsValues != null) && (oHashSetTagsValues.Count == (((Program.nNumElements * 9) + 2) * Program.nNumLines)))
                        {
                            DateTime oDateNowCurrent = DateTime.Now;
                            if (Program.bShowLog)
                            {
                                Program.writeLineInLogFile(Program.oLogFile, "{OK} Se han devuelto todos los valores del OPC de forma correcta sobre el minuto " + oDateNow.Minute + " a la hora: " + oDateNowCurrent.Hour + "h " + oDateNowCurrent.Minute + "m " + oDateNowCurrent.Second + "s", false);
                            }

                            for (int nLine = 1; nLine <= Program.nNumLines; nLine++)
                            {
                                if (Program.bShowLog)
                                {
                                    Program.writeLineInLogFile(Program.oLogFile, "{OK} Creando valores de los contaminantes de la Línea " + nLine + " sobre el minuto " + oDateNow.Minute, false);
                                }

                                Array  oArrayTagsValues  = oHashSetTagsValues.ToArray <TagItem>();
                                string sPathFilename     = Program.FOLDER_DESTINY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";
                                string sPathFilenameCopy = Program.FOLDER_DESTINY_COPY + Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls";

                                if (File.Exists(sPathFilename))
                                {
                                    oExcelApplication         = new Microsoft.Office.Interop.Excel.Application();
                                    oExcelApplication.Visible = false;

                                    Microsoft.Office.Interop.Excel.Workbooks oExcelWorkBooks = oExcelApplication.Workbooks;
                                    oExcelWorkBook = oExcelWorkBooks.Open(sPathFilename);

                                    if (Program.bShowLog)
                                    {
                                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel de la línea " + nLine + " abierto correctamente", false);
                                    }

                                    TagItem oTagItem1, oTagItem2, oTagItem3, oTagItem4, oTagItem5, oTagItem6, oTagItem7, oTagItem8, oTagItem9, oTagItem10, oTagItem11;
                                    for (int i = 1; i <= Program.nNumElements; i++)
                                    {
                                        string sStatus = "V";

                                        int nIndexBase = (((Program.nNumElements * 9) + 2) * (nLine - 1)) + ((i - 1) * 9) + 2;

                                        oTagItem1 = (TagItem)oArrayTagsValues.GetValue((((Program.nNumElements * 9) + 2) * (nLine - 1)));
                                        oTagItem2 = (TagItem)oArrayTagsValues.GetValue((((Program.nNumElements * 9) + 2) * (nLine - 1)) + 1);

                                        oTagItem3 = (TagItem)oArrayTagsValues.GetValue(nIndexBase);
                                        oTagItem4 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 1);
                                        oTagItem5 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 2);
                                        oTagItem6 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 3);
                                        oTagItem7 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 4);

                                        oTagItem8  = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 5);
                                        oTagItem9  = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 6);
                                        oTagItem10 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 7);
                                        oTagItem11 = (TagItem)oArrayTagsValues.GetValue(nIndexBase + 8);

                                        if (oTagItem1.getValue() == "1")
                                        {
                                            sStatus = "A";
                                        }
                                        else if (oTagItem2.getValue() == "1")
                                        {
                                            sStatus = "P";
                                        }
                                        else if (oTagItem5.getValue() == "1")
                                        {
                                            sStatus = "V";
                                        }
                                        else if (oTagItem6.getValue() == "1")
                                        {
                                            sStatus = "C";
                                        }
                                        else if (oTagItem7.getValue() == "1")
                                        {
                                            sStatus = "N";
                                        }

                                        if ((Program.bShowLog) && (Program.bShowVerboseLog))
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Volcando datos al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " {" + oTagItem3.getName().ToString() + ":" + oTagItem3.getValue().ToString() + ", " + oTagItem4.getName().ToString() + ":" + oTagItem4.getValue().ToString() + ", Status: " + sStatus + "}", false);
                                        }

                                        ElementValue oElementValue = new ElementValue(oTagItem3.getValue(), oTagItem4.getValue(), sStatus, oTagItem8.getValue(), oTagItem9.getValue(), oTagItem10.getValue(), oTagItem11.getValue());
                                        Microsoft.Office.Interop.Excel.Worksheet oWorkSheet = oExcelWorkBook.Worksheets[(i + 1)];
                                        flushMinuteValue(oWorkSheet, oDateNow, nMinute, oElementValue, (i - 1));
                                        oElementValue = null;

                                        oTagItem1  = null; oTagItem2 = null; oTagItem3 = null; oTagItem4 = null; oTagItem5 = null;
                                        oTagItem6  = null; oTagItem7 = null; oTagItem8 = null; oTagItem9 = null; oTagItem10 = null;
                                        oTagItem11 = null;

                                        nullExcelObject(oWorkSheet);

                                        if ((Program.bShowLog) && (Program.bShowVerboseLog))
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos volcados al Fichero Excel del contaminante " + i.ToString() + " de la línea " + nLine + " de forma correcta", false);
                                        }
                                    }

                                    try {
                                        oExcelWorkBook.Save();
                                        Program.writeLineInLogFile(Program.oLogFile, "{OK} Datos salvados al Fichero Excel de la línea " + nLine + " de forma correcta", false);

                                        if (nMinute == 59)
                                        {
                                            if (File.Exists(sPathFilenameCopy))
                                            {
                                                File.Delete(sPathFilenameCopy);
                                            }
                                            oExcelWorkBook.SaveAs(sPathFilenameCopy, XlFileFormat.xlExcel5);

                                            if (Program.bShowLog)
                                            {
                                                Program.writeLineInLogFile(Program.oLogFile, "{OK} Copia del Fichero Excel de la línea " + nLine + " realizada correctamente", false);
                                            }
                                        }
                                    } catch (Exception) {
                                        if (Program.bShowLog)
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error salvando los datos del Fichero Excel de la línea " + nLine, false);
                                        }
                                    }

                                    oExcelWorkBook.Close(false);
                                    nullExcelObject(oExcelWorkBook);

                                    oExcelWorkBooks.Close();
                                    nullExcelObject(oExcelWorkBooks);

                                    oExcelApplication.Application.Quit();
                                    nullExcelObject(oExcelApplication);

                                    killExcelProcesses();

                                    FileFormatXEAC oFileFormatXEAC = new FileFormatXEAC();
                                    if (oFileFormatXEAC.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1)))
                                    {
                                        if (Program.bShowLog)
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC", false);
                                        }
                                    }
                                    oFileFormatXEAC = null;

                                    FileFormatXEACReports oFileFormatXEACReports = new FileFormatXEACReports();
                                    if (oFileFormatXEACReports.convertExcelFile(Program.FILE_EXCEL_TOKEN_NAME + "DayExcelL" + nLine + "_" + oDateNow.Year.ToString() + oDateNow.Month.ToString().PadLeft(2, '0') + oDateNow.Day.ToString().PadLeft(2, '0') + "_" + oDateNow.Hour.ToString().PadLeft(2, '0') + "00_A_Hour_Hourly.xls", (nMinute + 1)))
                                    {
                                        if (Program.bShowLog)
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{OK} Fichero Excel convertido al formato de la XEAC - Reports", false);
                                        }
                                    }
                                    oFileFormatXEACReports = null;
                                }
                                else
                                {
                                    if (Program.bShowLog)
                                    {
                                        Program.writeLineInLogFile(Program.oLogFile, "{ERROR} No existe el Fichero Excel de la Línea " + nLine, false);
                                    }
                                }

                                oArrayTagsValues = null;
                            }
                        }
                        else
                        {
                            if (Program.bShowLog)
                            {
                                Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han devuelto todos los valores del OPC sobre el evento {timerHandler}", false);
                            }

                            killExcelProcesses();

                            if (Program.sMethod == "BEST_EFFORT")
                            {
                                if (Program.bShowLog)
                                {
                                    Program.writeLineInLogFile(Program.oLogFile, "{WARNING} Creando valores anteriores de los contaminantes sobre el minuto " + oDateNow.Minute, false);
                                }
                            }
                            else
                            {
                                if (Program.bShowLog)
                                {
                                    Program.writeLineInLogFile(Program.oLogFile, "{WARNING} Creando líneas vacias de los contaminantes sobre el minuto " + oDateNow.Minute, false);
                                }
                            }

                            for (int nLine = 1; nLine <= Program.nNumLines; nLine++)
                            {
                                if (Program.sMethod == "BEST_EFFORT")
                                {
                                    cleanOPCReaderValues(oDateNow, nMinute, nLine);
                                }
                                else
                                {
                                    flushEmptyMinute(oDateNow, nMinute, nLine);
                                }
                            }

                            if (Program.bShowLog)
                            {
                                Program.writeLineInLogFile(Program.oLogFile, "{WARNING} Fin de la creación de valores anteriores de los contaminantes", false);
                            }
                        }
                    }
                } catch (Exception err) {
                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Se ha producido una excepción sobre el evento {timerHandler:" + err.ToString() + "}", false);
                    }

                    killExcelProcesses();

                    if (Program.sMethod == "BEST_EFFORT")
                    {
                        if (Program.bShowLog)
                        {
                            Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Creando valores anteriores de los contaminantes sobre el minuto " + oDateNow.Minute, false);
                        }
                    }
                    else
                    {
                        if (Program.bShowLog)
                        {
                            Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Creando líneas vacias de los contaminantes sobre el minuto " + oDateNow.Minute, false);
                        }
                    }

                    for (int nLine = 1; nLine <= Program.nNumLines; nLine++)
                    {
                        if (Program.sMethod == "BEST_EFFORT")
                        {
                            cleanOPCReaderValues(oDateNow, nMinute, nLine);
                        }
                        else
                        {
                            flushEmptyMinute(oDateNow, nMinute, nLine);
                        }
                    }

                    if (Program.bShowLog)
                    {
                        Program.writeLineInLogFile(Program.oLogFile, "{EXCEPTION} Fin de la creación de valores anteriores de los contaminantes", false);
                    }
                }

                // Clean memory
                oHashSetTagsValues = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();

                if (Program.bShowLog)
                {
                    Program.writeLineInLogFile(Program.oLogFile, "{TIMERHANDLER_END:OK} Fin de la llamada al evento {timerHandler}", false);
                }
            }
        }