//---------------------------------------------------------------------------
#pragma hdrstop

#include "LogFunctions.h"       // переменные для отправки сообщений в лог
#include "Main.h"               // переменные для работы с главной формой
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
//--- ВЫВОД В ЛОГ ВРЕМЕНИ НАЧАЛА ОПЕРАЦИИ -----------------------------------
//---------------------------------------------------------------------------
void SendStartTimeToLog()
{ struct  time t;

  // получаем время и пишем его в лог
  gettime(&t);
  Form1->RichEdit5->Lines->Add("Start time: "+IntToStr(t.ti_hour)+":"+IntToStr(t.ti_min)+":"+IntToStr(t.ti_sec));
}
//---------------------------------------------------------------------------
//--- ВЫВОД В ЛОГ ВРЕМЕНИ ОКОНЧАНИЯ ОПЕРАЦИИ --------------------------------
//---------------------------------------------------------------------------
void SendEndTimeToLog()
{ struct  time t;

  // получаем время и пишем его в лог
  gettime(&t);
  Form1->RichEdit5->Lines->Add("End time: "+IntToStr(t.ti_hour)+":"+IntToStr(t.ti_min)+":"+IntToStr(t.ti_sec));
}
//---------------------------------------------------------------------------
//--- ВЫВОД В ЛОГ СООБЩЕНИЙ НА ВЫБРАННОМ ЯЗЫКЕ ------------------------------
//---------------------------------------------------------------------------
void SendMsgToLog(unsigned int MsgNum, AnsiString AddMsg)
{ //-------------------------------------------------------------------------
  // таблица сообщений ------------------------------------------------------
  //-------------------------------------------------------------------------
  AnsiString   MSG_0  = "";                                     // через это сообщение можно будет выводить всё, что угодно
  AnsiString   MSG_1  = "The COM-port is open: ";
  AnsiString   MSG_2  = "Error. The COM-port is not available";
  AnsiString   MSG_3  = "The COM-port is closed";
  AnsiString   MSG_4  = "Error getting the COM-port parameters";
  AnsiString   MSG_5  = "Error setting the COM-port parameters";
  AnsiString   MSG_6  = "Error executing commands: ";
  AnsiString   MSG_7  = "Error reading the answer";
  AnsiString   MSG_8  = "Log saved to file: ";
  AnsiString   MSG_9  = "Selected programmer is: ";
  AnsiString   MSG_10 = "Loading program from file: ";
  AnsiString   MSG_11 = "Loading data from file: ";
  AnsiString   MSG_12 = "Operation complete";
  AnsiString   MSG_13 = "Wrong file";
  AnsiString   MSG_14 = "No chip selected";
  AnsiString   MSG_15 = "Selected chip is ";
  AnsiString   MSG_16 = "Saving program to file: ";
  AnsiString   MSG_17 = "Saving data to file: ";
  AnsiString   MSG_18 = "Trying to";
  AnsiString   MSG_19 = "       Finished";
  AnsiString   MSG_20 = "Command is not available for this chip";

  switch(MsgNum)
  { case 0:   Form1->RichEdit5->Lines->Add(MSG_0+AddMsg);
              break;
    case 1:   Form1->RichEdit5->Lines->Add(MSG_1+AddMsg);
              break;
    case 2:   Form1->RichEdit5->Lines->Add(MSG_2+AddMsg);
              break;
    case 3:   Form1->RichEdit5->Lines->Add(MSG_3+AddMsg);
              break;
    case 4:   Form1->RichEdit5->Lines->Add(MSG_4+AddMsg);
              break;
    case 5:   Form1->RichEdit5->Lines->Add(MSG_5+AddMsg);
              break;
    case 6:   Form1->RichEdit5->Lines->Add(MSG_6+AddMsg);
              break;
    case 7:   Form1->RichEdit5->Lines->Add(MSG_7+AddMsg);
              break;
    case 8:   Form1->RichEdit5->Lines->Add(MSG_8+AddMsg);
              break;
    case 9:   Form1->RichEdit5->Lines->Add(MSG_9+AddMsg);
              break;
    case 10:  Form1->RichEdit5->Lines->Add(MSG_10+AddMsg);
              break;
    case 11:  Form1->RichEdit5->Lines->Add(MSG_11+AddMsg);
              break;
    case 12:  Form1->RichEdit5->Lines->Add(MSG_12+AddMsg);
              break;
    case 13:  Form1->RichEdit5->Lines->Add(MSG_13+AddMsg);
              break;
    case 14:  Form1->RichEdit5->Lines->Add(MSG_14+AddMsg);
              break;
    case 15:  Form1->RichEdit5->Lines->Add(MSG_15+AddMsg);
              break;
    case 16:  Form1->RichEdit5->Lines->Add(MSG_16+AddMsg);
              break;
    case 17:  Form1->RichEdit5->Lines->Add(MSG_17+AddMsg);
              break;
    case 18:  Form1->RichEdit5->Lines->Add(MSG_18+AddMsg);
              break;
    case 19:  Form1->RichEdit5->Lines->Add(MSG_19+AddMsg);
              break;
    case 20:  Form1->RichEdit5->Lines->Add(MSG_20+AddMsg);
              break;
    default:  break;
  }
}
//---------------------------------------------------------------------------
