<template>
|
<div
|
class="module-wrapper"
|
v-loading="loading"
|
element-loading-text="拼命加载中"
|
element-loading-spinner="el-icon-loading"
|
element-loading-background="rgba(0, 0, 0, 0.2)"
|
>
|
<div class="module-content-left">
|
<layout-box>
|
<div class="layout-content">
|
<div class="mon-vol-bar">
|
<flex-box title="单体电压" size="mini">
|
<el-select
|
v-model="group"
|
slot="tools"
|
size="mini"
|
@change="changeGroup"
|
>
|
<el-option
|
v-for="(item, key) in packList"
|
:key="'key' + key"
|
:value="item.value"
|
:label="item.label"
|
></el-option>
|
</el-select>
|
<divide-bar ref="monVol" name="单体电压" unit="V"></divide-bar>
|
</flex-box>
|
</div>
|
<div class="mon-temp-bar">
|
<flex-box title="电芯温度" size="mini">
|
<divide-bar ref="monTemp" name="单体温度" unit="℃"></divide-bar>
|
</flex-box>
|
</div>
|
</div>
|
</layout-box>
|
</div>
|
<div class="module-content-right">
|
<layout-box>
|
<div class="layout-content">
|
<div class="mon-vol-bar">
|
<flex-box title="模拟量" size="mini">
|
<el-table
|
stripe
|
size="small"
|
:data="analogData"
|
:show-header="false"
|
height="100%"
|
>
|
<el-table-column prop="label" align="center" label="模拟量名称">
|
</el-table-column>
|
<el-table-column prop="value" align="center" label="模拟量值">
|
</el-table-column>
|
</el-table>
|
</flex-box>
|
</div>
|
</div>
|
</layout-box>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import PowerStateBox from "@/components/PowerStateBox";
|
import FlexBox from "@/components/FlexBox";
|
import BarChart from "@/components/chart/BarChart";
|
import DivideBar from "@/components/myCharts/DivideBar";
|
import HdwLightInput from "@/components/HdwLightInput";
|
import HdwLightInputInline from "@/components/HdwLightInputInline";
|
import LayoutBox from "./layout-box";
|
import { getValByKey, regEquipType } from "@/assets/js/tools";
|
import getDCDCAnalogParams from "@/assets/js/tools/lithium/analogParams";
|
|
import const_digit from "@/assets/js/const/const_digit";
|
const {
|
cap: CAP,
|
vol: VOL,
|
curr: CURR,
|
res: RES,
|
conduct: CONDUCT,
|
temp: TEMP,
|
hum: HUM,
|
} = const_digit;
|
|
import createWs from "@/assets/js/websocket";
|
const WSMixin = createWs("li9130Bms");
|
export default {
|
name: "bmsInfo",
|
mixins: [WSMixin],
|
components: {
|
HdwLightInputInline,
|
HdwLightInput,
|
DivideBar,
|
LayoutBox,
|
FlexBox,
|
PowerStateBox,
|
BarChart,
|
},
|
props: {
|
batt: {
|
type: Object,
|
default() {
|
return {};
|
},
|
},
|
realUpdate: {
|
type: Boolean,
|
default: true,
|
},
|
},
|
data() {
|
return {
|
loading: false,
|
group: 0,
|
analogData: [],
|
// monVolWarn: [], // 单体电压告警
|
// monTempWarn: [], // 电芯温度告警
|
envTempAlm: [
|
{
|
key: "envTempAlm",
|
label: "环境温度",
|
value: -1,
|
},
|
],
|
mosTempAlm: [
|
{
|
key: "mosTempAlm",
|
label: "MOS管温度",
|
value: -1,
|
},
|
],
|
currentAlm: [
|
{
|
key: "currentAlm",
|
label: "电流",
|
value: -1,
|
},
|
],
|
sumVolAlm: [
|
{
|
key: "sumVolAlm",
|
label: "总压",
|
value: -1,
|
},
|
],
|
packList: [],
|
};
|
},
|
computed: {},
|
watch: {
|
realUpdate() {
|
this.resize();
|
},
|
},
|
methods: {
|
/**
|
* 设置电池包列表
|
* @param num 电池包的个数
|
*/
|
setPackList(num) {
|
let list = [];
|
num = num ? num : 4;
|
for (let i = 0; i < num; i++) {
|
list.push({
|
value: i,
|
label: "锂电池包" + (i + 1),
|
});
|
}
|
this.packList = list;
|
},
|
resize() {
|
this.$nextTick(() => {
|
// 单体电压图表
|
if (this.$refs.monVol) {
|
this.$refs.monVol.resize();
|
}
|
|
// 单体温度图表
|
if (this.$refs.monTemp) {
|
this.$refs.monTemp.resize();
|
}
|
if (this.isWSOpen) {
|
this.sendMessage();
|
}
|
});
|
},
|
changeGroup() {
|
this.loading = true;
|
},
|
onWSOpen() {
|
this.sendMessage();
|
},
|
sendMessage() {
|
let batt = this.batt;
|
// console.log(batt, '=====batt');
|
if (!batt.battGroupId || !this.isWSOpen) {
|
return false;
|
}
|
let params = {
|
devId: batt.fbsdeviceId,
|
groupNum: batt.groupIndexInFBSDevice,
|
};
|
console.log("====", params, JSON.stringify(params));
|
this.SOCKET.send(JSON.stringify(params));
|
},
|
onWSMessage(res) {
|
res = JSON.parse(res.data);
|
let data = res.data;
|
// console.log(data, "=====data?");
|
this.getDcDcAnalogParams(data.li9130BmsState);
|
// this.getDcDcWarnParams(data.li9130BmsAlarms);
|
},
|
getDcDcAnalogParams(res) {
|
// 是否实时更新
|
if (!this.realUpdate) {
|
return;
|
}
|
// 查询数据
|
let batt = this.batt;
|
if (res) {
|
// 关闭等待框
|
this.loading = false;
|
// 处理后台数据
|
// res = res.data;
|
let data = [];
|
if (res.code && res.data) {
|
data = res.data2;
|
}
|
this.setPackList(data.length);
|
// 格式化并并设置数据
|
this.formatData(data);
|
} else {
|
// 关闭等待框
|
this.loading = false;
|
// 格式化并并设置数据
|
this.formatData([]);
|
}
|
},
|
formatData(data) {
|
let group = this.group;
|
let list = getDCDCAnalogParams().list;
|
let info = {};
|
// 设置信息
|
if (data.length != 0 && data.length > group) {
|
info = data[group];
|
}
|
// 根据info的值设置list的值
|
list = list.map((item) => {
|
item.value = getValByKey(item.key, info, 0);
|
return item;
|
});
|
|
// 设置单体电压图表数据
|
let monVol = {
|
xLabel: [],
|
sData: [],
|
};
|
for (let i = 1; i < 17; i++) {
|
let key = "monVol" + i;
|
monVol.xLabel.push("单体" + i);
|
monVol.sData.push(getValByKey(key, info, 0, VOL));
|
}
|
if (this.$refs.monVol) {
|
this.$refs.monVol.setData(monVol);
|
}
|
|
// 设置单体温度图表数据
|
let monTemp = {
|
xLabel: [],
|
sData: [],
|
};
|
for (let i = 0, j = info.tmpCnt; i < j; i++) {
|
let idx = i + 1;
|
monTemp.xLabel.push("电芯" + idx);
|
let tempList = info.monTmps.split(",");
|
monTemp.sData.push((tempList[i] * 1).toHold(TEMP));
|
}
|
if (this.$refs.monTemp) {
|
this.$refs.monTemp.setData(monTemp);
|
}
|
|
// 设置模拟量
|
let analogData = ["envTemp", "mosTemp", "userDefCnt", "restCap"];
|
this.analogData = list
|
.filter((item) => analogData.includes(item.key))
|
.map((v) => {
|
if (v.key == "restCap") {
|
v.label = "SOC(%)";
|
}
|
if (v.key == "envTemp") {
|
v.label = "最高温度(℃)";
|
v.value = v.value.toHold(TEMP);
|
}
|
if (v.key == "mosTemp") {
|
v.label = "最低温度(℃)";
|
v.value = v.value.toHold(TEMP);
|
}
|
if (v.key == "userDefCnt") {
|
v.label = "电芯压差(mV)";
|
v.value = v.value.toHold(VOL);
|
}
|
return v;
|
});
|
},
|
// getDcDcWarnParams(res) {
|
// // 是否实时更新
|
// if (!this.realUpdate) {
|
// return;
|
// }
|
// // 查询数据
|
// if (res) {
|
// // res = res.data;
|
// let data = [];
|
// if (res.code) {
|
// data = res.data;
|
// }
|
// this.formatAlarmData(data);
|
// } else {
|
// this.formatAlarmData([]);
|
// }
|
// },
|
// formatAlarmData(data) {
|
// let group = this.group;
|
// // let list = getDCDCAnalogParams().list;
|
// let info = {};
|
// // 设置信息
|
// if (data.length != 0 && data.length > group) {
|
// info = data[group];
|
// }
|
// // 单体电压
|
// this.changeAlarmValue(this.monVolWarn, info);
|
|
// // 单体温度
|
// this.changeAlarmValue(this.monTempWarn, info);
|
|
// // 环境温度
|
// this.changeAlarmValue(this.envTempAlm, info);
|
|
// // Mos管温度
|
// this.changeAlarmValue(this.mosTempAlm, info);
|
|
// // 电流告警
|
// this.changeAlarmValue(this.currentAlm, info);
|
|
// // 总压告警
|
// this.changeAlarmValue(this.sumVolAlm, info);
|
|
// // 均衡事件
|
// this.changeAlarmValueByBit(this.junhengEventCode, info.junhengEventCode);
|
|
// // 电压事件
|
// this.changeAlarmValueByBit(this.volEventCode, info.volEventCode);
|
|
// // 温度事件
|
// this.changeAlarmValueByBit(this.tempEventCode, info.tempEventCode);
|
|
// // 电流事件
|
// this.changeAlarmValueByBit(this.currEventCode, info.currEventCode);
|
|
// // 剩余容量
|
// this.changeAlarmValueByBit(this.restCapAlm, info.restCapAlm);
|
|
// //FET状态
|
// this.changeAlarmValueByBit(this.fetStateCode, info.fetStateCode);
|
|
// // 均衡状态
|
// this.changeAlarmValueByBit(this.junhengStateCode, info.junhengStateCode);
|
|
// // 系统温度事件
|
// this.changeAlarmValueByBit(this.sysTempCode, info.sysTempCode);
|
// },
|
// changeAlarmValue(alarms, info) {
|
// alarms.map((item) => {
|
// item.value = getValByKey(item.key, info, -1);
|
// });
|
// },
|
// changeAlarmValueByBit(alarms, bit) {
|
// alarms.map((item) => {
|
// item.value = (item.bit & bit) > 0 ? 1 : 0;
|
// });
|
// },
|
// getListByKeys(keys, list) {
|
// let result = [];
|
// for (let i = 0; i < keys.length; i++) {
|
// let key = keys[i];
|
// let item = getItemByKey(key, list);
|
// if (item != 0) {
|
// result.push(item);
|
// }
|
// }
|
// return result;
|
// },
|
},
|
mounted() {
|
this.setPackList();
|
// let list = getDCDCWarnParams().list;
|
// // 单体电压告警
|
// let monVolWarnKey = [];
|
// for (let i = 1; i < 17; i++) {
|
// monVolWarnKey.push("monVolAlm" + i);
|
// }
|
// this.monVolWarn = this.getListByKeys(monVolWarnKey, list);
|
|
// 电芯温度告警
|
// let monTempWarnKeys = [];
|
// for (let i = 1; i < 5; i++) {
|
// monTempWarnKeys.push("monTmpAlm" + i);
|
// }
|
// this.monTempWarn = this.getListByKeys(monTempWarnKeys, list);
|
|
// // 均衡状态
|
// let junhengStateCode = [];
|
// for (let i = 0; i < 16; i++) {
|
// junhengStateCode.push({
|
// bit: Math.pow(2, i),
|
// label: "电芯" + (i + 1) + "均衡指示",
|
// value: -1,
|
// });
|
// }
|
// this.junhengStateCode = junhengStateCode;
|
},
|
beforeDestroy() {},
|
};
|
</script>
|
|
<style scoped>
|
.module-wrapper {
|
display: flex;
|
width: 100%;
|
height: 100%;
|
flex-direction: row;
|
box-sizing: border-box;
|
}
|
.module-content-left,
|
.module-content-right {
|
height: 100%;
|
}
|
.module-content-left {
|
flex: 1;
|
overflow-x: hidden;
|
margin-right: 8px;
|
}
|
.module-content-right {
|
width: 600px;
|
margin-left: 8px;
|
}
|
.layout-content {
|
box-sizing: border-box;
|
padding: 12px 16px 16px 16px;
|
height: 100%;
|
}
|
.mon-vol-bar,
|
.mon-temp-bar {
|
box-sizing: border-box;
|
height: 50%;
|
}
|
.mon-vol-bar {
|
padding-bottom: 8px;
|
}
|
.mon-temp-bar {
|
padding-top: 8px;
|
}
|
.warn-content {
|
box-sizing: border-box;
|
padding: 0 16px 0 16px;
|
}
|
</style>
|