📄 second.bak
字号:
{
now_step_uncount = now_uncount;
}
for(j=0; j<16; j++) //此循环用于查找当前相位用到的灯组
{
toto1 = 0x0001;
toto1 = toto1<<j;
inuse_lamp_temp = toto1&now_lamp;
if(inuse_lamp_temp!=0)
{
if(now_uncount>step_uncount[1][i])
{
lamp_state[j]=3; /*当前阶段用的灯组置成黄色*/
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)==0x04)
lamp_state[j]=4; /*灯组是行人灯组,在黄灯期间置红色*/
}
if(now_phase_tempn!=0)
lamp_state[j]=1; /*下一阶段用的灯组仍置成绿色*/
}
}
}
}
}
}
now_step_key++;
if(now_uncount==1) //一个阶段时间走完
{
step_counter++;
now_step_key = 0;
sensor_virgin_flag = 1;
if(step_counter>=step_num)period_update = 1;
}
}
/*****************************************************************************************************/
// 灯输出函数
/*****************************************************************************************************/
void lamp_out() using 1
{
uchar xdata i;
uchar xdata left;
greenl=0;
greenh=0;
yell=0;
yelh=0;
redl=0;
redh=0;
for(i=0;i<8;i++)
{
left=0x01;
left=left<<i;
switch(lamp_state[i])
{
case 0x01: //绿灯
greenl=(greenl|left);
break;
case 0x02: //绿闪
if(ssecond) greenl=(greenl|left);
else greenl=(greenl&(~left));
break;
case 0x03: //黄灯
yell=(yell|left);
break;
case 0x04: //红灯
redl=(redl|left);
break;
case 0x05: //黄闪
if(ssecond) yell=(yell|left);
else yell=(yell&(~left));
break;
default:break;
}
switch(lamp_state[i+8])
{
case 0x01:
greenh=(greenh|left);
break;
case 0x02:
if(ssecond) greenh=(greenh|left);
else greenh=(greenh&(~left));
break;
case 0x03:
yelh=(yelh|left);
break;
case 0x04:
redh=(redh|left);
break;
case 0x05:
if(ssecond) yelh=(yelh|left);
else yelh=(yelh&(~left));
break;
default:break;
}
}
// XBYTE[0Xc103]=0x80;
// XBYTE[0Xc183]=0x80;
XBYTE[0Xc100]=greenl;
XBYTE[0Xc101]=yell;
XBYTE[0Xc102]=redl;
XBYTE[0Xc180]=greenh;
XBYTE[0Xc181]=yelh;
XBYTE[0Xc182]=redh;
}
/*****************************************************************************************************/
// 装载状态函数
/*****************************************************************************************************/
void make0x83()
{
led82[0] = now_day_planid;
led82[1] = timeid;
led82[2] = now_schemeid;
led83[0] = now_step_schid/*+1*/; //当前的阶段表号
led83[1] = step_counter+1; //当前阶段
led83[4] = now_phase_status/256;
led83[5] = now_phase_status%256; //当前的相位状态
led83[9] = inuse_phasen[step_counter]/256;
led83[10] = inuse_phasen[step_counter]%256; //下一阶段的放行相位
led83[11] = now_step_uncount-1; //当前阶段的倒计时
led83[12] = machine_run_error; //运行故障信息
led83[13] = r_error1/256;
led83[14] = r_error1%256; /*驱而不亮的红灯组*/
led83[15] = y_error1/256;
led83[16] = y_error1%256; /*驱而不亮的黄灯组*/
led83[17] = g_error1/256;
led83[18] = g_error1%256; /*驱而不亮的绿灯组*/
led83[19] = r_error2/256;
led83[20] = r_error2%256; /*不驱而亮的红灯组*/
led83[21] = y_error2/256;
led83[22] = y_error2%256; /*不驱而亮的黄灯组*/
led83[23] = g_error2/256;
led83[24] = g_error2%256; /*不驱而亮的绿灯组*/
led83[25] = hpp/256;
led83[26] = hpp%256;
led83[27] = lpp/256;
led83[28] = lpp%256; //线圈故障信息
}
/*黄闪和四面红*/
void hand_control()
{
unsigned char data kkk=0;
unsigned data toto;
// unsigned int xdata fa_address;
// unsigned int xdata detail_addr;
temp=XBYTE[0X6d28];
co=XBYTE[0x6d29];
kkk=0;
switch (temp){
case 0x02:for(kkk=0;kkk<16;kkk++){
toto = 0x0001;
toto = toto<<kkk;
if((use_lamp&toto)==toto) lamp_state[kkk]=4; /*使用的灯组置成红色先*/
else lamp_state[kkk]=7;
}
break;
case 0x03:for(kkk=0;kkk<16;kkk++){
toto = 0x0001;
toto = toto<<kkk;
if((use_lamp&toto)==toto) lamp_state[kkk]=5; /*使用的灯组置成黄闪先*/
else lamp_state[kkk]=7;
}
break;
case 0x04:break;
default:break;
}
}
/*强制和遥控*/
handremote(){
unsigned int xdata toto,toto1;
unsigned char xdata i;
hand_counter++;
if(hand_counter>100)hand_counter=100;
if(hand_counter<4){
lai_nouse=(now_step_schid-1)*98; //阶段表号
lai_nouse=0x5242+lai_nouse;
toto=lai_nouse;
toto=toto+(step_counter)*3+2;
lai_nouse=toto;
toto1=XBYTE[toto];
temp=toto1;
toto1=toto1<<8;
toto1=toto1+XBYTE[toto+1]; //阶段对应放行的相位
lai=toto1;
toto=0x5246+(now_step_schid-1)*98;
tmd=toto;
temp=XBYTE[toto];
if(temp==0)toto=0x5001;
else toto=0x5122;
for(i=0;i<16;i++){
lai_nouse=0x0001;
lai_nouse=lai_nouse<<i; //确认放行的灯组
if((lai&lai_nouse)==lai_nouse){
hand_lamp=temp+i*18;
hand_phase=XBYTE[hand_lamp];
hand_phase=hand_phase<<8;
hand_phase=hand_phase+XBYTE[hand_lamp+1];
}
}
for(i=0;i<16;i++){
toto=0x0001;
toto=toto<<i;
if(hand_lamp&toto==toto)lamp_state[i]=2;
}
}
if(hand_counter>=4&&hand_counter<6){
for(i=0; i<16; i++){
toto = 0x0001;
toto = toto<<i;
if((now_lamp&toto)==toto) lamp_state[i]=3; /*使用的灯组置成绿闪先*/
}
}
}
}
/*****************************************************************************************************/
// 半秒中断
/*****************************************************************************************************/
void secondint() interrupt 2 using 1
{
uchar i;
i = D12887C;
FarContrlLed = !FarContrlLed;
WatchDog = !WatchDog;
ssecond = !ssecond;
if(ssecond)
{
start_counter++;
if(start_counter>20) start_counter=20;
if(start_counter<=3) /*开机黄闪*/
{
for(i=0;i<16;i++)
{
lamp_state[i]=5;
}
}
else if((start_counter>3) && (start_counter<6)) /*开机全红*/
{
for(i=0;i<16;i++)
{
lamp_state[i]=4;
}
}
else if(start_counter==6)
period_update=1; /*开机黄闪全红后,更改周期更迭标志*/
else if(start_counter>=7)
{
search_color(); // key++;
hand_control(); //手动控制
make0x83();
}
}
temp=XBYTE[0X6d28]; //手动强制标志 ///////////////////////////////////////////////
co=XBYTE[0x6d29]; //强制的阶段号
hand_lamp=0;
if(temp==1)handremote();/*强制和遥控*/
else {
lamp_out();
hand_counter=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -