📄 main.c
字号:
watchdog();
}
void refresh_menu()
{
watchdog();
setwfc(7);
cursor(5, 4+OldMenuItem*2);
mput(Menu[OldMenuItem]);
setwfc(9);
cursor(5, 4+MenuItem*2);
mput(Menu[MenuItem]);
setwfc(7);
watchdog();
}
void init_page12(uchar page_num) // refer to PAGE12_BASE_Y
{
uchar i, j;
clear_screen();
CurrentPage = Page1 + page_num;
mrectangle(8, PAGE12_BASE_Y*18, 632, (PAGE12_BASE_Y+1+(SW_NUM+1)/2)*18);
for(i=0; i<(SW_NUM+1)/2; i++)
mline(8, (PAGE12_BASE_Y+1+i)*18, 632, (PAGE12_BASE_Y+1+i)*18);
watchdog();
cursor(3, PAGE12_BASE_Y+1);
mput("电 气 名 称 线 号 A 节 车 B 节 车");
cursor(33, PAGE12_BASE_Y-1);
mput(Menu[page_num]+4);
watchdog();
for(i=0; i<(SW_NUM+1)/2; i++)
for(j=0; j<2; j++)
{
if(((SW_NUM%2) != 0) && (page_num != 0) && (i == ((SW_NUM+1)/2-1)))
continue;
cursor(3+j*34, PAGE12_BASE_Y+2+i);
mput(SwPrefix[j][page_num*((SW_NUM+1)/2)+i]);
}
watchdog();
}
void sort_sw()
{
uchar i;
watchdog();
for(i=0;i<2;i++)
{
SortedSw1[i][0]=(Sw[i][1]&0x07)|((Sw[i][0]&0x10)>>1)|((Sw[i][1]&0x80)>>3)|(Sw[i][2]&0x20)|
((Sw[i][2]&0x02)<<5)|((Sw[i][5]&0x08)<<4);
SortedSw1[i][1]=((Sw[i][5]&0x70)>>4)|((Sw[i][0]&0x02)<<2)|((Sw[i][3]&0x40)>>2)|
((Sw[i][6]&0x01)<<5)|((Sw[i][6]&0x04)<<4);
SortedSw2[i][0]=(Sw[i][4]&0x01)|((Sw[i][4]&0x20)>>4)|((Sw[i][6]&0x01)>>2)|(Sw[i][8]&0x08)|
((Sw[i][6]&0x60)>>1)|((Sw[i][7]&0x02)<<5)|((Sw[i][8]&0x20)<<2);
SortedSw2[i][1]=((Sw[i][7]&0x20)>>5)|((Sw[i][4]&0x04)>>1)|((Sw[i][7]&0xc0)>>4)|
((Sw[i][8]&0x01)<<4)|((Sw[i][8]&0x04)<<3)|((Sw[i][9]&0x08)<<3);
}
watchdog();
}
void refresh_page12(uchar page_num)
{
uchar i, j;
setwfc(9);
for(i=0;i<(SW_NUM+(page_num%2 == 0))/2;i++)
for(j=0;j<2;j++)
{
cursor(54+j*15, PAGE12_BASE_Y+2+i);
if(page_num == 0)
if(SortedSw1[j][i/8] & Mask[i%8])
mputchar('1');
else
mputchar('0');
else
if(SortedSw2[j][i/8] & Mask[i%8])
mputchar('1');
else
mputchar('0');
}
watchdog();
setwfc(7);
}
void init_page3()
{
uchar data i,j;
// uchar data wd=8,hd=18;
clear_screen();
CurrentPage = Page3;
mrectangle(5,6,635,460);
mrectangle(5,45,635,300);
mrectangle(5,76,635,300);
mline(320,45,320,300);
watchdog();
/* mputwordat(1*hd,30*wd,"机");
mputwordat(1*hd,34*wd,"车");
mputwordat(1*hd,38*wd,"运");
mputwordat(1*hd,42*wd,"行");
mputwordat(1*hd,46*wd,"状");
mputwordat(1*hd,50*wd,"态");// mput(" 机 车 运 行 状 态 \n");
mputcharat(3*hd,17*wd,'A'); //cursor(4,17); mput("A 节 车");
mputwordat(3*hd,19*wd,"节");
mputwordat(3*hd,22*wd,"车");
mputcharat(3*hd,57*wd,'B'); //cursor(4,57); mput("B 节 车");
mputwordat(3*hd,59*wd,"节");
mputwordat(3*hd,62*wd,"车");*/
cursor(32, 2); mput(Menu[2]+4);
cursor(17,4); mput("A 节 车");
cursor(57,4); mput("B 节 车");
for(i=0;i<10;i++)
for(j=0;j<2;j++)
{
cursor(9+j*40,6+i);
mput(AnalogPrefix[i]);
}
/* xxx=5;
yyy=8;
for(i=0;i<2;i++)
{
xx=xxx;
yy=yyy;
// cursor(xx++,yy); mput("15V电压信号:");
mputcharat(xx*hd,yy*wd,'1');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'5');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'V');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"压");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"信");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"号");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'V');
watchdog();
// cursor(xx++,yy); mput("主级位电压:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"主");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"级");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"位");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"压");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'V');
watchdog();
// cursor(xx++,yy); mput("副级位电压:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"副");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"级");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"位");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"压");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'V');
watchdog();
// cursor(xx++,yy); mput("电机1,2电压:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"机");
yy=yy+2;
mputcharat(xx*hd,yy*wd,'1');
yy=yy+1;
mputcharat(xx*hd,yy*wd,',');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'2');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"压");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'V');
watchdog();
//cursor(xx++,yy); mput("电机3,4电压:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"机");
yy=yy+2;
mputcharat(xx*hd,yy*wd,'3');
yy=yy+1;
mputcharat(xx*hd,yy*wd,',');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'4');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"压");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'V');
watchdog();
//cursor(xx++,yy); mput("电机 1 电流:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"机");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'1');
yy=yy+1;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"流");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'A');
watchdog();
//cursor(xx++,yy); mput("电机 2 电流:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"机");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'2');
yy=yy+1;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"流");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'A');
watchdog();
//cursor(xx++,yy); mput("电机 3 电流:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"机");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'3');
yy=yy+1;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"流");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'A');
watchdog();
//cursor(xx++,yy); mput("电机 4 电流:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"机");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputcharat(xx*hd,yy*wd,'4');
yy=yy+1;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputwordat(xx*hd,yy*wd,"流");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'A');
watchdog();
//cursor(xx++,yy); mput("励 磁 电 流:");
xx++;
yy=yyy;
mputwordat(xx*hd,yy*wd,"励");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"磁");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"电");
yy=yy+2;
mputcharat(xx*hd,yy*wd,' ');
yy=yy+1;
mputwordat(xx*hd,yy*wd,"流");
yy=yy+2;
mputcharat(xx*hd,yy*wd,':');
yy=yy+8;
mputcharat(xx*hd,yy*wd,'A');
watchdog();
yyy=48;
}*/
watchdog();
for(i=0;i<4;i++)
{
cursor(7, 20+i);
mput(SelfCheckPrefix[i]);
}
watchdog();
}
void refresh_page3()
{
uchar i, j;
char a[6];
float idata analog[2][10] = {0};
setwfc(9);
/* for(i=0;i<10;i++)
for(j=0;j<2;j++)
{
watchdog();
analog[j][i] = AnalogFactor[j]*(ulong)Analog[j][i]*20/0xfff;
a[0] = analog[j][i]/1000+0x30;
a[1] = analog[j][i]/100%10+0x30;
a[2] = analog[j][i]/10%10+0x30;
a[3] = analog[j][i]%10+0x30;
watchdog();
if(a[0] == 0x30)
{
a[0] = ' ';
if(a[1] == 0x30)
{
a[1] = ' ';
if(a[2] == 0x30)
a[2] = ' ';
}
}
a[4] = 0;
cursor(23+j*40, 6+i);
mput(a);
watchdog();
}*/
for(i=0;i<10;i++)
for(j=0;j<2;j++)
{
watchdog();
analog[j][i] = AnalogFactor[i]*(float)Analog[j][i]*20/0xfff;
if(i < 3)
{
if(analog[j][i]>14.1)
analog[j][i] = 15;
sprintf(a, "%6.2f", analog[j][i]);
}
else
{
if(analog[j][i]<15)
analog[j][i] = 0;
sprintf(a, "%6.1f", analog[j][i]);
}
cursor(22+j*40, 6+i);
mput(a);
watchdog();
}
if(NewSelfCheck)
{
for(i=0;i<4;i++)
{
cursor(35, 20+i);
if(SelfCheck[i] == 0x00)
mput("故障!");
else if(SelfCheck[i] == 0x01)
mput("正常!");
}
NewSelfCheck = 0;
}
setwfc(7);
watchdog();
}
void init_page45()
{
uchar data i;
clear_screen();
CurrentPage = Page4 + Page45Sel;
cursor(30, 2);
mput(Menu[3+Page45Sel]+4);
watchdog();
for(i=0;i<9;i++)
{
cursor(5, 4+i*2);
mput(CheckItem[i]);
}
watchdog();
}
void refresh_page45()
{
watchdog();
setwfc(7);
cursor(5, 4+Page45OldItem[Page45Sel]*2);
mput(CheckItem[Page45OldItem[Page45Sel]]);
setwfc(9);
cursor(5, 4+Page45Item[Page45Sel]*2);
mput(CheckItem[Page45Item[Page45Sel]]);
setwfc(7);
watchdog();
}
check_process1()
{
if(Sw[Page45Sel][3]&Mask[3])
mput(DiagnosisCode1[0]);
else
{
setwfc(9);
mput(DiagnosisCode1[1]);
setwfc(7);
}
if(Sw[Page45Sel][0]&Mask[2])
mput(DiagnosisCode1[2]);
else
{
setwfc(9);
mput(DiagnosisCode1[3]);
setwfc(7);
}
if(Sw[Page45Sel][3]&Mask[4])
mput(DiagnosisCode1[4]);
else
{
setwfc(9);
mput(DiagnosisCode1[5]);
setwfc(7);
}
watchdog();
if(Sw[Page45Sel][3]&Mask[5])
mput(DiagnosisCode1[6]);
else
{
setwfc(9);
mput(DiagnosisCode1[7]);
setwfc(7);
}
if(Sw[Page45Sel][3]&Mask[6])
mput(DiagnosisCode1[8]);
else
{
setwfc(9);
mput(DiagnosisCode1[9]);
setwfc(7);
}
mput(DiagnosisEnd);
}
check_process2()
{
uchar i;
if(Sw[Page45Sel][4]&Mask[4])
mput(DiagnosisCode2[0]);
else
{
setwfc(9);
mput(DiagnosisCode2[1]);
setwfc(7);
}
if(Sw[Page45Sel][4]&Mask[5])
mput(DiagnosisCode2[2]);
else
{
setwfc(9);
mput(DiagnosisCode2[3]);
setwfc(7);
}
if(Sw[Page45Sel][4]&Mask[3])
mput(DiagnosisCode2[4]);
else
{
setwfc(9);
mput(DiagnosisCode2[5]);
setwfc(7);
}
watchdog();
switch((Sw[Page45Sel][6]&(Mask[5]|Mask[4]))>>4)
{
case 0:
setwfc(9);
mput(DiagnosisCode2[9]);
setwfc(7);
break;
case 1:
mput(DiagnosisCode2[6]);
mput(" 还有 5 秒");
TR0 = 1;
for(i=4;i!=0xff;i--)
{
while(TimingFlag == 0) ;
TimingFlag = 0;
mput("\r\t"); mputchar(i+0x30);
watchdog();
}
TR0 = 0;
Count = 28;
switch((Sw[Page45Sel][6]&(Mask[5]|Mask[4]))>>4)
{
case 0:
setwfc(9);
mput(DiagnosisCode2[10]);
setwfc(7);
break;
case 1:
mput(DiagnosisCode2[11]);
break;
case 2:
setwfc(9);
mput(DiagnosisCode2[7]);
setwfc(7);
break;
case 3:
setwfc(9);
mput(DiagnosisCode2[12]);
setwfc(7);
break;
default: ;
}
break;
case 2:
mput(DiagnosisCode2[7]);
break;
case 3:
setwfc(9);
mput(DiagnosisCode2[8]);
setwfc(7);
break;
default: ;
}
mput(DiagnosisEnd);
}
check_process3()
{
uchar i, k=0;
if(Sw[Page45Sel][3]&Mask[3]) //531
{
mput(DiagnosisCode3[0]);
k++;
}
else
{
setwfc(9);
mput(DiagnosisCode3[1]);
setwfc(7);
}
if(Sw[Page45Sel][6]&Mask[3]) //548
{
mput(DiagnosisCode3[2]);
k++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -