修改继电器通信,修改新数据三维化部分操作

This commit is contained in:
sunzhenyu 2020-01-07 09:27:41 +08:00
parent 505e9a0da4
commit f1f21006fe
8 changed files with 69 additions and 68 deletions

View File

@ -40,7 +40,7 @@ export function Sectionaction(){
console.log(type);
let modellist;
if(type == "test"){
modellist = data.scene.getObjectByName("link").children;
modellist = data.scene.getObjectByName("section").children;
}else if(type == "suidao"){
modellist = data.scene.getObjectByName("section").children;
}else if(type == "switch"){
@ -80,8 +80,10 @@ export function Sectionaction(){
raycaster.setFromCamera( mouse, data.camera );
let intersects1;
console.log(modellist);
for(let i=0;i<modellist.length;i++){
intersects1 = raycaster.intersectObject(modellist[i],true);
console.log(intersects1);
if(intersects1[0]){
console.log(intersects1[0].object.code);
console.log(modellist[i].code);

View File

@ -255,6 +255,8 @@ export function JLmap3dEdit(dom, data, mapid) {
this.autoss = function(){
console.log("autoss");
console.log(scope.mapdata);
// scope.mapdata.signallist.resetsignal(scope.mapdata);
//old
scope.mapdata.signallist.resetsignal(scope.mapdata.linklist);
};

View File

@ -399,6 +399,7 @@ export function SectionList() {
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
testmesh2.code = data.code;
scope.sectiongroup.add( testmesh2 );
@ -578,7 +579,7 @@ export function SectionList() {
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
testmesh2.code = start;
// var geometry = new THREE.BoxBufferGeometry( scope.sections.datalist[start].lengthFact, 1, 3 );
// var material = new THREE.MeshBasicMaterial( {color: 0xFFFFFF*Math.random()} );
// var testmesh2 = new THREE.Mesh( geometry, material );

View File

@ -69,10 +69,11 @@ export function SignalList() {
newmesh.scale.z = 0.05;
newmesh.sectionOffset = data[i].sectionOffset;
newmesh.sectionCode = data[i].sectionCode;
newmesh.right = data[i].right;
newsignal.mesh = newmesh;
newsignal.sectionOffset = data[i].sectionOffset;
newsignal.mesh.status = "01";
scope.group.add(newsignal.mesh);
scope.group.add(newmesh);
scope.list.push(newsignal);
}else{
@ -99,9 +100,9 @@ export function SignalList() {
newmesh.scale.x = netsignal[i].scale.x;
newmesh.scale.y = netsignal[i].scale.y;
newmesh.scale.z = netsignal[i].scale.z;
newsignal.mesh = newmesh;
// newsignal.mesh = newmesh;
newsignal.mesh.status = "01";
scope.group.add(newsignal.mesh);
scope.group.add(newmesh);
scope.list.push(newsignal);
}
@ -149,26 +150,38 @@ export function SignalList() {
};
this.resetsignal = function(jlmap3ddata){
// console.log(jlmap3ddata.linksgroup);
// console.log(jlmap3ddata);
let linkdata = jlmap3ddata.linkdata;
console.log(jlmap3ddata.sectionlist.sections.datalist);
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
for(let i=0;i<scope.group.children.length;i++){
let signaldata = scope.group.children[i];
for(let j=0,lenj=linkdata.length;j<lenj;j++){
if(linkdata[j].code == signaldata.linkCode){
let posx = linkdata[j].lp.x + (signaldata.offset/linkdata[j].oldlength)*linkdata[j].lengthfact;
for(let j in sectiondata){
if(sectiondata[j].code == signaldata.sectionCode){
//根据线路方向修改信号灯位置
// console.log(posx);
if(signaldata.directionType == "01"){
signaldata.position.set(posx,0,linkdata[j].position.z-2.4);
signaldata.rotation.z = ( Math.PI / 2 );
// signaldata.scale.set(1,1,1);
}else if(signaldata.directionType == "02"){
signaldata.position.set(posx,0,linkdata[j].position.z+2.4);
signaldata.rotation.z = ( - Math.PI / 2 );
// signaldata.scale.set(1,1,1);
let section = sectiondata[signaldata.sectionCode];
let posx = null;
console.log(section);
if(signaldata.sectionOffset > section.lengthFact/2){
posx = section.mesh.position.x + signaldata.sectionOffset - section.lengthFact/2;
}else{
posx = section.mesh.position.x - (section.lengthFact/2 - signaldata.sectionOffset);
}
j = lenj;
//根据线路方向修改信号灯位置
if(signaldata.right == false){
if(section.standTrack == true){
posx = posx - 7;
}
signaldata.position.set(posx,0,section.mesh.position.z-3);
signaldata.rotation.z = ( Math.PI / 2 );
}else if(signaldata.right == true){
if(section.standTrack == true){
posx = posx + 7;
}
signaldata.position.set(posx,0,section.mesh.position.z+3);
signaldata.rotation.z = ( - Math.PI / 2 );
}
}
}

View File

@ -24,27 +24,27 @@ class StompClient {
}
connect() {
return new Promise((resolve, reject) => {
this.onUsed = true;
const that = this;
const header = {
login: 'relay',
passcode: 'relay'
};
this.client.connect(header,
()=>{
that.connected = true;
// 重连时需要重新订阅
that.subscribeMap.forEach((subscribe, dest) => {
that.subscribe(subscribe.dest, subscribe.handler);
});
resolve();
},
(error)=>{
console.error(error);
this.connected = false;
reject(error);
});
return new Promise((resolve, reject) => {
this.onUsed = true;
const that = this;
const header = {
login: 'relay',
passcode: 'relay'
};
this.client.connect(header,
()=>{
that.connected = true;
// 重连时需要重新订阅
that.subscribeMap.forEach((subscribe, dest) => {
that.subscribe(subscribe.dest, subscribe.handler);
});
resolve();
},
(error)=>{
console.error(error);
this.connected = false;
reject(error);
});
});
}

View File

@ -14,7 +14,7 @@ import StompClient from '@/jlmap3d/jl3ddevicetrain/component/StompClient.js';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
var clock = new THREE.Clock();
export function Jl3ddevice(dom) {
export function Jl3ddevice(dom,serviceid) {
let scope = this;
//helpbox选中包围框
//textplane三维介绍标牌
@ -157,26 +157,6 @@ export function Jl3ddevice(dom) {
}
};
//
// let teststomp = new StompClient();
// let topic = '/user/topic/simulation/assistant/'+group;
// let header = {'X-Token': token};
// try {
// // console.log("teststomp");
// teststomp.subscribe(topic, callback, header);
// } catch (error) {
// console.error('websocket订阅失败');
// }
//
// function callback(Response) {
// let data = JSON.parse(Response.body);
// if(scope.nowcode != data.body.code){
// scope.selectmodel(data);
// }else{
// scope.updateaction(data);
// }
//
// }
// let stats = new Stats();
// dom.appendChild( stats.dom );
@ -194,17 +174,17 @@ export function Jl3ddevice(dom) {
let moveanima = new Moveanimate();
this.anime = null;
this.modelmanager = new ModelManager();
this.modelmanager.loadpromise(Staticmodel, scope.mixers,scene).then(function (data) {
moveanima.initlist( scope.modelmanager.controllist);
connect = new StompClient();
// debugger
connect.subscribe("/queue/relay/status",callback);
connect.subscribe("/queue/simulation/"+serviceid,callback);
animate();
});
this.sendmsg = function (type,index){
let msg = {
// deskId:serviceid,
id:index+1,
on:null
};
@ -214,7 +194,9 @@ export function Jl3ddevice(dom) {
if(type == "1"){
msg.on = false;
}
connect.send("/app/topic/relay/"+msg.id+"/control/"+msg.on,msg);
//"/app/topic/relay/"+msg.id+"/control/"+msg.on
connect.send("/app/topic/simulation/"+serviceid+"/relay/"+msg.id+"/control/"+msg.on,{});
}
this.upmodelaction = function(type,index){

View File

@ -84,7 +84,7 @@ export function ModelManager(){
scope.controllist.push(jdq2.mesh);
scope.controllist.push(jdq3.mesh);
scope.controllist.push(jdq4.mesh);
console.log(jdq1);
// console.log(jdq1);
scope.actionlist.push(jdq1.action);
scope.actionlist.push(jdq2.action);
scope.actionlist.push(jdq3.action);

View File

@ -73,6 +73,7 @@
},
data() {
return {
device: this.$route.query.device,
jl3d: null,
devicelist:[],
msgshow:false,
@ -143,7 +144,7 @@
init: function () {
// let mapdata = this.$store.state.socket.device;
let dom = document.getElementById('jl3d');
this.jl3d = new Jl3ddevice(dom);
this.jl3d = new Jl3ddevice(dom,this.device);
},
sdevice(changedata) {