Merge remote-tracking branch 'origin/develop' into local-test

# Conflicts:
#	src/protos/stationLayoutGraphics.ts
This commit is contained in:
joylink_fanyuhong 2024-04-03 16:46:12 +08:00
commit c26f35e008
19 changed files with 1395 additions and 138 deletions

@ -1 +1 @@
Subproject commit 5dd8f8963e28e79012656f95999016ad503ae43a
Subproject commit 208bcaedccf71e7bfd2535e2889ca4cf7c4bdbb6

View File

@ -17,10 +17,19 @@
<q-input
outlined
class="q-mt-sm"
mask="#"
v-model.number="carWashingModel.duanNum"
@blur="onUpdate"
label="段数"
/>
<q-input
outlined
class="q-mt-sm"
:decimals="0"
v-model.number="carWashingModel.width"
@blur="onUpdate"
label="宽度"
/>
<q-select
outlined
style="margin-top: 10px"

View File

@ -99,7 +99,6 @@ onMounted(() => {
});
function getNameFormat() {
console.log(code.value, '1111111');
return code.value;
}

View File

@ -83,6 +83,7 @@ const list: KeyType[] = [
{ label: '防淹门索引', key: 'id' },
{ label: '防淹门名称', key: 'code', formatFn: getNameFormat },
{ label: '防淹门关闭', key: 'mgj', formatFn: getName },
{ label: '控制端', key: 'local', formatFn: getLocal },
{ label: '防淹门强制', key: 'param', formatFn: getForceName },
{ label: '设置故障', key: 'param', formatFn: getFaultName },
];
@ -117,6 +118,9 @@ function getName(v: boolean) {
if (v) return '是';
return '否';
}
function getLocal(v: boolean) {
return v ? '本地' : '远程';
}
function getForceName() {
return (

View File

@ -83,6 +83,7 @@ const list: KeyType[] = [
{ label: '车库门索引', key: 'id' },
{ label: '车库门名称', key: 'code', formatFn: getNameFormat },
{ label: '车库门关闭', key: 'mgj', formatFn: getName },
{ label: '控制端', key: 'local', formatFn: getLocal },
// { label: '', key: 'stateLoss', formatFn: getName },
{ label: '车库门强制', key: 'param', formatFn: getForceName },
{ label: '设置故障', key: 'param', formatFn: getFaultName },
@ -118,6 +119,9 @@ function getName(v: boolean) {
if (v) return '是';
return '否';
}
function getLocal(v: boolean) {
return v ? '本地' : '远程';
}
function getForceName() {
return (

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

@ -61,6 +61,12 @@ export class CarWashingData extends GraphicDataBase implements ICarWashingData {
set duanNum(v: number) {
this.data.duanNum = v;
}
get width(): number {
return this.data.width;
}
set width(v: number) {
this.data.width = v;
}
clone(): CarWashingData {
return new CarWashingData(this.data.cloneMessage());
}

View File

@ -108,6 +108,12 @@ export class FloodGateState
set param(param: request.CkmParam) {
this.states.param = param;
}
get local(): boolean {
return this.states.local;
}
set local(v: boolean) {
this.states.local = v;
}
get states(): state.CkmState {
return this.getState<state.CkmState>();
}

View File

@ -108,6 +108,12 @@ export class GarageDoorState
set param(param: request.CkmParam) {
this.states.param = param;
}
get local(): boolean {
return this.states.local;
}
set local(v: boolean) {
this.states.local = v;
}
get states(): state.CkmState {
return this.getState<state.CkmState>();
}

View File

@ -10,10 +10,6 @@ import { state } from 'src/protos/device_state';
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 { 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) {
@ -103,15 +99,15 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
g._tccHandle.eventMode = 'static';
g._tccHandle.cursor = 'Move';
g._tccHandle.onmousedown = (e) => {
e.stopPropagation();
this.onMouseDown(e);
};
g._tccHandle.onmouseup = (e) => {
this.onMouseUp(e);
e.stopPropagation();
this.onMouseUp();
};
g.onmousemove = (e) => {
this.onMouseMove(e);
};
g.onmouseleave = (e) => {
e.stopPropagation();
this.onMouseMove(e);
};
}
@ -120,12 +116,13 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
g._tccHandle.onmousedown = null;
g._tccHandle.onmouseup = null;
g.onmousemove = null;
g.onmouseleave = null;
}
onMouseDown(e: FederatedMouseEvent) {
const target = e.target as DisplayObject;
const tccHandle = target.getGraphic<TccHandle>();
if (!tccHandle) return;
useTccStore().tccHandleId = tccHandle.id;
useTccStore().mouseDownOnTccHandle = true;
this.isMouseDown = true;
this.mouseDownBeginPos = e.clientY;
this.mouseDownTccHandleBeginPos = tccHandle._tccHandle.y;
@ -149,25 +146,8 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
}
}
}
onMouseUp(e: FederatedMouseEvent) {
onMouseUp() {
this.isMouseDown = false;
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const tccId = useTccStore().tccId;
const target = e.target as DisplayObject;
const tccHandle = target.getGraphic<TccHandle>();
if (!tccHandle || !simulationId || !mapId) return;
const handleVal = Math.floor(-(tccHandle._tccHandle.y / 144) * 100);
tccOperation({
simulationId,
trainId: tccId + '',
deviceId: tccHandle.id,
controlType: request.TrainControl.TrainControlType.HANDLER,
handler: {
val: handleVal,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
useTccStore().mouseDownOnTccHandle = false;
}
}

View File

@ -96,7 +96,7 @@ export enum KeyRotationMethod {
export interface IKeyInteractionConfig {
gearPositionAmount?: number;
keyRotationMethod: KeyRotationMethod;
doAfterChangeRotation: (g: JlGraphic, rotation: number) => void;
doAfterChangeRotation: () => void;
}
export abstract class KeyInteraction<
G extends JlGraphic
@ -105,6 +105,7 @@ export abstract class KeyInteraction<
ratatingSprite: Sprite = new Sprite();
mouseDownBeginPos = new Point();
mouseDownBeginRotation = 0;
changeRotation = 0;
keyInteractionConfig: IKeyInteractionConfig;
lastTimenRotation = 0;
constructor(
@ -122,11 +123,17 @@ export abstract class KeyInteraction<
g.onmouseup = (e) => {
e.stopPropagation();
this.isMouseDown = false;
this.keyInteractionConfig.doAfterChangeRotation();
};
g.onmousedown = () => {
useTccStore().tccKeyDirId = g.id;
useTccStore().mouseDownOnTccKeyDir = true;
};
}
totalUnbind(g: G): void {
g.onmousemove = null;
g.onmouseup = null;
g.onmousedown = null;
}
keyBind(g: Sprite): void {
this.ratatingSprite = g;
@ -147,6 +154,7 @@ export abstract class KeyInteraction<
this.isMouseDown = true;
this.mouseDownBeginPos = this.app.toCanvasCoordinates(e.global);
this.mouseDownBeginRotation = this.ratatingSprite.rotation;
this.changeRotation = this.mouseDownBeginRotation;
this.lastTimenRotation = this.ratatingSprite.rotation;
}
onMousemove(e: FederatedMouseEvent) {
@ -160,45 +168,46 @@ export abstract class KeyInteraction<
g.position,
mouseEndPos
);
let changeRotation = 0;
if (
this.keyInteractionConfig.keyRotationMethod ==
KeyRotationMethod.jumpChange
) {
if (direction == 'ssz') {
if (angle < 45) {
changeRotation = this.mouseDownBeginRotation;
}
if (
this.changeRotation = this.mouseDownBeginRotation;
} else if (
angle >= 45 &&
angle < 90 &&
this.mouseDownBeginRotation !== Math.PI / 4
) {
changeRotation = this.mouseDownBeginRotation + Math.PI / 4;
this.changeRotation = this.mouseDownBeginRotation + Math.PI / 4;
} else if (
angle >= 90 &&
this.mouseDownBeginRotation == -Math.PI / 4
) {
changeRotation = this.mouseDownBeginRotation + Math.PI / 2;
}
if (this.lastTimenRotation !== changeRotation) {
this.lastTimenRotation = changeRotation;
this.keyInteractionConfig.doAfterChangeRotation(g, changeRotation);
this.changeRotation = this.mouseDownBeginRotation + Math.PI / 2;
}
}
if (direction == 'nsz') {
if (angle < 45) {
changeRotation = this.mouseDownBeginRotation;
} else if (angle >= 45 && angle < 90) {
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.changeRotation = this.mouseDownBeginRotation;
} else if (
angle >= 45 &&
angle < 90 &&
this.mouseDownBeginRotation !== -Math.PI / 4
) {
this.changeRotation = this.mouseDownBeginRotation - Math.PI / 4;
} else if (
angle >= 90 &&
this.mouseDownBeginRotation == Math.PI / 4
) {
this.changeRotation = this.mouseDownBeginRotation - Math.PI / 2;
}
}
if (this.lastTimenRotation !== this.changeRotation) {
this.lastTimenRotation = this.changeRotation;
this.ratatingSprite.rotation = this.changeRotation;
}
} else {
if (direction == 'ssz') {
this.ratatingSprite.rotation =
@ -218,8 +227,8 @@ export class TccKeyInteraction extends KeyInteraction<TccKey> {
super(TccKeyInteraction.Name, app, {
gearPositionAmount: 3,
keyRotationMethod: KeyRotationMethod.jumpChange,
doAfterChangeRotation: (g: JlGraphic, rotation: number) => {
this.changeState(g, rotation);
doAfterChangeRotation: () => {
this.changeState();
},
});
}
@ -276,34 +285,8 @@ export class TccKeyInteraction extends KeyInteraction<TccKey> {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
}
changeState(g: JlGraphic, rotation: number) {
let position = 0;
switch (rotation) {
case Math.PI / 4:
position = 0;
break;
case -Math.PI / 4:
position = 1;
break;
default:
position = 2;
break;
}
(g as TccKey).state.position = position;
const simulationId = useLineStore().simulationId;
const tccId = useTccStore().tccId;
if (!simulationId) return;
tccOperation({
simulationId,
trainId: tccId + '',
deviceId: g.id,
controlType: request.TrainControl.TrainControlType.DIRECTION_KEY_SWITCH,
dirKey: {
val: position,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
changeState() {
useTccStore().mouseDownOnTccKeyDir = false;
}
}

View File

@ -59,6 +59,14 @@ export function initTccScene(lineApp: IGraphicApp, sceneName: string) {
};
tccScene.canvas.onmouseup = () => {
tccStore.canvasMouseDown = false;
if (tccStore.mouseDownOnTccHandle) {
tccStore.onMouseUpFromTccHandle();
tccStore.mouseDownOnTccHandle = false;
}
if (tccStore.mouseDownOnTccKeyDir) {
tccStore.onMouseUpFromTccKeyDir();
tccStore.mouseDownOnTccKeyDir = false;
}
};
lineApp.on('destroy', () => {
tccScene.canvas.onmousedown = null;

View File

@ -19,6 +19,8 @@ export interface ICarWashingData extends GraphicData {
set centralizedStations(v: number[]);
get duanNum(): number;
set duanNum(v: number);
get width(): number;
set width(v: number);
clone(): ICarWashingData;
copyFrom(data: ICarWashingData): void;
eq(other: ICarWashingData): boolean;
@ -51,19 +53,23 @@ const carWashingConsts = {
codeColor: 0xffffff,
bodyRectLineColor: 0xffffff,
bodyRectLineWidth: 2,
bodyRectWidth: 10,
bodyRectHeight: 20,
bodyColor: 0x000000,
bodyRectWidth: 60,
bodyRectHeight: 40,
bodyColor: 0xffffff,
};
export class CarWashing extends JlGraphic {
static Type = 'carWashing';
codeGraph: VectorText = new VectorText('');
rectBody: Graphics = new Graphics();
stopText: VectorText = new VectorText('');
stateText: VectorText = new VectorText('');
constructor() {
super(CarWashing.Type);
this.addChild(this.codeGraph);
this.addChild(this.rectBody);
this.addChild(this.stopText);
this.addChild(this.stateText);
this.codeGraph.name = 'carw_code';
}
get code(): string {
@ -93,18 +99,49 @@ export class CarWashing extends JlGraphic {
codeGraph.position.set(0, -30);
}
this.rectBody.clear();
this.rectBody.beginFill(carWashingConsts.bodyColor, 0);
this.rectBody.lineStyle(
carWashingConsts.bodyRectLineWidth,
carWashingConsts.bodyRectLineColor
);
this.rectBody.beginFill(carWashingConsts.bodyColor, 1);
const width = this.datas.width || carWashingConsts.bodyRectWidth;
this.rectBody.drawRect(
-carWashingConsts.bodyRectWidth / 2,
-width / 2,
-carWashingConsts.bodyRectHeight / 2,
carWashingConsts.bodyRectWidth,
width,
carWashingConsts.bodyRectHeight
);
this.rectBody.endFill();
if (this.states.jtj) {
this.stopText.text = '紧';
this.stopText.style.fill = carWashingConsts.codeColor;
this.stopText.setVectorFontSize(carWashingConsts.codeFontSize);
this.stopText.anchor.set(0.5);
this.stopText.position.set(width / 2 + 20, -15);
}
let stateText = '';
if (this.states.xcjxj) {
stateText = '就绪';
} else if (this.states.xcyxj) {
stateText = '洗车';
} else if (this.states.tgyxj) {
stateText = '通过';
} else if (this.states.cfjList.length === 2) {
if (this.states.cfjList[0]) {
stateText = '头部';
} else if (this.states.cfjList[1]) {
stateText = '尾部';
}
} else if (this.states.cfjList.length === 3) {
if (this.states.cfjList[1]) {
stateText = '尾部';
} else if (this.states.cfjList[2]) {
stateText = '中部';
} else if (this.states.cfjList[0]) {
stateText = '头部';
}
}
this.stateText.text = stateText;
this.stateText.style.fill = carWashingConsts.codeColor;
this.stateText.setVectorFontSize(carWashingConsts.codeFontSize);
this.stateText.anchor.set(0.5);
this.stateText.position.set(width / 2 + 15, 15);
}
buildRelation() {
const sections = this.queryStore

View File

@ -9,6 +9,7 @@ import {
JlGraphic,
} from 'jl-graphic';
import { CarWashing, CarWashingTemplate, ICarWashingData } from './CarWashing';
import { Section } from '../section/Section';
export interface ICarWashingDataDrawOptions {
newData: () => ICarWashingData;
@ -61,24 +62,15 @@ function buildAbsorbablePositions(
carWashing: CarWashing
): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = [];
const carWashings = carWashing.queryStore.queryByType<CarWashing>(
CarWashing.Type
);
const canvas = carWashing.getCanvas();
carWashings.forEach((item) => {
if (item.id === carWashing.id) {
return;
}
const sections = carWashing.queryStore.queryByType<Section>(Section.Type);
sections.forEach((item) => {
const p1 = item.localToCanvasPoint(item.getStartPoint());
const p2 = item.localToCanvasPoint(item.getEndPoint());
const ala = new AbsorbableLine(
new Point(item.x, 0),
new Point(item.x, canvas.height)
);
const alb = new AbsorbableLine(
new Point(0, item.y),
new Point(canvas.width, item.y)
new Point(p1.x, p1.y),
new Point(p2.x, p2.y)
);
aps.push(ala);
aps.push(alb);
});
return aps;
}

View File

@ -31,6 +31,8 @@ export interface IFloodGateState extends GraphicState {
set mgj(v: boolean);
get param(): request.CkmParam;
set param(v: request.CkmParam);
get local(): boolean;
set local(v: boolean);
}
const garageConsts = {
@ -38,6 +40,7 @@ const garageConsts = {
codeColor: 0xffffff,
bodyLineColor: 0xffffff,
lossStateColor: 0x0000ff,
localStateColor: 0x00ff00,
bodyLineWidth: 2,
bodyColor: 0x000000,
bodyRectWidth: 10,
@ -87,10 +90,13 @@ export class FloodGate extends JlGraphic {
codeGraph.position.set(0, -30);
}
this.lineBody.clear();
const color =
this.states.param?.fault === request.Ckm.Fault.FA_State_Loss
? garageConsts.lossStateColor
: garageConsts.bodyLineColor;
let color = garageConsts.bodyLineColor;
if (this.states.local) {
color = garageConsts.localStateColor;
}
if (this.states.param?.fault === request.Ckm.Fault.FA_State_Loss) {
color = garageConsts.lossStateColor;
}
this.lineBody.lineStyle(garageConsts.bodyLineWidth, color);
this.lineBody.moveTo(
-garageConsts.bodyRectWidth / 2,

View File

@ -31,6 +31,8 @@ export interface IGarageDoorState extends GraphicState {
set mgj(v: boolean);
get param(): request.CkmParam;
set param(v: request.CkmParam);
get local(): boolean;
set local(v: boolean);
}
const garageConsts = {
@ -38,6 +40,7 @@ const garageConsts = {
codeColor: 0xffffff,
bodyLineColor: 0xffffff,
lossStateColor: 0x0000ff,
localStateColor: 0x00ff00,
bodyLineWidth: 2,
bodyColor: 0x000000,
bodyRectWidth: 10,
@ -87,10 +90,13 @@ export class GarageDoor extends JlGraphic {
codeGraph.position.set(0, -30);
}
this.lineBody.clear();
const color =
this.states.param?.fault === request.Ckm.Fault.FA_State_Loss
? garageConsts.lossStateColor
: garageConsts.bodyLineColor;
let color = garageConsts.bodyLineColor;
if (this.states.local) {
color = garageConsts.localStateColor;
}
if (this.states.param?.fault === request.Ckm.Fault.FA_State_Loss) {
color = garageConsts.lossStateColor;
}
this.lineBody.lineStyle(garageConsts.bodyLineWidth, color);
this.lineBody.moveTo(
-garageConsts.bodyRectWidth / 2,

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,12 @@
import { defineStore } from 'pinia';
import { initTccScene } from 'src/drawApp/tccScene';
import { getLineApp } from 'src/drawApp/lineApp';
import { useLineStore } from './line-store';
import { tccOperation } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
import { request } from 'src/protos/request';
import { TccHandle } from 'src/graphics/tccHandle/TccHandle';
import { TccKey } from 'src/graphics/tccKey/TccKey';
export const useTccStore = defineStore('tcc', {
state: () => ({
@ -8,6 +14,10 @@ export const useTccStore = defineStore('tcc', {
tccId: 0,
isTccDialogOpen: false,
canvasMouseDown: false,
mouseDownOnTccHandle: false,
tccHandleId: 0,
mouseDownOnTccKeyDir: false,
tccKeyDirId: 0,
}),
actions: {
getTccScene() {
@ -30,5 +40,56 @@ export const useTccStore = defineStore('tcc', {
this.trainControlMapId = 0;
this.isTccDialogOpen = false;
},
onMouseUpFromTccHandle() {
const simulationId = useLineStore().simulationId;
const tccHandle = this.getTccScene().queryStore.queryById<TccHandle>(
this.tccHandleId
);
if (!simulationId) return;
const handleVal = Number(
(-(tccHandle._tccHandle.y / 144) * 100).toFixed()
);
tccOperation({
simulationId,
trainId: this.tccId + '',
deviceId: this.tccHandleId,
controlType: request.TrainControl.TrainControlType.HANDLER,
handler: {
val: handleVal,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
},
onMouseUpFromTccKeyDir() {
const tccKeyDir = this.getTccScene().queryStore.queryById<TccKey>(
this.tccKeyDirId
);
let position = 0;
switch (tccKeyDir._tccKey.rotation) {
case Math.PI / 4:
position = 0;
break;
case -Math.PI / 4:
position = 1;
break;
default:
position = 2;
break;
}
const simulationId = useLineStore().simulationId;
if (!simulationId) return;
tccOperation({
simulationId,
trainId: this.tccId + '',
deviceId: this.tccKeyDirId,
controlType: request.TrainControl.TrainControlType.DIRECTION_KEY_SWITCH,
dirKey: {
val: position,
},
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
},
},
});