📄 second.bak
字号:
#include <second.h>
/*****************************************************************************************************/
// 读时间
/*****************************************************************************************************/
void read_time()
{
now_day = XBYTE[0XC006]; /*星期*/
now_year= XBYTE[0XC009]; /*年份*/
now_month=XBYTE[0XC008]; /*月份*/
now_date= XBYTE[0XC007]; /*日子*/
now_hour= XBYTE[0XC004]; /*小时*/
now_min = XBYTE[0XC002]; /*分钟*/
now_sec = XBYTE[0XC000]; /*秒*/
now_time=now_hour*60+now_min;
if(end_time<begin_time)
{
if((now_time>=begin_time) || (now_time<end_time))
work_time=1;
else
work_time=0;
}
else if(end_time>begin_time)
{
if((now_time>=begin_time) && (now_time<end_time))
work_time=1;
else
work_time=0;
}
else
work_time=0;
}
uchar search_step_time() using 1
{
uchar i;
uint j;
uint toto;
uchar time;
ensensor_flag = 1;
sensor_car_flag= 0;
sensor_counter = 0;
for(i=0; i<16; i++) //此循环用于查找当前阶段用到的相位
{
j = 18*i;
toto = 0x0001;
toto = toto<<i;
now_phase_temp = toto&inuse_phase[step_counter];
now_phase_tempn = toto&inuse_phasen[step_counter];
if(now_phase_temp!=0)
{
if(((XBYTE[baseaddr_now_phasesch+j+2]&0x04)!=0x04) && (now_phase_tempn==0))
{
sensor_distance=XBYTE[baseaddr_now_phasesch+j+11];
min_greentime = XBYTE[baseaddr_now_phasesch+j+12]-XBYTE[baseaddr_now_phasesch+j+17]-sensor_distance;
max_greentime = XBYTE[baseaddr_now_phasesch+j+13]-XBYTE[baseaddr_now_phasesch+j+17];
// add_greentime = min_greentime;
time = XBYTE[baseaddr_now_phasesch+j+12]+XBYTE[baseaddr_now_phasesch+j+15]+XBYTE[baseaddr_now_phasesch+j+16];
return (time);
}
}
}
}
/*****************************************************************************************************/
// 查找灯色
/*****************************************************************************************************/
void search_color() using 1
{
uchar data i,j;
uint data toto,toto1;
for(i=0; i<16; i++)
{
toto = 0x0001;
toto = toto<<i;
if((use_lamp&toto)==toto) lamp_state[i]=4; /*使用的灯组置成红色先*/
else lamp_state[i]=7; /*不用的灯组灭掉*/
}
if(sensor_step[step_counter]==0) //阶段为固定配时
{
now_uncount = XBYTE[baseaddr_now_schemesch+8+step_counter]-now_step_key; //查表的阶段时间与当前历时的倒计时
for(i=0; i<16; i++) //此循环用于查找当前阶段用到的相位
{
toto = 0x0001;
toto = toto<<i;
now_phase_temp = toto&inuse_phase[step_counter];
now_phase_tempn = toto&inuse_phasen[step_counter];
if(now_phase_temp!=0)
{
now_lamp_temp = XBYTE[baseaddr_now_phasesch+18*i];
now_lamp_temp = now_lamp_temp<<8;
now_lamp = now_lamp_temp|XBYTE[baseaddr_now_phasesch+18*i+1];
if(now_uncount>step_uncount[3][i])
{
now_phase_status = now_phase_status|now_phase_temp;
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04)
{
now_step_uncount = now_uncount-step_uncount[2][i];
}
for(j=0; j<16; j++) //此循环用于查找当前相位用到的灯组
{
toto1 = 0x0001;
toto1 = toto1<<j;
inuse_lamp_temp = toto1&now_lamp;
if(inuse_lamp_temp!=0)
{
lamp_state[j]=1; /*当前阶段用的灯组置成绿色*/
}
}
}
else if(now_uncount>step_uncount[2][i])
{
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04)
{
now_step_uncount = now_uncount-step_uncount[2][i];
}
for(j=0; j<16; j++)
{
toto1 = 0x0001;
toto1 = toto1<<j;
inuse_lamp_temp = toto1&now_lamp;
if(inuse_lamp_temp!=0)
{
lamp_state[j]=2; /*当前阶段用的灯组置成绿闪*/
if(now_phase_tempn!=0)
lamp_state[j]=1; /*下一阶段用的灯组仍置成绿色*/
}
}
}
else if(now_uncount>step_uncount[0][i])
{
if(now_phase_tempn==0)
now_phase_status = now_phase_status&(~now_phase_temp);
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04)
{
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; /*下一阶段用的灯组仍置成绿色*/
}
}
}
}
}
}
else if(sensor_step[step_counter]==1) //阶段为感应配时
{
if(sensor_virgin_flag)
{
sensor_virgin_flag = 0;
step_time = search_step_time(); //阶段时间在开始时只加载一次
}
now_uncount = step_time-now_step_key;
for(i=0; i<16; i++) //此循环用于查找当前阶段用到的相位
{
toto = 0x0001;
toto = toto<<i;
now_phase_temp = toto&inuse_phase[step_counter];
now_phase_tempn = toto&inuse_phasen[step_counter];
if(now_phase_temp!=0) //
{
now_lamp_temp = XBYTE[baseaddr_now_phasesch+18*i];
now_lamp_temp = now_lamp_temp<<8;
now_lamp = now_lamp_temp|XBYTE[baseaddr_now_phasesch+18*i+1];
if(now_uncount>step_uncount[3][i])
{
now_phase_status = now_phase_status|now_phase_temp;
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04)
{
now_step_uncount = now_uncount-step_uncount[2][i];
}
if((ensensor_flag) && ((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04) && (now_phase_tempn==0))
{
if(now_step_key==min_greentime)
{
sensor_car_flag = 1;
sensor_counter++;
if(sensor_counter>=sensor_distance)
{
ensensor_flag = 0;
sensor_car_flag = 0;
}
}
else if(now_step_key>min_greentime)
{
if(carnumber!=lastcarnumber)
{
add_greentime =now_step_key+sensor_distance;
if(add_greentime>=max_greentime)
{
ensensor_flag = 0;
sensor_car_flag = 0;
add_greentime = max_greentime;
}
step_time = add_greentime+XBYTE[baseaddr_now_phasesch+18*i+15]+XBYTE[baseaddr_now_phasesch+18*i+16]+XBYTE[baseaddr_now_phasesch+18*i+17];
sensor_counter = 1;
lastcarnumber = carnumber;
}
else
{
sensor_counter++;
if(sensor_counter>=sensor_distance)
{
ensensor_flag = 0;
sensor_car_flag = 0;
}
}
}
}
for(j=0; j<16; j++) //此循环用于查找当前相位用到的灯组
{
toto1 = 0x0001;
toto1 = toto1<<j;
inuse_lamp_temp = toto1&now_lamp;
if(inuse_lamp_temp!=0)
{
lamp_state[j]=1; /*当前阶段用的灯组置成绿色*/
}
}
}
else if(now_uncount>step_uncount[2][i])
{
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04)
{
now_step_uncount = now_uncount-step_uncount[2][i];
}
for(j=0; j<16; j++) //此循环用于查找当前相位用到的灯组
{
toto1 = 0x0001;
toto1 = toto1<<j;
inuse_lamp_temp = toto1&now_lamp;
if(inuse_lamp_temp!=0)
{
if(now_phase_tempn==0)
{
ensensor_flag = 0;
sensor_car_flag = 0;
step_time = now_step_key+now_uncount;
lamp_state[j]=2; /*当前阶段用的灯组置成绿闪*/
}
else
{
lamp_state[j]=1; /*下一阶段用的灯组仍置成绿色*/
}
}
}
}
else if(now_uncount>step_uncount[0][i])
{
if(now_phase_tempn==0)
now_phase_status = now_phase_status&(~now_phase_temp);
if((XBYTE[baseaddr_now_phasesch+18*i+2]&0x04)!=0x04)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -