#define Set_Param_GLOBAL
#include "INCLUDES.H"
unsigned int code PosGol[][2]=
{
{64,23},{118,23},{172,23},{226,23}
};
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//1x每类的页数
unsigned char code Page[]=
{1,1,1};
//2xx每页的变量数
unsigned char code ParaNo1T[]=
{7};
unsigned char code ParaNo2T[]=
{2};
unsigned char code ParaNo3T[]=
{4};
//3xxx变量最大字节数
unsigned char code ParaByteNo1T[]=
{
4,4,2,2,10,1,1
};
unsigned char code ParaByteNo2T1P[]=
{
10,10
};
unsigned char code ParaByteNo3T1P[]=
{
4,4,4,4
};
//4xxxx每个变量显示的字符数
unsigned char code DisCharNo1T1P[]=
{
5,5,4,4,10,2,1
};
unsigned char code DisCharNo2T1P[]=
{
10,10
};
unsigned char code DisCharNo3T1P[]=
{
5,6,5,6
};
//5xxxxx每个变量的定位
//(1类1页)
unsigned int code Position1T1P[][2]=
{
{5,0},{20,0},{5,16},{20,16},{9,32},{28,32},{28,48}
};
//(2类1页)
unsigned int code Position2T1P[][2]=
{
{10,16},{10,32}
};
unsigned int code Position3T1P[][2]=
{
{6,16},{20,16},{6,32},{20,32}
};
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
unsigned char xdata SetTempBuff[CharMaxNo];//暂存键盘输入值
unsigned char xdata SetByte[ParMaxNo];//暂存当前页各参数的字节数
//当前页的内容暂存 DisSet[变量][第几个字符]
unsigned char xdata No,DisSet[ParMaxNo][CharMaxNo];
//当前变量在整个结构中的字节地址 CurParNo当前通道的变量数
unsigned char xdata CurByte, CurParNo, CurrentNO,SetTempNo;
//unsigned char xdata GolBuff[MaxByte];
unsigned int xdata TempX, TempY; //X,Y定位
unsigned char xdata TempByte;//当前变量的字符数
unsigned int xdata CurrPageToaByte;//当前页总的字节数
unsigned char xdata Temp[3];
void SetRead(); //读出当前页的内容
void SetBegin(); //将变量的值以字符形式转换出来
void ValuePara(); //各变量的X,Y定位及显示的字符数
void MovePosition();//位置移动
void SaveValue();//转换内容,保存到存储器中
void SetEnd();//将当前页的内容转换到相应的变量中
bit SendIsTrue();
void SetRead()
{
unsigned char idata i;
Interface(CurrentType, CurrentPage);
if(CurrentType==1)
{
CurParNo=ParaNo1T[CurrentPage-1];//变量数
for(i=0; i<sizeof(ParaByteNo1T); i++)
{//每个变量的字节数
SetByte[i]=ParaByteNo1T[i];
CurrPageToaByte +=SetByte[i];
}
for(i=0; i<sizeof(Product);i++)
{
GolBuff[i]=SM_Receive(i+PRODUCTADD);
}
}//if(CurrentType==1)
else if(CurrentType==2)
{
CurParNo=ParaNo2T[CurrentPage-1];//变量数
for(i=0; i<sizeof(ParaByteNo2T1P); i++)
{//每个变量的字节数
SetByte[i]=ParaByteNo2T1P[i];
CurrPageToaByte +=SetByte[i];
}
for(i=0; i<sizeof(UnLockRFID);i++)
{
GolBuff[i]=SM_Receive(i+UNLOCKTADD);
}
}//if(CurrentType==2)
else if(CurrentType==3)
{
CurParNo=ParaNo3T[CurrentPage-1];//变量数
for(i=0; i<sizeof(ParaByteNo3T1P); i++)
{//每个变量的字节数
SetByte[i]=ParaByteNo3T1P[i];
CurrPageToaByte +=SetByte[i];
}
for(i=0; i<sizeof(JiaoZhen);i++)
{
GolBuff[i]=SM_Receive(i+JIAOZHUNADD);
}
}//if(CurrentType==3)
}//void SetRead()
//将变量的值以字符形式转换出来
void SetBegin()
{
unsigned char idata i;
unsigned char xdata CurNo, tempNo;//从GolBuff[i]第几个字节取值,当前的字节数
CurNo=0;
//将变量的值以字符形式存放在SetTempBuff[i]中便于显示
//存放在DisSet[k][i]中便于输入时更新
// for(CurrentNO=0; CurrentNO<CurParNo; CurrentNO++)//test20090323
for(CurrentNO=0; CurrentNO<CurParNo; CurrentNO++)
{
switch(SetByte[CurrentNO])
{
case 1://单字节字符
IntTo.Char[0]=0;
IntTo.Char[1]=GolBuff[CurNo];
No = itoa(IntTo.Int);
break;
case 2: //整形
for(i=0; i<2; i++)
{
IntTo.Char[i]=GolBuff[CurNo+i];
}
No = itoa(IntTo.Int);
break;
case 4: //浮点
for(i=0; i<4; i++)
{
FloatTo.Char[i]=GolBuff[CurNo+i];
}
// No=sprintf(DisBuf,"%-5.2f",FloatTo.Float);
No=ftoa(FloatTo.Float,3);
break;
case 3:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15://字符数组
i=0;
tempNo=SetByte[CurrentNO];
while(tempNo--)
{
DisBuf[i]=GolBuff[CurNo+i];
i++;
};
No=i;
DisBuf[i]=0;
break;
default:
break;
}//switch(SetByte[i])
CurNo +=SetByte[CurrentNO];
for(i=0;i<No;i++)
{
DisSet[CurrentNO][i] = DisBuf[i];//将变量的值以字符形式存放
SetTempBuff[i] = DisBuf[i];//显示用
}
SetTempBuff[i]=0;
DisSet[CurrentNO][i] = 0;
DisPara(0);
}//for(i=0, j=0; i<sizeof(SetByte); j++,i++)
//将第一个变量作显示
i=0;
while(DisSet[0][i]!=0)
{
SetTempBuff[i]=DisSet[0][i];
i++;
}
SetTempBuff[i]=0;
CurrentNO=0;
}//void SetBegin()
//各变量的X,Y定位及显示的字符数
void ValuePara()
{
if(CurrentType==1)
{
TempX = Position1T1P[CurrentNO][0];
TempY = Position1T1P[CurrentNO][1];
TempByte = DisCharNo1T1P[CurrentNO];
}
else if(CurrentType==2)
{
TempX = Position2T1P[CurrentNO][0];
TempY = Position2T1P[CurrentNO][1];
TempByte = DisCharNo2T1P[CurrentNO];
}
else if(CurrentType==3)
{
TempX = Position3T1P[CurrentNO][0];
TempY = Position3T1P[CurrentNO][1];
TempByte = DisCharNo3T1P[CurrentNO];
}
}//void ValuePara()
//将当前字符数组的内容转换到GolBuff[i]中
void SetEnd()
{
unsigned char idata i;
for(CurByte=0,CurrentNO=0; CurrentNO<CurParNo; CurrentNO++)
{
switch(SetByte[CurrentNO])
{
case 1:
IntTo.Int=atoi(DisSet[CurrentNO]);
GolBuff[CurByte]=IntTo.Char[1];
break;
case 2:
IntTo.Int=atoi(DisSet[CurrentNO]);
for(i=0; i<2; i++)
{
GolBuff[CurByte+i]=IntTo.Char[i];
}
break;
case 4: //浮点
FloatTo.Float=atof(DisSet[CurrentNO]);
for(i=0; i<4; i++)
{
GolBuff[CurByte+i]=FloatTo.Char[i];
}
break;
case 3:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15://字符数组
i=0;
while(DisSet[CurrentNO][i]!=0)
{
GolBuff[CurByte+i]=DisSet[CurrentNO][i];
i++;
};
break;
default:
break;
}//switch(SetByte[i])
CurByte +=SetByte[CurrentNO]; //累加 计算出当前变量在其所在结构中的字节位置
}
}//void SetEnd()
void SaveValue()
{
unsigned char idata i;
for(i=0; i<MaxByte; i++)
{GolBuff[i]=0;}
SetEnd();
if(CurrentType==1)
{
for(i=0; i<sizeof(Product);i++)
{
SM_Send(i+PRODUCTADD,GolBuff[i]);
}
Point = (unsigned char *)&Product.MaxValue;
for(i=0; i<sizeof(Product);i++)
{
*Point++=SM_Receive(i+PRODUCTADD);
}
}
else if(CurrentType==2)
{
for(i=0; i<sizeof(UnLockRFID);i++)
{
SM_Send(i+UNLOCKTADD,GolBuff[i]);
}
Point = (unsigned char *)&UnLockRFID[0][0];
for(i=0; i<sizeof(UnLockRFID);i++)
{
*Point++=SM_Receive(i+UNLOCKTADD);
}
}
else if(CurrentType==3)
{
for(i=0; i<sizeof(JiaoZhen);i++)
{
SM_Send(i+JIAOZHUNADD,GolBuff[i]);
}
Point = (unsigned char *)&JiaoZhen.BiaoZhunZhongLiang1;
for(i=0; i<sizeof(JiaoZhen);i++)
{
*Point++=SM_Receive(i+JIAOZHUNADD);
}
//斜率
XieLu= (JiaoZhen.BiaoZhunZhongLiang2-JiaoZhen.BiaoZhunZhongLiang1)/(JiaoZhen.BiaoZhunDianYa2-JiaoZhen.BiaoZhunDianYa1);
// XieLvValue=(JiaoZhen.BiaoZhunDianYa2-JiaoZhen.BiaoZhunDianYa1)/(JiaoZhen.BiaoZhunZhongLiang2-JiaoZhen.BiaoZhunZhongLiang1);
// Basic = (XieLvValue*JiaoZhen.BiaoZhunZhongLiang2-JiaoZhen.BiaoZhunDianYa2)/XieLvValue;
}
}//void