//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "monitoring.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMon *Mon;
//---------------------------------------------------------------------------
__fastcall TMon::TMon(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMon::Timer1Timer(TObject *Sender)
{
        char ch[256];
        int t, i, m, s, min;
        Timer1->Enabled=false;
        getdate(&dd);
        gettime(&tt);
        sprintf(ch,"%02d-%02d-%04d",dd.da_day,dd.da_mon,dd.da_year);
        StatusBar1->Panels->Items[0]->Text=ch;
        sprintf(ch,"%02d:%02d:%02d",tt.ti_hour,tt.ti_min,tt.ti_sec);
        StatusBar1->Panels->Items[1]->Text=ch;
        Nst[1]=tt.ti_hour*4+tt.ti_min/15;
        Nst[0]=DayYear(dd.da_year, dd.da_mon, dd.da_day);
        if(CheckBox2->Checked)
        {
        t=tt.ti_min*60+tt.ti_sec;
        min=100000;
        for(i=0; i<Nz; i++) if(min>tz[i]-t && tz[i]-t>=0) min=tz[i]-t;
        m=min/60;
        s=min-m*60;
        sprintf(ch,"Зондирование через %02d:%02d",m,s);
        StatusBar1->Panels->Items[2]->Text=ch;
        if(min==0)
        {
        RadioSounding();
        //Ion->IzobrIon();
        Ion->SaveIon(dd.da_year, dd.da_mon, dd.da_day, tt.ti_hour,tt.ti_min,tt.ti_sec);
        SaveIon2(dd.da_year, dd.da_mon, dd.da_day, tt.ti_hour,tt.ti_min,tt.ti_sec);
        /*
        unlink("f:\\calend");
        IQ->Tm=0;
        IQ->ProgressBar1->Position=0;
        IQ->ProgressBar1->Max=8;
        IQ->ProgressBar2->Position=0;
        IQ->ProgressBar3->Position=0;
        IQ->Timer1->Enabled=true;
        IQ->Visible=true;
        */
        //Application->MessageBox("Идет сеанс радиозондирования", "Радиозондирование", MB_OK);
        }
        }
        else StatusBar1->Panels->Items[2]->Text="Мониторинг остановлен";
        Timer1->Enabled=true;
}
//---------------------------------------------------------------------------
int TMon::DayYear(int year, int mon, int day)
{
        int m, nday=day;
        int mons[12]={31,28,31,30,31,30,31,31,30,31,30,31};
        if((int)(year/4)*4==year) mons[1]=29;
        for(m=1; m<mon; m++) nday+=mons[m];
        return nday;
}
//---------------------------------------------------------------------------
void TMon::ReadTime(void)
{
        int t0, t1, i, m, s;
        sscanf(Edit2->Text.c_str(),"%2d:%2d",&m,&s);
        t0=m*60+s;
        sscanf(ComboBox2->Text.c_str(),"%d",&m);
        t1=m*60;
        Nz=60/m;
        for(i=0; i<Nz; i++)
        {
        tz[i]=t0+t1*i;
        //if(tz[i]<180) tz[i]+=3600;
        }
}
//---------------------------------------------------------------------------
void __fastcall TMon::FormCreate(TObject *Sender)
{
        FILE *f0;
        int i;
        char ch[256];
        Pars.I=scn.nF/2;
        Pars.J=200;
        YN=1;
        Mon->Left=MainForm->Left+4;
        Mon->Top=MainForm->Top+MainForm->Height+4;
        f0=fopen("monitoring.ini","rt");
        fscanf(f0,"%d",&ynm);
        if(ynm==1) CheckBox2->Checked=true;
        else CheckBox2->Checked=false;
        fscanf(f0,"%d",&ntm);
        ComboBox2->Clear();
        for(i=0; i<ntm; i++)
        {
                fscanf(f0,"%d",&tm);
                ComboBox2->Items->Add(IntToStr(tm));
        }
        fscanf(f0,"%d",&tm);
        ComboBox2->ItemIndex=tm;
        fscanf(f0,"%s",&ch);
        Edit2->Text=ch;
        fscanf(f0,"%d",&yns);
        if(yns==1) CheckBox1->Checked=true;
        else CheckBox1->Checked=false;
        fscanf(f0,"%d",&ms);
        Edit1->Text=IntToStr(ms);
        fscanf(f0,"%d",&ns);
        ComboBox1->Clear();
        for(i=0; i<ns; i++)
        {
                fscanf(f0,"%s",&ch);
                ComboBox1->Items->Add(ch);
        }
        fscanf(f0,"%d",&tm);
        ComboBox1->ItemIndex=tm;
        fclose(f0);
//        ReadPar();
        f0=fopen("..\\scenary\\Основной сценарий.scn","rb");
        fread(&scn,256,1,f0);
        fclose(f0);
        ReadIonPars();
        ReadTime();
}
//---------------------------------------------------------------------------
void TMon::ReadIonPars(void)  // Чтение суточного хода foE, foF2, fxF2
{
        FILE *f0;
        int i, n=96;
        f0=fopen("c:\\tomion\\monitoring\\ionpars.dat","rb");
        fread(FoE,4,n,f0);
        fread(FoF2,4,n,f0);
        fread(FxF2,4,n,f0);
        fread(Nst0,4,16,f0);
        if(Nst0[3]>0) fread(Sverh,4,Nst0[3],f0);
        if(Nst0[5]>0) fread(SXverh,4,Nst0[5],f0);
        if(Nst0[7]>0) fread(SEniz,4,Nst0[7],f0);
        if(Nst0[9]>0) fread(SEsniz,4,Nst0[9],f0);
        fclose(f0);
}
//---------------------------------------------------------------------------
void TMon::SaveIonPars(void)  // Сохранение суточного хода foE, foF2, fxF2
{
        FILE *f0;
        int i, n=96;
        f0=fopen("c:\\tomion\\monitoring\\ionpars.dat","wb");
        fwrite(FoE,4,n,f0);
        fwrite(FoF2,4,n,f0);
        fwrite(FxF2,4,n,f0);
        fwrite(Nst,4,16,f0);
        if(Nst[3]>0) fwrite(Sverh,4,Nst[3],f0);
        if(Nst[5]>0) fwrite(SXverh,4,Nst[5],f0);
        if(Nst[7]>0) fwrite(SEniz,4,Nst[7],f0);
        if(Nst[9]>0) fwrite(SEsniz,4,Nst[9],f0);
        fclose(f0);
        for(i=0; i<16; i++) Nst0[i]=Nst[i];
}
//---------------------------------------------------------------------------
void TMon::ReadPar(void)
{
        FILE *f0;
        char ch[256];
        float longi, lati, lenbase;
        AnsiString ShifrStation;
        f0=fopen("radar.ini","rt");
        fscanf(f0,"%s",&ch); ShifrStation=AnsiString(ch);
        fscanf(f0,"%f",&longi);
        fscanf(f0,"%f",&lati);
        fscanf(f0,"%f",&lenbase);
        fclose(f0);
}
//---------------------------------------------------------------------------
void __fastcall TMon::ComboBox2Change(TObject *Sender)
{
        ReadTime();
}
//---------------------------------------------------------------------------
void __fastcall TMon::Button2Click(TObject *Sender)
{
        FILE *f0;
        int i;
        char ch[256];
        f0=fopen("monitoring.ini","wt");
        if(CheckBox2->Checked) fprintf(f0,"1\n");
        else fprintf(f0,"0\n");
        fprintf(f0,"%d\n",ComboBox2->Items->Count);
        for(i=0; i<ComboBox2->Items->Count; i++) fprintf(f0,"%s\n",ComboBox2->Items->Strings[i]);
        fprintf(f0,"%d\n",ComboBox2->ItemIndex);
        fprintf(f0,"%s\n",Edit2->Text.c_str());
        if(CheckBox1->Checked) fprintf(f0,"1\n");
        else fprintf(f0,"0\n");
        fprintf(f0,"%s\n",Edit1->Text.c_str());
        fprintf(f0,"%d\n",ComboBox1->Items->Count);
        for(i=0; i<ComboBox1->Items->Count; i++) fprintf(f0,"%s\n",ComboBox1->Items->Strings[i]);
        fprintf(f0,"%d\n",ComboBox1->ItemIndex);
        fclose(f0);
}
//---------------------------------------------------------------------------
void TMon::CreatScen(void)
{
        FILE *f0;
        int i;
        getdate(&dd);
        gettime(&tt);
        f0=fopen("afh.ini","rt");
        for(i=0; i<26; i++) fscanf(f0,"%d",&data[i]);
        fclose(f0);
        ReadPar();
        Del_bin();
        CalSignal();
//        CalSignal2();
        Sounding();
        Ion->SaveIon(dd.da_year, dd.da_mon, dd.da_day, tt.ti_hour,tt.ti_min,tt.ti_sec);
}
//---------------------------------------------------------------------------
void TMon::Del_bin(void)
{
        int d;
        struct ffblk ff;
        chdir("e:\\");
        d=findfirst("*.bin",&ff,0);
        while(d==0)
        {
        unlink(ff.ff_name);
        d=findnext(&ff);
        }
        chdir("c:\\tomion\\main");
}
//---------------------------------------------------------------------------
void TMon::Sounding(void)
{
        FILE *f0, *f1;
        struct ffblk ff;
        int i, j, k, k1, l, m, p, d, n=60000, v, pp, jf, nimp, dt, nn, bufsize=16000; //12800;
        float amax=1.0/scn.nf, t, a, b;
        float pi2=atan(1.0)*8.0;
        char ch[256];
        nn=scn.nF/8/scn.ng;
        f0=fopen("e:\\zond.ini","wt");
        fprintf(f0,"%d\n",nn);
        fclose(f0);
        chdir("c:\\tomion\\dac2");
        WinExec("dac2.exe",SW_SHOW);
        chdir("c:\\tomion\\adc");
        WinExec("adc.exe",SW_SHOW);

        ProgressBar1->Max=nn;
        chdir("c:\\tomion\\caliq");
        for(i=0; i<nn; i++)
        {
                ProgressBar1->Position=i;
                Application->ProcessMessages();
                sprintf(ch,"e:\\data%03d_1.bin",i+1);
                while(findfirst(ch,&ff,0)!=0);
                sprintf(ch,"caliq.exe %d %d",i,nn);
                WinExec(ch,SW_SHOW);
        }
        ProgressBar1->Position=0;
        do{
        j=0;
        for(i=0; i<nn; i++)
        {
        sprintf(ch,"e:\\end%03d.bin",i);
        if(findfirst(ch,&ff,0)==0) j++;
        }
        }while(j!=nn);

        f0=fopen("e:\\iq.dat","wb");
        for(i=0; i<scn.nF; i++)
        {
        sprintf(ch,"e:\\iq%03d.bin",Nfile[i]);
        f1=fopen(ch,"rb");
        //первые 4 канала
        for(k=0; k<=Nzap[i]; k++) fread(buff,1,bufsize,f1);
        fwrite(buff,1,bufsize,f0);
        //вторые 4 канала
        for(k=0; k<8*scn.ng; k++) fread(buff,1,bufsize,f1);
        fwrite(buff,1,bufsize,f0);
        fclose(f1);
        }//i
        fclose(f0);
        chdir("c:\\tomion\\main");
}
//---------------------------------------------------------------------------
void TMon::CalSignal(void)
{
       FILE *f0, *f1;
       int i, j, jf, k, n, Agate=32000, dn, m, nm, mm, kk, nnn, nni;
       int Dn, Mdn, Np, Ng;
       float pi2=atan(1.0)*8.0, delta;
       char ch[256];
       f0=fopen("e:\\data.sgn","wb");
       n=scn.pdt/10;
       Dn=scn.dt*100;
       Mdn=n;
       Np=scn.ti*100000;
       Ng=scn.ng;
       nm=scn.nF/Ng;
       ProgressBar1->Max=nm/8;
       for(j=0; j<nm/8; j++)
       {
       ProgressBar1->Position=i;
       sprintf(ch,"e:\\tab%03d.bin",j);
       f1=fopen(ch,"wt");
       fprintf(f1,"e:\\data%03d_0.bin\n",j);
       fprintf(f1,"e:\\data%03d_1.bin\n",j);
       fprintf(f1,"e:\\iq%03d.bin\n",j);
       fprintf(f1,"%d %d\n",j,nm/8);
       fprintf(f1,"%d\n",Ng);
       nnn=0;
       for(mm=0; mm<8; mm++)
       {
       k=0;
       for(m=0; m<Ng; m++)
       {
       kk=j*8+mm+m*nm;
       delta=pi2*TabFreq[kk]/100000.0;
       freq[nnn]=TabFreq[kk];
       smm[nnn]=Mdn+m*(Mdn+2*n+Dn);
       nnn++;
       fprintf(f1,"%f %d\n",TabFreq[kk],Mdn+m*(Mdn+2*n+Dn));
       Nfile[kk]=j;
       Nzap[kk]=mm*Ng+m;
       jf=TabFreq[kk]/1000;
       Amp[kk]=data[jf];
       for(i=0; i<Mdn; i++)
       {
          samples[k][0]=0;
          samples[k][1]=Agate;
          k++;
       }
       for(i=0; i<n; i++)
       {
          samples[k][0]=(int)(((float)Amp[kk]*(float)i/(float)n)*sin((float)k*delta));
          samples[k][1]=Agate;
          k++;
       }
       for(i=0; i<Dn; i++)
       {
          samples[k][0]=(int)((float)Amp[kk]*sin((float)k*delta)); //AmpChan0;
          samples[k][1]=Agate;
          k++;
       }
       for(i=0; i<n; i++)
       {
          samples[k][0]=(int)(((float)Amp[kk]*(float)(n-i)/(float)n)*sin((float)k*delta));
          samples[k][1]=Agate;
          k++;
       }
       }//m
       for(i=0; i<Mdn; i++)
       {
          samples[k][0]=0;
          samples[k][1]=Agate;
          k++;
       }
       for(i=0; i<Np-(Mdn+Dn+2*n)*Ng-Mdn; i++)
       {
          samples[k][0]=0;
          samples[k][1]=0;
          k++;
       }
       fwrite(samples,4,Np,f0);
       }//mm
       for(nni=0; nni<nnn; nni++) fprintf(f1,"%f %d\n",freq[nni],smm[nni]);
       fclose(f1);
       }//j
       fclose(f0);
       ProgressBar1->Position=0;
}
//---------------------------------------------------------------------------
void TMon::CalSignal2(void)
{
       FILE *f0, *f1;
       int i, j, jf, k, n, Agate=8192, dn, m, nm, mm, kk, ki, nnn, nni;
       int Dn, Mdn, Np, Ng;
       float pi2=atan(1.0)*8.0, delta;
       char ch[256];
       f0=fopen("e:\\data.sgn","wb");
       n=scn.pdt/10;
       Dn=scn.dt*100;
       Mdn=n;
       Np=scn.ti*100000;
       Ng=scn.ng;
       nm=scn.nF/Ng;
       ProgressBar1->Max=nm/8;
       for(j=0; j<nm/8; j++)
       {
       ProgressBar1->Position=i;
       sprintf(ch,"e:\\tab%03d.bin",j);
       f1=fopen(ch,"wt");
       fprintf(f1,"e:\\data%03d_0.bin\n",j);
       fprintf(f1,"e:\\data%03d_1.bin\n",j);
       fprintf(f1,"e:\\iq%03d.bin\n",j);
       fprintf(f1,"%d %d\n",j,nm/8);
       fprintf(f1,"%d\n",Ng);
       nnn=0;
       for(mm=0; mm<8; mm++)
       {
       k=0;
       for(m=0; m<Ng; m++)
       {
       kk=j*8+mm+m*nm;
       delta=pi2*TabFreq[kk]/100000.0;
       freq[nnn]=TabFreq[kk];
       smm[nnn]=0; //Mdn+m*(Mdn+2*n+Dn);
       fprintf(f1,"%f %d\n",TabFreq[kk],0);
       nnn++;
       Nfile[kk]=j;
       Nzap[kk]=mm*Ng+m;
       jf=TabFreq[kk]/1000;
       Amp[kk]=data[jf];
       for(i=0; i<kk*500; i++)
       {
          samples[k][0]=0;
          samples[k][1]=0;
          k++;
       }
       for(i=0; i<n; i++)
       {
          samples[k][0]=(int)(((float)Amp[kk]*(float)i/(float)n)*sin((float)k*delta));
          samples[k][1]=(int)(((float)Amp[kk]*(float)i/(float)n)*sin((float)k*delta)-pi2/4.0);
          k++;
       }
       for(i=0; i<Dn; i++)
       {
          samples[k][0]=(int)((float)Amp[kk]*sin((float)k*delta)); //AmpChan0;
          samples[k][1]=(int)((float)Amp[kk]*sin((float)k*delta-pi2/4.0));
          k++;
       }
       for(i=0; i<n; i++)
       {
          samples[k][0]=(int)(((float)Amp[kk]*(float)(n-i)/(float)n)*sin((float)k*delta));
          samples[k][1]=(int)(((float)Amp[kk]*(float)(n-i)/(float)n)*sin((float)k*delta-pi2/4.0));
          k++;
       }
       }//m
       ki=k;
       for(i=ki; i<Np; i++)
       {
          samples[k][0]=0;
          samples[k][1]=0;
          k++;
       }
       fwrite(samples,4,Np,f0);
       }//mm
       for(nni=0; nni<nnn; nni++) fprintf(f1,"%f %d\n",freq[nni],smm[nni]);
       fclose(f1);
       }//j
       fclose(f0);
       ProgressBar1->Position=0;
}
//---------------------------------------------------------------------------
void TMon::Raschet_TabFreq(void)
{
        int j, nF;
        if(scn.flag_pd==1)
        {
                nF=(scn.fmax-scn.fmin)/scn.df; // количество частот при линейном изменении частоты
                scn.nF=(int)(nF/scn.ng/scn.nf/8)*scn.ng*scn.nf*8;
                TabFreq[0]=scn.fmin;
                for(j=1; j<scn.nF; j++) TabFreq[j]=scn.fmin+(float)j*scn.df;
        }
        else
        {
                nF=log(scn.fmax/scn.fmin)/log(1.0+scn.q/100.0); // количество частот при процентном изменении частоты
                scn.nF=(int)(nF/scn.ng/scn.nf/8)*scn.ng*scn.nf*8;
                TabFreq[0]=scn.fmin;
                for(j=1; j<scn.nF; j++) TabFreq[j]=TabFreq[j-1]*(1.0+scn.q/100.0);
        }
}
//---------------------------------------------------------------------------
void TMon::HeadrFTP(FILE *f0)
{
        fprintf(f0,"open 92.63.68.114\n");
        fprintf(f0,"serkol\n");
        fprintf(f0,"serkolpass\n");
        fprintf(f0,"cd sosrff.tsu.ru\n");
        fprintf(f0,"cd new\n");
        fprintf(f0,"cd data\n");
        fprintf(f0,"cd ion\n");
        fprintf(f0,"binary\n");
}
//---------------------------------------------------------------------------
void TMon::SendFileToServer(char *file)
{
        FILE *f0;
        f0=fopen("c:\\tomion\\ion\\receive\\aaa","wt");
        HeadrFTP(f0);
        fprintf(f0,"cd in\n");
        fprintf(f0,"put %s\n",file);
        fprintf(f0,"quit\n");
        fclose(f0);
        chdir("c:\\tomion\\ion\\receive");
        system("ftp -s:aaa");
        unlink("aaa");
        unlink(file);
        chdir("c:\\tomion\\main");
}
//---------------------------------------------------------------------------
void __fastcall TMon::Button3Click(TObject *Sender)
{
        struct ffblk ff;
        SaveIon2(dd.da_year, dd.da_mon, dd.da_day, tt.ti_hour,tt.ti_min,tt.ti_sec);
        if(findfirst("c:\\tomion\\ion\\receive\\*.itm",&ff,0)==0)
        {
        SendFileToServer(ff.ff_name);
        }
}
//---------------------------------------------------------------------------
void TMon::SaveIon2(int year, int mon, int day, int hour, int min, int sec)
{
FILE *f0;
int i, jj, i0;
short ih[400], Nt[1];
unsigned char Nk;
float Amp[400];
char file[1024];
char datas[256];
sprintf(file,"c:\\tomion\\ion\\receive\\%s%02d%02d%02d%02d%02d.itm","38601",year,mon,day,hour,min);
f0=fopen(file,"wb");
//sprintf(datas,"Ver2.0 %s %04d-%02d-%02d %02d:%02d:%02d","38601",year,mon,day,hour,min,sec);
fwrite(&Pars,1,256,f0);
fwrite(&scn,1,256,f0);
fwrite(TabFreq,4,scn.nF,f0);

Pars.fmin=0;
Pars.foF2=0;
Pars.fxF2=0;
Pars.foE=0;
Pars.fxE=0;
Pars.foEs=0;
Pars.fxEs=0;
Pars.hF2=0;
Pars.hE=0;
Pars.hEs=0;
Pars.I=scn.nF/2;
Pars.J=100;

if(Pars.InoF2>0) fwrite(Sverh,4,Pars.InoF2,f0);
if(Pars.InxF2>0) fwrite(SXverh,4,Pars.InxF2,f0);
if(Pars.InE>0) fwrite(SEniz,4,Pars.InE,f0);
if(Pars.InEs>0) fwrite(SEsniz,4,Pars.InEs,f0);
for(i0=0; i0<2; i0++)
for(jj=0; jj<scn.nF; jj++)
{
       Nk=0;
       for(i=0; i<400; i++)
       if(Ion->Aki[i0][jj][i]>0)
       {
       Amp[Nk]=Ion->Aki[i0][jj][i];
       ih[Nk]=i;
       Nk++;
       }
       fputc(Nk,f0);
       if(Nk>0)
       {
       fwrite(ih,2,Nk,f0);
       fwrite(Amp,4,Nk,f0);
       }
}
fclose(f0);
        SendFileToServer(file);
        sprintf(file,"copy e:\\iq.dat c:\\tomion\\ion\\receive\\%s%02d%02d%02d%02d%02d.iq","38601",year,mon,day,hour,min);
        system(file);
}
//----------------------------------------------------------------------
void TMon::ReadFile(char *file)
{
FILE *f0;
int i, jj, i0;
short ih[400], Nt[1];
unsigned char Nk;
float Amp[400];
char datas[256];
f0=fopen(file,"rb");
fread(&Pars,1,256,f0);
fread(&scn,1,256,f0);
fread(TabFreq,4,scn.nF,f0);
if(Pars.InoF2>0) fread(Sverh,4,Pars.InoF2,f0);
if(Pars.InxF2>0) fread(SXverh,4,Pars.InxF2,f0);
if(Pars.InE>0) fread(SEniz,4,Pars.InE,f0);
if(Pars.InEs>0) fread(SEsniz,4,Pars.InEs,f0);
for(i0=0; i0<2; i0++)
{
for(jj=0; jj<scn.nF; jj++)
{
       for(i=0; i<400; i++) Ion->Ak[i0][jj][i]=0;
       Nk=fgetc(f0);
       if(Nk>0)
       {
       fread(ih,2,Nk,f0);
       fread(Amp,4,Nk,f0);
       for(i=0; i<Nk; i++)
       {
         Ion->Ak[i0][jj][ih[i]]=Amp[i];
       }
       }
}
}
fclose(f0);
}
//---------------------------------------------------------------------------
void __fastcall TMon::Button4Click(TObject *Sender)
{
        RadioSounding();
}
//---------------------------------------------------------------------------
void TMon::RadioSounding(void)
{
        CreatScen();
        Ion->Image1->Width=45+Mon->scn.nF;
        Ion->Chart1->Width=Ion->Image1->Width;
        Ion->Width=Ion->Image1->Width+13+Ion->GroupBox1->Width;
        Ion->ReadIQ();
        Ion->InitIon();
        Ion->RashetIon(0,40,Mon->scn.nF,400);
        Ion->OprAkX(0,40,Mon->scn.nF,400);
        Ion->PlotnostY();
        Ion->AkToAki(0,40,Mon->scn.nF,400);
        Ion->Sleds();
        SaveIonPars();
        Ion->Setka();
        Ion->IzobrIon();
        /*
        Ion->Setka();
        Ion->ReadIQ();
        Ion->OprOXXY2(0,40,Mon->scn.nF,400);
        Ion->OprAkX(0,40,Mon->scn.nF,400);
        Ion->PlotnostY(0,40,Mon->scn.nF,400);
        Ion->IzobrIon();
        */
        Ion->Show();
        //Ion->SaveIon(dd.da_year, dd.da_mon, dd.da_day, tt.ti_hour,tt.ti_min,tt.ti_sec);
        //SaveIon2(dd.da_year, dd.da_mon, dd.da_day, tt.ti_hour,tt.ti_min,tt.ti_sec);
}
//---------------------------------------------------------------------------

