上报报文
parent
7416dd2f43
commit
5dbbe12c8c
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.common;
|
package com.muyu.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.netty.channel.EventLoopGroup;
|
import io.netty.channel.EventLoopGroup;
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
|
||||||
|
@ -27,5 +28,16 @@ public class Common {
|
||||||
|
|
||||||
public static EventLoopGroup workerGroup = new NioEventLoopGroup();
|
public static EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int i = 0;
|
||||||
|
List<String> strings = JSONObject.parseArray(local_one, String.class);
|
||||||
|
for (String string : strings) {
|
||||||
|
int length = string.split(",")[1].length();
|
||||||
|
if (length > i){
|
||||||
|
i = length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(i);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.controller;
|
||||||
|
|
||||||
import com.muyu.common.Config;
|
import com.muyu.common.Config;
|
||||||
import com.muyu.common.Response;
|
import com.muyu.common.Response;
|
||||||
|
import com.muyu.netty.log.NettyClientLogQueue;
|
||||||
import com.muyu.netty.operate.NettyClientMsg;
|
import com.muyu.netty.operate.NettyClientMsg;
|
||||||
import com.muyu.pojo.Vehicle;
|
import com.muyu.pojo.Vehicle;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -38,6 +39,7 @@ public class VehicleController {
|
||||||
}
|
}
|
||||||
Config.VEHICLE.setStatus(1);
|
Config.VEHICLE.setStatus(1);
|
||||||
NettyClientMsg.sendMsg(Config.VEHICLE_START_SUF+Config.VIN);
|
NettyClientMsg.sendMsg(Config.VEHICLE_START_SUF+Config.VIN);
|
||||||
|
NettyClientLogQueue.add("<p>发送车辆启动报文:"+Config.VEHICLE_START_SUF+Config.VIN+"</p>");
|
||||||
return Response.success(Config.VEHICLE);
|
return Response.success(Config.VEHICLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ public class VehicleController {
|
||||||
}
|
}
|
||||||
Config.VEHICLE.setStatus(0);
|
Config.VEHICLE.setStatus(0);
|
||||||
NettyClientMsg.sendMsg(Config.VEHICLE_STOP_SUF+Config.VIN);
|
NettyClientMsg.sendMsg(Config.VEHICLE_STOP_SUF+Config.VIN);
|
||||||
|
NettyClientLogQueue.add("<p>发送车辆停止报文:"+Config.VEHICLE_STOP_SUF+Config.VIN+"</p>");
|
||||||
return Response.success(Config.VEHICLE);
|
return Response.success(Config.VEHICLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.muyu.common.Response;
|
||||||
import com.muyu.netty.log.NettyClientLogQueue;
|
import com.muyu.netty.log.NettyClientLogQueue;
|
||||||
import com.muyu.netty.operate.NettyClientMsg;
|
import com.muyu.netty.operate.NettyClientMsg;
|
||||||
import com.muyu.pojo.VehicleData;
|
import com.muyu.pojo.VehicleData;
|
||||||
|
import com.muyu.utils.ConversionUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -71,7 +72,7 @@ public class VehicleOperateController {
|
||||||
vehicleData.setLongitude(split[0]);
|
vehicleData.setLongitude(split[0]);
|
||||||
vehicleData.setLatitude(split[1]);
|
vehicleData.setLatitude(split[1]);
|
||||||
|
|
||||||
NettyClientMsg.sendMsg(Config.VEHICLE_MSG_SUF + vehicleData.getVin() +JSONObject.toJSONString(vehicleData));
|
NettyClientMsg.sendMsg(Config.VEHICLE_MSG_SUF + ConversionUtil.strToSixteen(vehicleData.getMsg()));
|
||||||
NettyClientLogQueue.add(vehicleData.getVehicleMsgLog());
|
NettyClientLogQueue.add(vehicleData.getVehicleMsgLog());
|
||||||
return Response.success();
|
return Response.success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,110 @@ public class VehicleData {
|
||||||
*/
|
*/
|
||||||
private String batteryMsg;
|
private String batteryMsg;
|
||||||
|
|
||||||
|
public String getMsg(){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
//第一位VIN
|
||||||
|
sb.append(vin);
|
||||||
|
//第二位经度 longitude latitude
|
||||||
|
sb.append(getValue(longitude ,10));
|
||||||
|
//第三位维度 longitude latitude
|
||||||
|
sb.append(getValue(latitude ,10));
|
||||||
|
//车速
|
||||||
|
sb.append(getValue(speed,6));
|
||||||
|
//总里程
|
||||||
|
sb.append(getValue(mileage,10));
|
||||||
|
// 总电压
|
||||||
|
sb.append(getValue(voltage,6));
|
||||||
|
//总电流
|
||||||
|
sb.append(getValue(current,5));
|
||||||
|
//绝缘电阻 79 - 87
|
||||||
|
sb.append(getValue(resistance,9));
|
||||||
|
// 加速踏板行程值
|
||||||
|
sb.append(getValue(accelerationPedal,2));
|
||||||
|
// 制动踏板行程值
|
||||||
|
sb.append(getValue(brakePedal,2));
|
||||||
|
// 燃料消耗率
|
||||||
|
sb.append(getValue(fuelConsumptionRate,6));
|
||||||
|
//电机控制器温度
|
||||||
|
sb.append(getValue(motorControllerTemperature,6));
|
||||||
|
//电机转速
|
||||||
|
sb.append(getValue(motorSpeed,5));
|
||||||
|
//电机温度
|
||||||
|
sb.append(getValue(motorTemperature,6));
|
||||||
|
//电机电压
|
||||||
|
sb.append(getValue(motorVoltage,5));
|
||||||
|
//电机电流
|
||||||
|
sb.append(getValue(motorCurrent,8));
|
||||||
|
//动力电池剩余电量SOC
|
||||||
|
sb.append(getValue(remainingBattery,6));
|
||||||
|
//当前状态允许的最大反馈功率
|
||||||
|
sb.append(getValue(maximumFeedbackPower,6));
|
||||||
|
//当前状态允许最大放电功率
|
||||||
|
sb.append(getValue(maximumDischargePower,6));
|
||||||
|
//BMS自检计数器
|
||||||
|
sb.append(getValue(selfCheckCounter,2));
|
||||||
|
//动力电池充放电电流
|
||||||
|
sb.append(getValue(totalBatteryCurrent,5));
|
||||||
|
//动力电池负载端总电压V3
|
||||||
|
sb.append(getValue(totalBatteryVoltage,6));
|
||||||
|
//单次最大电压
|
||||||
|
sb.append(getValue(singleBatteryMaxVoltage,4));
|
||||||
|
//单体电池最低电压
|
||||||
|
sb.append(getValue(singleBatteryMinVoltage,4));
|
||||||
|
//单体电池最高温度
|
||||||
|
sb.append(getValue(singleBatteryMaxTemperature,6));
|
||||||
|
//单体电池最低温度
|
||||||
|
sb.append(getValue(singleBatteryMinTemperature,6));
|
||||||
|
//动力电池可用容量
|
||||||
|
sb.append(getValue(availableBatteryCapacity,6));
|
||||||
|
//车辆状态
|
||||||
|
sb.append(vehicleStatus);
|
||||||
|
//充电状态
|
||||||
|
sb.append(chargingStatus);
|
||||||
|
//运行状态
|
||||||
|
sb.append(operatingStatus);
|
||||||
|
//SOC
|
||||||
|
sb.append(socStatus);
|
||||||
|
//可充电储能装置工作状态
|
||||||
|
sb.append(chargingEnergyStorageStatus);
|
||||||
|
//驱动电机状态
|
||||||
|
sb.append(driveMotorStatus);
|
||||||
|
//定位是否有效
|
||||||
|
sb.append(positionStatus);
|
||||||
|
//EAS
|
||||||
|
sb.append(easStatus);
|
||||||
|
//PTC
|
||||||
|
sb.append(ptcStatus);
|
||||||
|
//EPS
|
||||||
|
sb.append(epsStatus);
|
||||||
|
//ABS
|
||||||
|
sb.append(absStatus);
|
||||||
|
//MCU
|
||||||
|
sb.append(mcuStatus);
|
||||||
|
//动力电池加热状态
|
||||||
|
sb.append(heatingStatus);
|
||||||
|
//动力电池当前状态
|
||||||
|
sb.append(batteryStatus);
|
||||||
|
//动力电池保温状态
|
||||||
|
sb.append(batteryInsulationStatus);
|
||||||
|
//DCDC
|
||||||
|
sb.append(dcdcStatus);
|
||||||
|
//CHG
|
||||||
|
sb.append(chgStatus);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String val , int valLength){
|
||||||
|
int length = val.length();
|
||||||
|
if (length > valLength){
|
||||||
|
return val.substring( 0 , valLength);
|
||||||
|
}
|
||||||
|
for (int i = length; i < valLength; i++) {
|
||||||
|
val+="0";
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
public String getVehicleStatusMsg() {
|
public String getVehicleStatusMsg() {
|
||||||
StringBuilder vehicleStatusMsgSb = new StringBuilder(Config.VEHICLE_BASE_FAULT + "7X");
|
StringBuilder vehicleStatusMsgSb = new StringBuilder(Config.VEHICLE_BASE_FAULT + "7X");
|
||||||
vehicleStatusMsgSb.append(" 0").append(vehicleStatus);
|
vehicleStatusMsgSb.append(" 0").append(vehicleStatus);
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.utils;
|
||||||
|
|
||||||
|
public class ConversionUtil {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(strToSixteen("PDSN"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串转化成为16进制字符串
|
||||||
|
* @param s
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String strToSixteen(String s) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int length = s.length();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
int ch = s.charAt(i);
|
||||||
|
String s4 = Integer.toHexString(ch);
|
||||||
|
sb.append(s4 + " ");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -103,13 +103,6 @@
|
||||||
<button type="button" class="btn btn-sm btn-default" onclick="stopImitateData()">结束模拟</button>
|
<button type="button" class="btn btn-sm btn-default" onclick="stopImitateData()">结束模拟</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<#-- <div class="col-md-2 divCss divBorderHeight" style="padding: 7px 0">-->
|
|
||||||
<#-- <span class="col-md-7">当累计上报数据量:</span>-->
|
|
||||||
<#-- <span class="label label-info" id="sendSum">12312</span>-->
|
|
||||||
<#-- <span id="send" class="label label-success" style="display: none">上报中</span>-->
|
|
||||||
<#-- <span id="disSend" class="label label-danger">未上报</span>-->
|
|
||||||
<#-- </div>-->
|
|
||||||
</div>
|
</div>
|
||||||
<form id="vehicleForm">
|
<form id="vehicleForm">
|
||||||
<div class="col-md-12 divCss divBorderHeight" style="height: 875px;">
|
<div class="col-md-12 divCss divBorderHeight" style="height: 875px;">
|
||||||
|
@ -204,7 +197,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="motorSpeed">电机转速</label>
|
<label for="motorSpeed">电机转速</label>
|
||||||
<input type="text" min="0" max="10000" reserved="0" class="form-control" name="motorSpeed" id="motorSpeed" placeholder="电机转速">
|
<input type="text" min="0" max="99999" reserved="0" class="form-control" name="motorSpeed" id="motorSpeed" placeholder="电机转速">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="motorTorque">电机转矩</label>
|
<label for="motorTorque">电机转矩</label>
|
||||||
|
@ -534,8 +527,13 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="vinDiv" id="vehicleMsgLog" style="height :325px ;width: 100%; padding: 0 15px;">
|
<div class="vinDiv" style="height :325px ;width: 100%; padding: 0 15px;">
|
||||||
|
<div class="vinDiv" style="height :30px ;width: 100%; padding: 0 15px;">
|
||||||
|
<button type="button" class="btn btn-sm btn-default" onclick="clearLog()" style="float: right">清空日志</button>
|
||||||
|
</div>
|
||||||
|
<div class="vinDiv" id="vehicleMsgLog" style="height :295px ;width: 100%; padding: 0 15px; border-top: solid 1px #0081a7">
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -731,5 +729,9 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearLog() {
|
||||||
|
$("#vehicleMsgLog").empty();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue