偏移计算

This commit is contained in:
ZZ 2021-08-23 19:16:42 +08:00
parent 8455982258
commit 7c85579c86
2 changed files with 6 additions and 4 deletions

View File

@ -127,9 +127,7 @@ public class RealtimeDataLogic implements ServiceLogic {
return new ServiceResult(false); return new ServiceResult(false);
} }
private CacheRealtimeData translate(RealtimeData realtimeData) throws InvocationTargetException, IllegalAccessException, InstantiationException {
private CacheRealtimeData translate(RealtimeData realtimeData) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException, InstantiationException {
Class<CacheRealtimeData> crdclz = CacheRealtimeData.class; Class<CacheRealtimeData> crdclz = CacheRealtimeData.class;
Class<RealtimeData> rdclz = RealtimeData.class; Class<RealtimeData> rdclz = RealtimeData.class;

View File

@ -24,7 +24,11 @@ public class CacheDataUtils {
Object tarval; Object tarval;
if (tarfield.getType().getSimpleName().equals("Integer")) { if (tarfield.getType().getSimpleName().equals("Integer")) {
if (srcval.length() == 2) { if (srcval.length() == 2) {
tarval = Integer.parseInt(srcval, 16); tarval = Integer.valueOf(srcval, 16);
if (tarfield.getName().endsWith("Temperature")) {
tarval = (Integer) tarval - 50;
tarval = (Integer) tarval > 0 ? tarval : 0;
}
} else { } else {
tarval = HexUtils.reverseHexInt(srcval); tarval = HexUtils.reverseHexInt(srcval);
} }