//
void SetWire(void)
{
TU_UINT16 reg;
unsigned char buf[6];
reg.ID = Price;
buf[0] = reg.CD[0]; buf[1] = reg.CD[1];
reg.ID = Uxxx;
buf[2] = reg.CD[0]; buf[3] = reg.CD[1];
I_send_str(0x00,buf,4); //
reg.ID = Uaax;
buf[0] = reg.CD[0]; buf[1] = reg.CD[1];
reg.ID = Uabx;
buf[2] = reg.CD[0]; buf[3] = reg.CD[1];
reg.ID = Uacx;
buf[4] = reg.CD[0]; buf[5] = reg.CD[1];
I_send_str(0x08,buf,6); //
}
//
void SetRead(void)
{
TU_UINT16 reg;
unsigned char buf[6];
I_read_str(0x00,buf,4); ///
reg.CD[0]= buf[0]; reg.CD[1]= buf[1];
if(reg.ID>9999) Price = 620;
else Price = reg.ID;
reg.CD[0]=buf[2]; reg.CD[1]=buf[3];
if(reg.ID>9999) Uxxx = 1400;
else Uxxx = reg.ID;
I_read_str(0x08,buf,6); ///
reg.CD[0]= buf[0]; reg.CD[1]= buf[1];
if(reg.ID>9999) Uaax = 15;
else Uaax = reg.ID;
reg.CD[0]= buf[2]; reg.CD[1]= buf[3];
if(reg.ID>9999) Uabx = 31;
else Uabx = reg.ID;
reg.CD[0]= buf[4]; reg.CD[1]= buf[5];
if(reg.ID>9999) Uacx = 45;
else Uacx = reg.ID;
}
///每次运行的数
void RunWirte(void)
{
TU_UINT32 reg1;
unsigned char buf[8];
reg1.ID = PData;
buf[0]=reg1.CD[0]; buf[1]=reg1.CD[1];
buf[2]=reg1.CD[2]; buf[3]=reg1.CD[3]; //P
reg1.ID = LData;
buf[4]=reg1.CD[0]; buf[5]=reg1.CD[1];
buf[6]=reg1.CD[2]; buf[7]=reg1.CD[3]; //L
I_send_str(dat[RunNum],buf,8); ///
}
void TotalRead(void)
{
TU_UINT32 reg1;
unsigned char buf[6];
I_read_str(0x10,buf,5); //L
RunNum = buf[0];
reg1.CD[0]=buf[1]; reg1.CD[1]=buf[2];
reg1.CD[2]=buf[3]; reg1.CD[3]=buf[4];
TotalL = reg1.ID;
I_read_str(0x98,buf,4); //P
reg1.CD[0]=buf[0]; reg1.CD[1]=buf[1];
reg1.CD[2]=buf[2]; reg1.CD[3]=buf[3];
TotalP = reg1.ID;
}
//
void TotalWirte(void)
{
TU_UINT32 reg1,reg2;
unsigned char buf[6],i;
//总累计和运行次数
RunNum++;
if(RunNum>=10) RunNum=0;
reg1.ID = TotalL+10;
buf[0]=RunNum;
buf[1]=reg1.CD[0]; buf[2]=reg1.CD[1];
buf[3]=reg1.CD[2]; buf[4]=reg1.CD[3];
I_send_str(0X10,buf,5);
reg2.ID = TotalP+10;
buf[0]=reg2.CD[0]; buf[1]=reg2.CD[1];
buf[2]=reg2.CD[2]; buf[3]=reg2.CD[3];
for(i=0;i<5;i++)
I_send_str(0X98,buf,4);
}
这个保存有问题,下一个reg2.ID保存不了 |