订阅Topic修改为网关sn

main
刘妍 1 month ago
parent 4db89e8dc5
commit a5e7bb3bb2

@ -21,6 +21,7 @@ export const airPortStore = defineStore({
rtmp: 'rtmp://box.wisestcity.com:1935/live/', rtmp: 'rtmp://box.wisestcity.com:1935/live/',
url: 'http://box.wisestcity.com:8081/live/', url: 'http://box.wisestcity.com:8081/live/',
}, },
gateway: null,
}), }),
getters: { getters: {
getAirport(state) { getAirport(state) {
@ -32,6 +33,9 @@ export const airPortStore = defineStore({
getLiveInfo(state) { getLiveInfo(state) {
return state.liveInfo; return state.liveInfo;
}, },
getGateway(state) {
return state.gateway;
},
}, },
actions: { actions: {
setAirPort(item: any, value: any) { setAirPort(item: any, value: any) {
@ -40,5 +44,8 @@ export const airPortStore = defineStore({
setUAV(item: any, value: any) { setUAV(item: any, value: any) {
this.uav[item] = value; this.uav[item] = value;
}, },
setGateway(value: any) {
this.gateway = value;
},
}, },
}); });

@ -2,7 +2,7 @@ import { clientReizePublish, clientReizeSubscribe } from '@/utils/mqtt';
import { airPortStore } from '@/store/modules/airport'; import { airPortStore } from '@/store/modules/airport';
const airPortStoreVal = airPortStore(); const airPortStoreVal = airPortStore();
const airPort = airPortStoreVal.getAirport; const gateway = airPortStoreVal.getGateway;
export const return_home_status = { export const return_home_status = {
canceled: '取消或终止', canceled: '取消或终止',
@ -16,26 +16,26 @@ export const return_home_status = {
}; };
export const eventsTopicReize = (data) => { export const eventsTopicReize = (data) => {
// 发送消息 // 发送消息
clientReizePublish('thing/product/' + airPort.sn + '/events', data); clientReizePublish('thing/product/' + gateway + '/events', data);
}; };
export const events_replyTopicReize = () => { export const events_replyTopicReize = () => {
// 订阅消息 // 订阅消息
clientReizeSubscribe('thing/product/' + airPort.sn + '/events_reply'); clientReizeSubscribe('thing/product/' + gateway + '/events_reply');
}; };
export const servicesTopicReize = (data) => { export const servicesTopicReize = (data) => {
// 发送消息 // 发送消息
clientReizePublish('thing/product/' + airPort.sn + '/services', data); clientReizePublish('thing/product/' + gateway + '/services', data);
}; };
export const services_replyTopicReize = () => { export const services_replyTopicReize = () => {
// 订阅消息 // 订阅消息
clientReizeSubscribe('thing/product/' + airPort.sn + '/services_reply'); clientReizeSubscribe('thing/product/' + gateway + '/services_reply');
}; };
export const drcDownTopicReize = (data) => { export const drcDownTopicReize = (data) => {
// 发送消息thing/product/{gateway_sn}/drc/down // 发送消息thing/product/{gateway_sn}/drc/down
clientReizePublish('thing/product/' + airPort.sn + '/drc/down', data); clientReizePublish('thing/product/' + gateway + '/drc/down', data);
}; };
export const eventsTopicSubscribeReize = () => { export const eventsTopicSubscribeReize = () => {
// 发送消息 // 发送消息
clientReizeSubscribe('thing/product/' + airPort.sn + '/events'); clientReizeSubscribe('thing/product/' + gateway + '/events');
}; };

@ -3,8 +3,7 @@ import { airPortStore } from '@/store/modules/airport';
import errorCode from './error_code.json'; import errorCode from './error_code.json';
const airPortStoreVal = airPortStore(); const airPortStoreVal = airPortStore();
const airPort = airPortStoreVal.getAirport; const gateway = airPortStoreVal.getGateway;
const uav = airPortStoreVal.getUAV;
export const debug_mode_openOptions = { export const debug_mode_openOptions = {
canceled: '取消或终止', canceled: '取消或终止',
failed: '失败', failed: '失败',
@ -37,47 +36,38 @@ export const errorName = (code) => {
}; };
export const servicesTopic = (data) => { export const servicesTopic = (data) => {
// 发送消息 // 发送消息
clientPublish('thing/product/' + airPort.sn + '/services', data); clientPublish('thing/product/' + gateway + '/services', data);
}; };
export const services_replyTopic = () => { export const services_replyTopic = () => {
// 订阅消息 // 订阅消息
clientSubscribe('thing/product/' + airPort.sn + '/services_reply'); clientSubscribe('thing/product/' + gateway + '/services_reply');
};
// 无人机
export const servicesUAVTopic = (data) => {
// 发送消息
clientPublish('thing/product/' + uav.sn + '/services', data);
};
export const services_replyUAVTopic = () => {
// 订阅消息
clientSubscribe('thing/product/' + uav.sn + '/services_reply');
}; };
export const eventsTopic = (data) => { export const eventsTopic = (data) => {
// 发送消息 // 发送消息
clientPublish('thing/product/' + airPort.sn + '/events', data); clientPublish('thing/product/' + gateway + '/events', data);
}; };
export const events_replyTopic = () => { export const events_replyTopic = () => {
// 订阅消息 // 订阅消息
clientSubscribe('thing/product/' + airPort.sn + '/events_reply'); clientSubscribe('thing/product/' + gateway + '/events_reply');
}; };
export const drcDownTopic = (data) => { export const drcDownTopic = (data) => {
// 发送消息thing/product/{gateway_sn}/drc/down // 发送消息thing/product/{gateway_sn}/drc/down
clientPublish('thing/product/' + airPort.sn + '/drc/down', data); clientPublish('thing/product/' + gateway + '/drc/down', data);
}; };
export const eventsTopicSubscribe = () => { export const eventsTopicSubscribe = () => {
// 发送消息 // 发送消息
clientSubscribe('thing/product/' + airPort.sn + '/events'); clientSubscribe('thing/product/' + gateway + '/events');
}; };
export const drcUpTopic = () => { export const drcUpTopic = () => {
clientSubscribe('thing/product/' + airPort.sn + '/drc/up'); clientSubscribe('thing/product/' + gateway + '/drc/up');
}; };
export const setTopic = (data) => { export const setTopic = (data) => {
// 发送消息 // 发送消息
clientPublish('thing/product/' + airPort.sn + '/property/set', data); clientPublish('thing/product/' + gateway + '/property/set', data);
}; };
export const set_replyTopic = () => { export const set_replyTopic = () => {
// 订阅消息 // 订阅消息
clientSubscribe('thing/product/' + airPort.sn + '/services_reply'); clientSubscribe('thing/product/' + gateway + '/services_reply');
}; };

@ -114,7 +114,6 @@
}); });
const locationVal: any = ref({}); const locationVal: any = ref({});
const flyToThere = (e) => { const flyToThere = (e) => {
console.log(e);
locationVal.value.lat = e._lat; locationVal.value.lat = e._lat;
locationVal.value.lng = e._lng; locationVal.value.lng = e._lng;
locationVal.value.alt = e._alt; locationVal.value.alt = e._alt;

@ -46,6 +46,7 @@
project: null, project: null,
equipment: null, equipment: null,
airport: null, airport: null,
gateway: null,
}); });
const optionsArr = reactive({ const optionsArr = reactive({
projectOptions: [], projectOptions: [],
@ -55,6 +56,7 @@
const handleChange = () => { const handleChange = () => {
airPortStoreVal.setAirPort('sn', selectVal.airport); airPortStoreVal.setAirPort('sn', selectVal.airport);
airPortStoreVal.setUAV('sn', selectVal.equipment); airPortStoreVal.setUAV('sn', selectVal.equipment);
airPortStoreVal.setGateway(selectVal.gateway);
emits('selectChange', selectVal); emits('selectChange', selectVal);
}; };
// //
@ -67,9 +69,9 @@
value: item.Id, value: item.Id,
}; };
}); });
if(sessionStorage.getItem('homeToFlightId')){ if (sessionStorage.getItem('homeToFlightId')) {
selectVal.project = sessionStorage.getItem('homeToFlightId'); selectVal.project = sessionStorage.getItem('homeToFlightId');
sessionStorage.removeItem('homeToFlightId') sessionStorage.removeItem('homeToFlightId');
} else { } else {
selectVal.project = optionsArr.projectOptions[0].value; selectVal.project = optionsArr.projectOptions[0].value;
} }
@ -123,9 +125,11 @@
return { return {
label: item.name, label: item.name,
value: item.sn, value: item.sn,
gateway: item.gateway,
}; };
}); });
selectVal.equipment = optionsArr.equipmentOptions[0].value; selectVal.equipment = optionsArr.equipmentOptions[0].value;
selectVal.gateway = optionsArr.equipmentOptions[0].gateway;
handleChange(); handleChange();
} else { } else {
optionsArr.equipmentOptions = []; optionsArr.equipmentOptions = [];

Loading…
Cancel
Save