do_setpara.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:12k
- #include "My_head.h"
- #include "key.h"
- #include "mem_addr.h"
- /*************************************************/
- /*
- void My_KeyBuf_Clear(void)
- {
- memset(&thekey,0,sizeof(thekey));
- }
- bit My_Save_Key(BYTE Key)
- {
- if(thekey.key_count>KEY_SIZE-1)return(FALSE);
- thekey.key_buf[thekey.key_count++]=Key;
- return(TRUE);
- }
- bit My_Back_Key(void)
- {
- if(thekey.key_count<1)return(FALSE);
- thekey.key_count--;
- return(TRUE);
- }
- void My_Dis_KeyBuf(void)
- {
- BYTE buf[8];
- char i,j=thekey.key_count-1;
- for(i=7;(i>=0)&&(j>=0);i--,j--)
- {
- buf[i]=~D_DISPLAY[thekey.key_buf[j]];
- }
- for(;i>=0;i--)buf[i]=~D_DISPLAY[18];
- Display_str(buf);//Do_Led(buf[0]);
- }
- */
- BYTE code for_test_str[]={1,2,3,4,5,6,7,8,9,0};
- BYTE code my_super_str[]={1,6,7,3,8,8,8,8,2,2};
- //bit set_del_enble_flag=FALSE;
- bit my_for_test_bit=FALSE;
- /*
- bit Chech_PassWord(void)
- {
- BYTE *ptr=thekey.key_buf,i,j;
- if(ptr[1]!= KEY_FUN )return(FALSE);
- set_del_enble_flag=my_for_test_bit=FALSE;//"功能+功能+任何键+确认"将注销权限!!
- if(!memcmp(&ptr[2],for_test_str,10))
- {
- my_for_test_bit=TRUE;
- Stop_Timer(SETDEL_PASSWORD_Tevent);
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_PRESSKEY_TIME);
- return(TRUE);
- }
- if(!memcmp(&ptr[2],my_super_str,10))
- {
- memcpy(op_user_info.op_password,"x11x11x11",3);
- if(Saveparam_To_Mem()!=SUCCESS)return(FALSE);
- set_del_enble_flag=TRUE;
- Stop_Timer(SETDEL_PASSWORD_Tevent);
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_PRESSKEY_TIME);
- return(TRUE);
- }
- for(i=2;i<8;i++)
- {
- if(i%2)j=op_user_info.op_password[(i-2)/2]&0x0f;
- else j=op_user_info.op_password[(i-2)/2]>>0x4;
- //SendStr(&ptr[i],1);SendStr(&j,1);
- if(ptr[i] != j)return(FALSE);
- }
- if(thekey.key_count<9)
- {
- set_del_enble_flag=TRUE;
- Stop_Timer(SETDEL_PASSWORD_Tevent);
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_PRESSKEY_TIME);
- return(TRUE);//password is right!
- }
- if((ptr[8] != KEY_FUN) || (thekey.key_count != 15))return(FALSE);
- //modify password
- for(i=9;i<15;i++)if(ptr[i]>9)return(FALSE);
- for(i=9;i<15;i+=2)
- {
- op_user_info.op_password[(i-9)/2] = (ptr[i]<<4)|(ptr[i+1]&0xf);
- }
- //SendStr(op_user_info.op_password,3);
- if((i=Saveparam_To_Mem())!=SUCCESS)return(FALSE);
- set_del_enble_flag=TRUE;
- Stop_Timer(SETDEL_PASSWORD_Tevent);
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_PRESSKEY_TIME);
- return(TRUE);
- }
- */
- void Into_SeedCardInit(void)
- {
- Do_DisLed_Flash(0xff,0x00,25);
- //Stop_Timer(DIS_CLOCKEVENT_Tevent);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);
- Stop_Timer(WAIT_EXIT_Tevent);
- Set_TimerEvent(WAIT_EXIT_Tevent,WAIT_EXIT_TIME);
- SetCurState(MY_TEST_STATUS);
- }
- BYTE Do_SetPara(void)
- {
- BYTE idata *ptr=thekey.key_buf;
- BYTE count =thekey.key_count,i;
- if( (count<4) || (ptr[3]!=KEY_FUN) )return(FORMAT_ERR);
- switch(ptr[1])
- {
- case 0: //一些初始化操作;
- switch(ptr[2])
- {
- case 0: //所有内存初始(恢复出厂状态)
- if(count>4)return(FORMAT_ERR);
- //WAIT SEEDCARD OR OPCARD OR ENTER KEY
- //OLSE PRESS CANCAL KAY!
- //需要操作员卡???
- count=ClearConParam_From_Mem();
- if(count!=SUCCESS)return(count);
- break;
- case 1: //--单位用户用子卡初始化
- if((con_statusinfo.con_records>0))return(OP_UNALLOWED);//可能还有消费数据
- if(count>4)return(FORMAT_ERR);
- Into_SeedCardInit();//进入!
- return(SUCCESS);
- case 2: //--修改机号
- if((con_statusinfo.con_records>0))return(OP_UNALLOWED);//可能还有消费数据
- if((count<5)||(count>8))return(FORMAT_ERR);
- equip_addr.number_addr=0;
- for(i=4;i<count;i++)
- {
- if(ptr[i]>9)continue; //for KEY_FUN!
- equip_addr.number_addr *= 10;
- equip_addr.number_addr += ptr[i];
- }
- break;
- case 3: //--修改模式
- /* if((count<5)||(count>5)||(ptr[4]<1)||(ptr[4]>4))return(FORMAT_ERR);
- con_param_info.con_mode = ptr[4];
- Dis_ConMode();*/
- break;
- default: return(FORMAT_ERR);
- }
- break;
- case 1: //修改时间参数1(金额)
- switch(ptr[2])
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4: //定义消费时间段(1-5)
- if((count<5)||(count>8))return(FORMAT_ERR);
- break;
- case 7://记时消费模式下的单位时间(时、分);
- break;
- case 8://设置机器时钟(时分秒)
- break;
- case 9://设置机器时钟(年月日)
- break;
- default:break;
- }
- break;
- case 2: //修改消费参数1(金额)
- switch(ptr[2])
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4: //时间段(1-5)定值金额(单位:分)
- /* if((count<5)||(count>9))return(FORMAT_ERR);
- con_param_info.dz_money[ptr[2]]=0;
- for(i=4;i<count;i++)
- {
- if(ptr[i]>9)continue; //for KEY_FUN!
- con_param_info.dz_money[ptr[2]] *= 10;
- con_param_info.dz_money[ptr[2]] += ptr[i];
- }*/
- break;
- case 9: //修改卡最大有效余额。(单位:分)
- /* if((count<5)||(count>11))return(FORMAT_ERR);
- con_param_info.max_money=0;
- for(i=4;i<count;i++)
- {
- if(ptr[i]>9)continue; //for KEY_FUN!
- con_param_info.max_money *= 10;
- con_param_info.max_money += ptr[i];
- }*/
- break;
- default: return(FORMAT_ERR);
- }
- break;
- case 3: //修改消费参数2
- switch(ptr[2])
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4: //记时消费模式下单位金额(与时间段对应,单位:分)
- /* if((count<5)||(count>9))return(FORMAT_ERR);
- con_param_info.Js_money[ptr[2]]=0;
- for(i=4;i<count;i++)
- {
- if(ptr[i]>9)continue; //for KEY_FUN!
- con_param_info.Js_money[ptr[2]] *= 10;
- con_param_info.Js_money[ptr[2]] += ptr[i];
- }*/
- break;
- default: return(FORMAT_ERR);
- }
- break;
- default: return(FORMAT_ERR);
- }
- //不需要卡片的往这边来。
- count=Saveparam_To_Mem();
- do_buzzer(BUZZER_SUCCESS);
- Dis_Err(count);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- SetCurState(IDEL_STATUS);
- return(SUCCESS);
- }
- void Do_My_EquipCheck(void)
- {
- /*
- BYTE i;
- /*****************************
- if((KeyStr.Keys[0] == '#')&&(KeyStr.Keys[1] == '*')&&(KeyStr.Keys[2] =='#'))
- { //this is a test!!
- mysometest();
- Renew_To_AllInit();
- return;
- }
- /*****************************
- if((KeyStr.Keys[0] == '#')&&(KeyStr.Keys[1] == '0')&&(KeyStr.Keys[2] =='#'))
- {//this is a test!!
- memcpy(incallcode.Codes,"00000",5);//display version
- incallcode.Codes[5]=MyReVision_Str[0];
- incallcode.Codes[6]=MyReVision_Str[1];
- incallcode.Codes[7]=MyReVision_Str[2];
- incallcode.Count=8;
- WaitHookUp();
- RLS_SEND_RING;delay_seconds(1);RLS_STOP_RING;
- send_CID_flag=FALSE;
- Send_CallInCode();
- send_CID_flag=FALSE;
- Renew_To_AllInit();
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_KEY_TIME);
- return;
- }
- if((KeyStr.Keys[0] == '*')&&(KeyStr.Keys[1] == '*')&&(KeyStr.Keys[2] == '#'))
- {
- set_del_enble_flag=my_for_test_bit=FALSE;
- Renew_To_AllInit();
- return;
- }
- if((KeyStr.Keys[0] == '*')&&(KeyStr.Keys[1] == '0')&&(KeyStr.Keys[2] == '#'))
- {
- Display_Sign();
- Renew_To_AllInit();
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_KEY_TIME);
- return;
- }
- if((KeyStr.Keys[0] == '*')&&(KeyStr.Keys[1] == '1')&&(KeyStr.Keys[2] == '#'))
- {
- if(Test_24lc64())memcpy (incallcode.Codes,"11111111",INCALLCODE_SIZE);
- else memcpy (incallcode.Codes,"33333333",INCALLCODE_SIZE);
- incallcode.Count=8;
- WaitHookUp();
- RLS_SEND_RING;delay_seconds(1);RLS_STOP_RING;
- send_CID_flag=FALSE;
- Send_CallInCode();
- send_CID_flag=FALSE;
- Renew_To_AllInit();
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_KEY_TIME);
- return;
- }
- if((KeyStr.Keys[0] == '*')&&(KeyStr.Keys[1] == '2')&&(KeyStr.Keys[2] == '#'))
- {
- WaitHookUp();
- RLS_SEND_FJ;
- delay_seconds(2);
- RLS_SEND_RING;
- delay_seconds(2);
- Renew_To_AllInit();
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_KEY_TIME);
- return;
- }
- if((KeyStr.Keys[KeyStr.Count-2] == '*')&&(KeyStr.Keys[KeyStr.Count-1] == '#'))
- {
- memcpy (incallcode.Codes,KeyStr.Keys,INCALLCODE_SIZE);
- if(KeyStr.Count>INCALLCODE_SIZE)incallcode.Count=INCALLCODE_SIZE;
- else incallcode.Count=KeyStr.Count;
- WaitHookUp();
- RLS_SEND_RING;
- delay_seconds(1);
- RLS_STOP_RING;
- send_CID_flag=FALSE;
- Send_CallInCode();
- send_CID_flag=FALSE;
- Renew_To_AllInit();
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_KEY_TIME);
- return;
- }
- */
- }
- /*
- BYTE Do_SetParaKey_Even_11(BYTE Key)
- {
- BYTE i;
- if(Key > KEY_MAX-1)return(Key);
- Stop_Timer(WAIT_PRESSKEY_Tevent);
- Set_TimerEvent(WAIT_PRESSKEY_Tevent,SET_PRESSKEY_TIME);
- switch(Key)
- {
- case KEY_0 : Key =0; break;
- case KEY_1 : Key =1; break;
- case KEY_2 : Key =2; break;
- case KEY_3 : Key =3; break;
- case KEY_4 : Key =4; break;
- case KEY_5 : Key =5; break;
- case KEY_6 : Key =6; break;
- case KEY_7 : Key =7; break;
- case KEY_8 : Key =8; break;
- case KEY_9 : Key =9; break;
- case KEY_FUN:Key =19;break;
- case KEY_ENTER1:
- case KEY_ENTER2:
- if(Chech_PassWord())
- {
- do_buzzer(BUZZER_SUCCESS);
- Dis_Err(SUCCESS);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- SetCurState(IDEL_STATUS);
- return(SUCCESS);
- }
- if(my_for_test_bit)
- {
- Do_My_EquipCheck();
- Renew_To_AllInit();
- return(0);
- }
- if(!set_del_enble_flag)
- {
- //SendStr("T:",2);
- My_Do_Buzzer(350,3);//do_buzzer(BUZZER_ERROR);
- Dis_Err(PWDPOWER_ERR_CODE);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- SetCurState(IDEL_STATUS);
- return(PWDPOWER_ERR_CODE);
- }
- if((i=Do_SetPara())!=SUCCESS)
- {
- do_buzzer(BUZZER_ERROR);
- Dis_Err(i);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- SetCurState(IDEL_STATUS);
- return(FAILURE);
- }
- Stop_Timer(SETDEL_PASSWORD_Tevent);
- Set_TimerEvent(SETDEL_PASSWORD_Tevent,SET_PRESSKEY_TIME);
- return(SUCCESS);
- case KEY_CANCEL:Renew_To_AllInit();
- return(0);
- case KEY_BACK: if(!My_Back_Key())
- {
- Renew_To_AllInit();
- return(0);
- }
- My_Dis_KeyBuf();
- return(0);
- default:return(Key);
- }
- if(!My_Save_Key(Key))do_buzzer(BUZZER_ALARM);
- else My_Dis_KeyBuf();
- return(SUCCESS);
- }
- */