Merge branch 'local-test' of http://120.46.212.6:3000/joylink/rts-sim-testing-client into local-test
All checks were successful
CI / Docker-Build (push) Successful in 2m23s

This commit is contained in:
joylink_fanyuhong 2024-04-03 10:15:01 +08:00
commit 0522c10831
7 changed files with 87 additions and 121 deletions

View File

@ -184,51 +184,18 @@ export async function ibpKeyOperation(params: IbpKeyOperationParams) {
return await api.post(`${UriBase}/ibp/key/operation`, params);
}
export interface TccButtonOperationParams {
buttonId: number;
down: boolean;
mapId: number;
export interface TccOperationParams {
simulationId: string;
tccId: number;
trainId: string;
deviceId: number;
controlType: request.TrainControl.TrainControlType;
button?: object;
driverKey?: object;
dirKey?: object;
handler?: object;
}
export async function tccButtonOperation(params: TccButtonOperationParams) {
return await api.post(`${UriBase}/tcc/btn/operation`, params);
}
export interface TccKeyOperationParams {
simulationId: string;
mapId: number;
tccId: number;
val: boolean;
keyId: number;
}
export async function tccKeyOperation(params: TccKeyOperationParams) {
return await api.post(`${UriBase}/tcc/key/operation`, params);
}
export interface TccKeyDirOperationParams {
simulationId: string;
mapId: number;
tccId: number;
val: number;
keyId: number;
}
export async function tccKeyDirOperation(params: TccKeyDirOperationParams) {
return await api.post(`${UriBase}/tcc/key/operation`, params);
}
export interface TccHandleOperationParams {
simulationId: string;
mapId: number;
tccId: number;
val: number;
handleId: number;
}
export async function tccHandleOperation(params: TccHandleOperationParams) {
return await api.post(`${UriBase}/tcc/handle/operation`, params);
export async function tccOperation(params: TccOperationParams) {
return await api.post(`${UriBase}/train/control`, params);
}
export function checkMapData(data: { mapProto: string }) {

View File

@ -9,7 +9,7 @@ function getHost(): string {
// return '192.168.3.7:9091';
// return '192.168.3.47:9091';
// return '192.168.3.37:9091';
return '192.168.33.207:9091'; // 张骞
//return '192.168.33.207:9091'; // 张骞
// return '192.168.33.93:9091';
// return '192.168.3.37:9091'; //卫志宏
// return 'test.joylink.club/bjrtsts-service'; // 测试

View File

@ -11,8 +11,9 @@ import {
ITccButtonState,
TccButton,
} from 'src/graphics/tccButton/TccButton';
import { tccButtonOperation } from 'src/api/Simulation';
import { tccOperation } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
import { request } from 'src/protos/request';
export class TccButtonData extends GraphicDataBase implements ITccButtonData {
constructor(data?: tccGraphicData.TccButton) {
@ -115,21 +116,20 @@ export class TccButtonOperateInteraction extends GraphicInteractionPlugin<TccBut
onClick(e: FederatedMouseEvent): void {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const tccId = useTccStore().tccId;
const target = e.target as DisplayObject;
const tccButton = target.getGraphic<TccButton>();
if (!tccButton || !simulationId || !mapId) return;
tccButton.states.down = !tccButton.states.down;
tccButton.doRepaint();
/* tccButtonOperation({
if (!tccButton || !simulationId) return;
tccOperation({
simulationId,
mapId,
buttonId: tccButton.id,
tccId,
down: !tccButton.states.down,
trainId: tccId + '',
deviceId: tccButton.id,
controlType: request.TrainControl.TrainControlType.EMERGENT_BUTTON,
button: {
active: !tccButton.states.down,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
}); */
});
}
}

View File

@ -11,8 +11,9 @@ import { GraphicInteractionPlugin, IGraphicScene, JlGraphic } from 'jl-graphic';
import { type FederatedMouseEvent, DisplayObject } from 'pixi.js';
import { useTccStore } from 'src/stores/tcc-store';
import { useLineStore } from 'src/stores/line-store';
import { tccHandleOperation } from 'src/api/Simulation';
import { tccOperation } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
import { request } from 'src/protos/request';
export class TccHandleData extends GraphicDataBase implements ITccHandleData {
constructor(data?: tccGraphicData.TccHandle) {
@ -156,15 +157,17 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
const target = e.target as DisplayObject;
const tccHandle = target.getGraphic<TccHandle>();
if (!tccHandle || !simulationId || !mapId) return;
tccHandle.doRepaint();
/* tccHandleOperation({
const handleVal = Math.floor(-(tccHandle._tccHandle.y / 144) * 100);
tccOperation({
simulationId,
mapId,
handleId: tccHandle.id,
tccId,
val: tccHandle._tccHandle.y,
trainId: tccId + '',
deviceId: tccHandle.id,
controlType: request.TrainControl.TrainControlType.HANDLER,
handler: {
val: handleVal,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
}); */
});
}
}

View File

@ -11,10 +11,10 @@ import {
Sprite,
} from 'pixi.js';
import { useTccStore } from 'src/stores/tcc-store';
import { threadId } from 'worker_threads';
import { useLineStore } from 'src/stores/line-store';
import { tccKeyDirOperation, tccKeyOperation } from 'src/api/Simulation';
import { tccOperation } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
import { request } from 'src/protos/request';
export class TccKeyData extends GraphicDataBase implements ITccKeyData {
constructor(data?: tccGraphicData.TccKey) {
@ -97,7 +97,6 @@ export interface IKeyInteractionConfig {
gearPositionAmount?: number;
keyRotationMethod: KeyRotationMethod;
doAfterChangeRotation: (g: JlGraphic, rotation: number) => void;
doFinish: () => void;
}
export abstract class KeyInteraction<
G extends JlGraphic
@ -107,6 +106,7 @@ export abstract class KeyInteraction<
mouseDownBeginPos = new Point();
mouseDownBeginRotation = 0;
keyInteractionConfig: IKeyInteractionConfig;
lastTimenRotation = 0;
constructor(
name: string,
app: IGraphicScene,
@ -122,7 +122,6 @@ export abstract class KeyInteraction<
g.onmouseup = (e) => {
e.stopPropagation();
this.isMouseDown = false;
this.keyInteractionConfig.doFinish();
};
}
totalUnbind(g: G): void {
@ -148,6 +147,7 @@ export abstract class KeyInteraction<
this.isMouseDown = true;
this.mouseDownBeginPos = this.app.toCanvasCoordinates(e.global);
this.mouseDownBeginRotation = this.ratatingSprite.rotation;
this.lastTimenRotation = this.ratatingSprite.rotation;
}
onMousemove(e: FederatedMouseEvent) {
const target = e.target as DisplayObject;
@ -160,46 +160,44 @@ export abstract class KeyInteraction<
g.position,
mouseEndPos
);
let changeRotation = 0;
if (
this.keyInteractionConfig.keyRotationMethod ==
KeyRotationMethod.jumpChange
) {
if (direction == 'ssz') {
if (angle < 45) {
this.ratatingSprite.rotation = this.mouseDownBeginRotation;
changeRotation = this.mouseDownBeginRotation;
}
if (angle >= 45 && angle < 90) {
this.ratatingSprite.rotation =
this.mouseDownBeginRotation + Math.PI / 4;
if (
angle >= 45 &&
angle < 90 &&
this.mouseDownBeginRotation !== Math.PI / 4
) {
changeRotation = this.mouseDownBeginRotation + Math.PI / 4;
} else if (
angle >= 90 &&
this.mouseDownBeginRotation == -Math.PI / 4
) {
this.ratatingSprite.rotation =
this.mouseDownBeginRotation + Math.PI / 2;
changeRotation = this.mouseDownBeginRotation + Math.PI / 2;
}
if (this.lastTimenRotation !== changeRotation) {
this.lastTimenRotation = changeRotation;
this.keyInteractionConfig.doAfterChangeRotation(g, changeRotation);
}
this.keyInteractionConfig.doAfterChangeRotation(
g,
this.ratatingSprite.rotation
);
}
if (direction == 'nsz') {
if (angle < 45) {
this.ratatingSprite.rotation = this.mouseDownBeginRotation;
changeRotation = this.mouseDownBeginRotation;
} else if (angle >= 45 && angle < 90) {
this.ratatingSprite.rotation =
this.mouseDownBeginRotation - Math.PI / 4;
} else if (
angle >= 90 &&
this.mouseDownBeginRotation == Math.PI / 4
) {
this.ratatingSprite.rotation =
this.mouseDownBeginRotation - Math.PI / 2;
changeRotation = this.mouseDownBeginRotation - Math.PI / 4;
} else if (angle >= 90 && changeRotation == Math.PI / 4) {
changeRotation = this.mouseDownBeginRotation - Math.PI / 2;
}
if (this.lastTimenRotation !== changeRotation) {
this.lastTimenRotation = changeRotation;
this.keyInteractionConfig.doAfterChangeRotation(g, changeRotation);
}
this.keyInteractionConfig.doAfterChangeRotation(
g,
this.ratatingSprite.rotation
);
}
} else {
if (direction == 'ssz') {
@ -223,9 +221,6 @@ export class TccKeyInteraction extends KeyInteraction<TccKey> {
doAfterChangeRotation: (g: JlGraphic, rotation: number) => {
this.changeState(g, rotation);
},
doFinish: () => {
this.onFinish();
},
});
}
static init(app: IGraphicScene) {
@ -266,17 +261,20 @@ export class TccKeyInteraction extends KeyInteraction<TccKey> {
const target = e.target as DisplayObject;
const tccKey = target.getGraphic<TccKey>();
if (!tccKey || !simulationId || !mapId) return;
tccKey.state.position = tccKey?.state.position == 0 ? 1 : 0;
tccKey.doRepaint();
/* tccKeyOperation({
const state = tccKey?.state.position == 0 ? true : false;
const driverKeyType = tccKey?.datas.code == '司控器钥匙1' ? 0 : 1;
tccOperation({
simulationId,
mapId,
keyId: tccKey.id,
tccId,
val: !tccKey.state.position,
trainId: tccId + '',
deviceId: tccKey.id,
controlType: request.TrainControl.TrainControlType.DRIVER_KEY_SWITCH,
driverKey: {
val: state,
dt: driverKeyType,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
}); */
});
}
changeState(g: JlGraphic, rotation: number) {
let position = 0;
@ -292,22 +290,20 @@ export class TccKeyInteraction extends KeyInteraction<TccKey> {
break;
}
(g as TccKey).state.position = position;
g.doRepaint();
}
onFinish() {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const tccId = useTccStore().tccId;
if (!simulationId || !mapId) return;
/* tccKeyDirOperation({
if (!simulationId) return;
tccOperation({
simulationId,
mapId,
keyId: g.id,
tccId,
val: (g as TccKey).state.position,
trainId: tccId + '',
deviceId: g.id,
controlType: request.TrainControl.TrainControlType.DIRECTION_KEY_SWITCH,
dirKey: {
val: position,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
}); */
});
}
}

