|
@@ -449,22 +449,14 @@ export default {
|
|
let selectedService = uni.getStorageSync("sercviceChoice");
|
|
let selectedService = uni.getStorageSync("sercviceChoice");
|
|
if (!selectedService || selectedService == "aloneServe") {
|
|
if (!selectedService || selectedService == "aloneServe") {
|
|
if (__wxConfig.envVersion == "develop") {
|
|
if (__wxConfig.envVersion == "develop") {
|
|
- // client = mqtt.connect(
|
|
|
|
- // "wxs://cmd.radar-power.com:8084/mqtt",
|
|
|
|
- // params
|
|
|
|
- // );
|
|
|
|
client = mqtt.connect(
|
|
client = mqtt.connect(
|
|
- "wxs://radar-power.cn:8084/mqtt",
|
|
|
|
|
|
+ "wxs://cmd.radar-power.com:8084/mqtt",
|
|
params
|
|
params
|
|
);
|
|
);
|
|
}
|
|
}
|
|
if (__wxConfig.envVersion == "trial") {
|
|
if (__wxConfig.envVersion == "trial") {
|
|
- // client = mqtt.connect(
|
|
|
|
- // "wxs://cmd.radar-power.com:8084/mqtt",
|
|
|
|
- // params
|
|
|
|
- // );
|
|
|
|
client = mqtt.connect(
|
|
client = mqtt.connect(
|
|
- "wxs://radar-power.cn:8084/mqtt",
|
|
|
|
|
|
+ "wxs://cmd.radar-power.com:8084/mqtt",
|
|
params
|
|
params
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -517,10 +509,6 @@ export default {
|
|
client.on("message", (topic, message) => {
|
|
client.on("message", (topic, message) => {
|
|
console.log(JSON.parse(message.toString()), "8870");
|
|
console.log(JSON.parse(message.toString()), "8870");
|
|
// 处理点位消息
|
|
// 处理点位消息
|
|
- if (this.clientIdProp !== null) {
|
|
|
|
- this.handleMessage(topic, message, this.clientIdProp);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
let userId = uni.getStorageSync("userId");
|
|
let userId = uni.getStorageSync("userId");
|
|
const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
|
|
const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
|
|
const match = topic.match(noticeMatch);
|
|
const match = topic.match(noticeMatch);
|
|
@@ -615,132 +603,9 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
-
|
|
|
|
- // 处理点位消息
|
|
|
|
- handleMessage(topic, message, clientId) {
|
|
|
|
- // 清除不活动定时器
|
|
|
|
- clearTimeout(this.inactivityTimer);
|
|
|
|
- this.inactivityTimer = setTimeout(() => {
|
|
|
|
- this.targetPoints = {};
|
|
|
|
- console.log("长时间没有点位,清除数据");
|
|
|
|
- this.sendChange();
|
|
|
|
- this.$emit("sendHealth", 0);
|
|
|
|
- }, 1500);
|
|
|
|
-
|
|
|
|
- // 验证topic格式
|
|
|
|
- const match = topic.match(/^\/dev\/(.+)\/dsp_data$/);
|
|
|
|
- if (!match || match[1] !== clientId) return;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- const data = JSON.parse(message.toString());
|
|
|
|
- if (data.health) {
|
|
|
|
- if (
|
|
|
|
- data.health.breath_rpm ||
|
|
|
|
- data.health.breath_rpm === 0
|
|
|
|
- ) {
|
|
|
|
- this.$emit(
|
|
|
|
- "sendHealth",
|
|
|
|
- Math.floor(data.health.breath_rpm)
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- this.$emit("sendHealth", 0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.processTrackerData(data.tracker_targets);
|
|
|
|
- } catch (e) {
|
|
|
|
- console.error("MQTT消息解析失败", e);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- processTrackerData(arr) {
|
|
|
|
- if (Array.isArray(arr) && arr.length > 0 && Array.isArray(arr[0])) {
|
|
|
|
- this.targetPoints = {};
|
|
|
|
- const currentIds = new Set();
|
|
|
|
- const newTargetPoints = {};
|
|
|
|
- // 处理每个追踪目标
|
|
|
|
- arr.forEach((item) => {
|
|
|
|
- if (!Array.isArray(item) || item.length < 4) return;
|
|
|
|
-
|
|
|
|
- const [x, y, z, id] = item;
|
|
|
|
- currentIds.add(id.toString());
|
|
|
|
-
|
|
|
|
- // 处理新点或更新现有点
|
|
|
|
- if (!this.targetPoints[id]) {
|
|
|
|
- newTargetPoints[id] = this.createNewTargetPoint(
|
|
|
|
- x,
|
|
|
|
- y,
|
|
|
|
- z,
|
|
|
|
- id
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- newTargetPoints[id] = this.updateExistingTargetPoint(
|
|
|
|
- this.targetPoints[id],
|
|
|
|
- x,
|
|
|
|
- y,
|
|
|
|
- z,
|
|
|
|
- 2
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 移除不存在的点
|
|
|
|
- Object.keys(this.targetPoints).forEach((id) => {
|
|
|
|
- if (!currentIds.has(id)) {
|
|
|
|
- delete this.targetPoints[id];
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 更新目标点
|
|
|
|
- this.targetPoints = {
|
|
|
|
- ...this.targetPoints,
|
|
|
|
- ...newTargetPoints,
|
|
|
|
- };
|
|
|
|
- if (Array.isArray(this.targetPoints)) {
|
|
|
|
- this.targetPoints = this.targetPoints.filter(
|
|
|
|
- (item) => item !== null && item !== undefined
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- console.log("当前目标点11111", this.targetPoints);
|
|
|
|
- this.sendChange();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
sendChange() {
|
|
sendChange() {
|
|
this.$emit("sendChange", this.targetPoints);
|
|
this.$emit("sendChange", this.targetPoints);
|
|
},
|
|
},
|
|
- // 创建新目标点
|
|
|
|
- createNewTargetPoint(x, y, z, id) {
|
|
|
|
- return {
|
|
|
|
- x,
|
|
|
|
- y,
|
|
|
|
- z,
|
|
|
|
- id,
|
|
|
|
- displayX: x,
|
|
|
|
- displayY: y,
|
|
|
|
- lastX: x,
|
|
|
|
- lastY: y,
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- // 更新现有目标点
|
|
|
|
- updateExistingTargetPoint(existingPoint, x, y, z, THRESHOLD) {
|
|
|
|
- const dx = x - existingPoint.lastX;
|
|
|
|
- const dy = y - existingPoint.lastY;
|
|
|
|
- const distance = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
-
|
|
|
|
- if (distance > THRESHOLD) {
|
|
|
|
- return {
|
|
|
|
- ...existingPoint,
|
|
|
|
- x,
|
|
|
|
- y,
|
|
|
|
- z,
|
|
|
|
- lastX: x,
|
|
|
|
- lastY: y,
|
|
|
|
- displayX: x,
|
|
|
|
- displayY: y,
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return existingPoint;
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
this.connectMQTTwo();
|
|
this.connectMQTTwo();
|