修改三维大铁驾驶模块接通车速变化

This commit is contained in:
sunzhenyu 2021-05-28 18:09:10 +08:00
parent c2bda14c4f
commit 9ea7abf401
14 changed files with 1044 additions and 617 deletions

View File

@ -15,9 +15,9 @@ export function SetLights(scene){
let ambientLight = new THREE.AmbientLight( 0xffffff,1.3 );//1b1515
scene.add( ambientLight );
let light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
light.position.set( 0, 200, 0 );
scene.add( light );
// let light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
// light.position.set( 0, 200, 0 );
// scene.add( light );
// //辅助网格
// let helper = new THREE.GridHelper( 20000, 10 );

View File

@ -1,5 +1,4 @@
import request from '@/utils/request';
// 获取仿真成员列表(新版地图)
export function getSimulationMembersNew(group) {
return request({
@ -69,14 +68,16 @@ export function trainSimulationEb(group, data) {
}
// 改变列车牵引/制动力
export function trainSimulationForce(group, data) {
export function trainSimulationForce(group,memberId, data) {
return request({
url: `/simulation/${group}/operate/Driver_Force_Change`,
url: `/common/simulation/${group}/member/${memberId}/operate/Train_Drive_Speed_Control`,
method: 'post',
data: data
});
}
// 改变列车档位
export function trainSimulationGear(group, data) {
return request({

View File

@ -23,12 +23,12 @@ import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
// 加载器
import { DriverLoadNew } from '@/jlmap3d/jl3drailwaydrive/loader/DriverLoadNew';
// connect
import {Jl3dDrivingNew} from '@/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew';
import {Jl3dDrivingNew} from '@/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew';
import { getPublishMapVersion, getPublishMapDetail, getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
// utils
import { UpdateTrain } from '@/jlmap3d/jl3ddrive/moveupdate/UpdateTrain';
import { UpdateTrain } from '@/jlmap3d/jl3drailwaydrive/moveupdate/UpdateTrain';
// import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrainTest';
import { ReStart } from '@/jlmap3d/main/utils/ReStart';
@ -42,7 +42,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
let scope = this;
let stats =null;
let driverWebWorker = null;
// let driverWebWorker = null;
// let stats = new Stats();
// dom.appendChild( stats.dom );
//界面更新函数
@ -113,7 +113,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
// 地图模型数据
let mapdata = new Jl3ddata();
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 0.1, 400);
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 0.1, 400000);
camera.position.set( 0, 0, 0 );
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
@ -123,8 +123,6 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
camera.add( listener );
let sound = new THREE.Audio( listener );
// load a sound and set it as the Audio object's buffer
@ -158,8 +156,8 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
let assetsdata = JSON.parse(netdata.data.sections);
scope.datatype = "new";
driverWebWorker = new Worker(JL3D_LOCAL_STATIC+"/workertest/driverWebWorker.js");
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,driverWebWorker,stats);
// driverWebWorker = new Worker(JL3D_LOCAL_STATIC+"/workertest/railwayWorker.js");
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats);
// datanew();
@ -170,7 +168,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);
driverWebWorker.postMessage("connect");
scope.Subscribe.socketon();
clearInterval(timer);
}
}
@ -308,11 +306,7 @@ 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;
};
this.rayswitch = function(value) {

View File

@ -99,18 +99,20 @@ export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,
.then(function(data){
return trainlisttest.drivertrain(mapdata.trainList,sceneload,assetloader,mixers,actions,"01");
})
.then(function(data){
//console.log(data);
//console.log(assetloader);
console.log(stationstandlist);
return tdt.initTdt(stationstandlist.list,mapdata.sectionList,rails.sectionrail,sceneload);
})
// .then(function(data){
// //console.log(data);
// //console.log(assetloader);
// console.log(stationstandlist);
// return tdt.initTdt(stationstandlist.list,mapdata.sectionList,rails.sectionrail,sceneload);
// })
.then(function(data){
return new Promise(function(resolve, reject){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].deviceType && scope.assetloader.modellist[mn].type == "suidao"){
// scope.assetloader.modellist[mn].mesh.deviceType = "suidaobg";
// scope.assetloader.modellist[mn].mesh.position.y = 10;
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
@ -118,37 +120,37 @@ export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,
resolve("loadedsuidao");
});
})
.then(function(data){
return new Promise(function(resolve, reject){
if(scope.stationtexture["stationlist"]){
for(let mm=0;mm< stationstandlist.group.children.length;mm++){
let stationname = stationstandlist.group.children[mm].name;
if(stationstandlist.group.children[mm].getObjectByName("zhantailiebiao")){
stationstandlist.group.children[mm].getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
stationstandlist.group.children[mm].getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
}
if(stationstandlist.group.children[mm].getObjectByName("menkuangyanse")){
stationstandlist.group.children[mm].getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
stationstandlist.group.children[mm].getObjectByName("menkuangyanse").material.map.needsUpdate = true;
}
if(stationstandlist.group.children[mm].getObjectByName("zhantaiming")){
let newmaterial = stationstandlist.group.children[mm].getObjectByName("zhantaiming").material.clone();
newmaterial.map =scope.stationtexture[stationname];
stationstandlist.group.children[mm].getObjectByName("zhantaiming").material = newmaterial;
stationstandlist.group.children[mm].getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
}
}
resolve("mergemodel");
});
})
// .then(function(data){
// return new Promise(function(resolve, reject){
//
// if(scope.stationtexture["stationlist"]){
// for(let mm=0;mm< stationstandlist.group.children.length;mm++){
// let stationname = stationstandlist.group.children[mm].name;
// if(stationstandlist.group.children[mm].getObjectByName("zhantailiebiao")){
// stationstandlist.group.children[mm].getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
// stationstandlist.group.children[mm].getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
//
// }
// if(stationstandlist.group.children[mm].getObjectByName("menkuangyanse")){
// stationstandlist.group.children[mm].getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
// stationstandlist.group.children[mm].getObjectByName("menkuangyanse").material.map.needsUpdate = true;
// }
//
//
//
// if(stationstandlist.group.children[mm].getObjectByName("zhantaiming")){
// let newmaterial = stationstandlist.group.children[mm].getObjectByName("zhantaiming").material.clone();
// newmaterial.map =scope.stationtexture[stationname];
// stationstandlist.group.children[mm].getObjectByName("zhantaiming").material = newmaterial;
// stationstandlist.group.children[mm].getObjectByName("zhantaiming").material.map.needsUpdate = true;
// }
//
// }
//
// }
// resolve("mergemodel");
// });
// })
.then(function(data){
scope.animateswitch = true;

View File

@ -4,11 +4,10 @@ import { getBaseUrl } from '@/utils/baseUrl'
import { getToken } from '@/utils/auth';
// 定于仿真socket接口
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,driverWebWorker,stats) {
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats) {
let scope = this;
this.map = null;
let toppic = '/app/topic/simulation/client/'+routegroup+'/drive';
var trainlisttest = null;
var sectionlist = null;
var signallist = null;
@ -39,7 +38,8 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
var datatype = '00';
this.teststomp = new StompClient();
// let toppic = '/app/topic/simulation/client/'+routegroup+'/drive';
this.topic = '/user/queue/simulation/drive/'+routegroup;
console.log(routegroup);
this.topic = '/user/queue/simulation/'+routegroup+'/trainPosition';
let header = {'X-Token': getToken() };
let connectmsg = {
type:'init',
@ -47,70 +47,10 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
topic:this.topic,
token:getToken(),
};
driverWebWorker.postMessage(connectmsg);
driverWebWorker.onmessage = function (event) {
let data = event.data;
if(data.type == "TDT_3D"){
tdtUpdate(data);
}
if(data.type == "Train_Position"){
nowTrainRun(data.body);
return;
}
if(data.type == "Train_Position_3D"){
otherTrainRun(data.body);
return;
}
if(data.type == "Train_Hmi_3D"){
//改变当前列车code
if(data.body.groupNumber){
changeNowTrain(data.body);
updateDriveValue(data.body.groupNumber);
}
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;
}
}
//切换车辆修改列车属性
function changeNowTrain(data){
if(data.right == "0"){
if(data[i][3] == "0"){
if(data.rightDoorCanClose == false){
trainmodel.openright = '0';
@ -210,24 +150,18 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
drivingcode = code;
};
this.socketon = function(topic) {
this.socketon = function() {
try {
// console.log("teststomp");
// scope.teststomp.subscribe(topic, callback, header);
scope.teststomp.subscribe(scope.topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
};
this.socketoff = function(topic) {
if(driverWebWorker){
driverWebWorker.postMessage("off");
}else{
scope.teststomp.unsubscribe(topic);
}
this.socketoff = function() {
scope.teststomp.unsubscribe(scope.topic);
for (let i=0; i<trainlisttest.group.children.length; i++) {
if (trainlisttest.group.children[i].dispose == false) {
code = trainlisttest.group.children[i].name;
@ -249,50 +183,17 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
// 对象化数据
let data = JSON.parse(Response.body);
if(data.trainPosList){
// console.log(data.trainPosList);
// console.log(data.trainPosList);
nowTrainRun(data.trainPosList);
return;
}
// stats.update();
// 遍历后台数据
// console.log(data);
if(data.type == "Train_Position"){
nowTrainRun(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"){
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;
}
}
function DeviceDestroy(data){
@ -358,11 +259,11 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
updateTrainModel.curve = rails.sectionrail[data.section].lineleft;
}
if(updateTrainModel.right != data.right){
if(data.right == "0"){
if(updateTrainModel.right != data[i][3]){
if(data[i][3] == "0"){
updateTrainModel.right = "0";
updateTrainModel.rotation.y = Math.PI;
let point = updateTrainModel.curve.getPointAt(data.offset);
let point = updateTrainModel.curve.getPointAt(data[i][2]);
updateTrainModel.position.x = point.x;
for (let tl=0; tl<updateTrainModel.children.length; tl++) {
updateTrainModel.children[tl].position.z = point.z;
@ -370,7 +271,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
}else{
updateTrainModel.right = "1";
updateTrainModel.rotation.y = 0;
let point = updateTrainModel.curve.getPointAt(data.offset);
let point = updateTrainModel.curve.getPointAt(data[i][2]);
updateTrainModel.position.x = point.x;
for (let tl=0; tl<updateTrainModel.children.length; tl++) {
updateTrainModel.children[tl].position.z = point.z;
@ -378,15 +279,15 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
}
}
if(updateTrainModel.curve && updateTrainModel.offset != data.offset){
updateTrainModel.offset = data.offset;
let pos = updateTrainModel.curve.getPointAt(data.offset);
if(updateTrainModel.curve && updateTrainModel.offset != data[i][2]){
updateTrainModel.offset = data[i][2];
let pos = updateTrainModel.curve.getPointAt(data[i][2]);
updateTrainModel.position.x = pos.x;
// trainmodel.children[0].position.z = pos.z;
if(data.right == "0"){
if(data[i][3] == "0"){
if(-updateTrainModel.children[0].position.z != pos.z){
updateTrainModel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = updateTrainModel.curve.getTangentAt(data.offset).normalize();
let tangent = updateTrainModel.curve.getTangentAt(data[i][2]).normalize();
updateTrainModel.children[0].axis.crossVectors(updateTrainModel.children[0].up, tangent).normalize();
let radians = Math.acos(updateTrainModel.children[0].up.dot(tangent));
updateTrainModel.children[0].quaternion.setFromAxisAngle(updateTrainModel.children[0].axis, radians);
@ -443,7 +344,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
//
if(updateTrainModel.children[0].position.z < pos.z){
updateTrainModel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = updateTrainModel.curve.getTangentAt(data.offset).normalize();
let tangent = updateTrainModel.curve.getTangentAt(data[i][2]).normalize();
updateTrainModel.children[0].axis.crossVectors(updateTrainModel.children[0].up, tangent).normalize();
let radians = Math.acos(updateTrainModel.children[0].up.dot(tangent));
updateTrainModel.children[0].quaternion.setFromAxisAngle(updateTrainModel.children[0].axis, radians);
@ -461,7 +362,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
updateTrainModel.children[0].position.z += offsetz;
}else if(updateTrainModel.children[0].position.z > pos.z){
updateTrainModel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = updateTrainModel.curve.getTangentAt(data.offset).normalize();
let tangent = updateTrainModel.curve.getTangentAt(data[i][2]).normalize();
updateTrainModel.children[0].axis.crossVectors(updateTrainModel.children[0].up, tangent).normalize();
let radians = Math.acos(updateTrainModel.children[0].up.dot(tangent));
updateTrainModel.children[0].quaternion.setFromAxisAngle(updateTrainModel.children[0].axis, radians);
@ -512,218 +413,114 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
}
//更新当前驾驶车辆
function nowTrainRun(data){
console.log(data);
for(let i=0;i<data.length;i++){
//改变当前列车code
if(data[0][0] != trainmodel.code){
if(trainlisttest.otherTrainList[trainmodel.code] && trainmodel.code){
trainlisttest.otherTrainList[trainmodel.code].offset = 0;
}
//改变当前列车code
if(data.code != trainmodel.code){
if(trainlisttest.otherTrainList[trainmodel.code] && trainmodel.code){
trainlisttest.otherTrainList[trainmodel.code].offset = 0;
trainmodel.code = data[0][0];
trainmodel.nowcode = data[0][0];
}
trainmodel.code = data.code;
trainmodel.nowcode = data.code;
}
//改变当前列车行驶的区段code
if(data.section != trainmodel.nowsection){
trainmodel.nowsection = data.section;
trainmodel.curve = rails.sectionrail[data.section].lineleft;
}
//判断转向
if(trainmodel.right != data.right){
if(data.right == "0"){
trainmodel.right = "0";
trainmodel.rotation.y = Math.PI;
let point = trainmodel.curve.getPointAt(data.offset);
trainmodel.position.x = point.x;
for (let tl=0; tl<trainmodel.children.length; tl++) {
trainmodel.children[tl].position.z = point.z;
}
if(trainmodel.openleft == "1"){
trainmodel.openleft = "0";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].stop();
}
trainmodel.openright = "1";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
actions["traindoor"].down[an].timeScale = 1;
actions["traindoor"].down[an].play();
}
}else if(trainmodel.openright == "1"){
trainmodel.openright = "0";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].stop();
}
trainmodel.openleft = "1";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration;
actions["traindoor"].top[an].timeScale = 1;
actions["traindoor"].top[an].play();
}
}
}else{
trainmodel.right = "1";
trainmodel.rotation.y = 0;
let point = trainmodel.curve.getPointAt(data.offset);
trainmodel.position.x = point.x;
for (let tl=0; tl<trainmodel.children.length; tl++) {
trainmodel.children[tl].position.z = point.z;
}
if(trainmodel.openleft == "1"){
trainmodel.openleft = "0";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].stop();
}
trainmodel.openright = "1";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
actions["traindoor"].down[an].timeScale = 1;
actions["traindoor"].down[an].play();
}
}else if(trainmodel.openright == "1"){
trainmodel.openright = "0";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].stop();
}
trainmodel.openleft = "1";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration;
actions["traindoor"].top[an].timeScale = 1;
actions["traindoor"].top[an].play();
}
}
//改变当前列车行驶的区段code
if(data[i][1] != trainmodel.nowsection){
trainmodel.nowsection = data[i][1] ;
trainmodel.curve = rails.sectionrail[data[i][1]].lineleft;
}
}
//判断转向
if(trainmodel.right != data[i][3] ){
if(trainmodel.curve && trainmodel.offset != data.offset){
trainmodel.offset = data.offset;
let pos = trainmodel.curve.getPointAt(data.offset);
trainmodel.position.x = pos.x;
// trainmodel.children[0].position.z = pos.z;
if(data.right == "0"){
if(-trainmodel.children[0].position.z != pos.z || trainmodel.children[0].position.y != pos.y){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = trainmodel.curve.getTangentAt(data.offset).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
let newRotationZ = trainmodel.children[0].rotation.z;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = -newRotationZ;
if(data[i][3] == "0"){
trainmodel.right = "0";
trainmodel.rotation.y = Math.PI;
let point = trainmodel.curve.getPointAt(data[i][2] );
trainmodel.position.x = point.x;
for (let tl=0; tl<trainmodel.children.length; tl++) {
trainmodel.children[tl].position.z = point.z;
}
}else{
trainmodel.right = "1";
trainmodel.rotation.y = 0;
let point = trainmodel.curve.getPointAt(data[i][2] );
trainmodel.position.x = point.x;
for (let tl=0; tl<trainmodel.children.length; tl++) {
trainmodel.children[tl].position.z = point.z;
}
let rotas = {
posr:pos,
roty:trainmodel.children[0].rotation.y,
rotz:trainmodel.children[0].rotation.z
if(trainmodel.openleft == "1"){
trainmodel.openleft = "0";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].stop();
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = pos.z + trainmodel.children[0].position.z;
trainmodel.children[0].position.z -= offsetz;
// let offsety = pos.y - trainmodel.children[0].position.y;
// trainmodel.children[0].position.y += offsetz;
// trainmodel.position.z = point.z;
trainmodel.openright = "1";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
actions["traindoor"].down[an].timeScale = 1;
actions["traindoor"].down[an].play();
}
}else if(trainmodel.openright == "1"){
trainmodel.openright = "0";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].stop();
}
trainmodel.openleft = "1";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration;
actions["traindoor"].top[an].timeScale = 1;
actions["traindoor"].top[an].play();
}
}
}
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<trainmodel.children.length;rs++){
//console.log(rs);
if(trainmodel.children[rs].rotalist[0]){
}
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) + parseFloat(trainmodel.children[rs].position.z);
trainmodel.children[rs].position.z -= offsetz;
let offsety = parseFloat(trainmodel.children[rs].rotalist[0].posr.y) - parseFloat(trainmodel.children[rs].position.y);
trainmodel.children[rs].position.y += offsety;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+10)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != trainmodel.children.length-1){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rotz;
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].roty;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
xh = trainmodel.children[rs].rotalist.length;
}
}
//console.log(trainmodel.children[rs].rotalist.length);
if(trainmodel.curve && trainmodel.offset != data[i][2]){
trainmodel.offset = data[i][2];
let pos = trainmodel.curve.getPointAt(data[i][2]);
trainmodel.position.x = pos.x;
// trainmodel.children[0].position.z = pos.z;
if(data[i][3] == "0"){
if(-trainmodel.children[0].position.z != pos.z || trainmodel.children[0].position.y != pos.y){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = trainmodel.curve.getTangentAt(data[i][2]).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
let newRotationZ = trainmodel.children[0].rotation.z;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = -newRotationZ;
let rotas = {
posr:pos,
roty:trainmodel.children[0].rotation.y,
rotz:trainmodel.children[0].rotation.z
}
let offsetz = pos.z + trainmodel.children[0].position.z;
trainmodel.children[0].position.z -= offsetz;
}
// console.log(trainmodel.rotalist);
}
}else{
//
let rotas = {
posr:null,
roty:null,
rotz:null,
};
if(trainmodel.children[0].position.z < pos.z ){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = trainmodel.curve.getTangentAt(data.offset).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
rotas.posr = pos;
// rotas.roty = trainmodel.children[0].rotation.y;
rotas.rotz = trainmodel.children[0].rotation.z;
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
trainmodel.children[0].position.z += offsetz;
}else if(trainmodel.children[0].position.z > pos.z){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = trainmodel.curve.getTangentAt(data.offset).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
rotas.posr = pos;
// rotas.roty = trainmodel.children[0].rotation.y;
rotas.rotz = trainmodel.children[0].rotation.z;
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
trainmodel.children[0].position.z += offsetz;
}
if(trainmodel.children[0].position.y != pos.y){
if(rotas.posr == null){
}else{
//
let rotas = {
posr:null,
roty:null,
rotz:null,
};
if(trainmodel.children[0].position.z < pos.z ){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = trainmodel.curve.getTangentAt(data.offset).normalize();
let tangent = trainmodel.curve.getTangentAt(data[i][2]).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
@ -732,64 +529,59 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
trainmodel.children[0].rotation.y = 0;
rotas.posr = pos;
rotas.roty = trainmodel.children[0].rotation.y;
// rotas.roty = trainmodel.children[0].rotation.y;
rotas.rotz = trainmodel.children[0].rotation.z;
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
trainmodel.children[0].position.z += offsetz;
}else if(trainmodel.children[0].position.z > pos.z){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = trainmodel.curve.getTangentAt(data[i][2]).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
rotas.posr = pos;
// rotas.roty = trainmodel.children[0].rotation.y;
rotas.rotz = trainmodel.children[0].rotation.z;
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
trainmodel.children[0].position.z += offsetz;
let offsety = parseFloat(pos.y) - parseFloat(trainmodel.children[0].position.y);
trainmodel.children[0].position.y += offsety;
}else{
rotas.roty = trainmodel.children[0].rotation.y;
let offsety = parseFloat(rotas.posr.y) - parseFloat(trainmodel.children[0].position.y);
trainmodel.children[0].position.y += offsety;
}
}
if(rotas.posr!= null){
trainmodel.children[1].rotalist.push(rotas);
}
if(trainmodel.children[0].position.y != pos.y){
if(rotas.posr == null){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = trainmodel.curve.getTangentAt(data[i][2]).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
rotas.posr = pos;
rotas.roty = trainmodel.children[0].rotation.y;
rotas.rotz = trainmodel.children[0].rotation.z;
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<trainmodel.children.length;rs++){
//console.log(rs);
if(trainmodel.children[rs].rotalist[0]){
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
trainmodel.children[rs].position.z += offsetz;
let offsety = parseFloat(trainmodel.children[rs].rotalist[0].posr.y) - parseFloat(trainmodel.children[rs].matrixWorld.elements[13]);
trainmodel.children[rs].position.y += offsety;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-10)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != trainmodel.children.length-1){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
if(trainmodel.children[rs].rotalist[0].roty != null){
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].roty;
}
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rotz;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
xh = trainmodel.children[rs].rotalist.length;
}
}
//console.log(trainmodel.children[rs].rotalist.length);
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
trainmodel.children[0].position.z += offsetz;
let offsety = parseFloat(pos.y) - parseFloat(trainmodel.children[0].position.y);
trainmodel.children[0].position.y += offsety;
}else{
rotas.roty = trainmodel.children[0].rotation.y;
let offsety = parseFloat(rotas.posr.y) - parseFloat(trainmodel.children[0].position.y);
trainmodel.children[0].position.y += offsety;
}
}
}
}
}
// let pos = ;
}
function initall(data){
@ -909,7 +701,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri
if ( trainmodel) {
trainmodel.driveMode = data.driveMode;
trainmodel.status = data.right;
trainmodel.status = data[i][3];
// 车门开关验证

View File

@ -689,6 +689,11 @@ export function AssetLoader(){
asset.mesh = realtrain;
asset.animations = object.animations[0].tracks;
}else if(asset.type == "train" && object.name == "C6"){
let realtrain = new THREE.Group();
object.position.x = object.position.x+scope.trainoffset;
realtrain.add(object);
asset.mesh = realtrain;
}else{
asset.mesh = object;

View File

@ -27,7 +27,9 @@
<script>
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
import { trainSimulationForce,trainSimulationGear } from '@/jlmap3d/jl3ddrive/drivecontrol/simulation.js';
import { trainSimulationForce,trainSimulationGear } from '@/jlmap3d/jl3drailwaydrive/drivecontrol/simulation.js';
import store from '@/store/index';
import { throttle } from '@/utils/throttle.js';
export default {
name: 'CentercPane',
@ -227,22 +229,27 @@
this.movex=this.moveheight-7+"px";
if(this.moveheight>=145){
this.movex= 150+"px";
this.move = -2;
this.move = -1;
}
}
let param = {
groupNumber:this.groupNum,
percent:this.move
// id:this.groupNum,
id:"001",
p:parseInt(this.move*100)
};
console.log(param.p);
const userInfo = store.state.training.simulationUserList.find(el => el.id == store.state.user.id);
console.log(this.group);
console.log(userInfo.memberId);
throttle(
trainSimulationForce(this.group,param).then(res => {
trainSimulationForce(this.group,userInfo.memberId,param).then(res => {
// console.log(res);
}).catch((error) => {
console.log(error);
})
,200,true);
updatemmic1(this.move);
// updatemmic1(param.percent);
},
speedend: function(event){
document.getElementById("div1").onmousemove = null;

View File

@ -51,15 +51,15 @@
<script>
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
import CentercPane from '@/views/jlmap3d/drive/drivecontrol/centerpane';
import LeftPane from '@/views/jlmap3d/drive/drivecontrol/leftpane';
import RightPane from '@/views/jlmap3d/drive/drivecontrol/rightpane';
import TopRightPane from '@/views/jlmap3d/drive/drivecontrol/toprightpane';
import CentercPane from '@/views/jlmap3d/railwaydrive/drivecontrol/centerpane';
import LeftPane from '@/views/jlmap3d/railwaydrive/drivecontrol/leftpane';
import RightPane from '@/views/jlmap3d/railwaydrive/drivecontrol/rightpane';
import TopRightPane from '@/views/jlmap3d/railwaydrive/drivecontrol/toprightpane';
import StompClient from '@/utils/sock';
import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
import { bindSimulationTrain,getSimulationTrainlistNew,getSimulationMembersNew,trainSimulationEb,trainSimulationForce,trainSimulationGear} from '@/jlmap3d/jl3ddrive/drivecontrol/simulation.js';
import { bindSimulationTrain,getSimulationTrainlistNew,getSimulationMembersNew,trainSimulationEb,trainSimulationForce,trainSimulationGear} from '@/jlmap3d/jl3drailwaydrive/drivecontrol/simulation.js';
import { getSimulationInfoNew } from '@/api/simulation';
import { tuoguan3ddrive } from '@/api/jlmap3d/load3ddata';
@ -120,15 +120,15 @@ import axios from 'axios';
},
},
async mounted() {
if(this.$route.query.group){
getSimulationInfoNew(this.$route.query.group).then(netdata => {
if(netdata.data.type == "SCRIPT_MAKING"){
this.tuoguanbutton = true;
}
this.inittrainlist();
});
}
// if(this.$route.query.group){
// getSimulationInfoNew(this.$route.query.group).then(netdata => {
//
// if(netdata.data.type == "SCRIPT_MAKING"){
// this.tuoguanbutton = true;
// }
// this.inittrainlist();
// });
// }
window.updateDriverTrust = this.updateDriverTrust;
window.updateDriveValue = this.updateDriveValue;

View File

@ -1,77 +1,50 @@
<template>
<div style="width:25%;height:100%;position:absolute;bottom:0;left:0;">
<!-- 高速断路器 -->
<!-- <div id="breaker" class="panebutton" style="top:3%;left:3%;" @tap="breakerclick">
<img class="buttonimg" :src="greenzimg" />
<div class="buttontext">{{ $t('jlmap3d.highSpeedCircuitBreaker') }}</div>
</div> -->
<!-- 洗车模式 -->
<!-- <div id="carwash" class="panebutton" style="top:3%;left:14%;" @tap="carwashclick">
<img class="buttonimg" :src="redzimg" />
<div class="buttontext">{{ $t('jlmap3d.washCarModel') }}</div>
</div> -->
<!-- 空压机强迫启动 -->
<!-- <div id="aircom" class="panebutton" style="top:3%;left:28%;" @tap="aircomclick">
<img class="buttonimg" :src="aircomimg" />
<div class="buttontext">{{ $t('jlmap3d.forcedAirCompressor') }}</div>
</div> -->
<!-- ATB启动 -->
<div id="atb" class="panebutton" style="top:3%;left:42%;" @tap="atbclick">
<!-- <div id="atb" class="panebutton" style="top:3%;left:42%;" @tap="atbclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">{{ $t('jlmap3d.ATBStart') }}</div>
</div>
</div> -->
<!-- BM/CBTC -->
<div id="bmcbtc" class="panebutton" style="top:3%;left:56%;" @tap="bmcbtcclick">
<!-- <div id="bmcbtc" class="panebutton" style="top:3%;left:56%;" @tap="bmcbtcclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">BM/CBTC</div>
</div>
</div> -->
<!-- RM -->
<div id="rm" class="panebutton" style="top:3%;left:70%;" @tap="rmclick">
<!-- <div id="rm" class="panebutton" style="top:3%;left:70%;" @tap="rmclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">RM</div>
</div>
<!-- 强迫缓解 -->
<!-- <div id="relieve" class="panebutton" style="top:3%;left:84%;" @tap="relieveclick">
<img class="buttonimg" :src="aircomimg" />
<div class="buttontext">{{ $t('jlmap3d.forcedRelieve') }}</div>
</div> -->
<!-- 关左门 -->
<div id="dlclose" class="panebutton" style="bottom:3%;left:3%;" @tap="dlcclick">
<!-- <div id="dlclose" class="panebutton" style="bottom:3%;left:3%;" @tap="dlcclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">{{ $t('jlmap3d.closeLeftDoor') }}</div>
</div>
</div> -->
<!-- 开左门A -->
<div id="dlopen" class="panebutton" style="bottom:3%;left:14%;" @tap="dloclick">
<img class="buttonimg" :src="redimg" />
<div class="buttontext">{{ $t('jlmap3d.openLeftDoor') }}</div>
</div>
<!-- 开左门B -->
<!-- <div id="dlopen" class="panebutton" style="bottom:3%;left:28%;" @tap="dloclick">
<!-- <div id="dlopen" class="panebutton" style="bottom:3%;left:14%;" @tap="dloclick">
<img class="buttonimg" :src="redimg" />
<div class="buttontext">{{ $t('jlmap3d.openLeftDoor') }}</div>
</div> -->
<!-- ATO启动A -->
<div id="atoa" class="panebutton" style="bottom:3%;left:42%;" @tap="atoaclick">
<img class="buttonimg" :src="apoimg" />
<div class="buttontext">{{ $t('jlmap3d.ATOStart') }}</div>
</div>
<!-- ATO启动B -->
<!-- <div id="atob" class="panebutton" style="bottom:3%;left:56%;" @tap="atobclick">
<!-- <div id="atoa" class="panebutton" style="bottom:3%;left:42%;" @tap="atoaclick">
<img class="buttonimg" :src="apoimg" />
<div class="buttontext">{{ $t('jlmap3d.ATOStart') }}</div>
</div> -->
<!-- cbtc -->
<div id="cbtc" class="panebutton" style="bottom:3%;left:70%;" @tap="cbtcclick">
<!-- <div id="cbtc" class="panebutton" style="bottom:3%;left:70%;" @tap="cbtcclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">CBTC</div>
</div>
</div> -->
<!-- 电笛按钮 -->
<div id="elflute" class="panebutton" style="bottom:3%;left:84%;" @tap="elfluteclick">
<!-- <div id="elflute" class="panebutton" style="bottom:3%;left:84%;" @tap="elfluteclick">
<img class="buttonimg" :src="grayimg" />
<div class="buttontext">{{ $t('jlmap3d.electricHornButton') }}</div>
</div>
</div> -->
</div>

View File

@ -1,38 +1,17 @@
<template>
<div style="width:25%;height:100%;position:absolute;left:75%;">
<!-- <div style="width:25%;height:100%;position:absolute;left:75%;">
<div id="dropen" class="panebutton" style="bottom:1%;left:1%;" @tap="droclick">
<img class="buttonimg" :src="redlimg" />
<div class="buttontext">{{ $t('jlmap3d.openRightDoor') }}</div>
</div>
<!-- <div id="dropen" class="panebutton" style="bottom:1%;left:21%;" @tap="droclick">
<img class="buttonimg" :src="redlimg" />
<div class="buttontext">{{ $t('jlmap3d.openRightDoor') }}</div>
</div> -->
<div id="drclose" class="panebutton" style="bottom:1%;left:41%;" @tap="drcclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">{{ $t('jlmap3d.closeRightDoor') }}</div>
</div>
<!-- <div id="waterswitch" class="panebutton2" style="bottom:1%;left:61%;" @tap="waterclick">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:watertou}" @touchstart='watertouchstart' @touchmove='watertouchmove' @touchend='watertouchend'/>
<div class="tfbutton" style="font-size:1px;top:5px;left:33px;">{{ $t('jlmap3d.close') }}</div>
<div class="tfbutton" style="font-size:1px;top:15px;left:50px;">{{ $t('jlmap3d.sprayWater') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.waterSwitch') }}</div>
</div>
<div id="wiper" class="panebutton2" style="bottom:1%;left:81%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:washtou}" @touchstart='washtouchstart' @touchmove='washtouchmove' @touchend='washtouchend'/>
<div class="tfbutton" style="font-size:1px;top:5px;left:33px;">{{ $t('jlmap3d.close') }}</div>
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">{{ $t('jlmap3d.slow') }}</div>
<div class="tfbutton" style="font-size:1px;top:23px;left:50px;">{{ $t('jlmap3d.highSpeed') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.wiperSwitch') }}</div>
</div> -->
<div id="urgestop" class="panebutton" style="top:1%;left:1%;">
<img class="buttonimg" :src="urgestopimg" />
<div class="buttontext">{{ $t('jlmap3d.emergencyBraking') }}</div>
@ -45,15 +24,6 @@
<div class="tfbutton" style="font-size:1px;top:5px;left:33px;">{{ $t('jlmap3d.location0') }}</div>
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">{{ $t('jlmap3d.rightSide') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.doorSideChoose') }}</div>
</div>
<!-- <div id="doormode" class="panebutton2" style="top:1%;left:66%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:doormodetou}" @touchstart='doormodetouchstart' @touchmove='doormodetouchmove' @touchend='doormodetouchend'/>
<div class="tfbutton" style="font-size:1px;top:13px;left:5px;">AA</div>
<div class="tfbutton" style="font-size:1px;top:5px;left:33px;">AM</div>
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">MM</div>
<div class="buttontext2">{{ $t('jlmap3d.doorModel') }}</div>
</div> -->
</div>

View File

@ -1,117 +1,58 @@
<template>
<div style="width:100%;height:48%;position:absolute;top:0px;">
<!-- ATB启动 -->
<!-- <div id="atb" class="panebutton" style="top:8%;left:3%;" @click="atbclick">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">{{ $t('jlmap3d.ATBStart') }}</div>
</div> -->
<!-- 换端 -->
<div id="ch" class="panebutton" style="top:8%;left:3%;"@click="changehead">
<!-- <div id="ch" class="panebutton" style="top:8%;left:3%;"@click="changehead">
<img class="buttonimg" :src="greenimg" />
<div class="buttontext">{{ $t('jlmap3d.ChangeHead') }}</div>
</div>
</div> -->
<!-- BM/CBTC -->
<div id="bmcbtc" class="panebutton" style="top:8%;left:17%;" @click="bmcbtcclick">
<!-- <div id="bmcbtc" class="panebutton" style="top:8%;left:17%;" @click="bmcbtcclick">
<img class="buttonimg" :src="cbtcbuttonimg" />
<div class="buttontext">BM/CBTC</div>
</div>
</div> -->
<!-- RM -->
<div id="rm" class="panebutton" style="top:8%;left:31%;" @click="rmclick">
<!-- <div id="rm" class="panebutton" style="top:8%;left:31%;" @click="rmclick">
<img class="buttonimg" :src="rmbuttonimg" />
<div class="buttontext">RM</div>
</div>
</div> -->
<!-- 关左门 -->
<div id="dlclose" class="panebutton" style="top:8%;left:45%;" @click="dlcclick">
<!-- <div id="dlclose" class="panebutton" style="top:8%;left:45%;" @click="dlcclick">
<img class="buttonimg" :src="doorleftimg" />
<div class="buttontext">{{ $t('jlmap3d.closeLeftDoor') }}</div>
</div>
</div> -->
<!-- 开左门A -->
<div id="dlopen" class="panebutton" style="top:8%;left:59%;" @click="dloclick">
<!-- <div id="dlopen" class="panebutton" style="top:8%;left:59%;" @click="dloclick">
<img class="buttonimg" :src="redimg" />
<div class="buttontext">{{ $t('jlmap3d.openLeftDoor') }}</div>
</div>
</div> -->
<!-- ATO启动A -->
<div id="atoa" class="panebutton" style="top:8%;left:73%;" @click="atoaclick">
<!-- <div id="atoa" class="panebutton" style="top:8%;left:73%;" @click="atoaclick">
<img class="buttonimg" :src="atobuttonimg" />
<div class="buttontext">{{ $t('jlmap3d.ATOStart') }}</div>
</div>
<!-- cbtc -->
<!-- <div id="cbtc" class="panebutton" style="top:8%;left:87%;" @click="cbtcclick">
<img class="buttonimg" :src="cbtcbuttonimg" />
<div class="buttontext">CBTC</div>
</div> -->
<!-- 电笛按钮 -->
<!-- <div id="elflute" class="panebutton" style="bottom:3%;left:84%;" @click="elfluteclick">
<img class="buttonimg" :src="grayimg" />
<div class="buttontext">{{ $t('jlmap3d.electricHornButton') }}</div>
</div> -->
<!-- <div id="passlight" class="panebutton2" style="top:1%;left:1%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:passlighttf}" @touchstart='passlighttouchstart' @touchmove='passlighttouchmove' @touchend='passlighttouchend'/>
<div class="tfbutton" style="font-size:1px;top:8px;left:33px;">{{ $t('jlmap3d.close') }}</div>
<div class="tfbutton" style="font-size:1px;top:25px;left:50px;">{{ $t('jlmap3d.open') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.roomLightingControl') }}</div>
</div>
<div id="siv" class="panebutton2" style="top:1%;left:20%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:sivtf}" @touchstart='sivtouchstart' @touchmove='sivtouchmove' @touchend='sivtouchend'/>
<div class="tfbutton" style="font-size:1px;top:8px;left:33px;">{{ $t('jlmap3d.close') }}</div>
<div class="tfbutton" style="font-size:1px;top:25px;left:50px;">{{ $t('jlmap3d.open') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.sivsControl') }}</div>
</div> -->
<!-- <div id="driverlight" class="panebutton2" style="top:1%;left:40%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:driverlighttf}" @touchstart='driverlighttouchstart' @touchmove='driverlighttouchmove' @touchend='driverlighttouchend'/>
<div class="tfbutton" style="font-size:1px;top:8px;left:28px;">{{ $t('jlmap3d.shut') }}</div>
<div class="tfbutton" style="font-size:1px;top:25px;left:50px;">{{ $t('jlmap3d.open') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.driverRoomLights') }}</div>
</div>
<div id="headlight" class="panebutton2" style="top:1%;left:60%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:headlighttf}" @touchstart='headlighttouchstart' @touchmove='headlighttouchmove' @touchend='headlighttouchend'/>
<div class="tfbutton" style="font-size:1px;top:8px;left:28px;">{{ $t('jlmap3d.shut') }}</div>
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">{{ $t('jlmap3d.passingBeam') }}</div>
<div class="tfbutton" style="font-size:1px;top:25px;left:50px">{{ $t('jlmap3d.distanceLight') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.headLamp') }}</div>
</div> -->
<!-- 受电弓升 -->
<div id="sg" class="panebutton" style="bottom:6%;left:3%;" @click="sgclink">
<!-- <div id="sg" class="panebutton" style="bottom:6%;left:3%;" @click="sgclink">
<img class="buttonimg" :src="sgimg" />
<div class="buttontext">{{ $t('jlmap3d.electricGongSheng') }}</div>
</div>
</div> -->
<!-- 受电弓降 -->
<div id="jg" class="panebutton" style="bottom:6%;left:17%;" @click="jgclick">
<!-- <div id="jg" class="panebutton" style="bottom:6%;left:17%;" @click="jgclick">
<img class="buttonimg" :src="jgimg" />
<div class="buttontext">{{ $t('jlmap3d.pantographFall') }}</div>
</div>
<!-- 试灯按钮 -->
<!-- <div id="sl" class="panebutton" style="bottom:6%;left:40%;" @click="slclick">
<img class="buttonimg" :src="slimg" />
<div class="buttontext">{{ $t('jlmap3d.lampButton') }}</div>
</div>
</div> -->
<!-- ATP切除 -->
<div id="atp" class="panebutton" style="bottom:6%;left:31%;" @click="atpclick">
<!-- <div id="atp" class="panebutton" style="bottom:6%;left:31%;" @click="atpclick">
<img class="buttonimg" :src="atpimg" />
<div class="buttontext">{{ $t('jlmap3d.removalATP') }}</div>
</div>
<!-- <div id="staymode" class="panebutton2" style="bottom:6%;left:80%;">
<img class="buttonimg2" :src="zuoimg" />
<img class="buttonimg2" :src="niuimg" :style="{transform:toutransform}" @touchstart='stopmodetouchstart' @touchmove='stopmodetouchmove' @touchend='stopmodetouchend'/>
<div class="tfbutton" style="top:25px;left:1px;">{{ $t('jlmap3d.infliction') }}</div>
<div class="tfbutton" style="top:8px;left:25px;">{{ $t('jlmap3d.mesoPosition') }}</div>
<div class="tfbutton" style="top:25px;left:50px;">{{ $t('jlmap3d.remission') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.parkingBrakeMode') }}</div>
</div> -->
<div id="dropen" class="panebutton" style="bottom:6%;left:45%;" @click="droclick">
<!-- <div id="dropen" class="panebutton" style="bottom:6%;left:45%;" @click="droclick">
<img class="buttonimg" :src="redlimg" />
<div class="buttontext">{{ $t('jlmap3d.openRightDoor') }}</div>
</div>
@ -130,7 +71,7 @@
<div class="tfbutton" style="font-size:1px;top:8px;left:33px;">{{ $t('jlmap3d.location0') }}</div>
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">{{ $t('jlmap3d.rightSide') }}</div>
<div class="buttontext2">{{ $t('jlmap3d.doorSideChoose') }}</div>
</div>
</div> -->
</div>

View File

@ -31,10 +31,10 @@
</div>
</div>
<!-- <Drive-Mmi v-if="mmishow" ref="mmiui" />
<Drive-Mmi v-if="mmishow" ref="mmiui" />
<Drive-Tms v-if="mmishow" /> -->
<!-- <Drive-Control v-if="dcontrolshow" ref="dcontrol" @warningmsg="warningmsg" @warningmsgoff="warningmsgoff" /> -->
<!-- <Drive-Tms v-if="mmishow" /> -->
<Drive-Control v-if="dcontrolshow" ref="dcontrol" @warningmsg="warningmsg" @warningmsgoff="warningmsgoff" />
</div>
</template>
@ -57,17 +57,17 @@ import { UrlConfig } from '@/scripts/ConstDic';
import { JLmapDriving } from '@/jlmap3d/jl3drailwaydrive/jl3drailwaydrive';
// import DriveMmi from '@/views/jlmap3d/drive/sceneview/mmiview';
// import DriveTms from '@/views/jlmap3d/drive/sceneview/tmsview';
// import DriveControl from '@/views/jlmap3d/drive/drivecontrol/drivecontrol';
import DriveMmi from '@/views/jlmap3d/railwaydrive/sceneview/mmiview';
import DriveTms from '@/views/jlmap3d/railwaydrive/sceneview/tmsview';
import DriveControl from '@/views/jlmap3d/railwaydrive/drivecontrol/drivecontrol';
var train;
export default {
name: 'Jl3dRailwayDrive',
components: {
// DriveMmi,
DriveMmi,
// DriveTms,
// DriveControl
DriveControl
},
data() {
return {

View File

@ -6,27 +6,27 @@
</div>
<div class = "top">
<div style="left:5%;width:10%;height:100%;" :style="{background:a1state}">
</div>
<!-- <div style="left:5%;width:10%;height:100%;" :style="{background:a1state}">
</div> -->
<div class="toptext" style="left:16%;top:15px;">
<!-- <div class="toptext" style="left:16%;top:15px;">
{{$t('jlmap3d.terminal')}}{{endstation}}
</div>
<div class="toptext" style="left:46%;top:15px;">
{{$t('jlmap3d.nextStation')}}{{nextstation}}
</div>
</div> -->
<div class="toptext" style="left:76%;top:15px;">
<!-- <div class="toptext" style="left:76%;top:15px;">
T0002
</div>
<div class="toptext" style="left:88%;top:15px;">
C00001
</div>
</div> -->
</div>
<div class = "right">
<!-- <div class = "right">
<div class = "rightstatus narea n-tiaoting" :style="{backgroundImage: 'url(' + nimage + ')' }">
</div>
<div class = "rightstatus darea d-info" :style="{backgroundImage: 'url(' + dimage + ')' }">
@ -60,10 +60,10 @@
<div class = "righttext" style="left:0px;bottom:0;">
{{$t('jlmap3d.confirmSignalOpen')}}
</div>
</div>
</div> -->
<div class = "down">
<div class="trainstatus">
<!-- <div class="trainstatus">
<div id="ato" class="downstatus c1area c1-qianyin" :style="{backgroundImage: 'url(' + c1image + ')' }">
</div>
<div id="trainmode" class="downstatus c2area c2-rm" :style="{backgroundImage: 'url(' + c2image + ')' }">
@ -72,7 +72,7 @@
</div>
<div id="traindevice" class="downstatus c5area c5-normal" :style="{backgroundImage: 'url(' + c5image + ')' }">
</div>
</div>
</div> -->
<div class="errortext">
{{$t('jlmap3d.faultInformation')}}
@ -163,13 +163,13 @@ export default {
},
watch: {
'$store.state.training.initTime': function (initTime) {
let date = new Date(initTime);
this.timer = `${prefixIntrger(date.getHours(), 2)}:${prefixIntrger(date.getMinutes(), 2)}:${prefixIntrger(date.getSeconds(), 2)}`;
document.getElementById("timeupdate").innerHTML = this.timer;
}
},
// watch: {
// '$store.state.training.initTime': function (initTime) {
// let date = new Date(initTime);
// this.timer = `${prefixIntrger(date.getHours(), 2)}:${prefixIntrger(date.getMinutes(), 2)}:${prefixIntrger(date.getSeconds(), 2)}`;
// document.getElementById("timeupdate").innerHTML = this.timer;
// }
// },
methods: {
init(){
this.time();

View File

@ -0,0 +1,742 @@
// 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.trainPosList){
postMessage(data);
return;
}
if(data.type == "Train_Position_3D"){
postMessage(data);
return;
}
if(data.type == "Train_Hmi_3D"){
postMessage(data);
return;
}
if(data.type == 'TDT_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();