|
@ -10,6 +10,7 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { mapState } from "vuex"; |
|
|
import { mapState } from "vuex"; |
|
|
|
|
|
import audioSrc from '@/assets/audio/y913.mp3'; |
|
|
export default { |
|
|
export default { |
|
|
name: "Websocket", |
|
|
name: "Websocket", |
|
|
data() { |
|
|
data() { |
|
@ -30,13 +31,13 @@ export default { |
|
|
// 建立 websocket 连接 |
|
|
// 建立 websocket 连接 |
|
|
this.socket.initialize({ |
|
|
this.socket.initialize({ |
|
|
// url: 'ws://' + location.hostname + ':' + port + path, |
|
|
// url: 'ws://' + location.hostname + ':' + port + path, |
|
|
url: 'wss://' + location.hostname + ':' + window.location.port + '/ws' || 80 + '/ws', |
|
|
//url: 'wss://' + locatoin.hostname + ':' + window.location.port + '/ws' || 80 + '/ws', |
|
|
// url: "ws://10.168.66.196:7789" + path, |
|
|
// url: "ws://10.168.66.196:7789" + path, |
|
|
// url: 'ws://10.168.77.128:7789/ws', |
|
|
// url: 'ws://10.168.77.128:7789/ws', |
|
|
// url: "ws://10.7.179.15" + ":" + port + path, |
|
|
// url: "ws://10.7.179.15" + ":" + port + path, |
|
|
// url: "ws://10.168.64.171" + ":" + port + path, |
|
|
// url: "ws://10.168.64.171" + ":" + port + path, |
|
|
// url: 'ws://10.168.78.127'+ ':' + port + path, |
|
|
// url: 'ws://10.168.78.127'+ ':' + port + path, |
|
|
|
|
|
url: 'ws://127.0.0.1'+ ':' + 7789 + '/ws', |
|
|
password: password, |
|
|
password: password, |
|
|
tokenSN: this.token, |
|
|
tokenSN: this.token, |
|
|
heartRate: interval, |
|
|
heartRate: interval, |
|
@ -104,13 +105,21 @@ export default { |
|
|
}); |
|
|
}); |
|
|
break; |
|
|
break; |
|
|
case "0": |
|
|
case "0": |
|
|
case "1": |
|
|
|
|
|
case "2": |
|
|
|
|
|
case "3": |
|
|
case "3": |
|
|
|
|
|
case "2": |
|
|
case "trafficFlowDataEarlyWarning": |
|
|
case "trafficFlowDataEarlyWarning": |
|
|
this.$emit("newEvent", params); |
|
|
this.$emit("newEvent", params); |
|
|
break; |
|
|
break; |
|
|
|
|
|
case "1": |
|
|
|
|
|
if(content.event.warningSource ==5||content.event.warningType==10||content.event.warningType==11){ |
|
|
|
|
|
this.triggerAlert() |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
this.$emit("newEvent", params); |
|
|
|
|
|
}, 1000); // 1000 毫秒 = 1 秒 |
|
|
|
|
|
}else{ |
|
|
|
|
|
this.$emit("newEvent", params); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
case "deviceState": |
|
|
case "deviceState": |
|
|
this.EventBus.$emit("deviceState", contentList); |
|
|
this.EventBus.$emit("deviceState", contentList); |
|
|
break; |
|
|
break; |
|
@ -128,12 +137,16 @@ export default { |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
created() { }, |
|
|
created() { }, |
|
|
methods: {}, |
|
|
methods: { |
|
|
|
|
|
triggerAlert(){ |
|
|
|
|
|
const audio = new Audio(audioSrc); |
|
|
|
|
|
audio.play(); |
|
|
|
|
|
}}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
let _this = this; |
|
|
let _this = this; |
|
|
if (process.env.NODE_ENV == "development") { |
|
|
if (process.env.NODE_ENV == "development") { |
|
|
//测试websocket用的 |
|
|
//测试websocket用的 |
|
|
return; |
|
|
// return; |
|
|
let deviceState = "0"; |
|
|
let deviceState = "0"; |
|
|
document.onkeydown = function (e) { |
|
|
document.onkeydown = function (e) { |
|
|
deviceState == "0" ? deviceState = "1" : deviceState = "0"; |
|
|
deviceState == "0" ? deviceState = "1" : deviceState = "0"; |
|
@ -143,9 +156,11 @@ export default { |
|
|
// 消息数字 |
|
|
// 消息数字 |
|
|
// _this.$root.$emit('update-warning', Math.floor(Math.random() * 20)); |
|
|
// _this.$root.$emit('update-warning', Math.floor(Math.random() * 20)); |
|
|
// 事件弹窗 |
|
|
// 事件弹窗 |
|
|
// let params = { |
|
|
const audio = new Audio(audioSrc); |
|
|
// "subEvent":"2","content":{"event":{"id":"ad84780896584c4ab67d034c0ab9b853","stakeMark":"K078+300","direction":"1","warningState":1,"warningTime":"2024-08-20 10:43:23","warningSource":5,"warningType":6,"warningSubclass":"6-3","warningTitle":"菏泽方向 发生障碍物(障碍物)事件","otherConfig":"","lane":"0","number":0,"longitude":"116.699758","latitude":"36.435038","duration":0,"endTime":"2024-08-20 12:00:43","createTime":"2024-08-20 11:00:43","remark":"2024年08月20日 10:43:21 K078+300 菏泽方向 发生障碍物(障碍物)事件","params":{}},"content":"菏泽方向 K078+300 发生障碍物事件"} |
|
|
audio.play(); |
|
|
// }; |
|
|
let params = { |
|
|
|
|
|
"subEvent":"2","content":{"event":{"id":"ad84780896584c4ab67d034c0ab9b853","stakeMark":"K078+300","direction":"1","warningState":1,"warningTime":"2024-08-20 10:43:23","warningSource":5,"warningType":6,"warningSubclass":"6-3","warningTitle":"菏泽方向 发生障碍物(障碍物)事件","otherConfig":"","lane":"0","number":0,"longitude":"116.699758","latitude":"36.435038","duration":0,"endTime":"2024-08-20 12:00:43","createTime":"2024-08-20 11:00:43","remark":"2024年08月20日 10:43:21 K078+300 菏泽方向 发生障碍物(障碍物)事件","params":{}},"content":"菏泽方向 K078+300 发生障碍物事件"} |
|
|
|
|
|
}; |
|
|
// 交通流预警 |
|
|
// 交通流预警 |
|
|
// let params = { |
|
|
// let params = { |
|
|
// "subEvent": "trafficFlowDataEarlyWarning", |
|
|
// "subEvent": "trafficFlowDataEarlyWarning", |
|
@ -166,32 +181,31 @@ export default { |
|
|
// } |
|
|
// } |
|
|
|
|
|
|
|
|
//设备故障 |
|
|
//设备故障 |
|
|
let params = { |
|
|
// let params = { |
|
|
"subEvent": "deviceOfflineRecord", |
|
|
// "subEvent": "deviceOfflineRecord", |
|
|
"content": { |
|
|
// "content": { |
|
|
"deviceOfflineRecord": { |
|
|
// "deviceOfflineRecord": { |
|
|
"id": 86, |
|
|
// "id": 86, |
|
|
"deviceId": 2171, |
|
|
// "deviceId": 2171, |
|
|
"iotDeviceId": "10.0.36.142-1883", |
|
|
// "iotDeviceId": "10.0.36.142-1883", |
|
|
"deviceName": "远端机(K112+037)", |
|
|
// "deviceName": "远端机(K112+037)", |
|
|
"deviceType": "16", |
|
|
// "deviceType": "16", |
|
|
"stakeMark": "K112+037", |
|
|
// "stakeMark": "K112+037", |
|
|
"direction": "1", |
|
|
// "direction": "1", |
|
|
"deviceIp": "10.0.36.142", |
|
|
// "deviceIp": "10.0.36.142", |
|
|
"facilitiesType": "1", |
|
|
// "facilitiesType": "1", |
|
|
"longitude": "116.475787", |
|
|
// "longitude": "116.475787", |
|
|
"latitude": "36.221393", |
|
|
// "latitude": "36.221393", |
|
|
"status": "0", |
|
|
// "status": "0", |
|
|
"createTime": "2024-09-21 11:05:12", |
|
|
// "createTime": "2024-09-21 11:05:12", |
|
|
"params": {} |
|
|
// "params": {} |
|
|
}, |
|
|
// }, |
|
|
"content": "K112+037菏泽方向远端机(K112+037)发生故障" |
|
|
// "content": "K112+037菏泽方向远端机(K112+037)发生故障" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
// } |
|
|
} |
|
|
// } |
|
|
_this.$emit("newEvent", params); |
|
|
_this.$emit("newEvent", params); |
|
|
|
|
|
|
|
|
// 测试事件变更 |
|
|
// 测试事件变更 |
|
|
// let params = { |
|
|
// let params = { |
|
|
// "subEvent": "deviceState", |
|
|
// "subEvent": "deviceState", |
|
@ -210,5 +224,6 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|