grgw_wdcj_java/wsdjc/.svn/pristine/30/307176864bae7e1d069eb46bdff...

45 lines
947 B
Plaintext

package com.surfbird.util.convert;
import java.text.DecimalFormat;
/**
* 4-20Ma数据转换公式.
* @author Administrator
* 2018.11.05
**/
public class DataFormula {
/**
* 解析温度变送器数据(0-100)
* @param value
* @return
**/
public static String toT100(String value) {
DecimalFormat format = new DecimalFormat("#####0.##");
int result = Integer.parseInt(value, 16);
return format.format(result/160.0);
}
/**
* 解析温度变送器数据(0-150)
* @param value
* @return
**/
public static String toT150(String value) {
DecimalFormat format = new DecimalFormat("#####0.##");
int result = Integer.parseInt(value, 16);
return format.format(result/106.67);
}
/**
* 解析数据缩小一百倍.
* @param value
* @return
**/
public static String toSmallerHundred(String value) {
DecimalFormat format = new DecimalFormat("#####0.##");
int result = Integer.parseInt(value, 16);
return format.format(result/100.0);
}
}