/** \数据处理
* \param rid RTU ID
* \param dat 原始数据
*/
void data_process(unsigned char rid, int32_t dat)
{
int32_t temp;
//一阶滤波
if ((rid != RID_WIND_DIRCT) && (rid != RID_RAIN) && (rid != RID_RAIN_24H) && (rid != RID_RAIN_12H)
&& (rid != RID_RAIN_1H) && (rid != RID_RAIN_30M)) {
temp = dat * rtu_data_mult[rid] * 10l; ////
temp += rtu_data[rid] * 0l; //// 这三句计算是错的,有时错,有时对。勾选USE microlib时没有问题!
temp = temp / 10; ////
}
else {
temp = dat * rtu_data_mult[rid];
}
//温度校正
if (rid == RID_TEMP) {
temp = temp * 24 / 25;
}
if (BCK(power_valid, rid)) {
rtu_data[rid] = temp;
#if DEBUG
//调试输出
dbg_printf(" %s:%d\r\n", param_name[rid], rtu_data[rid]);
#endif
}
}
|