/**
* 混合动力 Cltc 续航里程 数据初始化
*/
private static void initCltcTotalRemainingRange() {
int value;
try {
float level = BatteryManager.getInstance().getCltcTotalRemainingRange();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initTotalMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init TotalMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.CLTC_TOTAL_REMAINING_MILEAGE, value);
}
/**
* 混合动力 Cltc 续航里程 订阅
*/
private static void subscribeCltcTotalRemainingMileage() {
try {
BatteryManager.getInstance().subscribeCltcTotalRemainingRange(new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float signal) {
LogUtil.info(TAG, "TotalRemainingMileageChanged, value: " + signal);
int value = (int) Math.floor(signal);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.CLTC_TOTAL_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(TAG, "subscribeTotalRemainingMileage error, " + "zoneId: " + zoneId
+ ", errorCode: " + errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeWltcTotalRemainingMileage catch Exception: " + e.getMessage());
}
}
/**
* 纯电 综合 续航里程 数据初始化
*/
private static void initElectricRemainingMileage() {
int value;
try {
float level = BatteryManager.getInstance().getRemainingMileage();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initElectricRemainingMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init ElectricRemainingMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.Electric_REMAINING_MILEAGE, value);
}
/**
* 纯电 综合 纯电续航里程 订阅
*/
private static void subscribeElectricRemainingMileage() {
try {
BatteryManager.getInstance().subscribeRemainingMileage(new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float aFloat) {
LogUtil.info(TAG, "The ElectricRemainingMileageChanged, value is " + aFloat);
int value = (int) Math.floor(aFloat);
AtomAbilityManagement.saveCockpitAttribute(
AtomConstant.Electric_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(
TAG, "subscribeElectricRemainingMileage onFloatErrorSignal, "
+ "the zoneId is "
+ zoneId
+ ", the errorCode is "
+ errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeElectricRemainingMileage catch Exception: " + e.getMessage());
}
}
/**
* 纯电 Wltc 续航里程 数据初始化
*/
private static void initWltcElectricRemainingMileage() {
int value;
try {
float level = BatteryManager.getInstance().getWltcRemainingRange();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initWltcElectricRemainingMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init WltcElectricRemainingMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.WLTC_Electric_REMAINING_MILEAGE, value);
}
/**
* 纯电 Wltc 续航里程 订阅
*/
private static void subscribeWltcElectricRemainingMileage() {
try {
BatteryManager.getInstance().subscribeWltcRemainingRange(new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float aFloat) {
LogUtil.info(TAG, "The WltcElectricRemainingMileageChanged, value is " + aFloat);
int value = (int) Math.floor(aFloat);
AtomAbilityManagement.saveCockpitAttribute(
AtomConstant.WLTC_Electric_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(
TAG, "subscribeWltcElectricRemainingMileage onFloatErrorSignal, "
+ "the zoneId is "
+ zoneId
+ ", the errorCode is "
+ errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeWltcElectricRemainingMileage catch Exception" + e.getMessage());
}
}
/**
* 纯电 Cltc 续航里程 数据初始化
*/
private static void initCltcElectricRemainingMileage() {
int value;
try {
float level = BatteryManager.getInstance().getCltcRemainingRange();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initCltcElectricRemainingMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init CltcElectricRemainingMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.CLTC_Electric_REMAINING_MILEAGE, value);
}
/**
* 纯电 Cltc 续航里程 订阅
*/
private static void subscribeCltcElectricRemainingMileage() {
try {
BatteryManager.getInstance().subscribeCltcRemainingRange(
new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float aFloat) {
LogUtil.info(TAG, "The CltcElectricRemainingMileageChanged, value is " + aFloat);
int value = (int) Math.floor(aFloat);
AtomAbilityManagement.saveCockpitAttribute(
AtomConstant.CLTC_Electric_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(
TAG, "subscribeCltcElectricRemainingMileage onFloatErrorSignal, "
+ "the zoneId is "
+ zoneId
+ ", the errorCode is "
+ errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeCltcElectricRemainingMileage catch Exception" + e.getMessage());
}
}
/**
* 燃油 综合 续航里程 数据初始化
* CLTC_Fuel_REMAINING_MILEAGE
*/
private static void initFuelRemainingMileage() {
int value;
try {
float level = BatteryManager.getInstance().getCltcFuelRemainingRange();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initFuelRemainingMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init FuelRemainingMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.Fuel_REMAINING_MILEAGE, value);
}
/**
* 燃油 综合 续航里程 订阅
*/
private static void subscribeFuelRemainingMileage() {
try {
BatteryManager.getInstance().subscribeCltcFuelRemainingRange(
new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float aFloat) {
LogUtil.info(TAG, "The FuelRemainingMileageChanged, value is " + aFloat);
int value = (int) Math.floor(aFloat);
AtomAbilityManagement.saveCockpitAttribute(
AtomConstant.Fuel_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(
TAG, "subscribeFuelRemainingMileage onFloatErrorSignal, "
+ "the zoneId is "
+ zoneId
+ ", the errorCode is "
+ errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeCltcFuelRemainingMileage catch Exception" + e.getMessage());
}
}
/**
* 燃油 Wltc 续航里程 数据初始化
*/
private static void initeWltcFuelRemainingMileage() {
int value;
try {
float level = BatteryManager.getInstance().getWltcFuelRemainingRange();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initWltcFuelRemainingMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init WltcFuelRemainingMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.CLTC_Fuel_REMAINING_MILEAGE, value);
}
/**
* 燃油 Wltc 续航里程 订阅
*/
private static void subscribeWltcFuelRemainingMileage() {
try {
BatteryManager.getInstance().subscribeWltcFuelRemainingRange(
new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float aFloat) {
LogUtil.info(TAG, "The WltcFuelRemainingMileageChanged, value is " + aFloat);
int value = (int) Math.floor(aFloat);
AtomAbilityManagement.saveCockpitAttribute(
AtomConstant.CLTC_Fuel_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(
TAG, "subscribeCltcFuelRemainingMileage onFloatErrorSignal, "
+ "the zoneId is "
+ zoneId
+ ", the errorCode is "
+ errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeCltcFuelRemainingMileage catch Exception" + e.getMessage());
}
}
/**
* 燃油 Cltc 续航里程 数据初始化
*/
private static void initCltcFuelRemainingMileage() {
int value;
try {
float level = BatteryManager.getInstance().getCltcFuelRemainingRange();
value = (int) Math.floor(level);
} catch (Exception e) {
LogUtil.error(TAG, "initCltcFuelRemainingMileage catch exception" + e.getMessage());
value = ConstantUtil.INVALID_SIGNAL_VALUE;
}
LogUtil.info(TAG, "Get the init CltcFuelRemainingMileage is " + value);
AtomAbilityManagement.saveCockpitAttribute(AtomConstant.CLTC_Fuel_REMAINING_MILEAGE, value);
}
/**
* 燃油 Cltc 续航里程 订阅
*/
private static void subscribeCltcFuelRemainingMileage() {
try {
BatteryManager.getInstance().subscribeCltcFuelRemainingRange(
new FloatSubscribeCallback() {
@Override
public void onFloatChangeSignal(Float aFloat) {
LogUtil.info(TAG, "The CLTCFuelRemainingMileageChanged, value is " + aFloat);
int value = (int) Math.floor(aFloat);
AtomAbilityManagement.saveCockpitAttribute(
AtomConstant.CLTC_Fuel_REMAINING_MILEAGE, value);
}
@Override
public void onFloatErrorSignal(int zoneId, int errorCode) {
LogUtil.error(
TAG, "subscribeCltcFuelRemainingMileage onFloatErrorSignal, "
+ "the zoneId is "
+ zoneId
+ ", the errorCode is "
+ errorCode);
}
});
} catch (Exception e) {
LogUtil.error(TAG, "subscribeCltcFuelRemainingMileage catch Exception" + e.getMessage());
}
}
这段代码重复的部分可以抽出来吗