Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
b4c5a29026
@ -43,6 +43,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
||||
|
||||
let scope = this;
|
||||
let stats =null;
|
||||
let driverWebWorker = null;
|
||||
// let stats = new Stats();
|
||||
// dom.appendChild( stats.dom );
|
||||
//界面更新函数
|
||||
@ -161,6 +162,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
||||
// scope.jsonwebwork = new Worker("../../static/workertest/jsonworker.js");
|
||||
// scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
|
||||
// scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||
|
||||
scope.Subscribe = new Jl3dDriving(mixers,updatemmi,sound,translation,routegroup);
|
||||
|
||||
scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||
@ -206,12 +208,11 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
||||
}, 2000);
|
||||
}else{
|
||||
scope.datatype = "new";
|
||||
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats);
|
||||
driverWebWorker = new Worker("../../static/workertest/driverWebWorker.js");
|
||||
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,driverWebWorker,stats);
|
||||
|
||||
datanew();
|
||||
// scope.jsonwebworknew = new Worker("../../static/workertest/jsonworkernew.js");
|
||||
// scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew);
|
||||
// scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||
|
||||
DriverLoadNew(mapnetdata,scope,netdata.data,mapdata,sectionlist,signallist,switchlist,stationstandlist,trainlisttest,rails,camera,controls3,scene,mixers);
|
||||
var timer = setInterval(function() {
|
||||
if(trainlisttest){
|
||||
@ -219,7 +220,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
||||
if(trainlisttest.group.children[0]){
|
||||
updatemmi.updatedrivingcodenew(trainlisttest.group.children[0].code);
|
||||
scope.Subscribe.initdrivercode(trainlisttest.group.children[0].code);
|
||||
scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||
driverWebWorker.postMessage("connect");
|
||||
clearInterval(timer);
|
||||
}
|
||||
}
|
||||
@ -357,6 +358,9 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
||||
scope.Subscribe = null;
|
||||
// sound.stop();
|
||||
scope.webwork.terminate();
|
||||
if(driverWebWorker){
|
||||
driverWebWorker.terminate();
|
||||
}
|
||||
// console.log(scope);
|
||||
// scope = null;
|
||||
};
|
||||
@ -417,6 +421,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
||||
|
||||
this.endsocket = function() {
|
||||
scope.Subscribe.socketoff(scope.Subscribe.topic);
|
||||
|
||||
};
|
||||
|
||||
this.loaderdata = function(loadsectionlist,loadlinklist,loadsignallist,loadstationstandlist,loadtrainlisttest,loadrealsectionlist,loadrails){
|
||||
|
@ -1,12 +1,10 @@
|
||||
import StompClient from '@/utils/sock';
|
||||
|
||||
import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation';
|
||||
|
||||
import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
|
||||
import { getBaseUrl } from '@/utils/baseUrl'
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
// 定于仿真socket接口
|
||||
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats) {
|
||||
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,driverWebWorker,stats) {
|
||||
|
||||
let scope = this;
|
||||
this.map = null;
|
||||
@ -39,8 +37,61 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
|
||||
// reset = 02;
|
||||
var datatype = '00';
|
||||
this.teststomp = new StompClient();
|
||||
// let toppic = '/app/topic/simulation/client/'+routegroup+'/drive';
|
||||
this.topic = '/user/queue/simulation/drive/'+routegroup;
|
||||
let header = {'X-Token': getToken() };
|
||||
let connectmsg = {
|
||||
type:'init',
|
||||
baseurl:getBaseUrl(),
|
||||
topic:this.topic,
|
||||
token:getToken(),
|
||||
};
|
||||
driverWebWorker.postMessage(connectmsg);
|
||||
driverWebWorker.onmessage = function (event) {
|
||||
|
||||
let data = event.data;
|
||||
if(data.type == "Train_Position"){
|
||||
trainrun(data.body);
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.type == "Train_Position_3D"){
|
||||
otherTrainRun(data.body);
|
||||
return;
|
||||
}
|
||||
if(data.type == "Train_Hmi_3D"){
|
||||
updatestatus(data.body);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(data.type == "DeviceCtrl_3D"){
|
||||
// console.log(data);
|
||||
if (data.body.type== 'SIGNAL' && signallist) {
|
||||
signalupdate(data.body);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.body.type== "PSD" && actions) {
|
||||
standupdate(data.body);
|
||||
return;
|
||||
}
|
||||
if (data.body.type == "SWITCH") {
|
||||
switchupdate(data.body);
|
||||
return;
|
||||
}
|
||||
if (data.body.type == 'TRAIN_DOOR') {
|
||||
traindoorupdate(data.body);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.type == "Device_Load_Destroy_3D"){
|
||||
DeviceDestroy(data.body);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) {
|
||||
// console.log(mapdata);
|
||||
// console.log(newtrainlisttest);
|
||||
@ -71,7 +122,13 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
|
||||
};
|
||||
|
||||
this.socketoff = function(topic) {
|
||||
scope.teststomp.unsubscribe(topic);
|
||||
if(driverWebWorker){
|
||||
driverWebWorker.postMessage("off");
|
||||
}else{
|
||||
scope.teststomp.unsubscribe(topic);
|
||||
}
|
||||
|
||||
|
||||
for (let i=0; i<trainlisttest.group.children.length; i++) {
|
||||
if (trainlisttest.group.children[i].dispose == false) {
|
||||
code = trainlisttest.group.children[i].name;
|
||||
@ -106,24 +163,11 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
|
||||
return;
|
||||
}
|
||||
if(data.type == "Train_Hmi_3D"){
|
||||
// console.log(data.body);
|
||||
|
||||
updatestatus(data.body);
|
||||
|
||||
// if(data.body.trust){
|
||||
// if(data.body.trust == '1'){
|
||||
// updateDriverTrust(data.body.code,true);
|
||||
// }else{
|
||||
// updateDriverTrust(data.body.code,false);
|
||||
// }
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
// if (event.data.type== 'SIGNAL' && signallist) {
|
||||
// signalupdate(event.data);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
if(data.type == "DeviceCtrl_3D"){
|
||||
if (data.body.type== 'SIGNAL' && signallist) {
|
||||
@ -149,27 +193,6 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
|
||||
DeviceDestroy(data.body);
|
||||
return;
|
||||
}
|
||||
// if (event.data.type== "PSD" && actions) {
|
||||
// standupdate(event.data);
|
||||
// return;
|
||||
// }
|
||||
// if (event.data.type == "SWITCH") {
|
||||
// switchupdate(event.data);
|
||||
// return;
|
||||
// }
|
||||
// if (event.data.type == 'TRAIN_DOOR') {
|
||||
// traindoorupdate(event.data);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(event.data.type == 'Simulation_Reset'){
|
||||
// simulationreset(event.data);
|
||||
// return;
|
||||
// }
|
||||
// if(event.data.type == 'Simulation_DeviceStatus'){
|
||||
// initall(event.data.body);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
function DeviceDestroy(data){
|
||||
@ -216,7 +239,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
|
||||
// if(data.code = "336"){
|
||||
// console.log(data);
|
||||
// }
|
||||
|
||||
|
||||
if(updateTrainModel.code != trainmodel.code){
|
||||
if(data.section != updateTrainModel.nowsection){
|
||||
updateTrainModel.nowsection = data.section;
|
||||
|
@ -104,7 +104,7 @@ export function Jl3dOtherVR(dom,group,skinCode) {
|
||||
//定义相机
|
||||
|
||||
this.camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.01, 300);
|
||||
this.camera.position.set(0, 0, 0);
|
||||
this.camera.position.set(0, 100, 100);
|
||||
this.camera.aspect = window.innerWidth / window.innerHeight;
|
||||
this.camera.updateProjectionMatrix();
|
||||
//定义场景(渲染容器)
|
||||
|
@ -206,12 +206,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -284,7 +287,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -206,12 +206,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPointReverse({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPointReverse({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -284,7 +287,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -181,12 +181,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -259,7 +262,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -199,12 +199,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPointReverse({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPointReverse({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
|
@ -266,12 +266,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
|
@ -266,12 +266,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.directionCode}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
|
@ -226,12 +226,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}${elem.destinationCode || ''}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}${elem.destinationCode || ''}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -304,7 +307,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -104,6 +104,7 @@
|
||||
<signal-guide ref="signalGuide" />
|
||||
<initialzed-signal-can-block ref="initializeSignalCanBlock" />
|
||||
<signal-can-block ref="signalCanBlock" />
|
||||
<route-command ref="routeCommand" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -131,6 +132,7 @@ import InitializeSignalGuide from './menuDialog/initializeSignalGuide';
|
||||
import SignalGuide from './menuDialog/signalGuide';
|
||||
import InitialzedSignalCanBlock from './menuDialog/initializeSignalCanBlock';
|
||||
import SignalCanBlock from './menuDialog/signalCanBlock';
|
||||
import RouteCommand from './menuDialog/routeCommand';
|
||||
|
||||
export default {
|
||||
name: 'MenuBar',
|
||||
@ -152,7 +154,8 @@ export default {
|
||||
InitializeSignalGuide,
|
||||
SignalGuide,
|
||||
InitialzedSignalCanBlock,
|
||||
SignalCanBlock
|
||||
SignalCanBlock,
|
||||
RouteCommand
|
||||
},
|
||||
props: {
|
||||
selected: {
|
||||
@ -358,7 +361,7 @@ export default {
|
||||
},
|
||||
{
|
||||
title: '进路/命令',
|
||||
click: this.undeveloped
|
||||
click: this.setRouteCommand
|
||||
},
|
||||
{
|
||||
title: '信号指示模式',
|
||||
@ -768,7 +771,7 @@ export default {
|
||||
},
|
||||
{
|
||||
title: '进路/命令',
|
||||
click: this.undeveloped
|
||||
click: this.setRouteCommand
|
||||
},
|
||||
{
|
||||
title: '信号指示模式',
|
||||
@ -1340,6 +1343,19 @@ export default {
|
||||
// this.$refs.signalCanBlock.doShow();
|
||||
}
|
||||
});
|
||||
},
|
||||
setRouteCommand() {
|
||||
const operate = {
|
||||
type: 'bar',
|
||||
operation: ''
|
||||
};
|
||||
this.$store.dispatch('training/nextNew', operate).then(({valid}) => {
|
||||
if (valid) {
|
||||
this.closeMenu(true);
|
||||
this.$store.dispatch('menuOperation/handleBreakFlag', {break: true});
|
||||
this.$refs.routeCommand.doShow();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -4,24 +4,24 @@
|
||||
<el-col :span="3">
|
||||
<el-row>
|
||||
<div>开始</div>
|
||||
<el-table :data="signalList">
|
||||
<el-table :data="signalList" height="150">
|
||||
<el-table-column prop="name" label="信号机" />
|
||||
</el-table>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div>结束</div>
|
||||
<el-table :data="signalList">
|
||||
<el-table :data="signalList" height="150">
|
||||
<el-table-column prop="name" label="信号机" />
|
||||
</el-table>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-col :span="6">
|
||||
<el-table :data="tempData">
|
||||
<el-table-column prop="path" label="路径" />
|
||||
<el-table-column prop="direction" label="运行方向" />
|
||||
</el-table>
|
||||
</el-col>
|
||||
<el-col :span="17">
|
||||
<el-col :span="15">
|
||||
<el-tabs v-model="activeName" type="card">
|
||||
<el-tab-pane label="设置进路" name="first">用户管理</el-tab-pane>
|
||||
<el-tab-pane label="取消进路" name="second">配置管理</el-tab-pane>
|
||||
|
@ -218,12 +218,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -296,7 +299,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -217,12 +217,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -295,7 +298,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -43,6 +43,7 @@ export default {
|
||||
fieldNum: 8,
|
||||
sepField: 'Trip',
|
||||
idField: 'Train ID',
|
||||
destinationCode: 'DID',
|
||||
columns: {
|
||||
'LOC': { key: 'stationName', formatter: (val) => { return StationMap[val]; } },
|
||||
'Arrive': { key: 'arriveTime', formatter: (val) => { return val; } },
|
||||
@ -58,7 +59,7 @@ export default {
|
||||
if (dataList && dataList.length) {
|
||||
for (var colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
|
||||
var isContinue = true;
|
||||
var tripObj = { code: '', trainId: '', arrivalList: [] };
|
||||
var tripObj = { code: '', trainId: '', destinationCode: '', arrivalList: [] };
|
||||
for (var rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
|
||||
isContinue = false;
|
||||
|
||||
@ -86,7 +87,7 @@ export default {
|
||||
valueStr = tripObj.trainId + valueStr;
|
||||
delete tripObj.trainId;
|
||||
JsonData.push(tripObj);
|
||||
tripObj = { code: valueStr, arrivalList: [] };
|
||||
tripObj = { code: valueStr, destinationCode: '', arrivalList: [] };
|
||||
} else {
|
||||
if (valueStr.includes('FT') || valueStr.includes('LT')) {
|
||||
valueStr = valueStr.replace('FT', '').replace('LT', '');
|
||||
@ -95,8 +96,10 @@ export default {
|
||||
delete tripObj.trainId;
|
||||
tripObj.code = valueStr;
|
||||
}
|
||||
} else if (titleStr === this.ExcelConfig.idField) {
|
||||
} else if (titleStr == this.ExcelConfig.idField) {
|
||||
tripObj.trainId = valueStr;
|
||||
} else if (titleStr == this.ExcelConfig.destinationCode) {
|
||||
tripObj.destinationCode = valueStr;
|
||||
}
|
||||
|
||||
// 取需要的字段
|
||||
@ -268,12 +271,15 @@ export default {
|
||||
|
||||
/** 如果此记录车组号的数据为第一条时,则打上标签*/
|
||||
if (runPlanData[elem.serviceNumber][elem.tripNumber].length <= 1) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(time), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
const result = serie.markPoint.data.some(ele => ele.name == `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`);
|
||||
if (!result) {
|
||||
serie.markPoint.data.push(createMartPoint({
|
||||
directionCode: elem.directionCode,
|
||||
coord: [parseInt(time), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
|
||||
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
|
||||
color: lineStyle.color || '#000'
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/** 计算折返点*/
|
||||
@ -346,7 +352,8 @@ export default {
|
||||
|
||||
/** 根据是否和上一个车次是否相交,计算下一个车次的折返的高度*/
|
||||
computedReentryNumber(code) {
|
||||
return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
// return parseInt(code || 1) % 2 ? 1 : 2;
|
||||
return 1;
|
||||
},
|
||||
|
||||
/** 根据方向计算y折返偏移量*/
|
||||
|
@ -45,7 +45,7 @@ export const loginInfo = {
|
||||
systemType: '011'
|
||||
},
|
||||
drts: {
|
||||
title: '行车调度员竞赛练习系统',
|
||||
title: '行车调度员实训系统国赛备战版',
|
||||
loginPath: '/login?project=drts',
|
||||
loginParam: 'DRTS',
|
||||
loginTitle: '空串',
|
||||
|
@ -17,10 +17,6 @@
|
||||
<div class="countdown_box">{{ days[1] }}</div>
|
||||
<div class="countdown_box">{{ days[2] }}</div>
|
||||
<div style="display: inline-block;">天</div>
|
||||
<div style="width: 300px;font-size: 28px;justify-content:space-between;display: flex;margin:0 auto;margin-top: 30px">
|
||||
<div style="display: inline-block;">备战国赛</div>
|
||||
<div style="display: inline-block;">免费使用</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="project === 'drts' && gameOver" style="position: absolute; top: 100px;font-size: 50px;color:#F00;">
|
||||
<div style="display: inline-block;">全国调度大赛已结束</div>
|
||||
@ -115,7 +111,13 @@
|
||||
</div>
|
||||
<float-part v-if="isProject && !versionBaseNoShow.includes(project)" />
|
||||
<div v-if="!mainBodyNoShow.includes(project)" style="position: absolute; bottom: 10px;right: 20px; font-size: 14px;"><span>主体:北京玖琏科技有限公司 备案号:京ICP备18028522号</span></div>
|
||||
<div v-if="project === 'drts'" style="position: absolute; bottom: 200px;text-align: center; font-size: 32px;color:#F00;">郑重承诺:满足用户的一切技术需求!新地图上线三周!新需求两周完成!新BUG两天修复!</div>
|
||||
<div v-if="project === 'drts'" style="position: absolute; bottom: 200px;text-align: center; font-size: 32px;color:#F00;">
|
||||
<div>郑重承诺:满足用户的一切技术需求!新地图上线三周!新需求两周完成!新BUG两天修复!</div>
|
||||
<div style="width: 300px;font-size: 28px;justify-content:space-between;display: flex;margin:0 auto;margin-top: 30px;">
|
||||
<div style="display: inline-block;">备战国赛</div>
|
||||
<div style="display: inline-block;">免费使用</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="project === 'drts'" style="position: absolute; bottom: 50px; font-size: 20px;right: 20px;color:#3D3D3D;width: 370px;">
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
|
@ -55,6 +55,7 @@
|
||||
import Cookies from 'js-cookie';
|
||||
import ConstConfig from '@/scripts/ConstConfig';
|
||||
import {getScriptPageListOnlineNew, getScriptByIdNew } from '@/api/script';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
// 剧本弹窗
|
||||
export default {
|
||||
@ -188,6 +189,7 @@ export default {
|
||||
const res = await getScriptByIdNew(row.id);
|
||||
let newMemberList = [];
|
||||
if (res.code == 200) {
|
||||
EventBus.$emit('clearRunSeries');
|
||||
if (res.data.memberList && res.data.memberList.length > 0) {
|
||||
// newMemberList
|
||||
// const playerList = res.data.memberList.filter(item => item.hasPlay === true);
|
||||
|
@ -41,6 +41,7 @@ import DataTable from '@/views/planSchedule/menusPlan/components/dataTable';
|
||||
import echarts from 'echarts';
|
||||
import {toTimeStamp, formatDuring} from '@/utils/date';
|
||||
import { deepAssign } from '@/utils/index';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name: 'PlanSchedule',
|
||||
@ -148,6 +149,9 @@ export default {
|
||||
mounted() {
|
||||
this.staticSeries = []; this.selectSeries = []; this.runSeries = [];
|
||||
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
|
||||
EventBus.$on('clearRunSeries', () => {
|
||||
this.runSeries = [];
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.destroy();
|
||||
@ -401,9 +405,10 @@ export default {
|
||||
return this.PlanConvert.computedFormatYAxis(this.stations, params);
|
||||
},
|
||||
xAxisLableFormat(value, index) {
|
||||
if (value % 60 === 0) {
|
||||
return timeFormat(value);
|
||||
}
|
||||
// if (value % 60 === 0) {
|
||||
// return timeFormat(value);
|
||||
// }
|
||||
return timeFormat(value);
|
||||
},
|
||||
yAxisLableFormat(value, index) {
|
||||
return '';
|
||||
|
@ -19,7 +19,8 @@
|
||||
<!-- 排班计划 -->
|
||||
<el-button v-if="scheduleLoadShow" type="primary" size="small" @click="jumpScheduling">派班计划加载</el-button>
|
||||
<el-button v-if="schedulePreviewShow" type="primary" size="small" @click="schedulingView">派班计划预览</el-button>
|
||||
<el-button v-if="isContest" size="small" type="primary" @click="viewChangeMap">切换地图</el-button>
|
||||
<el-button v-if="isContest" size="small" @click="fieldPractice">实操练习</el-button>
|
||||
<el-button v-if="isContest" size="small" @click="viewChangeMap">切换地图</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
<Jl3d-Device
|
||||
@ -201,6 +202,9 @@ export default {
|
||||
},
|
||||
changeMap(query) {
|
||||
this.$emit('changeMap', query);
|
||||
},
|
||||
fieldPractice() {
|
||||
this.$emit('fieldPractice');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
:driver-show="isDrive"
|
||||
:all-style="'top:'+(offset+textStatusHeight)+'px'"
|
||||
@changeMap="changeMap"
|
||||
@fieldPractice="fieldPractice"
|
||||
/>
|
||||
|
||||
<div class="display-draft" :class="{'haerbin_btn_box': $route.query.lineCode == '07'}" :style="{bottom: offsetBottom + 'px'}">
|
||||
@ -27,8 +28,10 @@
|
||||
<template v-if="isScriptRun">
|
||||
<el-button type="danger" size="small" @click="handleQuitQuest">退出剧本</el-button>
|
||||
</template>
|
||||
<el-button type="danger" size="small" @click="end">{{ $t('display.demon.initialize') }}</el-button>
|
||||
<el-button type="success" :disabled="isDisable" size="small" @click="selectBeginTime">{{ $t('display.demon.drivingByPlan') }}</el-button>
|
||||
<template v-else>
|
||||
<el-button type="danger" size="small" @click="end">{{ $t('display.demon.initialize') }}</el-button>
|
||||
<el-button type="success" :disabled="isDisable" size="small" @click="selectBeginTime">{{ $t('display.demon.drivingByPlan') }}</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-button-group>
|
||||
</div>
|
||||
@ -170,9 +173,11 @@ export default {
|
||||
this.setRuning(false);
|
||||
},
|
||||
'$store.state.map.mapViewLoadedCount': function (val) { // 地图视图加载完成标识 开始加载默认状态
|
||||
const initTime = new Date(this.$store.state.training.initTime || null);
|
||||
const model = {initTime:this.formatTime(initTime)};
|
||||
this.start(model);
|
||||
if (this.$route.query.noFirst) {
|
||||
const initTime = new Date(this.$store.state.training.initTime || null);
|
||||
const model = {initTime:this.formatTime(initTime)};
|
||||
this.start(model);
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -258,6 +263,7 @@ export default {
|
||||
this.$store.dispatch('training/setPrdType', this.currentPrdType); // 改变prdType
|
||||
query.group = resp.data;
|
||||
const newQuery = Object.assign({}, query);
|
||||
newQuery.noFirst = true;
|
||||
this.$router.replace({query: newQuery});
|
||||
launchFullscreen();
|
||||
}).catch(error => {
|
||||
@ -428,6 +434,9 @@ export default {
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
fieldPractice() {
|
||||
this.$refs.menuSchema.viewRunQuest();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -179,6 +179,8 @@ export default {
|
||||
if (resp && resp.code == 200) {
|
||||
const detail = resp.data;
|
||||
await this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]);
|
||||
|
||||
await this.$store.dispatch('training/setTrainingData', detail); // 设置实训信息
|
||||
} else {
|
||||
this.$messageBox(`获取实训步骤数据失败`);
|
||||
this.endViewLoading();
|
||||
|
@ -209,6 +209,7 @@ export default {
|
||||
this.textStatusHeight = textStatus.offsetHeight || 0;
|
||||
textStatus.style.top = this.offset - 15 + 'px';
|
||||
}
|
||||
console.log(this.offset, '*************');
|
||||
});
|
||||
},
|
||||
// 缩放设置
|
||||
|
@ -64,6 +64,7 @@ import { quitScriptNew } from '@/api/simulation';
|
||||
import { setGoodsTryUse } from '@/api/management/goods';
|
||||
import {loadScriptNew } from '@/api/simulation';
|
||||
import Vue from 'vue';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name: 'MenuDemon',
|
||||
@ -296,6 +297,8 @@ export default {
|
||||
handleQuitQuest() {
|
||||
quitScriptNew(this.group).then(resp => {
|
||||
getSimulationInfoNew(this.group).then((res)=>{
|
||||
this.isDisable = false;
|
||||
EventBus.$emit('clearRunSeries');
|
||||
this.quitQuest();
|
||||
this.initLoadPage();
|
||||
this.clearAllData();
|
||||
|
@ -6,7 +6,7 @@
|
||||
<el-button-group>
|
||||
<el-button v-if="isScheduling && isDepot" size="small" type="primary" @click="runPlanEditShow">运行图编辑</el-button>
|
||||
<!-- 加载剧本 -->
|
||||
<el-button v-if="isDemon && !isScheduling" size="small" :disabled="viewDisabled" type="success" @click="viewRunQuest">{{ $t('display.schema.loadScript') }}</el-button>
|
||||
<el-button v-if="isDemon && !isScheduling && !isContest" size="small" :disabled="viewDisabled" type="success" @click="viewRunQuest">{{ $t('display.schema.loadScript') }}</el-button>
|
||||
<!-- 运行图加载 -->
|
||||
<el-button v-if="notScript && running" size="small" :disabled="viewDisabled" @click="viewRunPlan">{{ $t('display.schema.previewRunDiagram') }}</el-button>
|
||||
<el-button v-if="notScript && !running" size="small" type="warning" @click="loadRunPlan">{{ $t('display.schema.loadRunDiagram') }}</el-button>
|
||||
@ -101,6 +101,9 @@ export default {
|
||||
},
|
||||
isDepot() {
|
||||
return this.$route.query.type === 'DEPOT';
|
||||
},
|
||||
isContest() {
|
||||
return this.project === 'drts';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -57,7 +57,7 @@ export default {
|
||||
return (this.$route.query.lineCode == 10 || this.$route.query.lineCode == 11) && this.isDisplay;
|
||||
},
|
||||
top() {
|
||||
return this.isShowDate ? (this.$route.query.prdType == '05' ? 5 : 35) : this.offset;
|
||||
return this.isShowDate ? (this.$route.query.prdType == '05' ? 5 : this.offset - 10) : this.offset;
|
||||
},
|
||||
newRight() {
|
||||
return this.isShowDate ? this.$store.state.config.width - 420 : this.$store.state.config.width / 2 - 55;
|
||||
|
737
static/workertest/driverWebWorker.js
Normal file
737
static/workertest/driverWebWorker.js
Normal file
@ -0,0 +1,737 @@
|
||||
// importScripts('sockjs.js');
|
||||
// import { getToken } from '@/utils/auth';
|
||||
// import { getBaseUrl } from '@/utils/baseUrl';
|
||||
// import SockJS from 'sockjs-client';
|
||||
|
||||
// const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token=';
|
||||
// const websocketUrl = `http://192.168.3.6:9000/joylink-websocket?token=`;
|
||||
let websocketUrl = null;
|
||||
let token = null;
|
||||
var StompClient = function (headers, token) {
|
||||
const scope = this;
|
||||
this.url = websocketUrl + token;
|
||||
this.headers = headers || {};
|
||||
this.connect();
|
||||
};
|
||||
|
||||
StompClient.prototype = {
|
||||
socket: null,
|
||||
|
||||
clientIns: null,
|
||||
|
||||
subscribeMap: null,
|
||||
|
||||
url: '',
|
||||
|
||||
status: false,
|
||||
|
||||
sockStatus: 0,
|
||||
|
||||
headers: {
|
||||
// 'X-Token': getToken()
|
||||
},
|
||||
|
||||
count: 0,
|
||||
|
||||
topic: '',
|
||||
|
||||
onmessage: null,
|
||||
|
||||
checkTimer: null,
|
||||
|
||||
// 连接服务端
|
||||
connect() {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
// 断开已有连接
|
||||
if (this.clientIns && this.clientIns.connected) {
|
||||
this.clientIns.disconnect();
|
||||
this.clientIns = null;
|
||||
}
|
||||
|
||||
// // 建立连接对象(还未发起连接)
|
||||
// this.socket = new SockJS(websocketUrl + token);
|
||||
//
|
||||
// // 获取 STOMP 子协议的客户端对象
|
||||
// this.clientIns = Stomp.over(this.socket);
|
||||
|
||||
this.websocket = new WebSocket(this.url.replace(/https/, 'wss').replace(/http/, 'ws'));
|
||||
|
||||
this.clientIns = Stomp.over(this.websocket);
|
||||
|
||||
this.closeStompDebug();
|
||||
|
||||
// 向服务器发起websocket连接并发送CONNECT帧
|
||||
this.clientIns.connect({ 'X-Token': token }, () => {
|
||||
console.info('连接成功.');
|
||||
this.count = 0;
|
||||
this.status = true;
|
||||
|
||||
// 恢复订阅
|
||||
if (this.topic && this.onmessage) {
|
||||
this.unsubscribe(this.topic);
|
||||
this.subscribe(this.topic, this.onmessage, this.headers);
|
||||
}
|
||||
|
||||
resolve(this);
|
||||
}, () => {
|
||||
if (this.checkTimer) {
|
||||
clearInterval(this.checkTimer);
|
||||
this.checkTimer = null;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
logOut(err) {
|
||||
if (err.code == 50008 || err.code == 50014) {
|
||||
this.url = websocketUrl + token;
|
||||
this.status = false;
|
||||
this.count++;
|
||||
this.reconnect(this.count);
|
||||
}
|
||||
},
|
||||
// 恢复链接
|
||||
reconnect(count) {
|
||||
console.info(`尝试第${count || 1}次连接.`);
|
||||
this.connect().then(() => { }).catch(() => {
|
||||
this.count++;
|
||||
this.reconnect(this.count);
|
||||
});
|
||||
},
|
||||
|
||||
closeStompDebug() {
|
||||
if (this.clientIns) {
|
||||
this.clientIns.debug = undefined;
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// 订阅指定的topic
|
||||
subscribe(topic, onmessage, headers) {
|
||||
this.topic = topic;
|
||||
this.onmessage = onmessage;
|
||||
this.headers = headers;
|
||||
if (this.status) {
|
||||
if (!this.subscribeMap) {
|
||||
this.subscribeMap = new Map();
|
||||
}
|
||||
|
||||
try {
|
||||
var subscription = this.subscribeMap.get(topic);
|
||||
if (!subscription) {
|
||||
subscription = this.clientIns.subscribe(topic, onmessage, headers); // 接收消息通过 subscribe() 方法实现
|
||||
this.subscribeMap.set(topic, subscription);
|
||||
}
|
||||
} catch (err) {
|
||||
setTimeout(() => {
|
||||
this.subscribe(topic, onmessage, headers);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.subscribe(topic, onmessage, headers);
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
unsubscribe(topic) {
|
||||
if (this.subscribeMap) {
|
||||
const subscription = this.subscribeMap.get(topic);
|
||||
if (subscription) {
|
||||
subscription.unsubscribe();
|
||||
this.subscribeMap.delete(topic);
|
||||
console.log('取消订阅');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 发送消息
|
||||
send(url, msg) {
|
||||
if (this.status) {
|
||||
if (msg) {
|
||||
msg = JSON.stringify(msg);
|
||||
}
|
||||
try {
|
||||
this.clientIns.send(url, {}, msg);
|
||||
} catch (err) {
|
||||
this.status = false;
|
||||
this.send(url, msg);
|
||||
}
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.send(url, msg);
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
disconnect() {
|
||||
if (this.checkTimer) {
|
||||
clearInterval(this.checkTimer);
|
||||
this.checkTimer = null;
|
||||
}
|
||||
|
||||
if (this.clientIns && this.clientIns.connected) {
|
||||
this.clientIns.disconnect();
|
||||
this.clientIns = null;
|
||||
}
|
||||
this.status = false;
|
||||
console.log('断开连接');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var Byte; var Client; var Frame; var Stomp;
|
||||
var __hasProp = {}.hasOwnProperty;
|
||||
var __slice = [].slice;
|
||||
|
||||
Byte = {
|
||||
LF: '\x0A',
|
||||
NULL: '\x00'
|
||||
};
|
||||
|
||||
Frame = (function() {
|
||||
var unmarshallSingle;
|
||||
|
||||
function Frame(command, headers, body) {
|
||||
this.command = command;
|
||||
this.headers = headers != null ? headers : {};
|
||||
this.body = body != null ? body : '';
|
||||
}
|
||||
|
||||
Frame.prototype.toString = function() {
|
||||
var lines, name, skipContentLength, value, _ref;
|
||||
lines = [this.command];
|
||||
skipContentLength = this.headers['content-length'] === false;
|
||||
if (skipContentLength) {
|
||||
delete this.headers['content-length'];
|
||||
}
|
||||
_ref = this.headers;
|
||||
for (name in _ref) {
|
||||
if (!__hasProp.call(_ref, name)) continue;
|
||||
value = _ref[name];
|
||||
lines.push('' + name + ':' + value);
|
||||
}
|
||||
if (this.body && !skipContentLength) {
|
||||
lines.push('content-length:' + (Frame.sizeOfUTF8(this.body)));
|
||||
}
|
||||
lines.push(Byte.LF + this.body);
|
||||
return lines.join(Byte.LF);
|
||||
};
|
||||
|
||||
Frame.sizeOfUTF8 = function(s) {
|
||||
if (s) {
|
||||
return encodeURI(s).match(/%..|./g).length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
unmarshallSingle = function(data) {
|
||||
var body, chr, command, divider, headerLines, headers, i, idx, len, line, start, trim, _i, _j, _len, _ref, _ref1;
|
||||
divider = data.search(RegExp('' + Byte.LF + Byte.LF));
|
||||
headerLines = data.substring(0, divider).split(Byte.LF);
|
||||
command = headerLines.shift();
|
||||
headers = {};
|
||||
trim = function(str) {
|
||||
return str.replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
_ref = headerLines.reverse();
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
line = _ref[_i];
|
||||
idx = line.indexOf(':');
|
||||
headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1));
|
||||
}
|
||||
body = '';
|
||||
start = divider + 2;
|
||||
if (headers['content-length']) {
|
||||
len = parseInt(headers['content-length']);
|
||||
body = ('' + data).substring(start, start + len);
|
||||
} else {
|
||||
chr = null;
|
||||
for (i = _j = start, _ref1 = data.length; start <= _ref1 ? _j < _ref1 : _j > _ref1; i = start <= _ref1 ? ++_j : --_j) {
|
||||
chr = data.charAt(i);
|
||||
if (chr === Byte.NULL) {
|
||||
break;
|
||||
}
|
||||
body += chr;
|
||||
}
|
||||
}
|
||||
return new Frame(command, headers, body);
|
||||
};
|
||||
|
||||
Frame.unmarshall = function(datas) {
|
||||
var data;
|
||||
return (function() {
|
||||
var _i, _len, _ref, _results;
|
||||
_ref = datas.split(RegExp('' + Byte.NULL + Byte.LF + '*'));
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
data = _ref[_i];
|
||||
if ((data != null ? data.length : void 0) > 0) {
|
||||
_results.push(unmarshallSingle(data));
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
};
|
||||
|
||||
Frame.marshall = function(command, headers, body) {
|
||||
var frame;
|
||||
frame = new Frame(command, headers, body);
|
||||
return frame.toString() + Byte.NULL;
|
||||
};
|
||||
|
||||
return Frame;
|
||||
|
||||
})();
|
||||
|
||||
Client = (function() {
|
||||
var now;
|
||||
|
||||
function Client(ws) {
|
||||
this.ws = ws;
|
||||
this.ws.binaryType = 'arraybuffer';
|
||||
this.counter = 0;
|
||||
this.connected = false;
|
||||
this.heartbeat = {
|
||||
outgoing: 10000,
|
||||
incoming: 10000
|
||||
};
|
||||
this.maxWebSocketFrameSize = 16 * 1024;
|
||||
this.subscriptions = {};
|
||||
}
|
||||
|
||||
Client.prototype.debug = function(message) {
|
||||
var _ref;
|
||||
return typeof window !== 'undefined' && window !== null ? (_ref = window.console) != null ? _ref.log(message) : void 0 : void 0;
|
||||
};
|
||||
|
||||
now = function() {
|
||||
if (Date.now) {
|
||||
return Date.now();
|
||||
} else {
|
||||
return new Date().valueOf;
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype._transmit = function(command, headers, body) {
|
||||
var out;
|
||||
out = Frame.marshall(command, headers, body);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('>>> ' + out);
|
||||
}
|
||||
while (true) {
|
||||
if (out.length > this.maxWebSocketFrameSize) {
|
||||
this.ws.send(out.substring(0, this.maxWebSocketFrameSize));
|
||||
out = out.substring(this.maxWebSocketFrameSize);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('remaining = ' + out.length);
|
||||
}
|
||||
} else {
|
||||
return this.ws.send(out);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype._setupHeartbeat = function(headers) {
|
||||
var serverIncoming, serverOutgoing, ttl, v, _ref, _ref1;
|
||||
if ((_ref = headers.version) !== Stomp.VERSIONS.V1_1 && _ref !== Stomp.VERSIONS.V1_2) {
|
||||
return;
|
||||
}
|
||||
_ref1 = (function() {
|
||||
var _i, _len, _ref1, _results;
|
||||
_ref1 = headers['heart-beat'].split(',');
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
v = _ref1[_i];
|
||||
_results.push(parseInt(v));
|
||||
}
|
||||
return _results;
|
||||
})(), serverOutgoing = _ref1[0], serverIncoming = _ref1[1];
|
||||
if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) {
|
||||
ttl = Math.max(this.heartbeat.outgoing, serverIncoming);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('send PING every ' + ttl + 'ms');
|
||||
}
|
||||
this.pinger = Stomp.setInterval(ttl, (function(_this) {
|
||||
return function() {
|
||||
_this.ws.send(Byte.LF);
|
||||
return typeof _this.debug === 'function' ? _this.debug('>>> PING') : void 0;
|
||||
};
|
||||
})(this));
|
||||
}
|
||||
if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) {
|
||||
ttl = Math.max(this.heartbeat.incoming, serverOutgoing);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('check PONG every ' + ttl + 'ms');
|
||||
}
|
||||
return this.ponger = Stomp.setInterval(ttl, (function(_this) {
|
||||
return function() {
|
||||
var delta;
|
||||
delta = now() - _this.serverActivity;
|
||||
if (delta > ttl * 2) {
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('did not receive server activity for the last ' + delta + 'ms');
|
||||
}
|
||||
return _this.ws.close();
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype._parseConnect = function() {
|
||||
var args, connectCallback, errorCallback, headers;
|
||||
args = arguments.length >= 1 ? __slice.call(arguments, 0) : [];
|
||||
headers = {};
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
headers = args[0], connectCallback = args[1];
|
||||
break;
|
||||
case 3:
|
||||
if (args[1] instanceof Function) {
|
||||
headers = args[0], connectCallback = args[1], errorCallback = args[2];
|
||||
} else {
|
||||
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3];
|
||||
break;
|
||||
default:
|
||||
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], headers.host = args[4];
|
||||
}
|
||||
return [headers, connectCallback, errorCallback];
|
||||
};
|
||||
|
||||
Client.prototype.connect = function() {
|
||||
var args, errorCallback, headers, out;
|
||||
args = arguments.length >= 1 ? __slice.call(arguments, 0) : [];
|
||||
out = this._parseConnect.apply(this, args);
|
||||
headers = out[0], this.connectCallback = out[1], errorCallback = out[2];
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('Opening Web Socket...');
|
||||
}
|
||||
this.ws.onmessage = (function(_this) {
|
||||
return function(evt) {
|
||||
var arr, c, client, data, frame, messageID, onreceive, subscription, _i, _len, _ref, _results;
|
||||
data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === 'function' ? _this.debug('--- got data length: ' + arr.length) : void 0, ((function() {
|
||||
var _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
c = arr[_i];
|
||||
_results.push(String.fromCharCode(c));
|
||||
}
|
||||
return _results;
|
||||
})()).join('')) : evt.data;
|
||||
_this.serverActivity = now();
|
||||
if (data === Byte.LF) {
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('<<< PONG');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('<<< ' + data);
|
||||
}
|
||||
_ref = Frame.unmarshall(data);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
frame = _ref[_i];
|
||||
switch (frame.command) {
|
||||
case 'CONNECTED':
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('connected to server ' + frame.headers.server);
|
||||
}
|
||||
_this.connected = true;
|
||||
_this._setupHeartbeat(frame.headers);
|
||||
_results.push(typeof _this.connectCallback === 'function' ? _this.connectCallback(frame) : void 0);
|
||||
break;
|
||||
case 'MESSAGE':
|
||||
subscription = frame.headers.subscription;
|
||||
onreceive = _this.subscriptions[subscription] || _this.onreceive;
|
||||
if (onreceive) {
|
||||
client = _this;
|
||||
messageID = frame.headers['message-id'];
|
||||
frame.ack = function(headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
return client.ack(messageID, subscription, headers);
|
||||
};
|
||||
frame.nack = function(headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
return client.nack(messageID, subscription, headers);
|
||||
};
|
||||
_results.push(onreceive(frame));
|
||||
} else {
|
||||
_results.push(typeof _this.debug === 'function' ? _this.debug('Unhandled received MESSAGE: ' + frame) : void 0);
|
||||
}
|
||||
break;
|
||||
case 'RECEIPT':
|
||||
_results.push(typeof _this.onreceipt === 'function' ? _this.onreceipt(frame) : void 0);
|
||||
break;
|
||||
case 'ERROR':
|
||||
_results.push(typeof errorCallback === 'function' ? errorCallback(frame) : void 0);
|
||||
break;
|
||||
default:
|
||||
_results.push(typeof _this.debug === 'function' ? _this.debug('Unhandled frame: ' + frame) : void 0);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
})(this);
|
||||
this.ws.onclose = (function(_this) {
|
||||
return function() {
|
||||
var msg;
|
||||
msg = 'Whoops! Lost connection to ' + _this.ws.url;
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug(msg);
|
||||
}
|
||||
_this._cleanUp();
|
||||
return typeof errorCallback === 'function' ? errorCallback(msg) : void 0;
|
||||
};
|
||||
})(this);
|
||||
return this.ws.onopen = (function(_this) {
|
||||
return function() {
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('Web Socket Opened...');
|
||||
}
|
||||
headers['accept-version'] = Stomp.VERSIONS.supportedVersions();
|
||||
headers['heart-beat'] = [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',');
|
||||
return _this._transmit('CONNECT', headers);
|
||||
};
|
||||
})(this);
|
||||
};
|
||||
|
||||
Client.prototype.disconnect = function(disconnectCallback, headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
this._transmit('DISCONNECT', headers);
|
||||
this.ws.onclose = null;
|
||||
this.ws.close();
|
||||
this._cleanUp();
|
||||
return typeof disconnectCallback === 'function' ? disconnectCallback() : void 0;
|
||||
};
|
||||
|
||||
Client.prototype._cleanUp = function() {
|
||||
this.connected = false;
|
||||
if (this.pinger) {
|
||||
Stomp.clearInterval(this.pinger);
|
||||
}
|
||||
if (this.ponger) {
|
||||
return Stomp.clearInterval(this.ponger);
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype.send = function(destination, headers, body) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
if (body == null) {
|
||||
body = '';
|
||||
}
|
||||
headers.destination = destination;
|
||||
return this._transmit('SEND', headers, body);
|
||||
};
|
||||
|
||||
Client.prototype.subscribe = function(destination, callback, headers) {
|
||||
var client;
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
if (!headers.id) {
|
||||
headers.id = 'sub-' + this.counter++;
|
||||
}
|
||||
headers.destination = destination;
|
||||
this.subscriptions[headers.id] = callback;
|
||||
this._transmit('SUBSCRIBE', headers);
|
||||
client = this;
|
||||
return {
|
||||
id: headers.id,
|
||||
unsubscribe: function() {
|
||||
return client.unsubscribe(headers.id);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Client.prototype.unsubscribe = function(id) {
|
||||
delete this.subscriptions[id];
|
||||
return this._transmit('UNSUBSCRIBE', {
|
||||
id: id
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.begin = function(transaction) {
|
||||
var client, txid;
|
||||
txid = transaction || 'tx-' + this.counter++;
|
||||
this._transmit('BEGIN', {
|
||||
transaction: txid
|
||||
});
|
||||
client = this;
|
||||
return {
|
||||
id: txid,
|
||||
commit: function() {
|
||||
return client.commit(txid);
|
||||
},
|
||||
abort: function() {
|
||||
return client.abort(txid);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Client.prototype.commit = function(transaction) {
|
||||
return this._transmit('COMMIT', {
|
||||
transaction: transaction
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.abort = function(transaction) {
|
||||
return this._transmit('ABORT', {
|
||||
transaction: transaction
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.ack = function(messageID, subscription, headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
headers['message-id'] = messageID;
|
||||
headers.subscription = subscription;
|
||||
return this._transmit('ACK', headers);
|
||||
};
|
||||
|
||||
Client.prototype.nack = function(messageID, subscription, headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
headers['message-id'] = messageID;
|
||||
headers.subscription = subscription;
|
||||
return this._transmit('NACK', headers);
|
||||
};
|
||||
|
||||
return Client;
|
||||
|
||||
})();
|
||||
|
||||
Stomp = {
|
||||
VERSIONS: {
|
||||
V1_0: '1.0',
|
||||
V1_1: '1.1',
|
||||
V1_2: '1.2',
|
||||
supportedVersions: function() {
|
||||
return '1.1,1.0';
|
||||
}
|
||||
},
|
||||
client: function(url, protocols) {
|
||||
var klass, ws;
|
||||
if (protocols == null) {
|
||||
protocols = ['v10.stomp', 'v11.stomp'];
|
||||
}
|
||||
klass = Stomp.WebSocketClass || WebSocket;
|
||||
ws = new klass(url, protocols);
|
||||
return new Client(ws);
|
||||
},
|
||||
over: function(ws) {
|
||||
return new Client(ws);
|
||||
},
|
||||
Frame: Frame
|
||||
};
|
||||
|
||||
if (typeof exports !== 'undefined' && exports !== null) {
|
||||
exports.Stomp = Stomp;
|
||||
}
|
||||
Stomp.setInterval = function(interval, f) {
|
||||
return setInterval(f, interval);
|
||||
};
|
||||
Stomp.clearInterval = function(id) {
|
||||
return clearInterval(id);
|
||||
};
|
||||
|
||||
let data = null;
|
||||
|
||||
let topic = null;
|
||||
let header = null;
|
||||
let teststomp = null;
|
||||
function timedCount() {
|
||||
|
||||
onmessage = (e) => {
|
||||
|
||||
if (e.data.type == 'init') {
|
||||
topic = e.data.topic;
|
||||
header = {'X-Token': e.data.token };
|
||||
token = e.data.token;
|
||||
websocketUrl = e.data.baseurl + '/joylink-websocket?token=';
|
||||
|
||||
}
|
||||
|
||||
if (e.data == 'connect') {
|
||||
teststomp = new StompClient(header, token);
|
||||
teststomp.subscribe(topic, callback, header);
|
||||
}
|
||||
|
||||
if (e.data == 'off') {
|
||||
teststomp.unsubscribe(topic);
|
||||
}
|
||||
|
||||
};
|
||||
function callback(Response) {
|
||||
|
||||
data = JSON.parse(Response.body);
|
||||
// console.log(data);
|
||||
|
||||
if(data.type == "Train_Position"){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.type == "Train_Position_3D"){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if(data.type == "Train_Hmi_3D"){
|
||||
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(data.type == "DeviceCtrl_3D"){
|
||||
if (data.body.type== 'SIGNAL') {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.body.type== "PSD") {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if (data.body.type == "SWITCH") {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if (data.body.type == 'TRAIN_DOOR') {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.type == "Device_Load_Destroy_3D"){
|
||||
postMessage(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timedCount();
|
Loading…
Reference in New Issue
Block a user