View File

@ -54,7 +54,7 @@ export class TccHandle extends JlGraphic {
return this.getStates<ITccHandleState>();
}
doRepaint(): void {
this._tccHandle.rotation = (-Math.PI / 2) * this.state.gear;
this._tccHandle.y = -Math.floor((this.state.gear * 144) / 100);
this._tccHandle.texture = this.tccHandleTextures.tccHandle;
}
}

View File

@ -1422,7 +1422,7 @@ export namespace request {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
simulationId?: string;
trainId?: number;
trainId?: string;
deviceId?: number;
controlType?: TrainControl.TrainControlType;
button?: TrainControl.EmergentButton;
@ -1466,9 +1466,9 @@ export namespace request {
pb_1.Message.setField(this, 1, value);
}
get trainId() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set trainId(value: number) {
set trainId(value: string) {
pb_1.Message.setField(this, 2, value);
}
get deviceId() {
@ -1521,7 +1521,7 @@ export namespace request {
}
static fromObject(data: {
simulationId?: string;
trainId?: number;
trainId?: string;
deviceId?: number;
controlType?: TrainControl.TrainControlType;
button?: ReturnType<typeof TrainControl.EmergentButton.prototype.toObject>;
@ -1559,7 +1559,7 @@ export namespace request {
toObject() {
const data: {
simulationId?: string;
trainId?: number;
trainId?: string;
deviceId?: number;
controlType?: TrainControl.TrainControlType;
button?: ReturnType<typeof TrainControl.EmergentButton.prototype.toObject>;
@ -1599,8 +1599,8 @@ export namespace request {
const writer = w || new pb_1.BinaryWriter();
if (this.simulationId.length)
writer.writeString(1, this.simulationId);
if (this.trainId != 0)
writer.writeUint32(2, this.trainId);
if (this.trainId.length)
writer.writeString(2, this.trainId);
if (this.deviceId != 0)
writer.writeUint32(3, this.deviceId);
if (this.controlType != TrainControl.TrainControlType.EMERGENT_BUTTON)
@ -1626,7 +1626,7 @@ export namespace request {
message.simulationId = reader.readString();
break;
case 2:
message.trainId = reader.readUint32();
message.trainId = reader.readString();
break;
case 3:
message.deviceId = reader.readUint32();