Merge branch 'test_dispaly' of https://git.code.tencent.com/lian-cbtc/jl-client into test_dispaly1

This commit is contained in:
fan 2022-12-30 15:22:06 +08:00
commit 9306d7b8ae

View File

@ -3,13 +3,13 @@ import { getToken } from '@/utils/auth';
import store from '@/store/index';
// 定于仿真socket接口
export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passerStation,passerAi) {
export function PassflowConnect(deviceaction, toptrain, downtrain, routegroup, passerStation, passerAi) {
const scope = this;
this.teststomp = new StompClient();
// let topic = '/user/queue/simulation/jl3d/'+routegroup;
let topic = '/user/queue/simulation/'+ routegroup +'/jl3d';
let header = {'X-Token': getToken() };
const topic = '/user/queue/simulation/' + routegroup + '/jl3d';
const header = {'X-Token': getToken() };
socketon(topic);
@ -20,7 +20,7 @@ export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passe
console.error('websocket订阅失败');
}
};
}
this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic);
@ -30,31 +30,31 @@ export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passe
function callback(Response) {
const data = JSON.parse(Response.body);
if(data.type == "DeviceCtrl_3D"){
if(data.body.type == "PSD"){
if(data.body.code == passerStation.nowStation.toppsd){
if(data.body.command == 'G'){
if (data.type == 'DeviceCtrl_3D') {
if (data.body.type == 'PSD') {
if (data.body.code == passerStation.nowStation.toppsd) {
if (data.body.command == 'G') {
deviceaction.top.action.reset();
deviceaction.top.action.time =deviceaction.top.action._clip.duration;
deviceaction.top.action.time = deviceaction.top.action._clip.duration;
deviceaction.top.action.timeScale = -1;
deviceaction.top.action.play();
}else{
passerAi.passerout("top")
} else {
passerAi.passerout('top');
deviceaction.top.action.reset();
deviceaction.top.action.time = 0;
deviceaction.top.action.timeScale = 1;
deviceaction.top.action.play();
}
}
if(data.body.code == passerStation.nowStation.downpsd){
if(data.body.command == 'G'){
if (data.body.code == passerStation.nowStation.downpsd) {
if (data.body.command == 'G') {
deviceaction.down.action.reset();
deviceaction.down.action.time = deviceaction.down.action._clip.duration;
deviceaction.down.action.timeScale = -1;
deviceaction.down.action.play();
}else{
passerAi.passerout("down");
} else {
passerAi.passerout('down');
deviceaction.down.action.reset();
deviceaction.down.action.time = 0;
deviceaction.down.action.timeScale = 1;
@ -63,25 +63,25 @@ export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passe
}
}
if(data.body.type == "TRAIN_DOOR"){
if(toptrain.nowcode == data.body.trainCode){
if (data.body.type == 'TRAIN_DOOR') {
if (toptrain.nowcode == data.body.trainCode) {
if(data.body.command == 'G'){
closetraindoor(toptrain,data.body.code,"top");
if (data.body.command == 'G') {
closetraindoor(toptrain, data.body.code, 'top');
}else{
opentraindoor(toptrain,data.body.code,"top");
} else {
opentraindoor(toptrain, data.body.code, 'top');
}
}
if(downtrain.nowcode == data.body.trainCode){
if (downtrain.nowcode == data.body.trainCode) {
// console.log(data.body);
if(data.body.command == 'G'){
closetraindoor(downtrain,data.body.code,"down");
if (data.body.command == 'G') {
closetraindoor(downtrain, data.body.code, 'down');
}else{
opentraindoor(downtrain,data.body.code,"down");
} else {
opentraindoor(downtrain, data.body.code, 'down');
}
@ -89,92 +89,92 @@ export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passe
}
}
if(data.type == "TrainRun_3D"){
if (data.type == 'TrainRun_3D') {
for(let i=0,leni = data.body.length;i<leni;i++){
if(data.body[i].section == passerStation.nowStation.topsection){
if(toptrain.nowcode != data.body[i].code){
for (let i = 0, leni = data.body.length; i < leni; i++) {
if (data.body[i].section == passerStation.nowStation.topsection) {
if (toptrain.nowcode != data.body[i].code) {
toptrain.nowcode = data.body[i].code;
}
toptrain.position.copy(passerStation.nowStation.topcurve.getPointAt(data.body[i].offset));
// }
}else{
if(downtrain.nowcode == data.body[i].code){
} else {
if (downtrain.nowcode == data.body[i].code) {
toptrain.position.x -= 1;
}
}
if(data.body[i].section == passerStation.nowStation.downsection){
if(downtrain.nowcode != data.body[i].code){
if (data.body[i].section == passerStation.nowStation.downsection) {
if (downtrain.nowcode != data.body[i].code) {
downtrain.nowcode = data.body[i].code;
}
downtrain.position.copy(passerStation.nowStation.downcurve.getPointAt(data.body[i].offset));
}else{
if(downtrain.nowcode == data.body[i].code){
} else {
if (downtrain.nowcode == data.body[i].code) {
downtrain.position.x += 1;
}
}
}
}
if(data.type == 'Simulation_Over') {
store.dispatch('LogOut').then(() => {
location.reload();
});
}
// if(data.type == 'Simulation_Over') {
// store.dispatch('LogOut').then(() => {
// location.reload();
// });
// }
}
let actions;
function opentraindoor(train,doorcode,direct){
if(direct == "top"){
if(doorcode == "1"){
function opentraindoor(train, doorcode, direct) {
if (direct == 'top') {
if (doorcode == '1') {
actions = train.action.down;
}
if(doorcode == "2"){
if (doorcode == '2') {
actions = train.action.top;
}
}else{
if(doorcode == "1"){
} else {
if (doorcode == '1') {
actions = train.action.top;
}
if(doorcode == "2"){
if (doorcode == '2') {
actions = train.action.down;
}
}
for(let an=actions.length-1;an>=0;an--){
for (let an = actions.length - 1; an >= 0; an--) {
actions[an].reset();
actions[an].time = 0;
actions[an].timeScale = 1;
actions[an].play();
}
}
function closetraindoor(train,doorcode,direct){
function closetraindoor(train, doorcode, direct) {
if(direct == "top"){
if(doorcode == "1"){
if (direct == 'top') {
if (doorcode == '1') {
actions = train.action.down;
}
if(doorcode == "2"){
if (doorcode == '2') {
actions = train.action.top;
}
toptrain.nowcode = null;
}else{
if(doorcode == "1"){
} else {
if (doorcode == '1') {
actions = train.action.top;
}
if(doorcode == "2"){
if (doorcode == '2') {
actions = train.action.down;
}
downtrain.nowcode = null;
}
for(let an=actions.length-1;an>=0;an--){
for (let an = actions.length - 1; an >= 0; an--) {
actions[an].reset();
actions[an].time = actions[an]._clip.duration;
actions[an].timeScale = -1;