📄 main.cpp
字号:
_disp.flag_db_bw2=TRUE;
else
_disp.flag_db_bw2=FALSE;
//printf("f");
_disp.db_bw2.r_bandwidth=_disp.db_bw2.r_freq_r-_disp.db_bw2.r_freq_l;
if((_disp.db_bw2.r_bandwidth>_disp.db_bw2.bandwidth.freq&&_disp.db_bw2.bandwidth.above_below==1)||
(_disp.db_bw2.r_bandwidth<_disp.db_bw2.bandwidth.freq&&_disp.db_bw2.bandwidth.above_below==0))
_disp.flag_bandwidth2=TRUE;
else
_disp.flag_bandwidth2=FALSE;
if(((_disp.r_cen_freq+_disp.sb_att.freq_offset > _freq[0].end_freq)||(_disp.r_cen_freq-_disp.sb_att.freq_offset < _freq[0].start_freq))){
if((_keyid==DISPLAY&&_softkeyid==1&&_softkeyid2==0&&_disp.disp_way==1)){
CLR_LN4;
Outchar12(35,462,"阻带带宽设置超出范围!",TEXTDIGITAL);
}
}
else{
_disp.sb_att.r_attenuation_l=conv(y_a[(int) ((double)(_disp.r_cen_freq-_disp.sb_att.freq_offset-_freq[0].start_freq)\
*(swp_pnt-1)/(_freq[0].freq_width))])-_marker[0].max_mkr.power-_power[0].output_power;
// printf("%f",((double)(_disp.r_cen_freq+_disp.sb_att.freq_offset-_freq[0].start_freq)\
// /(double)_freq[0].freq_width*(double)swp_pnt));
_disp.sb_att.r_attenuation_r=conv(y_a[(int) ((double)(_disp.r_cen_freq+_disp.sb_att.freq_offset-_freq[0].start_freq)\
*(swp_pnt-1)/(_freq[0].freq_width))])-_marker[0].max_mkr.power-_power[0].output_power;
if(_disp.sb_att.r_attenuation_l<_disp.sb_att.attenuation&&
_disp.sb_att.r_attenuation_r<_disp.sb_att.attenuation)
_disp.flag_sb_att=TRUE;
else
_disp.flag_sb_att=FALSE;
}
if(!((_disp.active[0]==ON&&_disp.flag_freq_diff==FALSE)||
(_disp.active[1]==ON&&_disp.flag_loss==FALSE)||
(_disp.active[2]==ON&&_disp.flag_ripple==FALSE)||
(_disp.active[3]==ON&&_disp.flag_db_bw1==FALSE)||
(_disp.active[4]==ON&&_disp.flag_bandwidth1==FALSE)||
(_disp.active[5]==ON&&_disp.flag_db_bw2==FALSE)||
(_disp.active[6]==ON&&_disp.flag_bandwidth2==FALSE)||
(_disp.active[7]==ON&&_disp.flag_sb_att==FALSE)))
_disp.flag_all = TRUE;
else
_disp.flag_all = FALSE;
if(_disp.disp_way==1){
fill_form_r();
}
else if(_disp.disp_way==2){
fill_form_b();
}
}
enable();
if(_status[chs].trig_way==1){ //keep
_status[chs].keep_start=0;
while(_status[chs].keep_start==0)
{
key_process();
}
}
ALT: if(alternative==OFF)
{
if(aflag==1)
{ //chs=0;
disable();
mda_map->ScreenClear();
mda_map->Line(0,0,0,0,chs==0?_system.colora:_system.colorb);
mda_map->ScreenMove();
chs=1-chs;// printf("b:%d",chs);
disable();
mda_map->ScreenClear();
mda_map->Line(0,0,0,0,chs==0?_system.colora:_system.colorb);
mda_map->ScreenMove();
enable();
// chs=1-chs;
chs=ch_sel;
aflag=0;
}
else if(_chab[ch_sel].on_off==ON||_chab[!ch_sel].on_off==ON)
{
chs=ch_sel;
if(chss!=chs)
{
chs=1-chs;
mda_map->ScreenClear();
mda_map->Line(0,0,0,0,chs==0?_system.colora:_system.colorb);
mda_map->ScreenMove();
chs=1-chs;
chss=chs;
}
}
else {
// chs=1-chs;
// mda_map->ScreenClear();
// mda_map->Line(0,0,0,0);
// mda_map->ScreenMove();
chs=1-chs;
mda_map->ScreenClear();
mda_map->Line(0,0,0,0,chs==0?_system.colora:_system.colorb);
mda_map->ScreenMove();
chs=1-chs;
}
}
else
aflag=1;
if(alternative==ON){
// chs = 1 - chs;
if((_chab[0].on_off==ON&&_chab[1].on_off==ON)||
(_chab[0].on_off==OFF&&_chab[1].on_off==OFF)){ // both off,
chs=1-chs;
//
// printf("%d ",chs);
}
else if(_chab[0].on_off==ON&&_chab[1].on_off==OFF)
// chs=0;
chs=1-chs;
else if(_chab[0].on_off==OFF&&_chab[1].on_off==ON)
// chs=1;
chs=1-chs;
}
}//end while
}
void InitGraph()
{
int gdriver = DETECT, gmode, errorcode;
const char *gpath = "..\\tc30\\bgi";
FILE *fp12;
if( (fp12=fopen("hzk12.dat","rb"))==NULL )
{
printf("Open HZKLIB File Error!\n\n");
exit(1);
}
font12= new FILETOXMS("HZK12.DAT");
fclose(fp12);
// if (fclose(fp12)) printf(" file close error.\n");
registerfarbgidriver(EGAVGA_driver_far); // refer to Util.doc
registerfarbgifont(0);
/* initialize graphics mode */
initgraph(&gdriver, &gmode, gpath);
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
// _maxx = getmaxx();
// _maxy = getmaxy();
}
void CloseGraph()
{
// outtextxy(0, _maxy - 10, "Press any key to EXIT system.");
// getch();
//int errorcode;
closegraph();
// delete[]font12;
}
void interrupt_init()
{
// old_key=getvect(0x09);
// setvect(0x09,new_key);
old_IRQ9=getvect(0x71);
setvect(0x71,new_IRQ9);
enable();
}
void interrupt_destory()
{
disable();
// setvect(0x09,old_key);
setvect(0x71,old_IRQ9);
enable();
}
void interrupt new_key(__CPPARGS)
{
disable();
/* if(WritingFile)
return;
KEY key;
if(!KeyBusy&&!WritingFile)
{
KeyBusy = TRUE;
disable();
while( !(inportb(0x64)&0x01) );
key=inportb(0x60);
key_process(key);
outportb(0x20,0x20);
enable();
KeyBusy = FALSE;
} */
while(!(inportb(0x64)&0x01));
// printf("\n\n\n\t\t\t%#x",inportb(0x60));
// keylink->AddKey(inportb(0x60));
outportb(0x20,0x20);
// while(!(inportb(0x64)&0x02));
outportb(0x64,0xae);
enable();
}
void interrupt new_IRQ9(__CPPARGS)
{
disable();
IRQ9_process();
outportb(0xa0,0x20);
outportb(0x20,0x20);
enable();
}
void IRQ9_process(void)
{
}
void graph()
{
// clear_rect(0,0,_maxx,_maxy);
clear_rect(0,0,A_RX+3,479);
clear_rect(0,0,A_RX+3,479);
setbkcolor(BACKGROUND); //set background color
setcolor(DOTLINE); //set main line
draw_dotted_line();
setcolor(MAINFRAME); //set main frame and menu frame
draw_border(A_LX,A_LY,A_RX,A_RY);
draw_border(A_LX-2,A_LY-2,A_RX+2,A_RY+2);
draw_border(A_LX-3,A_LY-3,A_RX+3,A_RY+3);
// draw_border(B_LX,B_LY,B_RX,B_RY);
// draw_border(B_LX+1,B_LY+1,B_RX-1,B_RY-1);
}
void graph1()
{
char msg[20];
clear_rect(0,0,A_RX+3,479);
clear_rect(0,0,A_RX+3,479);
disable();
setbkcolor(BACKGROUND); //set background color
setcolor(MAINFRAME); //set main frame and menu frame
disable();
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
rectangle(A_LX-1,A_LY-2,A_RX+1,A_RY-80);
rectangle(E_LX-1,E_LY-2,E_RX+1,E_RY);
setlinestyle(DOTTED_LINE,0,NORM_WIDTH);
for(int i=1;i<10;i++){
line(D_LX,D_LY+i*32,D_RX,D_LY+i*32);
line(D_LX+i*50,D_LY,D_LX+i*50,D_RY);
}
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
for(i=1;i<7;i++)
line(E_LX+i*71,E_LY,E_LX+i*71,E_RY);
line(E_LX,E_LY+30,E_RX,E_LY+30);
Outchar12(E_LX+10,E_LY+8,"中心频率",WRI_FORM);
Outchar12(E_LX+82,E_LY+8,"插入损耗",WRI_FORM);
Outchar12(E_LX+153,E_LY+8,"通带波动",WRI_FORM);
sprintf(msg,"%.0fdB",_disp.db_bw1.attenuation);
disable();
setcolor(WRI_FORM);
outtextxy(E_LX+216,E_LY+10,msg);
Outchar12(E_LX+216+40,E_LY+8,"带宽",WRI_FORM);
// Outchar12(E_LX+220,E_LY+8,"分贝带宽1",WRI_FORM);
disable();
setcolor(WRI_FORM);
sprintf(msg,"%.0fdB",_disp.db_bw2.attenuation);
outtextxy(E_LX+287,E_LY+10,msg);
Outchar12(E_LX+287+40,E_LY+8,"带宽",WRI_FORM);
// Outchar12(E_LX+291,E_LY+8,"分贝带宽2",WRI_FORM);
Outchar12(E_LX+366,E_LY+8,"偏差衰减",WRI_FORM);
Outchar12(E_LX+437,E_LY+8,"综合结论",WRI_FORM);
// delay(5000);
}
void StoreStatus()
{
if(WritingFile)
return;
WritingFile = TRUE;
disable();
FILE *fp;
if((fp=fopen("datafile.dat","wb"))==NULL){
return;
}
disable();
fwrite(_freq,sizeof(_FREQ),2,fp);
fwrite(_power,sizeof(_POWER),2,fp);
fwrite(_sweep,sizeof(_SWEEP),2,fp);
fwrite(_chab,sizeof(_CHAB),2,fp);
fwrite(_format,sizeof(_FORMAT),2,fp);
fwrite(_avg,sizeof(_AVG),2,fp);
fwrite(_status,sizeof(_STATUS),2,fp);
fwrite(&_system,sizeof(_SYSTEM),1,fp);
fwrite(&ch_sel,sizeof(char),1,fp);
fwrite(&alternative,sizeof(char),1,fp);
fwrite(&_on_off,sizeof(char),1,fp);
fclose(fp);
WritingFile = FALSE;
enable();
}
void Greet()
{
setbkcolor(BLACK);
// clrscr();
// printf("\n\n\n\n\n\n\t\t\tWelcome to use EE1251 Digital Frequency");
// printf("\n\n\n\t\t\tNanJingXinLianYiQi");
// printf("\n\n\n\t\t\tInitial system...");
disable();
rectangle(190,180,350,213);
enable();
// Outchar12(160,100,"欢迎使用EE1251数字化扫频仪",WHITE);
// Outchar12(180,140,"南京新联电讯仪器有限公司",WHITE);
Outchar12(210,190,"系统初始化中",WHITE);
Outchar12(450,450,"南京新联电讯仪器有限公司",WHITE);
enable();
for(int i=0;i<1;i++){
// for(j=0;j<32767;j++);
delay(400);
clear_rect(290,181,338,210);
clear_rect(290,181,338,210);
outtextxy(291,195,".");
// for(j=0;j<32767;j++);
delay(400);
clear_rect(290,181,338,210);
clear_rect(290,181,338,210);
disable();
outtextxy(291,195,"..");
// for(j=0;j<32767;j++);
delay(400);
clear_rect(290,181,338,210);
clear_rect(290,181,338,210);
outtextxy(291,195,"...");
// for(j=0;j<32767;j++);
delay(400);
clear_rect(290,181,338,210);
clear_rect(290,181,338,210);
outtextxy(291,195,"....");
// for(j=0;j<32767;j++);
delay(400);
clear_rect(290,181,338,210);
clear_rect(290,181,338,210);
outtextxy(291,195,".....");
delay(400);
clear_rect(290,181,338,210);
clear_rect(290,181,338,210);
outtextxy(291,195,"......");
}
}
void draw_graph(int color1)
{
int x_old,y_old;
int the_points;
if(_sweep[chs].flag1==0) //automatic sweep
the_points=_status[chs].sweep_points;
else if(_sweep[chs].flag1==1){
the_points=_sweep[chs].swp_pc+1;
}
// for(int i=0;i<_status[chs].sweep_points;i++)
for(int i=0;i<the_points;i++)
{
power_in=conv(chs==0?y_a[i]:y_b[i]);
if(_chab[chs].flag==0)
power_in-=_power[chs].output_power;
draw_map(_status[chs].sweep_points-1,i,power_in);
if(i>0){
if(y_old<0){
if(y_map<0){
}
else if(y_map<DISP_Y2-36){
mda_map->Line(((double)x_old*y_map-(double)x_map*y_old)/(y_map-y_old),0,x_map,y_map,color1);
}
else{
mda_map->Line(((double)x_old*y_map-(double)x_map*y_old)/(y_map-y_old),0,((double)x_old*y_map-(double)x_map*y_old+(double)(DISP_Y2-36)*(x_map-x_old))/(y_map-y_old),DISP_Y2-36,color1);
}
}
else if(y_old<DISP_Y2-36){
if(y_map<0){
mda_map->Line(x_old,y_old,((double)x_old*y_map-(double)x_map*y_old)/(y_map-y_old),0,color1);
}
else if(y_map<DISP_Y2-36){
mda_map->Line(x_old,y_old,x_map,y_map,color1);
}
else{
mda_map->Line(x_old,y_old,((double)x_old*y_map-(double)x_map*y_old+(double)(DISP_Y2-36)*(x_map-x_old))/(y_map-y_old),DISP_Y2-36,color1);
}
}
else
{
if(y_map<0){
mda_map->Line(((double)x_old*y_map-(double)x_map*y_old+(double)(DISP_Y2-36)*(x_map-x_old))/(y_map-y_old),DISP_Y2-36,((double)x_old*y_map-(double)x_map*y_old)/(y_map-y_old),0,color1);
}
else if(y_map<DISP_Y2-36){
mda_map->Line(((double)x_old*y_map-(double)x_map*y_old+(double)(DISP_Y2-36)*(x_map-x_old))/(y_map-y_old),DISP_Y2-36,x_map,y_map,color1);
}
else{
}
}
}
x_old=x_map;
y_old=y_map;
}//end for
mda_map->Line(0,0,0,0,(chs==0?_system.colora:_system.colorb));
mda_map->ScreenMove();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -