From 182ea7c0993ff27828c393cf7a35c40f1538d3e0 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Sat, 11 May 2024 09:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E8=BD=A6=E5=A4=B4=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E7=AB=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rts-sim-testing-message | 2 +- src/configs/UrlManage.ts | 4 +- src/drawApp/graphics/TrainInteraction.ts | 24 +++---- src/graphics/train/Train.ts | 83 ++++++++++++------------ 4 files changed, 55 insertions(+), 58 deletions(-) diff --git a/rts-sim-testing-message b/rts-sim-testing-message index e4c55ea..0ed6b1d 160000 --- a/rts-sim-testing-message +++ b/rts-sim-testing-message @@ -1 +1 @@ -Subproject commit e4c55ea4b6f9f5f875d59fc5bba51fc21bc8ef97 +Subproject commit 0ed6b1d451f617804d608ede072121a0f1e36fb5 diff --git a/src/configs/UrlManage.ts b/src/configs/UrlManage.ts index d22c5bd..154ed06 100644 --- a/src/configs/UrlManage.ts +++ b/src/configs/UrlManage.ts @@ -10,7 +10,7 @@ function getHost(): string { // return '192.168.3.47:9091'; // return '192.168.3.37:9091'; //return '192.168.33.207:9091'; // 张骞 - // return '192.168.33.93:9091'; + return '192.168.33.93:9091'; // return '192.168.3.37:9091'; //卫志宏 // return 'test.joylink.club/bjrtsts-service'; // 测试 return '192.168.33.233:9091'; @@ -26,7 +26,7 @@ export function getHttpBase() { export function getWebsocketUrl() { let protocol = 'ws'; - let host = '192.168.33.233'; + let host = '192.168.33.93'; // let host = 'test.joylink.club'; let port = '8083'; let url = `${protocol}://${host}:${port}`; diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 030f3d5..b7015da 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -77,23 +77,23 @@ export class TrainState extends GraphicStateBase implements ITrainState { set devicePort(v: string) { this.states.devicePort = v; } - get pointTo(): boolean { - return this.states.pointTo; + get driftTo(): boolean { + return this.states.driftTo; } - set pointTo(v: boolean) { - this.states.pointTo = v; + set driftTo(v: boolean) { + this.states.driftTo = v; } - get runDirection(): boolean { - return this.states.runDirection; + get trainRunUp(): boolean { + return this.states.trainRunUp; } - set runDirection(v: boolean) { - this.states.runDirection = v; + set trainRunUp(v: boolean) { + this.states.trainRunUp = v; } - get headDirection(): boolean { - return this.states.headDirection; + get trainActiveDirection(): number { + return this.states.trainActiveDirection; } - set headDirection(v: boolean) { - this.states.headDirection = v; + set trainActiveDirection(v: number) { + this.states.trainActiveDirection = v; } get trainKilometer(): number { return this.states.trainKilometer; diff --git a/src/graphics/train/Train.ts b/src/graphics/train/Train.ts index 53981ab..2870fa1 100644 --- a/src/graphics/train/Train.ts +++ b/src/graphics/train/Train.ts @@ -40,12 +40,12 @@ export interface ITrainState extends GraphicState { set headOffset(v: number); get devicePort(): string; set devicePort(v: string); - get pointTo(): boolean; - set pointTo(v: boolean); - get runDirection(): boolean; - set runDirection(v: boolean); - get headDirection(): boolean; - set headDirection(v: boolean); + get driftTo(): boolean; + set driftTo(v: boolean); + get trainRunUp(): boolean; + set trainRunUp(v: boolean); + get trainActiveDirection(): number; + set trainActiveDirection(v: number); get trainKilometer(): number; set trainKilometer(v: number); get controlDelayTime(): number; @@ -335,10 +335,7 @@ export class TrainHead extends Container { ]; // 道岔时运行x轴是否在增大决定箭头方向 // 区段时是否从A到B决定箭头方向 - if ( - (states.devicePort && this.train.isSyntropy) || - (!states.devicePort && states.pointTo) - ) { + if (states.devicePort && !this.train.arrowIsLeft) { const aP: Array = []; arrowPoint.forEach((item, index) => { if (index % 2 == 1) { @@ -349,25 +346,30 @@ export class TrainHead extends Container { }); arrowPoint = aP; } - if ( - (states.devicePort && this.train.isSyntropy) || - (!states.devicePort && states.pointTo) - ) { - const pP: Array = []; - pausePoint.forEach((item, index) => { - if (index % 2 == 1) { - const p = new Point(pausePoint[index - 1], item); - const newP = calculateMirrorPoint(new Point(0, 0), p); - pP.push(newP.x, newP.y); - } - }); - pausePoint = pP; + if (states.trainActiveDirection !== 0) { + const lineIsLeft = + this.train.arrowIsLeft && + states.driftTo === (states.trainActiveDirection === 1); + if (!lineIsLeft) { + const pP: Array = []; + pausePoint.forEach((item, index) => { + if (index % 2 == 1) { + const p = new Point(pausePoint[index - 1], item); + const newP = calculateMirrorPoint(new Point(0, 0), p); + pP.push(newP.x, newP.y); + } + }); + pausePoint = pP; + } + const pColor = DiriveModelColorEnum.AM; + this.pause.lineStyle(pauseW, pColor, 1); + this.pause.moveTo(pausePoint[0], pausePoint[1]); + this.pause.lineTo(pausePoint[2], pausePoint[3]); + } else { + this.pause.visible = false; } const aColor = DiriveModelColorEnum.AM; - const pColor = DiriveModelColorEnum.AM; - this.pause.lineStyle(pauseW, pColor, 1); - this.pause.moveTo(pausePoint[0], pausePoint[1]); - this.pause.lineTo(pausePoint[2], pausePoint[3]); + const arrow = this.arrow; arrow.beginFill(aColor, 1); arrow.drawPolygon(arrowPoint); @@ -377,11 +379,11 @@ export class TrainHead extends Container { } else { this.arrow.visible = false; } - if (states.tc1Active || states.tc2Active) { - this.pause.visible = true; - } else { - this.pause.visible = false; - } + // if (states.tc1Active || states.tc2Active) { + // this.pause.visible = true; + // } else { + // this.pause.visible = false; + // } } } @@ -488,14 +490,14 @@ export class Train extends JlGraphic { trainHead: TrainHead; trainbody: TrainBody; statusTextMap: Map = new Map(); - isSyntropy: boolean; //判断x坐标是否在增大 + arrowIsLeft: boolean; // 箭头是否在列车body的相对左侧 constructor() { super(Train.Type); this.trainbody = new TrainBody(this); this.trainHead = new TrainHead(this); this.addChild(this.trainHead); this.addChild(this.trainbody); - this.isSyntropy = false; + this.arrowIsLeft = true; } get datas(): ITrainData { @@ -562,15 +564,10 @@ export class Train extends JlGraphic { } allLength = getKmDistance(pKm, oKm); const portP = points[points.length - 1]; - const j = 10; - if (Math.abs(portP.x) < j) { - this.isSyntropy = this.states.runDirection; + if (this.states.driftTo) { + this.arrowIsLeft = 0 < portP.x; } else { - if (this.states.pointTo) { - this.isSyntropy = 0 > portP.x; - } else { - this.isSyntropy = portP.x > 0; - } + this.arrowIsLeft = portP.x < 0; } } else { dev = this.queryStore.queryById
(this.states.headDeviceId); @@ -610,7 +607,7 @@ export class Train extends JlGraphic { allLength = getKmDistance(BKm, AKm); const portS = points[0]; const portE = points[points.length - 1]; - this.isSyntropy = portE.x > portS.x; + this.arrowIsLeft = portE.x > portS.x && !this.states.driftTo; } } this.trainbody.doRepaint();