版权所有
北京腾控科技有限公司
void send_hj212_real_data(void)
{
INT16U tmp_lenth,tmp_crc;
INT16U tmp,tmp_str_lenth;
INT8U *tmp_dest,*tmp_src;
INT32U send_ctl;
const INT8U send_real_data[]=
{
"CN=2011;"
};
const INT8U send_real_data2[]=
{
"CP=&&DataTime="
};
const INT8U rtd_tab[]=
{
"-Rtd="
};
const INT8U flag_tab[]=
{
"-Flag=N;"
};
tmp_lenth =0;
tmp_dest=sio1_buf;
tmp_src = (INT8U*)start;
for ( tmp=0;tmp <sizeof(start)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
} // "##0000"
tmp_lenth+=tmp;
tmp_src = (INT8U *)syscode_tab[hld_reg[HJ212_SYSCODE]];
tmp_str_lenth =strlen(tmp_src);
for ( tmp=0;tmp <tmp_str_lenth;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp_src=(INT8U*)send_real_data;
for ( tmp=0;tmp <sizeof(send_real_data)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
} //"CN=2011;"
tmp_lenth+=tmp;
tmp_src= pass_word;
for ( tmp=0;tmp <sizeof(pass_word)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
} // "PW=123456"
tmp_lenth+=tmp;
tmp = gen_mn_num( tmp_dest);
tmp_dest +=tmp;
tmp_lenth+=tmp; //"MN=8s8s787000"
tmp_src=(INT8U*) send_real_data2;
for ( tmp=0;tmp <sizeof(send_real_data2)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth+=tmp; //"CP=&&DataTime="
*tmp_dest++='2';tmp_lenth++;
*tmp_dest++='0';tmp_lenth++;
write_hex ( tmp_dest, hld_reg[H_YEAR]);
tmp_dest +=4;tmp_lenth+=4;
write_hex ( tmp_dest, hld_reg[H_DAY]);
tmp_dest +=4;tmp_lenth+=4;
write_hex ( tmp_dest, hld_reg[H_MIN]);
tmp_dest +=4;tmp_lenth+=4;
*tmp_dest++=';'; tmp_lenth++; //"20yymmddhhmmss;"
send_ctl= hld_reg[IEC_CTL2];
send_ctl= send_ctl *65536L +hld_reg[IEC_CTL1];
for ( tmp_crc=0;tmp_crc<32;tmp_crc++ )
{
if ( send_ctl & 1L )
{
//----rtd----
if ( hld_reg[IEC_SEND_NUM +tmp_crc] &0x8000)
{
tmp_src = (INT8U *)polution_tab[hld_reg[IEC_SEND_NUM +tmp_crc]&0xff];
tmp_str_lenth =strlen(tmp_src);
for ( tmp=0;tmp <tmp_str_lenth;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp_src = (INT8U *)rtd_tab;
for ( tmp=0;tmp <sizeof(rtd_tab)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp= sprintf(tmp_dest,"%.2f,",float_data[tmp_crc]);
tmp_dest +=tmp;
tmp_lenth += tmp;
if ( hld_reg[IEC_SEND_NUM +tmp_crc] &0x4000) _NOP();
else
{
tmp_src =(INT8U *) polution_tab[hld_reg[IEC_SEND_NUM +tmp_crc]&0xff];
tmp_str_lenth =strlen(tmp_src);
for ( tmp=0;tmp <tmp_str_lenth;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp_src =(INT8U *) flag_tab;
for ( tmp=0;tmp <sizeof(flag_tab)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
}
}
}
*(tmp_dest-1) = ';';
send_ctl >>=1;
}
send_ctl= hld_reg[IEC_CTL2];
send_ctl= send_ctl *65536L +hld_reg[IEC_CTL1];
for ( tmp_crc=0;tmp_crc<32;tmp_crc++ )
{
if ( send_ctl & 1L )
{
//----rtd----
if (hld_reg[IEC_SEND_NUM +tmp_crc] &0x8000) _NOP();
else
{
tmp_src = (INT8U *)polution_tab[hld_reg[IEC_SEND_NUM +tmp_crc]&0xff];
tmp_str_lenth =strlen(tmp_src);
for ( tmp=0;tmp <tmp_str_lenth;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp_src = (INT8U *)rtd_tab;
for ( tmp=0;tmp <sizeof(rtd_tab)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp= sprintf(tmp_dest,"%.2f,",float_data[tmp_crc]);
tmp_dest +=tmp;
tmp_lenth += tmp;
//------------flag
if ( hld_reg[IEC_SEND_NUM +tmp_crc] &0x4000) _NOP();
else
{
tmp_src =(INT8U *) polution_tab[hld_reg[IEC_SEND_NUM +tmp_crc]&0xff];
tmp_str_lenth =strlen(tmp_src);
for ( tmp=0;tmp <tmp_str_lenth;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
tmp_src =(INT8U *) flag_tab;
for ( tmp=0;tmp <sizeof(flag_tab)-1;tmp ++)
{
*tmp_dest++ = *tmp_src++;
}
tmp_lenth += tmp;
}
}
}
*(tmp_dest-1) = ';';
send_ctl >>=1;
}
if ( hld_reg[HJ212_DIO_CTL] )
{
tmp_crc= di[1];
tmp_crc = tmp_crc *256 +di[0];
tmp=sprintf(tmp_dest,"DI=%x;DO=%x;",tmp_crc,do_out[0]);
tmp_lenth += tmp;
tmp_dest += tmp;
}
*(tmp_dest-1) ='&';
*tmp_dest++ ='&';tmp_lenth++;
write_int( &sio1_buf[2],tmp_lenth-6 );
tmp_crc=hj212_crc ( &sio1_buf[6],tmp_lenth );
write_hex( tmp_dest,tmp_crc);
tmp_dest+=4;
*tmp_dest++ =0x0d;
*tmp_dest =0x0a;
com1_tr();
sio1_led_on();
sio1_tx_lenth =0;
sio1_tx_lenth2=tmp_lenth +6;
UCA0TXBUF= sio1_buf[0];
} |