From 8096076be302d7ff1e86990c0ac63483fa1ce19e Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Tue, 4 Aug 2020 13:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E5=AD=90=E6=B2=99=E7=9B=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E9=80=80=E5=87=BA=E5=92=8C=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../connect/Jlmap3dSubscribeNew.js | 1480 ++++++++--------- .../jlmap3d/simulation/jl3dsimulation.vue | 15 +- src/views/login/index.vue | 4 +- static/workertest/jsonworkernew.js | 4 + 4 files changed, 758 insertions(+), 745 deletions(-) diff --git a/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js b/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js index c35bdce7e..bff07de6e 100644 --- a/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js +++ b/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js @@ -1,778 +1,772 @@ import StompClient from '@/utils/sock'; - +import store from '@/store/index_APP_TARGET'; // import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation'; // import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp'; -import { getBaseUrl } from '@/utils/baseUrl' +import { getBaseUrl } from '@/utils/baseUrl'; import { getToken } from '@/utils/auth'; // 定于仿真socket接口 -export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) { +export function Jlmap3dSubscribeNew(jlmap3d, routegroup, jsonwebwork) { - const scope = this; - this.map = null; + const scope = this; + this.map = null; - var trainlisttest = null; - var sectionlist = null; - var signallist = null; - var stationstandlist = null; - var sectionlist = null; - var materials = null; - var actions = null; - var rails = null; - var links = null; + var trainlisttest = null; + var sectionlist = null; + var signallist = null; + var stationstandlist = null; + var sectionlist = null; + var materials = null; + var actions = null; + var rails = null; + var links = null; - var scenes = null; + var scenes = null; - var code = null; + var code = null; - var drivingcode = null; - var drivingspeed = null; - var drivingaptspeed = null; + var drivingcode = null; + var drivingspeed = null; + var drivingaptspeed = null; - let driverswitch = false; + const driverswitch = false; - let stoptimer = null; - let num = 30; - let pointstand = null; + const stoptimer = null; + const num = 30; + const pointstand = null; - let data = null; - // run as plane = 01; - // reset = 02; + const data = null; + // run as plane = 01; + // reset = 02; - var datatype = '00'; - this.teststomp = new StompClient(); - this.topic = '/user/queue/simulation/jl3d/'+routegroup; - let header = {'X-Token': getToken() }; - let connectmsg = { - type:'init', - baseurl:getBaseUrl(), - topic:this.topic, - token:getToken(), - }; - jsonwebwork.postMessage(connectmsg); - jsonwebwork.onmessage = function (event) { + var datatype = '00'; + this.teststomp = new StompClient(); + this.topic = '/user/queue/simulation/jl3d/' + routegroup; + const header = {'X-Token': getToken() }; + const connectmsg = { + type:'init', + baseurl:getBaseUrl(), + topic:this.topic, + token:getToken() + }; + jsonwebwork.postMessage(connectmsg); + jsonwebwork.onmessage = function (event) { + // console.log(event.data); + // if(event.data.deviceType == "TRAIN"){ + // // console.log(event.data); + // + // } + // console.log(event.data); + if (event.data.type == 'Device_Load_Destroy_3D') { + DeviceDestroy(event.data); + return; + } - // console.log(event.data); - // if(event.data.deviceType == "TRAIN"){ - // // console.log(event.data); - // - // } - // console.log(event.data); - if(event.data.type == "Device_Load_Destroy_3D"){ - DeviceDestroy(event.data); - return; - } + if (event.data.type == 'TrainRun_3D') { - if(event.data.type == 'TrainRun_3D'){ - - for(let i=0,leni=event.data.body.length;i 0 || trainlisttest.list[code].children[2].rotalist.length > 0 || trainlisttest.list[code].children[3].rotalist.length > 0 || trainlisttest.list[code].children[4].rotalist.length > 0|| trainlisttest.list[code].children[5].rotalist.length > 0){ - for(let rs = 1;rs<6;rs++){ - //console.log(rs); - if(trainlisttest.list[code].children[rs].rotalist[0]){ - let offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) - parseFloat(trainlisttest.list[code].children[rs].matrixWorld.elements[14]); - - trainlisttest.list[code].children[rs].position.z += offsetz; - - for(let xh=0;xh=trainlisttest.list[code].children[rs].rotalist[0].posr.x){ - // if(trainlisttest.list[code].groupNumber == "005"){ - // console.log("rs:"+rs); - // console.log(trainlisttest.list[code].children[rs].matrixWorld.elements[12]); - // console.log(trainlisttest.list[code].children[rs].rotalist[0].posr.x); - // } - if(rs != 5){ - let asd = trainlisttest.list[code].children[rs].rotalist[0]; - trainlisttest.list[code].children[rs+1].rotalist.push(asd); - - } - - trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rota; - trainlisttest.list[code].children[rs].rotalist.splice(0,1) - xh--; - }else{ - xh = trainlisttest.list[code].children[rs].rotalist.length; - } - } - //console.log(trainlisttest.list[code].children[rs].rotalist.length); - } - } - } - - - - } else if (data.right == '0') { // 向左 - trainlisttest.list[code].right = '0'; - trainlisttest.list[code].progress = 1-data.offset; - // trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack; - // if(rails.sectionrail[data.section].standTrack){ - // trainlisttest.list[code].statsstop = 0; - // } - let point = rails.sectionrail[data.section].lineright.getPointAt(trainlisttest.list[code].progress); - - trainlisttest.list[code].rotation.y = Math.PI; - trainlisttest.list[code].position.x = point.x; - trainlisttest.list[code].position.y = 0; - - // for (let tl=0; tl<6; tl++) { - // trainlisttest.list[code].children[tl].position.z = parseFloat(-point.z); - // } - - // trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright; - // if(data.next){ - // trainlisttest.list[code].nextcode = data.next; - // trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineright; - // trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; - // } - // trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact; - trainlisttest.list[code].status = '0'; - if(-trainlisttest.list[code].children[0].position.z != point.z){ - - - trainlisttest.list[code].children[0].up = new THREE.Vector3(-1,0,0); - let tangent = rails.sectionrail[data.section].lineright.getTangentAt(data.offset).normalize(); - trainlisttest.list[code].children[0].axis.crossVectors(trainlisttest.list[code].children[0].up, tangent).normalize(); - let radians = Math.acos(trainlisttest.list[code].children[0].up.dot(tangent)); - trainlisttest.list[code].children[0].quaternion.setFromAxisAngle(trainlisttest.list[code].children[0].axis, radians); - trainlisttest.list[code].children[0].rotation.x = -Math.PI/2; - trainlisttest.list[code].children[0].rotation.z = trainlisttest.list[code].children[0].rotation.y; - trainlisttest.list[code].children[0].rotation.y = 0; - - let rotas = { - posr:point, - rota:trainlisttest.list[code].children[0].rotation.z - } - trainlisttest.list[code].children[1].rotalist.push(rotas); - let offsetz = point.z + trainlisttest.list[code].children[0].position.z; - trainlisttest.list[code].children[0].position.z -= offsetz; - // trainlisttest.list[code].position.z = point.z; - - } - if(trainlisttest.list[code].children[1].rotalist.length > 0 || trainlisttest.list[code].children[2].rotalist.length > 0 || trainlisttest.list[code].children[3].rotalist.length > 0 || trainlisttest.list[code].children[4].rotalist.length > 0|| trainlisttest.list[code].children[5].rotalist.length > 0){ - - for(let rs = 1;rs<6;rs++){ - //console.log(rs); - if(trainlisttest.list[code].children[rs].rotalist[0]){ - - let offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) + parseFloat(trainlisttest.list[code].children[rs].position.z); - trainlisttest.list[code].children[rs].position.z -= offsetz; - - for(let xh=0;xh=0;an--){ - actions[code].top[an].reset(); - actions[code].top[an].time = actions[code].top[an]._clip.duration; - actions[code].top[an].timeScale = -1; - actions[code].top[an].play(); - } - }else if(trainlisttest.list[code].open != data.open && data.open == "1"){ - trainlisttest.list[code].open = "1"; - for(let an=actions[code].top.length-1;an>=0;an--){ - actions[code].top[an].reset(); - actions[code].top[an].time = 0; - actions[code].top[an].timeScale = 1; - actions[code].top[an].play(); - } - } - }else{ - - - if (trainlisttest.list[code].open != data.open && data.open == '0') { - trainlisttest.list[code].open = '0'; - for (let an=actions[code].down.length-1; an>=0; an--) { - actions[code].down[an].reset(); - actions[code].down[an].time = actions[code].down[an]._clip.duration; - actions[code].down[an].timeScale = -1; - actions[code].down[an].play(); - } - } else if (trainlisttest.list[code].open != data.open && data.open == '1') { - trainlisttest.list[code].open = "1"; - for(let an=actions[code].down.length-1;an>=0;an--){ - actions[code].down[an].reset(); - actions[code].down[an].time = 0; - actions[code].down[an].timeScale = 1; - actions[code].down[an].play(); - } - } - - } - }else{ - if(data.doorCode == "1"){ - - if(trainlisttest.list[code].open != data.open && data.open == "0"){ - trainlisttest.list[code].open = "0"; - for(let an=actions[code].top.length-1;an>=0;an--){ - actions[code].top[an].reset(); - actions[code].top[an].time = actions[code].top[an]._clip.duration; - actions[code].top[an].timeScale = -1; - actions[code].top[an].play(); - } - }else if(trainlisttest.list[code].open != data.open && data.open == "1"){ - trainlisttest.list[code].open = "1"; - for(let an=actions[code].top.length-1;an>=0;an--){ - actions[code].top[an].reset(); - actions[code].top[an].time = 0; - actions[code].top[an].timeScale = 1; - actions[code].top[an].play(); - } - } - }else{ - - - if (trainlisttest.list[code].open != data.open && data.open == '0') { - trainlisttest.list[code].open = '0'; - for (let an=actions[code].down.length-1; an>=0; an--) { - actions[code].down[an].reset(); - actions[code].down[an].time = actions[code].down[an]._clip.duration; - actions[code].down[an].timeScale = -1; - actions[code].down[an].play(); - } - } else if (trainlisttest.list[code].open != data.open && data.open == '1') { - trainlisttest.list[code].open = "1"; - for(let an=actions[code].down.length-1;an>=0;an--){ - actions[code].down[an].reset(); - actions[code].down[an].time = 0; - actions[code].down[an].timeScale = 1; - actions[code].down[an].play(); - } - } - - } - } - - } - - function trainstatus(data){ - // 遍历列车对象组 - if (trainlisttest) { - - code = data.code; - // 剔除不显示的车 - // 找到对应列车 - if ( trainlisttest.list[code]) { - - trainlisttest.list[code].driveMode = data.driveMode; - trainlisttest.list[code].status = data.right; - // 车门开关验证 - - - // 遍历获取所在轨道 - if (trainlisttest.list[code].dispose != data.dispose && data.dispose == "0") { - if (rails.sectionrail[data.sectionCode]) { - - trainlisttest.group.add(trainlisttest.list[code]); - trainlisttest.list[code].position.y = 0; - // trainlisttest.list[code].progress = 0; - trainlisttest.list[code].dispose = "0"; - trainlisttest.list[code].nowcode = data.sectionCode; - trainlisttest.list[code].nextcode = null; - trainlisttest.list[code].curve = null; + // if(event.data.type == 'TRAIN'){ + // console.log(event.data); + // trainrun(event.data); + // } + if (event.data.type == 'SIGNAL' && signallist) { + signalupdate(event.data); + // console.log(event.data); + 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; + } + if (event.data.type == 'Simulation_Over') { + store.dispatch('socket/setStomp', event.data); + return; + } + }; + + this.updatamap = function(newsectionlist, newlinklist, newsignallist, newstationstandlist, newtrainlisttest, newrealsectionlist, newrails, materiallist, nowaction, scene) { + trainlisttest = newtrainlisttest; + sectionlist = newsectionlist; + signallist = newsignallist; + stationstandlist = newstationstandlist; + materials = materiallist; + scenes = scene; + actions = nowaction; + links = newlinklist; + rails = newrails; + }; + + this.socketon = function(topic) { + try { + // console.log("teststomp"); + // scope.teststomp.subscribe(topic, callback, header); + } catch (error) { + console.error('websocket订阅失败'); + } + + }; + + this.socketoff = function(topic) { + 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; + trainlisttest.list[code].rotation.y = 0; + trainlisttest.list[code].open = '1'; + trainlisttest.list[code].speed = 0; + trainlisttest.group.children[i].dispose = true; + trainlisttest.group.children[i].position.x = -50000; + trainlisttest.group.children[i].position.y = -50000; + + trainlisttest.group.remove(trainlisttest.group.children[i]); + i--; + } + } + }; + + function trainrunnew(data) { + const code = data.code; + + if (trainlisttest.list[code].right != data.right) { + if (data.right == '0') { + trainlisttest.list[code].right = '0'; + trainlisttest.list[code].rotation.y = Math.PI; + const point = rails.sectionrail[data.section].lineleft.getPointAt(data.offset); + trainlisttest.list[code].position.x = point.x; + for (let tl = 0; tl < 6; tl++) { + trainlisttest.list[code].children[tl].position.z = point.z; + } + } else { + trainlisttest.list[code].right = '1'; + trainlisttest.list[code].rotation.y = 0; + const point = rails.sectionrail[data.section].lineleft.getPointAt(data.offset); + trainlisttest.list[code].position.x = point.x; + for (let tl = 0; tl < 6; tl++) { + trainlisttest.list[code].children[tl].position.z = point.z; + } + } + } + + // console.log(data); + + if (trainlisttest.list[code].dispose == '0') { + if (data.right == '1') { // 向右 + trainlisttest.list[code].right = '1'; + trainlisttest.list[code].progress = data.offset; + // trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack; + // if(rails.sectionrail[data.section].standTrack){ + // trainlisttest.list[code].statsstop = 0; + // } + const point = rails.sectionrail[data.section].lineleft.getPointAt(trainlisttest.list[code].progress); + trainlisttest.list[code].rotation.y = 0; + trainlisttest.list[code].position.x = point.x; + trainlisttest.list[code].position.y = 0; + + // for (let tl=0; tl<6; tl++) { + // trainlisttest.list[code].children[tl].position.z = parseFloat(point.z); + // } + + // trainlisttest.list[code].curve = rails.sectionrail[data.section].lineleft; + + // if(data.next){ + // trainlisttest.list[code].nextcode = data.next; + // trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineleft; + // trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; + // } + // trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact; + trainlisttest.list[code].status = '1'; + + if (trainlisttest.list[code].children[0].position.z != point.z) { + trainlisttest.list[code].children[0].up = new THREE.Vector3(1, 0, 0); + const tangent = rails.sectionrail[data.section].lineleft.getTangentAt(data.offset).normalize(); + trainlisttest.list[code].children[0].axis.crossVectors(trainlisttest.list[code].children[0].up, tangent).normalize(); + const radians = Math.acos(trainlisttest.list[code].children[0].up.dot(tangent)); + trainlisttest.list[code].children[0].quaternion.setFromAxisAngle(trainlisttest.list[code].children[0].axis, radians); + trainlisttest.list[code].children[0].rotation.x = -Math.PI / 2; + trainlisttest.list[code].children[0].rotation.z = trainlisttest.list[code].children[0].rotation.y; + trainlisttest.list[code].children[0].rotation.y = 0; + const rotas = { + posr:point, + rota:trainlisttest.list[code].children[0].rotation.z + }; + trainlisttest.list[code].children[1].rotalist.push(rotas); + + const offsetz = parseFloat(point.z) - parseFloat(trainlisttest.list[code].children[0].position.z); + trainlisttest.list[code].children[0].position.z += offsetz; + } + if (trainlisttest.list[code].children[1].rotalist.length > 0 || trainlisttest.list[code].children[2].rotalist.length > 0 || trainlisttest.list[code].children[3].rotalist.length > 0 || trainlisttest.list[code].children[4].rotalist.length > 0 || trainlisttest.list[code].children[5].rotalist.length > 0) { + for (let rs = 1; rs < 6; rs++) { + // console.log(rs); + if (trainlisttest.list[code].children[rs].rotalist[0]) { + const offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) - parseFloat(trainlisttest.list[code].children[rs].matrixWorld.elements[14]); + + trainlisttest.list[code].children[rs].position.z += offsetz; + + for (let xh = 0; xh < trainlisttest.list[code].children[rs].rotalist.length; xh++) { + if ((trainlisttest.list[code].children[rs].matrixWorld.elements[12]) >= trainlisttest.list[code].children[rs].rotalist[0].posr.x) { + // if(trainlisttest.list[code].groupNumber == "005"){ + // console.log("rs:"+rs); + // console.log(trainlisttest.list[code].children[rs].matrixWorld.elements[12]); + // console.log(trainlisttest.list[code].children[rs].rotalist[0].posr.x); + // } + if (rs != 5) { + const asd = trainlisttest.list[code].children[rs].rotalist[0]; + trainlisttest.list[code].children[rs + 1].rotalist.push(asd); + + } + + trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rota; + trainlisttest.list[code].children[rs].rotalist.splice(0, 1); + xh--; + } else { + xh = trainlisttest.list[code].children[rs].rotalist.length; + } + } + // console.log(trainlisttest.list[code].children[rs].rotalist.length); + } + } + } + + } else if (data.right == '0') { // 向左 + trainlisttest.list[code].right = '0'; + trainlisttest.list[code].progress = 1 - data.offset; + // trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack; + // if(rails.sectionrail[data.section].standTrack){ + // trainlisttest.list[code].statsstop = 0; + // } + const point = rails.sectionrail[data.section].lineright.getPointAt(trainlisttest.list[code].progress); + + trainlisttest.list[code].rotation.y = Math.PI; + trainlisttest.list[code].position.x = point.x; + trainlisttest.list[code].position.y = 0; + + // for (let tl=0; tl<6; tl++) { + // trainlisttest.list[code].children[tl].position.z = parseFloat(-point.z); + // } + + // trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright; + // if(data.next){ + // trainlisttest.list[code].nextcode = data.next; + // trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineright; + // trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; + // } + // trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact; + trainlisttest.list[code].status = '0'; + if (-trainlisttest.list[code].children[0].position.z != point.z) { + + trainlisttest.list[code].children[0].up = new THREE.Vector3(-1, 0, 0); + const tangent = rails.sectionrail[data.section].lineright.getTangentAt(data.offset).normalize(); + trainlisttest.list[code].children[0].axis.crossVectors(trainlisttest.list[code].children[0].up, tangent).normalize(); + const radians = Math.acos(trainlisttest.list[code].children[0].up.dot(tangent)); + trainlisttest.list[code].children[0].quaternion.setFromAxisAngle(trainlisttest.list[code].children[0].axis, radians); + trainlisttest.list[code].children[0].rotation.x = -Math.PI / 2; + trainlisttest.list[code].children[0].rotation.z = trainlisttest.list[code].children[0].rotation.y; + trainlisttest.list[code].children[0].rotation.y = 0; + + const rotas = { + posr:point, + rota:trainlisttest.list[code].children[0].rotation.z + }; + trainlisttest.list[code].children[1].rotalist.push(rotas); + const offsetz = point.z + trainlisttest.list[code].children[0].position.z; + trainlisttest.list[code].children[0].position.z -= offsetz; + // trainlisttest.list[code].position.z = point.z; + + } + if (trainlisttest.list[code].children[1].rotalist.length > 0 || trainlisttest.list[code].children[2].rotalist.length > 0 || trainlisttest.list[code].children[3].rotalist.length > 0 || trainlisttest.list[code].children[4].rotalist.length > 0 || trainlisttest.list[code].children[5].rotalist.length > 0) { + + for (let rs = 1; rs < 6; rs++) { + // console.log(rs); + if (trainlisttest.list[code].children[rs].rotalist[0]) { + + const offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) + parseFloat(trainlisttest.list[code].children[rs].position.z); + trainlisttest.list[code].children[rs].position.z -= offsetz; + + for (let xh = 0; xh < trainlisttest.list[code].children[rs].rotalist.length; xh++) { + if ((trainlisttest.list[code].children[rs].matrixWorld.elements[12]) <= trainlisttest.list[code].children[rs].rotalist[0].posr.x) { + + if (rs != 5) { + const asd = trainlisttest.list[code].children[rs].rotalist[0]; + trainlisttest.list[code].children[rs + 1].rotalist.push(asd); + + } + // let offsetx = trainlisttest.list[code].children[1].matrixWorld.elements[12]-trainlisttest.list[code].children[0].children[3].matrixWorld.elements[12]; + + trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rota; + trainlisttest.list[code].children[rs].rotalist.splice(0, 1); + xh--; + } else { + xh = trainlisttest.list[code].children[rs].rotalist.length; + } + } + // console.log(trainlisttest.list[code].children[rs].rotalist.length); + + } + + } + // console.log(trainlisttest.list[code].rotalist); + } + + } + + } + } + function trainrun(data) { + const code = data.code; + // console.log(data); + if (trainlisttest.list[code].dispose == '0') { + if (trainlisttest.list[code].curve == null) { + if (data.right == '1') { // 向右 + trainlisttest.list[code].right = '1'; + trainlisttest.list[code].progress = data.offset; + trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack; + if (rails.sectionrail[data.section].standTrack) { + trainlisttest.list[code].statsstop = 0; + } + const point = rails.sectionrail[data.section].lineleft.getPointAt(trainlisttest.list[code].progress); + trainlisttest.list[code].rotation.y = 0; + trainlisttest.list[code].position.x = point.x; + trainlisttest.list[code].position.y = 0; + for (let tl = 0; tl < 6; tl++) { + trainlisttest.list[code].children[tl].position.z = parseFloat(point.z); + } + + trainlisttest.list[code].curve = rails.sectionrail[data.section].lineleft; + + if (data.next) { + trainlisttest.list[code].nextcode = data.next; + trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineleft; + trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; + } + trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact; + trainlisttest.list[code].status = '1'; + + } else if (data.right == '0') { // 向左 + trainlisttest.list[code].right = '0'; + trainlisttest.list[code].progress = 1 - data.offset; + trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack; + if (rails.sectionrail[data.section].standTrack) { + trainlisttest.list[code].statsstop = 0; + } + const point = rails.sectionrail[data.section].lineright.getPointAt(trainlisttest.list[code].progress); + + trainlisttest.list[code].rotation.y = Math.PI; + trainlisttest.list[code].position.x = point.x; + trainlisttest.list[code].position.y = 0; + + for (let tl = 0; tl < 6; tl++) { + trainlisttest.list[code].children[tl].position.z = parseFloat(-point.z); + } + + trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright; + if (data.next) { + trainlisttest.list[code].nextcode = data.next; + trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineright; + trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; + } + trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact; + trainlisttest.list[code].status = '0'; + } + + } else { + // 后端数据驱动车的位置更新与代码驱动车的移动相结合 + + if (data.code != trainlisttest.list[code].code) { + if (data.right == '1') { // 向右 + trainlisttest.list[code].right = '1'; + trainlisttest.list[code].nowcode = data.code; + trainlisttest.list[code].curve = rails.sectionrail[data.section].lineleft; + trainlisttest.list[code].progress = data.offset; + trainlisttest.list[code].nextcode = data.next; + trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineleft; + trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; + trainlisttest.list[code].nextissection = rails.sectionrail[data.next].standTrack; + } else if (data.right == '0') { // 向左 + trainlisttest.list[code].right = '0'; + trainlisttest.list[code].nowcode = data.code; + trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright; + trainlisttest.list[code].progress = 1 - data.offset; + trainlisttest.list[code].nextcode = data.next; + trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineright; + trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact; + trainlisttest.list[code].nextissection = rails.sectionrail[data.next].standTrack; + } + } + } + if (data.speed == 0) { + trainlisttest.list[code].speeds = 0; + trainlisttest.list[code].statsstop = 0; + } else { + trainlisttest.list[code].speeds = parseFloat(data.speed * 10 / 36 / 18 / trainlisttest.list[code].len); + } + if (data.right != trainlisttest.list[code].status) { + + trainlisttest.list[code].status = data.right; + trainlisttest.list[code].curve = null; + trainlisttest.list[code].nextcurve = null; + trainlisttest.list[code].nextlen = null; + } + } + } + + function initall(data) { + for (let i = 0, leni = data.length; i < leni; i++) { + if (data[i].deviceType == 'SWITCH') { + initswitch(data[i]); + } else if (data[i].deviceType == 'PSD') { + initstand(data[i]); + } else { + console.log(data[i]); + } + } + } + + function DeviceDestroy(data) { + for (let i = 0, leni = data.body.deviceList.length; i < leni; i++) { + + if (data.body.deviceList[i].type == 'TRAIN') { + code = data.body.deviceList[i].code; + if (trainlisttest.list[code].dispose != data.body.deviceList[i].dispose && data.body.deviceList[i].dispose == '0') { + + if (rails.sectionrail[data.body.deviceList[i].section]) { + + trainlisttest.group.add(trainlisttest.list[code]); + trainlisttest.list[code].position.y = 0; + // trainlisttest.list[code].progress = 0; + trainlisttest.list[code].dispose = '0'; + trainlisttest.list[code].nowcode = data.body.deviceList[i].section; + trainlisttest.list[code].nextcode = null; + trainlisttest.list[code].curve = null; + trainlisttest.list[code].nextcurve = null; + trainlisttest.list[code].pc = 1; + + if (trainlisttest.list[code].mixerpush == false) { + + for (let mi = 0, lenmi = trainlisttest.list[code].mixer.length; mi < lenmi; mi++) { + jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]); + } + trainlisttest.list[code].mixerpush = true; + } + } + } else if (trainlisttest.list[code].dispose != data.body.deviceList[i].dispose && data.body.deviceList[i].dispose == '1') { + trainlisttest.list[code].status = 1; + trainlisttest.group.remove(trainlisttest.list[code]); + trainlisttest.list[code].progress = null; + trainlisttest.list[code].dispose = '1'; + code = trainlisttest.group.children[i].name; + trainlisttest.list[code].rotation.y = 0; + trainlisttest.list[code].open = '1'; + trainlisttest.list[code].curve = null; + trainlisttest.list[code].nextcurve = null; + trainlisttest.list[code].speed = 0; + trainlisttest.list[code].position.x = -50000; + trainlisttest.list[code].position.y = -50000; + trainlisttest.list[code].pc = 1; + + } + } + if (data.body.deviceList[i].type == 'SIGNAL') { + signalupdate(data.body.deviceList[i]); + } + if (data.body.deviceList[i].type == 'SWITCH') { + switchupdate(data.body.deviceList[i]); + } + if (data.body.deviceList[i].type == 'PSD') { + standupdate(data.body.deviceList[i]); + } + if (data.body.deviceList[i].type == 'TRAIN_DOOR') { + traindoorupdate(data.body.deviceList[i]); + } + } + } + + function traindoorupdate(data) { + const code = data.code; + if (trainlisttest.list[code].right == '0') { + if (data.doorCode == '2') { + + if (trainlisttest.list[code].open != data.open && data.open == '0') { + trainlisttest.list[code].open = '0'; + for (let an = actions[code].top.length - 1; an >= 0; an--) { + actions[code].top[an].reset(); + actions[code].top[an].time = actions[code].top[an]._clip.duration; + actions[code].top[an].timeScale = -1; + actions[code].top[an].play(); + } + } else if (trainlisttest.list[code].open != data.open && data.open == '1') { + trainlisttest.list[code].open = '1'; + for (let an = actions[code].top.length - 1; an >= 0; an--) { + actions[code].top[an].reset(); + actions[code].top[an].time = 0; + actions[code].top[an].timeScale = 1; + actions[code].top[an].play(); + } + } + } else { + + if (trainlisttest.list[code].open != data.open && data.open == '0') { + trainlisttest.list[code].open = '0'; + for (let an = actions[code].down.length - 1; an >= 0; an--) { + actions[code].down[an].reset(); + actions[code].down[an].time = actions[code].down[an]._clip.duration; + actions[code].down[an].timeScale = -1; + actions[code].down[an].play(); + } + } else if (trainlisttest.list[code].open != data.open && data.open == '1') { + trainlisttest.list[code].open = '1'; + for (let an = actions[code].down.length - 1; an >= 0; an--) { + actions[code].down[an].reset(); + actions[code].down[an].time = 0; + actions[code].down[an].timeScale = 1; + actions[code].down[an].play(); + } + } + + } + } else { + if (data.doorCode == '1') { + + if (trainlisttest.list[code].open != data.open && data.open == '0') { + trainlisttest.list[code].open = '0'; + for (let an = actions[code].top.length - 1; an >= 0; an--) { + actions[code].top[an].reset(); + actions[code].top[an].time = actions[code].top[an]._clip.duration; + actions[code].top[an].timeScale = -1; + actions[code].top[an].play(); + } + } else if (trainlisttest.list[code].open != data.open && data.open == '1') { + trainlisttest.list[code].open = '1'; + for (let an = actions[code].top.length - 1; an >= 0; an--) { + actions[code].top[an].reset(); + actions[code].top[an].time = 0; + actions[code].top[an].timeScale = 1; + actions[code].top[an].play(); + } + } + } else { + + if (trainlisttest.list[code].open != data.open && data.open == '0') { + trainlisttest.list[code].open = '0'; + for (let an = actions[code].down.length - 1; an >= 0; an--) { + actions[code].down[an].reset(); + actions[code].down[an].time = actions[code].down[an]._clip.duration; + actions[code].down[an].timeScale = -1; + actions[code].down[an].play(); + } + } else if (trainlisttest.list[code].open != data.open && data.open == '1') { + trainlisttest.list[code].open = '1'; + for (let an = actions[code].down.length - 1; an >= 0; an--) { + actions[code].down[an].reset(); + actions[code].down[an].time = 0; + actions[code].down[an].timeScale = 1; + actions[code].down[an].play(); + } + } + + } + } + + } + + function trainstatus(data) { + // 遍历列车对象组 + if (trainlisttest) { + + code = data.code; + // 剔除不显示的车 + // 找到对应列车 + if ( trainlisttest.list[code]) { + + trainlisttest.list[code].driveMode = data.driveMode; + trainlisttest.list[code].status = data.right; + // 车门开关验证 + + // 遍历获取所在轨道 + if (trainlisttest.list[code].dispose != data.dispose && data.dispose == '0') { + if (rails.sectionrail[data.sectionCode]) { + + trainlisttest.group.add(trainlisttest.list[code]); + trainlisttest.list[code].position.y = 0; + // trainlisttest.list[code].progress = 0; + trainlisttest.list[code].dispose = '0'; + trainlisttest.list[code].nowcode = data.sectionCode; + trainlisttest.list[code].nextcode = null; + trainlisttest.list[code].curve = null; trainlisttest.list[code].nextcurve = null; - trainlisttest.list[code].pc = 1; + trainlisttest.list[code].pc = 1; - if(trainlisttest.list[code].mixerpush == false){ - for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi { + this.$store.dispatch('LogOut').then(() => { + location.reload(); + }); + }); + } else { + window.close(); + } // this.$emit('showpanel'); // this.jlmap3d.eventoff(); // this.jlmap3d.animateoff(); diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 9a05e54d0..65240b0da 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -475,7 +475,9 @@ export default { mapid: query.mapId, group: query.group, project: getSessionStorage('project'), - token: getToken() + token: getToken(), + projectDevice: this.$route.query.projectDevice, + type: this.$route.query.type }; this.$router.push({ path: `/jlmap3d/sandbox`, query: sandboxQuery }); } else { diff --git a/static/workertest/jsonworkernew.js b/static/workertest/jsonworkernew.js index 2ce7ab39d..e7a821f6f 100644 --- a/static/workertest/jsonworkernew.js +++ b/static/workertest/jsonworkernew.js @@ -721,6 +721,10 @@ function timedCount() { postMessage(data); return; } + if (data.type == 'Simulation_Over') { + postMessage(data); + return; + } if ( data.body.length > 300) { // console.log(data); postMessage(data);