模拟器
parent
e9528c8e4b
commit
4c978050f0
|
@ -79,4 +79,15 @@ public class VehicleUtils {
|
|||
num = (double) Math.round(num * 100) / 100;
|
||||
return BigDecimal.valueOf(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给予开始和结束的值生成数据
|
||||
* @param start 起始范围
|
||||
* @param end 截止范围
|
||||
* @return 返回结果
|
||||
*/
|
||||
public static String genValue(int start, int end){
|
||||
Random rand = new Random();
|
||||
return String.valueOf(rand.nextInt(start, end));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.Objects;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import static com.muyu.common.SystemConstant.powerConsumption;
|
||||
|
||||
/**
|
||||
* @author DongZeLiang
|
||||
* @version 1.0
|
||||
|
@ -36,28 +38,22 @@ import java.util.concurrent.ScheduledFuture;
|
|||
@AllArgsConstructor
|
||||
public class VehicleInstance {
|
||||
|
||||
/**
|
||||
* 路径队列
|
||||
*/
|
||||
private final LinkedBlockingQueue<PositionModel> positionQueue = new LinkedBlockingQueue<>();
|
||||
/**
|
||||
* 车辆
|
||||
*/
|
||||
private Vehicle vehicle;
|
||||
|
||||
|
||||
/**
|
||||
* 实例数据
|
||||
*/
|
||||
private VehicleData vehicleData;
|
||||
|
||||
/**
|
||||
* 上一个定位点
|
||||
*/
|
||||
private PositionModel lastPosition;
|
||||
|
||||
/**
|
||||
* 路径队列
|
||||
*/
|
||||
private final LinkedBlockingQueue<PositionModel> positionQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
|
||||
/**
|
||||
* 车辆工作线程
|
||||
*/
|
||||
|
@ -172,6 +168,10 @@ public class VehicleInstance {
|
|||
* 模拟车辆数据
|
||||
*/
|
||||
public void imitateData() {
|
||||
String gear = this.vehicleData.getGear();
|
||||
if (!gear.equals("D")){
|
||||
// TODO 不为D档,则无法启动车辆
|
||||
}
|
||||
// 获取上一次定位点
|
||||
PositionModel lastPositionModel = this.lastPosition;
|
||||
// 获取当前定位点
|
||||
|
@ -192,10 +192,19 @@ public class VehicleInstance {
|
|||
// 百公里占比
|
||||
BigDecimal hundredKMScale = distance.divide(SystemConstant.hundredKilometers).setScale(3, RoundingMode.HALF_UP);
|
||||
// 使用电量
|
||||
BigDecimal powerUsage = SystemConstant.powerConsumption.multiply(hundredKMScale)
|
||||
BigDecimal powerUsage = powerConsumption.multiply(hundredKMScale)
|
||||
.multiply(batteryFloat)
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
// 剩余电量
|
||||
vehicleData.setRemainingBattery(vehicleData.getRemainingBattery().subtract(powerUsage));
|
||||
// 百公里消耗量
|
||||
vehicleData.setFuelConsumptionRate(
|
||||
powerConsumption.multiply(batteryFloat).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_UP).toString()
|
||||
);
|
||||
// 计算总速度
|
||||
vehicleData.setSpeed(
|
||||
distance.divide(new BigDecimal(10)).multiply(new BigDecimal("3.6")).setScale(2, RoundingMode.HALF_UP).toString()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.vehicle.model;
|
|||
|
||||
|
||||
import com.muyu.domain.Vehicle;
|
||||
import com.muyu.utils.VehicleUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -9,6 +10,8 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static com.muyu.utils.VehicleUtils.genValue;
|
||||
|
||||
/**
|
||||
* @author 牧鱼
|
||||
* @Classname VehicleData
|
||||
|
@ -396,74 +399,65 @@ public class VehicleData {
|
|||
}
|
||||
|
||||
/**
|
||||
VIN
|
||||
vin;
|
||||
行驶路线
|
||||
drivingRoute;
|
||||
经度
|
||||
longitude;
|
||||
维度
|
||||
latitude;
|
||||
速度
|
||||
speed;
|
||||
里程
|
||||
mileage;
|
||||
总电压
|
||||
voltage;
|
||||
总电流
|
||||
current;
|
||||
绝缘电阻
|
||||
resistance;
|
||||
档位
|
||||
gear;
|
||||
加速踏板行程值
|
||||
accelerationPedal;
|
||||
制动踏板行程值
|
||||
brakePedal;
|
||||
燃料消耗率
|
||||
fuelConsumptionRate;
|
||||
* 模拟基础项
|
||||
*/
|
||||
public void imitateBase(){
|
||||
// 总电压
|
||||
this.voltage = genValue(110, 750);
|
||||
// 总电流
|
||||
this.current = genValue(3, 50);
|
||||
// 绝缘电阻
|
||||
this.resistance = genValue(0,30000);
|
||||
// 加速踏板行程值
|
||||
this.accelerationPedal = genValue(0, 10);
|
||||
// 制动踏板行程值
|
||||
this.brakePedal = genValue(0, 10);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
电机控制器温度
|
||||
motorControllerTemperature;
|
||||
电机转速
|
||||
motorSpeed;
|
||||
电机转矩
|
||||
motorTorque;
|
||||
电机温度
|
||||
motorTemperature;
|
||||
电机电压
|
||||
motorVoltage;
|
||||
电机电流
|
||||
motorCurrent;
|
||||
* 模拟电机数据
|
||||
*/
|
||||
public void imitateMotor(){
|
||||
// 电机控制器温度
|
||||
this.motorControllerTemperature = genValue(0, 100);
|
||||
// 电机转速
|
||||
this.motorSpeed = genValue(0, 99999);
|
||||
// 电机转矩
|
||||
this.motorTorque = genValue(0, 1000);
|
||||
// 电机温度
|
||||
this.motorTemperature = genValue(0, 150);
|
||||
// 电机电压
|
||||
this.motorVoltage = genValue(110, 300);
|
||||
// 电机电流
|
||||
this.motorCurrent = genValue(0, 15000);
|
||||
}
|
||||
|
||||
/**
|
||||
动力电池剩余电量SOC
|
||||
remainingBattery;
|
||||
当前状态允许的最大反馈功率
|
||||
maximumFeedbackPower;
|
||||
当前状态允许最大放电功率
|
||||
maximumDischargePower;
|
||||
BMS自检计数器
|
||||
selfCheckCounter;
|
||||
动力电池充放电电流
|
||||
totalBatteryCurrent;
|
||||
动力电池负载端总电压V3
|
||||
totalBatteryVoltage;
|
||||
单次最大电压
|
||||
singleBatteryMaxVoltage;
|
||||
单体电池最低电压
|
||||
singleBatteryMinVoltage;
|
||||
单体电池最高温度
|
||||
singleBatteryMaxTemperature;
|
||||
单体电池最低温度
|
||||
singleBatteryMinTemperature;
|
||||
动力电池可用容量
|
||||
availableBatteryCapacity;
|
||||
* 模拟电池包数据
|
||||
*/
|
||||
|
||||
public void imitateBatteryPack(){
|
||||
// 当前状态允许的最大反馈功率
|
||||
this.maximumFeedbackPower = genValue(0, 100);
|
||||
// 当前状态允许最大放电功率
|
||||
this.maximumDischargePower = genValue(0, 100);
|
||||
// BMS自检计数器
|
||||
this.selfCheckCounter = genValue(0, 15);
|
||||
// 动力电池充放电电流
|
||||
this.totalBatteryCurrent = genValue(0, 15);
|
||||
// 动力电池负载端总电压V3
|
||||
this.totalBatteryVoltage = genValue(220, 750);
|
||||
// 单体电池最高电压
|
||||
this.singleBatteryMaxVoltage = genValue(3, 5);
|
||||
// 单体电池最低电压
|
||||
this.singleBatteryMinVoltage = genValue(3, 5);
|
||||
// 单体电池最高温度
|
||||
this.singleBatteryMaxTemperature = genValue(0, 100);
|
||||
// 单体电池最低温度
|
||||
this.singleBatteryMinTemperature = genValue(0, 100);
|
||||
// 动力电池可用容量
|
||||
this.availableBatteryCapacity = genValue(0,100 );
|
||||
}
|
||||
/**
|
||||
车辆状态
|
||||
vehicleStatus;
|
||||
|
|
Loading…
Reference in New Issue