From bd0e1f1a9afabff8ba4fd1c65523a298320b68c9 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Fri, 30 Dec 2022 14:15:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=8ECCTV=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E7=82=B9=E5=87=BB=E8=8F=9C=E5=8D=95=E9=80=80=E5=87=BA?= =?UTF-8?q?=E4=BC=9A=E7=9B=B4=E6=8E=A5=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jl3dpassflow/connect/passflowconnect.js | 298 +++++++++--------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js b/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js index 7efe6acf5..c73a83689 100644 --- a/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js +++ b/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js @@ -3,183 +3,183 @@ import { getToken } from '@/utils/auth'; import store from '@/store/index'; // 定于仿真socket接口 -export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passerStation,passerAi) { - const scope = this; - this.teststomp = new StompClient(); +export function PassflowConnect(deviceaction, toptrain, downtrain, routegroup, passerStation, passerAi) { + const scope = this; + this.teststomp = new StompClient(); - // let topic = '/user/queue/simulation/jl3d/'+routegroup; - let topic = '/user/queue/simulation/'+ routegroup +'/jl3d'; - let header = {'X-Token': getToken() }; + // let topic = '/user/queue/simulation/jl3d/'+routegroup; + const topic = '/user/queue/simulation/' + routegroup + '/jl3d'; + const header = {'X-Token': getToken() }; - socketon(topic); + socketon(topic); - function socketon(topic) { - try { - scope.teststomp.subscribe(topic, callback, header); - } catch (error) { - console.error('websocket订阅失败'); - } + function socketon(topic) { + try { + scope.teststomp.subscribe(topic, callback, header); + } catch (error) { + console.error('websocket订阅失败'); + } - }; + } - this.socketoff = function(topic) { - scope.teststomp.unsubscribe(topic); - }; + this.socketoff = function(topic) { + scope.teststomp.unsubscribe(topic); + }; - // 仿真socket接口回调函数 - function callback(Response) { - const data = JSON.parse(Response.body); + // 仿真socket接口回调函数 + function callback(Response) { + const data = JSON.parse(Response.body); - if(data.type == "DeviceCtrl_3D"){ - if(data.body.type == "PSD"){ - if(data.body.code == passerStation.nowStation.toppsd){ - if(data.body.command == 'G'){ + if (data.type == 'DeviceCtrl_3D') { + if (data.body.type == 'PSD') { + if (data.body.code == passerStation.nowStation.toppsd) { + if (data.body.command == 'G') { - deviceaction.top.action.reset(); - deviceaction.top.action.time =deviceaction.top.action._clip.duration; - deviceaction.top.action.timeScale = -1; - deviceaction.top.action.play(); - }else{ - passerAi.passerout("top") - deviceaction.top.action.reset(); - deviceaction.top.action.time = 0; - deviceaction.top.action.timeScale = 1; - deviceaction.top.action.play(); - } - } - if(data.body.code == passerStation.nowStation.downpsd){ - if(data.body.command == 'G'){ - deviceaction.down.action.reset(); - deviceaction.down.action.time = deviceaction.down.action._clip.duration; - deviceaction.down.action.timeScale = -1; - deviceaction.down.action.play(); - }else{ - passerAi.passerout("down"); - deviceaction.down.action.reset(); - deviceaction.down.action.time = 0; - deviceaction.down.action.timeScale = 1; - deviceaction.down.action.play(); - } + deviceaction.top.action.reset(); + deviceaction.top.action.time = deviceaction.top.action._clip.duration; + deviceaction.top.action.timeScale = -1; + deviceaction.top.action.play(); + } else { + passerAi.passerout('top'); + deviceaction.top.action.reset(); + deviceaction.top.action.time = 0; + deviceaction.top.action.timeScale = 1; + deviceaction.top.action.play(); + } + } + if (data.body.code == passerStation.nowStation.downpsd) { + if (data.body.command == 'G') { + deviceaction.down.action.reset(); + deviceaction.down.action.time = deviceaction.down.action._clip.duration; + deviceaction.down.action.timeScale = -1; + deviceaction.down.action.play(); + } else { + passerAi.passerout('down'); + deviceaction.down.action.reset(); + deviceaction.down.action.time = 0; + deviceaction.down.action.timeScale = 1; + deviceaction.down.action.play(); + } - } - } - if(data.body.type == "TRAIN_DOOR"){ - if(toptrain.nowcode == data.body.trainCode){ + } + } + if (data.body.type == 'TRAIN_DOOR') { + if (toptrain.nowcode == data.body.trainCode) { - if(data.body.command == 'G'){ - closetraindoor(toptrain,data.body.code,"top"); + if (data.body.command == 'G') { + closetraindoor(toptrain, data.body.code, 'top'); - }else{ - opentraindoor(toptrain,data.body.code,"top"); + } else { + opentraindoor(toptrain, data.body.code, 'top'); - } + } - } - if(downtrain.nowcode == data.body.trainCode){ - // console.log(data.body); - if(data.body.command == 'G'){ - closetraindoor(downtrain,data.body.code,"down"); + } + if (downtrain.nowcode == data.body.trainCode) { + // console.log(data.body); + if (data.body.command == 'G') { + closetraindoor(downtrain, data.body.code, 'down'); - }else{ - opentraindoor(downtrain,data.body.code,"down"); + } else { + opentraindoor(downtrain, data.body.code, 'down'); - } + } - } - } - } + } + } + } - if(data.type == "TrainRun_3D"){ + if (data.type == 'TrainRun_3D') { - for(let i=0,leni = data.body.length;i { - location.reload(); - }); - } - } - let actions; + } else { + if (downtrain.nowcode == data.body[i].code) { + downtrain.position.x += 1; + } + } + } + } + // if(data.type == 'Simulation_Over') { + // store.dispatch('LogOut').then(() => { + // location.reload(); + // }); + // } + } + let actions; - function opentraindoor(train,doorcode,direct){ - if(direct == "top"){ - if(doorcode == "1"){ - actions = train.action.down; - } + function opentraindoor(train, doorcode, direct) { + if (direct == 'top') { + if (doorcode == '1') { + actions = train.action.down; + } - if(doorcode == "2"){ - actions = train.action.top; - } - }else{ - if(doorcode == "1"){ - actions = train.action.top; - } + if (doorcode == '2') { + actions = train.action.top; + } + } else { + if (doorcode == '1') { + actions = train.action.top; + } - if(doorcode == "2"){ - actions = train.action.down; - } - } + if (doorcode == '2') { + actions = train.action.down; + } + } - for(let an=actions.length-1;an>=0;an--){ - actions[an].reset(); - actions[an].time = 0; - actions[an].timeScale = 1; - actions[an].play(); - } - } - function closetraindoor(train,doorcode,direct){ + for (let an = actions.length - 1; an >= 0; an--) { + actions[an].reset(); + actions[an].time = 0; + actions[an].timeScale = 1; + actions[an].play(); + } + } + function closetraindoor(train, doorcode, direct) { - if(direct == "top"){ - if(doorcode == "1"){ - actions = train.action.down; - } - if(doorcode == "2"){ - actions = train.action.top; - } - toptrain.nowcode = null; - }else{ - if(doorcode == "1"){ - actions = train.action.top; - } - if(doorcode == "2"){ - actions = train.action.down; - } - downtrain.nowcode = null; - } + if (direct == 'top') { + if (doorcode == '1') { + actions = train.action.down; + } + if (doorcode == '2') { + actions = train.action.top; + } + toptrain.nowcode = null; + } else { + if (doorcode == '1') { + actions = train.action.top; + } + if (doorcode == '2') { + actions = train.action.down; + } + downtrain.nowcode = null; + } - for(let an=actions.length-1;an>=0;an--){ - actions[an].reset(); - actions[an].time = actions[an]._clip.duration; - actions[an].timeScale = -1; - actions[an].play(); - } + for (let an = actions.length - 1; an >= 0; an--) { + actions[an].reset(); + actions[an].time = actions[an]._clip.duration; + actions[an].timeScale = -1; + actions[an].play(); + } - } + } }