📄 c_manage.c
字号:
unsigned char call_out_req(unsigned char phone[6])//呼出资源申请
{
unsigned char xdata temp,i,j;
for(temp = 0;temp < TRK_MAX;temp++)
{
if(user_e1[temp].type == CALL_OUT)
{
if(user_e1[temp].flag == LEISURE)
{
user_e1[temp].flag = OCCUPY;
for(i = 0;i < 6;i++)
{
j = phone[i] >> 4;
if(j != 0)
{
user_e1[temp].telephone[2 * i] = j;
}
else
{
user_e1[temp].telephone[2 * i] = 10;
}
j = phone[i] & 0x0f;
if(j != 0)
{
user_e1[temp].telephone[2 * i + 1] = j;
}
else
{
user_e1[temp].telephone[2 * i + 1] = 10;
}
}
return(temp);
}
}
}
return(IDLE);
}
void back_index(unsigned char user_num)//激活呼出用户
{
unsigned char xdata temp;
for(temp = 0;temp < 128;temp++)//激活普通呼出用户
{
if(user_back[temp].user_num == user_num)
{
if(user_back[temp].call_flag == 0)
{
if(call_out_req(user_back[temp].telephone) != IDLE)
{
user_back[temp].call_flag = 1;
}
}
}
}
for(temp = 0;temp < 64;temp++)//激活老聊友呼出用户
{
if(chat_number[temp].user_num == user_num)
{
if(chat_number[temp].call_flag == 0)
{
if(call_out_req(chat_number[temp].telephone) != IDLE)
{
chat_number[temp].call_flag = 1;
}
}
}
}
}
unsigned char back_req(unsigned char user_num,unsigned char user_sex,unsigned char user_age,unsigned char opp_sex,unsigned char opp_age,unsigned char chat_type,unsigned char phone[6])
{//回呼资源申请
unsigned char xdata temp,i;
for(temp = 0;temp < 128;temp++)
{
if(user_back[temp].user_num == IDLE)
{
user_back[temp].user_num = user_num;
user_back[temp].user_sex = user_sex;
user_back[temp].user_age = user_age;
user_back[temp].opp_sex = opp_sex;
user_back[temp].opp_age = opp_age;
if(chat_type != IDLE)
{
user_back[temp].chat_type = chat_type;
}
else
{
user_back[temp].chat_type = 0x80;
}
for(i = 0;i < 6;i++)
{
user_back[temp].telephone[i] = phone[i];
user_back[temp].password[i] = user_e1[user_num].password[i];
}
user_back[temp].call_flag = 0;
return(temp);
}
}
return(IDLE);
}
unsigned char back_search(unsigned char phone[6],unsigned char type)//查找回呼用户,type 1:查找 0:查找并删除
{
unsigned char xdata temp,i,flag;
for(i = 0;i < 128;i++)
{
flag = 0;
for(temp = 0;temp < 6;temp++)
{
if(user_back[i].telephone[temp] != phone[temp])
{
flag = 1;
}
}
if(flag == 0)
{
if(type == 0)
{
user_back[i].user_num = IDLE;
user_back[i].user_sex = IDLE;
user_back[i].user_age = IDLE;
user_back[i].opp_sex = IDLE;
user_back[i].opp_age = IDLE;
user_back[i].chat_type = IDLE;
for(temp = 0;temp < 6;temp++)
{
user_back[i].telephone[temp] = IDLE;
user_back[i].password[temp] = IDLE;
}
user_back[i].call_flag = 0;
}
return(i);
}
}
return(IDLE);
}
unsigned char number_release(unsigned char phone[6],unsigned char type)
{//查找老聊友回呼
unsigned char xdata temp,i,flag;
for(i = 0;i < 64;i++)
{
flag = 0;
for(temp = 0;temp < 6;temp++)
{
if(chat_number[i].telephone[temp] != phone[temp])
{
flag = 1;
}
}
if(flag == 0)
{
if(type == 0)
{
chat_number[i].user_num = IDLE;
chat_number[temp].user_sex = IDLE;
chat_number[temp].user_age = IDLE;
chat_number[i].call_flag = 0;
for(temp = 0;temp < 6;temp++)
{
chat_number[i].telephone[temp] = IDLE;
}
}
return(i);
}
}
return(IDLE);
}
unsigned char number_req(unsigned char user_num,unsigned char user_sex,unsigned char user_age,unsigned char phone[6])
{//老聊友回呼资源申请
unsigned char xdata temp,i;
for(temp = 0;temp < 64;temp++)
{
if(chat_number[temp].user_num == IDLE)
{
chat_number[temp].user_num = user_num;
chat_number[temp].user_sex = user_sex;
chat_number[temp].user_age = user_age;
for(i = 0;i < 6;i++)
{
chat_number[temp].telephone[i] = phone[i];
}
chat_number[i].call_flag = 0;
return(temp);
}
}
return(IDLE);
}
unsigned char number_search(unsigned char user_num,unsigned char phone[6])
{//在线寻找老聊友
unsigned char xdata temp,i,flag;
for(temp = 0;temp < TRK_MAX;temp++)
{
flag = 0;
for(i = 0;i < 6;i++)
{
if(user_e1[temp].telephone[i] != phone[i])
{
flag = 1;
}
}
if(flag == 0)
{
user_e1[user_num].opp_num = temp;
return(temp);
}
}
return(IDLE);
}
receive()//处理后台发来的命令
{
unsigned char xdata temp,i,phone[6];
switch(p_data[0])//命令字类的区分
{
case 0://测试类命令字
{
switch(p_data[1])
{
case 0://MFC测试
{
mfc_count = 0;//测试须占用两路资源
command(8,0,mfc_count,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE);
mfc_test_num = p_data[2];//置测试通道号
chat_mfc_resource[mfc_test_num].delay = 2;//设置200毫秒的测试时间
temp = 1;
while(temp)
{
if(((MFC_W_R >> (2 * mfc_test_num + 4)) & 0x01) != 0x01)
{
XBYTE[chat_mfc_resource[mfc_test_num].addr] = 0x3d;//将该路置为发前收后
temp =0;
}
}
for(temp = 0;temp < 20;temp++)
delay_time(IDLE);
temp = 1;
while(temp)
{
if(((MFC_W_R >> (2 * mfc_test_num + 4)) & 0x01) != 0x01)
{
XBYTE[chat_mfc_resource[mfc_test_num].addr] = 0x80 + p_data[3];//发送测试值
temp = 0;
}
}
temp = 1;
while(temp)
{
if(((MFC_W_R >> (2 * (1 - mfc_test_num) + 4)) & 0x01) != 0x01)
{
XBYTE[chat_mfc_resource[1 - mfc_test_num].addr] = 0x3c;//将另一路置为收前发后
temp =0;
}
}
connect(chat_mfc_resource[mfc_test_num].slot,chat_mfc_resource[1 - mfc_test_num].slot);//连接相应时隙
}
break;
case 1://DTMF测试
{
dtmf_test_num = p_data[2];//置测试单元号
audio_dtmf_count--;//剩余数减1
command(8,1,audio_dtmf_count,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE);
audio_dtmf_resource[dtmf_test_num].flag = OCCUPY;//置占用标志
audio_dtmf_resource[dtmf_test_num].delay = 2;//设置测试时间
connect(dtmf_send_slot[p_data[3]],audio_dtmf_resource[dtmf_test_num].slot);//连接相应时隙
}
break;
case 2://提示音测试
{
if(p_data[4] == 1)//开始测试
{
audio_test_num = p_data[2];//置测试单元号
test_duan_num = p_data[3];//置测试段号
audio_dtmf_count--;//剩余数减1
command(8,1,audio_dtmf_count,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE,IDLE);
audio_dtmf_resource[audio_test_num].flag = OCCUPY;//置占用标志
audio_dtmf_resource[audio_test_num].index = 0;
audio_play(audio_test_num,test_duan_num);//放音
connect(audio_dtmf_resource[audio_test_num].slot,CHAIRMAN_SLOT);//连接相应时隙
}
else//停止测试
{
audio_stop(audio_test_num);//停止放音
dtmf_release(audio_test_num);//释放测试单元
no_sound(CHAIRMAN_SLOT);//无音处理
audio_test_num = IDLE;//将测试单元号置为空
test_duan_num = IDLE;//
}
}
break;
case 3://呼叫测试
{
if(p_data[3] == 0x01)//开始测试
{
user_test_num = p_data[2];
user_e1[p_data[2]].flag = OCCUPY;
for(i = 0;i < 6;i++)
{
temp = p_data[i + 4] >> 4;
if(temp != 0)
{
user_e1[p_data[2]].telephone[2 * i] = temp;
}
else
{
user_e1[p_data[2]].telephone[2 * i] = 10;
}
temp = p_data[i + 4] & 0x0f;
if(temp != 0)
{
user_e1[p_data[2]].telephone[2 * i + 1] = temp;
}
else
{
user_e1[p_data[2]].telephone[2 * i + 1] = 10;
}
}
}
else//停止测试
{
user_test_num = IDLE;
connect(CHAIRMAN_SLOT,CHAIRMAN_SLOT);//连接提示音
no_sound(p_data[2]);//无音处理
audio_stop(user_e1[p_data[2]].dtmf);
audio_dtmf_resource[user_e1[p_data[2]].dtmf].auto_flag = LEISURE;
sig_req(SS_OHANG,p_data[2]);//发主叫挂机
user_e1[p_data[2]].delay = 3;//设置150毫秒的等待时间
user_e1[p_data[2]].control = 50;//设置2.5秒的控制时间
user_e1[p_data[2]].lc_state = WAIT_RELEASE;//转到线路信令的处理
user_e1[p_data[2]].mfc_state = IDLE;
}
}
break;
default:
break;
}
}
break;
case 1://系统配置类命令字
{
switch(p_data[1])
{
case 0://虚拟主叫号设置
{
read_warn();
interface_init();
LAN_num_length = p_data[2];//局向号长度
temp = 0;
while(p_data[temp + 3] != IDLE)
{
if(p_data[temp + 3] == 0)
{
id_call[temp] = 0x0a;
}
else
{
id_call[temp] = p_data[temp + 3];
}
temp++;
}
ID_num_length = temp;//虚拟主叫号长度
}
break;
case 1://中继设置
{
for(temp = 0;temp < 8;temp++)
{
user_e1[p_data[2] * 8 + temp].type = p_data[temp + 3];
}
}
break;
case 2://时钟跟踪设置
{
if(p_data[2] == 1)//跟踪时钟
{
time_route = p_data[3];//跟踪的路数
switch(time_route)
{
case 0://0路
{
trk_e1_led = trk_e1_led & 0xf3;
}
case 1://1路
{
trk_e1_led = trk_e1_led & 0xf2;
}
case 2://2路
{
trk_e1_led = trk_e1_led & 0xf1;
}
case 3://3路
{
trk_e1_led = trk_e1_led & 0xf0;
}
break;
default:
break;
}
time_flag = 1;//置跟踪标志
MS_MT9041 = 0;//设置跟踪
XBYTE[0xc700] = trk_e1_led;//置跟踪灯
}
else//设置为自由振荡
{
MS_MT9041 = 1;//设置为自由振荡
time_flag = 0;//清跟踪标志
REF_LED = 1;//熄灭跟踪灯
}
}
break;
case 3://环路忙闲判别标准设置
{
}
break;
case 4://混音增益设置
{
switch(p_data[2] & 0x07)
{
case 0:
{
tone_set = 0xb7; //-6db
}
break;
case 1:
{
tone
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -