74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import { getClient, createConnection, clientPublish, clientSubscribe } from '@/utils/mqtt';
|
|
import { airPortStore } from '@/store/modules/airport';
|
|
import errorCode from './error_code.json';
|
|
|
|
const airPortStoreVal = airPortStore();
|
|
export const debug_mode_openOptions = {
|
|
canceled: '取消或终止',
|
|
failed: '失败',
|
|
in_progress: '执行中',
|
|
ok: '执行成功',
|
|
paused: '暂停',
|
|
rejected: '拒绝',
|
|
sent: '已下发',
|
|
timeout: '超时',
|
|
};
|
|
export const cover_stateOptions = { '0': '关闭', '1': '打开', '2': '半开', '3': '舱盖状态异常' };
|
|
export const cover_opensStatus = {
|
|
canceled: '取消或终止',
|
|
failed: '失败',
|
|
in_progress: '执行中',
|
|
ok: '执行成功',
|
|
paused: '暂停',
|
|
rejected: '拒绝',
|
|
sent: '已下发',
|
|
timeout: '超时',
|
|
};
|
|
|
|
export const errorName = (code) => {
|
|
const error_code = errorCode.error_code;
|
|
if (error_code[code]) {
|
|
return error_code[code];
|
|
} else {
|
|
return '错误码' + code;
|
|
}
|
|
};
|
|
export const servicesTopic = (data) => {
|
|
console.log(airPortStoreVal.getGateway);
|
|
// 发送消息
|
|
clientPublish('thing/product/' + airPortStoreVal.getGateway + '/services', data);
|
|
};
|
|
export const services_replyTopic = () => {
|
|
// 订阅消息
|
|
clientSubscribe('thing/product/' + airPortStoreVal.getGateway + '/services_reply');
|
|
};
|
|
export const eventsTopic = (data) => {
|
|
// 发送消息
|
|
clientPublish('thing/product/' + airPortStoreVal.getGateway + '/events', data);
|
|
};
|
|
export const events_replyTopic = () => {
|
|
// 订阅消息
|
|
clientSubscribe('thing/product/' + airPortStoreVal.getGateway + '/events_reply');
|
|
};
|
|
export const drcDownTopic = (data) => {
|
|
// 发送消息thing/product/{gateway_sn}/drc/down
|
|
clientPublish('thing/product/' + airPortStoreVal.getGateway + '/drc/down', data);
|
|
};
|
|
|
|
export const eventsTopicSubscribe = () => {
|
|
// 发送消息
|
|
clientSubscribe('thing/product/' + airPortStoreVal.getGateway + '/events');
|
|
};
|
|
export const drcUpTopic = () => {
|
|
clientSubscribe('thing/product/' + airPortStoreVal.getGateway + '/drc/up');
|
|
};
|
|
|
|
export const setTopic = (data) => {
|
|
// 发送消息
|
|
clientPublish('thing/product/' + airPortStoreVal.getGateway + '/property/set', data);
|
|
};
|
|
export const set_replyTopic = () => {
|
|
// 订阅消息
|
|
clientSubscribe('thing/product/' + airPortStoreVal.getGateway + '/services_reply');
|
|
};
|