This commit is contained in:
joylink_cuiweidong 2020-08-04 14:02:54 +08:00
commit 01701479fd
12 changed files with 792 additions and 760 deletions

View File

@ -103,7 +103,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
return;
}
if(data.type == "Train_Hmi_3D"){
// console.log(data.body);
console.log(data.body);
updatestatus(data.body);
// if(data.body.trust){

View File

@ -1,12 +1,12 @@
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;
@ -29,44 +29,43 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
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;
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 = {
this.topic = '/user/queue/simulation/jl3d/' + routegroup;
const header = {'X-Token': getToken() };
const connectmsg = {
type:'init',
baseurl:getBaseUrl(),
topic:this.topic,
token:getToken(),
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"){
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<leni;i++){
for (let i = 0, leni = event.data.body.length; i < leni; i++) {
// console.log(event.data.body[i]);
trainrunnew(event.data.body[i]);
}
@ -77,17 +76,17 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
// console.log(event.data);
// trainrun(event.data);
// }
if (event.data.type== 'SIGNAL' && signallist) {
if (event.data.type == 'SIGNAL' && signallist) {
signalupdate(event.data);
// console.log(event.data);
return;
}
if (event.data.type== "PSD" && actions) {
if (event.data.type == 'PSD' && actions) {
standupdate(event.data);
return;
}
if (event.data.type == "SWITCH") {
if (event.data.type == 'SWITCH') {
switchupdate(event.data);
return;
}
@ -96,17 +95,21 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
return;
}
if(event.data.type == 'Simulation_Reset'){
if (event.data.type == 'Simulation_Reset') {
simulationreset(event.data);
return;
}
if(event.data.type == 'Simulation_DeviceStatus'){
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) {
this.updatamap = function(newsectionlist, newlinklist, newsignallist, newstationstandlist, newtrainlisttest, newrealsectionlist, newrails, materiallist, nowaction, scene) {
trainlisttest = newtrainlisttest;
sectionlist = newsectionlist;
signallist = newsignallist;
@ -130,7 +133,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic);
for (let i=0; i<trainlisttest.group.children.length; i++) {
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;
@ -146,24 +149,24 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
};
function trainrunnew(data){
let code = data.code;
function trainrunnew(data) {
const code = data.code;
if(trainlisttest.list[code].right != data.right){
if(data.right == "0"){
trainlisttest.list[code].right = "0";
if (trainlisttest.list[code].right != data.right) {
if (data.right == '0') {
trainlisttest.list[code].right = '0';
trainlisttest.list[code].rotation.y = Math.PI;
let point = rails.sectionrail[data.section].lineleft.getPointAt(data.offset);
const point = rails.sectionrail[data.section].lineleft.getPointAt(data.offset);
trainlisttest.list[code].position.x = point.x;
for (let tl=0; tl<6; tl++) {
for (let tl = 0; tl < 6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}else{
trainlisttest.list[code].right = "1";
} else {
trainlisttest.list[code].right = '1';
trainlisttest.list[code].rotation.y = 0;
let point = rails.sectionrail[data.section].lineleft.getPointAt(data.offset);
const point = rails.sectionrail[data.section].lineleft.getPointAt(data.offset);
trainlisttest.list[code].position.x = point.x;
for (let tl=0; tl<6; tl++) {
for (let tl = 0; tl < 6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}
@ -171,7 +174,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
// console.log(data);
if(trainlisttest.list[code].dispose == "0"){
if (trainlisttest.list[code].dispose == '0') {
if (data.right == '1') { // 向右
trainlisttest.list[code].right = '1';
trainlisttest.list[code].progress = data.offset;
@ -179,7 +182,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
// if(rails.sectionrail[data.section].standTrack){
// trainlisttest.list[code].statsstop = 0;
// }
let point = rails.sectionrail[data.section].lineleft.getPointAt(trainlisttest.list[code].progress);
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;
@ -198,68 +201,65 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
// 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);
let tangent = rails.sectionrail[data.section].lineleft.getTangentAt(data.offset).normalize();
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();
let radians = Math.acos(trainlisttest.list[code].children[0].up.dot(tangent));
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.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 = {
const rotas = {
posr:point,
rota:trainlisttest.list[code].children[0].rotation.z
}
};
trainlisttest.list[code].children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainlisttest.list[code].children[0].position.z);
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]){
let offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) - parseFloat(trainlisttest.list[code].children[rs].matrixWorld.elements[14]);
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){
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){
let asd = trainlisttest.list[code].children[rs].rotalist[0];
trainlisttest.list[code].children[rs+1].rotalist.push(asd);
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)
trainlisttest.list[code].children[rs].rotalist.splice(0, 1);
xh--;
}else{
} else {
xh = trainlisttest.list[code].children[rs].rotalist.length;
}
}
//console.log(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].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);
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;
@ -277,59 +277,57 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
// }
// trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact;
trainlisttest.list[code].status = '0';
if(-trainlisttest.list[code].children[0].position.z != point.z){
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].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();
let radians = Math.acos(trainlisttest.list[code].children[0].up.dot(tangent));
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.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 = {
const 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;
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){
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]){
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);
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){
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){
let asd = trainlisttest.list[code].children[rs].rotalist[0];
trainlisttest.list[code].children[rs+1].rotalist.push(asd);
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];
// 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)
trainlisttest.list[code].children[rs].rotalist.splice(0, 1);
xh--;
}else{
} else {
xh = trainlisttest.list[code].children[rs].rotalist.length;
}
}
//console.log(trainlisttest.list[code].children[rs].rotalist.length);
// console.log(trainlisttest.list[code].children[rs].rotalist.length);
}
}
// console.log(trainlisttest.list[code].rotalist);
}
@ -338,29 +336,29 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
}
function trainrun(data){
let code = data.code;
function trainrun(data) {
const code = data.code;
// console.log(data);
if(trainlisttest.list[code].dispose == "0"){
if(trainlisttest.list[code].curve == null){
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){
if (rails.sectionrail[data.section].standTrack) {
trainlisttest.list[code].statsstop = 0;
}
let point = rails.sectionrail[data.section].lineleft.getPointAt(trainlisttest.list[code].progress);
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++) {
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){
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;
@ -370,23 +368,23 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
} else if (data.right == '0') { // 向左
trainlisttest.list[code].right = '0';
trainlisttest.list[code].progress = 1-data.offset;
trainlisttest.list[code].progress = 1 - data.offset;
trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack;
if(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);
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++) {
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){
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;
@ -395,11 +393,10 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
trainlisttest.list[code].status = '0';
}
} else {
// 后端数据驱动车的位置更新与代码驱动车的移动相结合
}else{
//后端数据驱动车的位置更新与代码驱动车的移动相结合
if(data.code != trainlisttest.list[code].code){
if (data.code != trainlisttest.list[code].code) {
if (data.right == '1') { // 向右
trainlisttest.list[code].right = '1';
trainlisttest.list[code].nowcode = data.code;
@ -413,7 +410,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
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].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;
@ -421,13 +418,13 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
}
}
if(data.speed == 0){
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);
} else {
trainlisttest.list[code].speeds = parseFloat(data.speed * 10 / 36 / 18 / trainlisttest.list[code].len);
}
if(data.right != trainlisttest.list[code].status){
if (data.right != trainlisttest.list[code].status) {
trainlisttest.list[code].status = data.right;
trainlisttest.list[code].curve = null;
@ -437,50 +434,50 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
}
function initall(data){
for(let i=0,leni=data.length;i<leni;i++){
if(data[i].deviceType == "SWITCH"){
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"){
} else if (data[i].deviceType == 'PSD') {
initstand(data[i]);
}else{
} else {
console.log(data[i]);
}
}
}
function DeviceDestroy(data){
for(let i=0,leni=data.body.deviceList.length;i<leni;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 (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].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){
if (trainlisttest.list[code].mixerpush == false) {
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
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") {
} 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";
trainlisttest.list[code].dispose = '1';
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].open = '1';
@ -493,57 +490,56 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
}
if(data.body.deviceList[i].type == "SIGNAL"){
if (data.body.deviceList[i].type == 'SIGNAL') {
signalupdate(data.body.deviceList[i]);
}
if(data.body.deviceList[i].type == "SWITCH"){
if (data.body.deviceList[i].type == 'SWITCH') {
switchupdate(data.body.deviceList[i]);
}
if(data.body.deviceList[i].type == "PSD"){
if (data.body.deviceList[i].type == 'PSD') {
standupdate(data.body.deviceList[i]);
}
if(data.body.deviceList[i].type == "TRAIN_DOOR"){
if (data.body.deviceList[i].type == 'TRAIN_DOOR') {
traindoorupdate(data.body.deviceList[i]);
}
}
}
function traindoorupdate(data){
let code = data.code;
if(trainlisttest.list[code].right == "0"){
if(data.doorCode == "2"){
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--){
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--){
} 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{
} 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--) {
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--){
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;
@ -552,40 +548,39 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
}
}else{
if(data.doorCode == "1"){
} 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--){
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--){
} 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{
} 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--) {
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--){
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;
@ -598,7 +593,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
function trainstatus(data){
function trainstatus(data) {
// 遍历列车对象组
if (trainlisttest) {
@ -611,33 +606,32 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
trainlisttest.list[code].status = data.right;
// 车门开关验证
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.dispose && data.dispose == "0") {
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].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;
if(trainlisttest.list[code].mixerpush == false){
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
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.dispose && data.dispose == "1") {
} else if (trainlisttest.list[code].dispose != data.dispose && data.dispose == '1') {
trainlisttest.list[code].status = 1;
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = "1";
trainlisttest.list[code].dispose = '1';
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].open = '1';
@ -692,31 +686,31 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}
function signalupdate(data) {
code = data.code;
if(data.red == 1){
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
}else{
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
if (data.red == 1) {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[0];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
} else {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
}
if(data.yellow == 1){
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
if (data.yellow == 1) {
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[1];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
}else{
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
} else {
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
}
if(data.green == 1){
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
if (data.green == 1) {
signallist.list[code].mesh.getObjectByName('green').material.map = materials[2];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}else{
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
} else {
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
@ -730,14 +724,14 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
actions[code].normal = "02";
actions[code].normal = '02';
} else if (data.routeLock == '1') {
// sectionlist.switchs.modellist[j].normal = data.normal;
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
actions[code].normal = "01";
actions[code].normal = '01';
}
}
@ -750,19 +744,19 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
actions[code].normal = "02";
actions[code].normal = '02';
} else if (data.normal == '01') {
// sectionlist.switchs.modellist[j].normal = data.normal;
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
actions[code].normal = "01";
actions[code].normal = '01';
}
}
}
function simulationreset(data){
for(let i=0;i<trainlisttest.group.children.length;i++){
function simulationreset(data) {
for (let i = 0; i < trainlisttest.group.children.length; i++) {
trainlisttest.group.children[i].dispose = true;
trainlisttest.group.children[i].stopstation = null;
trainlisttest.group.children[i].pc = null;

View File

@ -108,7 +108,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
getPublishMapDetail(skinCode).then(data => {
let mapnetdata = data.data;
getPublish3dMapDetail(skinCode).then(netdata => {
console.log(netdata);
let assetsdata = JSON.parse(netdata.data.sections);
if(assetsdata.link){
scope.datatype = "old";

View File

@ -143,6 +143,13 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
});
})
.then(function(data){
camera.position.x = stationstandlist.group.children[0].position.x;
camera.position.y = stationstandlist.group.children[0].position.y+500;
camera.position.z = stationstandlist.group.children[0].position.z+800;
//更新相机方向
controls.target = new THREE.Vector3(stationstandlist.group.children[0].position.x,stationstandlist.group.children[0].position.y,stationstandlist.group.children[0].position.z);
controls.upmodeldirect(stationstandlist,trainlisttest);
controls.update();
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);

View File

@ -117,6 +117,7 @@ const training = {
},
over: (state) => {
state.started = false;
state.switchcount += 1;
},
updateMapState: (state, deviceStatus) => {
Vue.prototype.$jlmap && Vue.prototype.$jlmap.update(deviceStatus);

View File

@ -2,9 +2,9 @@ export function getBaseUrl() {
let BASE_API;
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
// BASE_API = 'http://b29z135112.zicp.vip';

View File

@ -80,6 +80,11 @@ export default {
token:null
};
},
watch: {
'$store.state.socket.simulationOver':function(val) {
this.back();
}
},
beforeDestroy() {
// console.log("destroy");
if (this.jlmap3d) {
@ -183,7 +188,15 @@ export default {
},
back() {
if (this.$route.query.projectDevice) {
this.$store.dispatch('training/over').then(() => {
this.$store.dispatch('LogOut').then(() => {
location.reload();
});
});
} else {
window.close();
}
// this.$emit('showpanel');
// this.jlmap3d.eventoff();
// this.jlmap3d.animateoff();

View File

@ -144,6 +144,7 @@ export default {
width:80%;
height:30px;
margin:0px 0px 50px 0px;
cursor:pointer;
}
.modelpic{
left:0;

View File

@ -7,7 +7,6 @@
:element-loading-text="loadingText"
element-loading-background="rgba(0, 0, 0, 0)"
>
<el-button v-if="syncLogin && loadingCode" type="text" style="font-size: 24px;font-weight: bold;" @click="loginRefresh">关联设备未登录,点击重新检测</el-button>
<div v-if="loginTitle && !syncLogin" :class="project.endsWith('heb')?'text-box':'left-logo-box'">
<img class="logo" :src="logoImg" :style="{width: logoWidth}">
<span>{{ loginTitle==='空串'?'':loginTitle }}</span>
@ -309,7 +308,8 @@ export default {
}
},
loginRefresh() {
this.loadingCode = true;
// this.loadingCode = true;
const self = this;
const params = LoginParams[this.loginClient];
params.project = loginInfo[this.project].loginParam;
if (this.$route.query.projectDevice) {
@ -321,8 +321,14 @@ export default {
this.loadingCode = false;
this.checkLoginStatus();
}).catch(() => {
if (this.syncLogin) {
setTimeout(() =>{
self.loginRefresh();
}, 3000);
} else {
this.loadingCode = false;
this.$messageBox(this.$t('login.getLoginQrCode'));
}
});
},
checkLoginStatus() {
@ -344,8 +350,12 @@ export default {
});
}).catch(error => {
if ((error.data && error.data.status === 'EXPIRE') || error.code != 200) {
if (this.syncLogin) {
self.loginRefresh();
} else {
this.loadingCode = true;
this.loginUrl = '';
}
} else {
self.checkLoginStatus();
}
@ -475,7 +485,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 {

View File

@ -74,10 +74,11 @@ export default {
});
this.editModel.logicSectionCodeList.forEach(logicCode => {
const section = this.$store.getters['map/getDeviceByCode'](logicCode);
if (section) {
models.push(deepAssign(section, {_dispose: true}));
const trainWindowModel = this.$store.getters['map/getDeviceByCode'](section.trainWindowCode);
models.push(deepAssign(trainWindowModel, {_dispose: true}));
trainWindowModel && models.push(deepAssign(trainWindowModel, {_dispose: true}));
}
});
if (this.logicNum === 0) {
logicSectionCodeList = [];

View File

@ -175,8 +175,8 @@ export default {
width: data.width,
height: data.height
};
}
data.offsetList.length = data.bigScreenSplitConfig.length + 1;
}
if (data.offsetList && data.offsetList.length) {
this.list = [];
data.offsetList.forEach(item => {

View File

@ -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);