<template>
|
<el-row>
|
<el-col :span="24">
|
<device-stacker v-for="stacker in Stackers" :key="stacker.deviceName" :Stacker="stacker"></device-stacker>
|
</el-col>
|
</el-row>
|
</template>
|
|
<script setup>
|
import { onMounted, reactive, toRefs } from "vue";
|
import eventBus from "@/uitils/eventBus";
|
import DeviceStacker from "@/components/DeviceStacker.vue";
|
|
// 堆垛机
|
const Stackers = reactive([]);
|
|
// 设备列表(修改重复设备名称)
|
const devices = reactive([]);
|
|
const intToBitArrayFromBinaryString = (num, numBits) => {
|
let binaryString = num.toString(2).padStart(numBits, '0');
|
return Array.from({ length: numBits }, (_, index) => binaryString[index] === '1');
|
};
|
|
// 监听设备数据变化
|
onMounted(() => {
|
eventBus.on('stackerData', eventData => {
|
if (Stackers.length == 0) {
|
Stackers.push({ deviceName: eventData.deviceName, data: eventData.data });
|
}
|
else {
|
const Stacker = Stackers.find(c => c.deviceName == eventData.deviceName);
|
if (Stacker) {
|
Stacker.data = eventData.data
|
}
|
else {
|
Stackers.push({ deviceName: eventData.deviceName, data: eventData.data });
|
}
|
}
|
})
|
});
|
</script>
|
<style scoped>
|
.Stackerbox {
|
width: 550px;
|
float: left;
|
height: 300px;
|
}
|
|
.box1 {
|
float: left;
|
}
|
|
.card-body {
|
text-align: center;
|
border-radius: 6%;
|
}
|
|
.Stacker {
|
background-color: burlywood;
|
}
|
|
.lis {
|
float: left;
|
width: 233px;
|
}
|
</style>
|