if(me[dko][iex[dko]-1]!=i-1 ){
me[dko][iex[dko]++]=i-1;
mo[dko][io[dko]++]=out[dko][me[dko][iex[dko]-1]];
fex[dko]=0;
md[dko][ipd[dko]++]=pd;
ms[dko][ips[dko]++]=ps;
circle(me[dko][iex[dko]-1]+10,(dko*100+350)-out[dko][ me[dko][iex[dko]-1]]/2,2);
floodfill(me[dko][iex[dko]-1]+10,(dko*100+350)-out[dko][ me[dko][iex[dko]-1]]/2,15);
}
flags1[dko]=1;
}
else
i=j;
}
else
if((out[dko][i]<out[dko][i-1])&&(flags1[dko]==1))
{
st[dko]=i;
for(j=i+1,t=0;(t<13)&&(j<imean[dko]);t++,j++)
if(out[dko][j]>out[dko][i-1])
{fla[dko]=0;break; }
else fla[dko]=1;
if((fla[dko]==1))
{
if(me[dko][iex[dko]-1]!=i-1 ){
me[dko][iex[dko]++]=i-1;
md[dko][ipd[dko]++]=pd;
ms[dko][ips[dko]++]=ps;
mo[dko][io[dko]++]=out[dko][me[dko][iex[dko]-1]];
fex[dko]=1;
circle(me[dko][iex[dko]-1]+10,(dko*100+350)-out[dko][ me[dko][iex[dko]-1]]/2,2);
floodfill(me[dko][iex[dko]-1]+10,(dko*100+350)-out[dko][ me[dko][iex[dko]-1]]/2,15);
}
flags1[dko]=-1;
}
else
i=j;
}
}
}
if((iex[dko]>1)&&(fex[dko]))
{
tf=me[0][1]-me[0][0]+1;
tf1=mo[0][14]-mo[0][12];
if(percnt[dko]==0)
line(me[dko][0]+10,dko*100+70,me[dko][0]+10,dko*100+80);
if(out[dko] [ me[dko] [iex[dko]-2]]<out[dko][ me[dko] [iex[dko]-iex[dko]]]+20)
{
fex[dko]=0;
++percnt[dko];
per[dko][percnt[dko]]=me[dko][iex[dko]-2];
if(percnt[dko]>0)
{
ne=iex[dko]-1+percnt[dko]-1;
if(ne%5)
goto End;
masp[dko][1] = dko + 1;
ot1=me[dko][(percnt[dko]-1)*4+0];
ot2=me[dko][(percnt[dko]-1)*4+1];
masp[dko][2]=out[dko][ot2];
ot3=me[dko][(percnt[dko]-1)*4+3];
masp[dko][5]=out[dko][ot3];
ot4=me[dko][(percnt[dko]-1)*4+2];
masp[dko][4]=out[dko][ot4];
masp[dko][3]=out[dko][ot4-4];
masp[dko][7]=per[dko][percnt[dko]]-per[dko][percnt[dko]-1];
if(!((masp[dko][7]>98)&&(masp[dko][7]<104) ))
goto End;
masp[dko][6]=me[dko][iex[dko]-1]-me[dko][iex[dko]-2]+1;
if(!( (masp[dko][6]>tf-3)&&(masp[dko][6]<tf+3)))
goto End;
for(int w =0;out[dko][ot2]!=mo[dko][w];w++);
if(! ( mo[dko][w]-mo[dko][w-2]+2) )
goto End;
line(me[dko][iex[dko]-2]+10,dko*100+70,me[dko][iex[dko]-2]+10,dko*100+80);
sprintf(str,"%d",masp[dko][7]);
setcolor(11);
outtextxy(me[dko][iex[dko]-2]-50,dko*100+85,str);
setcolor(15);
ot6=me[dko][(percnt[dko]-1)*4+4];
masp[dko][9]=me[dko][(percnt[dko]-1)*4+4]/100;
masp[dko][10]=me[dko][(percnt[dko]-1)*4+4]%100;
kaz=(out[dko][ot1]+out[dko][ot6])/2;
for(vk=2;vk<6;vk++)
masp[dko][vk]=masp[dko][vk]-kaz;
s=0;
for(vk=0;vk<ot4-1;vk++)
s=s+(out[dko][vk]+out[dko][vk+1])/2;
sq=(s/ot4-kaz)*masp[dko][7];
masp[dko][8]=sq;
fprintf(outst,"\t%d",percnt[dko]);
fprintf(outst,"\t");
for(z=1;z<11;z++)
fprintf(outst,"%5d ",masp[dko][z]);
fprintf(outst,"\n");
}
}
}
}
}
else
++krs[dko];
}
else
++ofsmed[dko];
End:if(dko==3)
{
++pd;
if(pd==100)
{
++ps;
pd=0;
}
dko=0;
++dx;
++dx1;
}
else
++dko;
}
else
stop=-1;
}
void main(void)
{
int gdriver = DETECT, gmode, errorcode;
unsigned int newtic=10947,oldtic=65535L;// new tic for 100,1 in second
init_azp(azp,"kanal1.dat");
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
outst=fopen("masp.res","w");
if(outst==NULL){
puts("Anable open file\n");
exit(1);
}
fprintf(outst,"\t\t\t\tРезультаты обработки \n");
fprintf(outst,"\n");
fprintf(outst," Период\t\t\t\tПараметры сигнала \n");
setbkcolor(0);
setcolor(1);
cleardevice();
line(1,100,640,100);
line(1,200,640,200);
line(1,300,640,300);
line(1,400,640,400);
line(1,1,1,400);
setcolor(15);
outportb(0x43,0x36);
outportb(0x40,newtic&0x00ff);
outportb(0x40,newtic>>8);
oldhandler = getvect(INTR);
setvect(INTR, handler);
while (stop==1)
{
}
setvect(INTR, oldhandler);
outportb(0x43,0x36);
outportb(0x40,oldtic&0x00ff);
outportb(0x40,oldtic>>8);
fclose(outst);
getch();
closegraph();
}
void init_azp(int mas[][Meanings],char filename[])
{
int i=0,j;
unsigned int *tmp;
FILE *f;
char mode[]="rt";
f=fopen(filename,mode);
if(f==NULL){
puts("Anable open file\n");
exit(1);
}
for(i=0;i<4;i++)
{
for(j=0;j<500;j++)
{
fscanf(f,"%d",tmp);
mas[i][j]=*tmp;
}
rewind(f);
}
fclose(f);
}
Результати роботи програми