Merge branch 'master' of git.code.tencent.com:beijing-rtss-test/bj-rtss-client

This commit is contained in:
Yuan 2023-10-10 17:08:27 +08:00
commit 056d4959d1
8 changed files with 191 additions and 78 deletions

View File

@ -35,7 +35,10 @@
<script setup lang="ts"> <script setup lang="ts">
import DraggableDialog from 'src/components/common/DraggableDialog.vue'; import DraggableDialog from 'src/components/common/DraggableDialog.vue';
import { RelayCabinetData } from 'src/drawApp/relayCabinetGraphics/RelayCabinetInteraction'; import { RelayCabinetData } from 'src/drawApp/relayCabinetGraphics/RelayCabinetInteraction';
import { RelayData } from 'src/drawApp/relayCabinetGraphics/RelayInteraction'; import {
RelayData,
RelayState,
} from 'src/drawApp/relayCabinetGraphics/RelayInteraction';
import { Relay } from 'src/graphics/relay/Relay'; import { Relay } from 'src/graphics/relay/Relay';
import { import {
RelayCabinet, RelayCabinet,
@ -107,6 +110,7 @@ function oneClickRelay() {
if (j == numCols - 1 && remainder !== 0 && i >= remainder) break; if (j == numCols - 1 && remainder !== 0 && i >= remainder) break;
const relay = new Relay(); const relay = new Relay();
relay.loadData(new RelayData()); relay.loadData(new RelayData());
relay.loadState(new RelayState());
relay.id = GraphicIdGenerator.next(); relay.id = GraphicIdGenerator.next();
relay.position.set( relay.position.set(
relayCabinet.x - relayCabinet.x -

View File

@ -8,13 +8,6 @@
@blur="onUpdate" @blur="onUpdate"
label="索引" label="索引"
/> />
<q-input
outlined
v-model.number="platformModel.refStationIndex"
type="number"
@blur="onUpdate"
label="对应车站索引"
/>
<q-select <q-select
outlined outlined
@blur="onUpdate" @blur="onUpdate"
@ -33,6 +26,26 @@
:options="optionsDirection" :options="optionsDirection"
label="方向" label="方向"
/> />
<q-input
v-if="platformModel.hasdoor"
outlined
v-model.number="platformModel.sonDoorAmount"
type="number"
@blur="onUpdate"
label="子屏蔽门的数量"
/>
<q-list bordered separator class="rounded-borders">
<q-item>
<q-item-section no-wrap class="q-gutter-y-sm column">
<q-item-label> 关联的车站 </q-item-label>
<div class="q-gutter-sm row">
<q-chip square color="primary" text-color="white">
{{ stationRelation }}
</q-chip>
</div>
</q-item-section>
</q-item>
</q-list>
</q-form> </q-form>
</template> </template>
@ -40,7 +53,15 @@
import { PlatformData } from 'src/drawApp/graphics/PlatformInteraction'; import { PlatformData } from 'src/drawApp/graphics/PlatformInteraction';
import { useFormData } from 'src/components/DrawAppFormUtils'; import { useFormData } from 'src/components/DrawAppFormUtils';
import { useDrawStore } from 'src/stores/draw-store'; import { useDrawStore } from 'src/stores/draw-store';
import { computed } from 'vue';
import { Station } from 'src/graphics/station/Station';
import { Platform } from 'src/graphics/platform/Platform';
const drawStore = useDrawStore();
const { data: platformModel, onUpdate } = useFormData(
new PlatformData(),
drawStore.getDrawApp()
);
const optionsDoor = [ const optionsDoor = [
{ label: '是', value: true }, { label: '是', value: true },
{ label: '否', value: false }, { label: '否', value: false },
@ -50,8 +71,15 @@ const optionsDirection = [
{ label: '向下', value: 'down' }, { label: '向下', value: 'down' },
]; ];
const { data: platformModel, onUpdate } = useFormData( const stationRelation = computed(() => {
new PlatformData(), const platform = drawStore.selectedGraphic as Platform;
useDrawStore().getDrawApp() const refStations = platform?.relationManage
); .getRelationsOfGraphicAndOtherType(platform, Station.Type)
.map((relation) => relation.getOtherGraphic<Station>(platform).datas.code);
let refStation;
if (refStations) {
return (refStation = refStations[0]);
}
return refStation;
});
</script> </script>

View File

@ -58,11 +58,17 @@ export class PlatformData extends GraphicDataBase implements IPlatformData {
set index(v: number) { set index(v: number) {
this.data.index = v; this.data.index = v;
} }
get refStationIndex(): number { get refStation(): string {
return this.data.refStationIndex; return this.data.refStation;
} }
set refStationIndex(v: number) { set refStation(v: string) {
this.data.refStationIndex = v; this.data.refStation = v;
}
get sonDoorAmount(): number {
return this.data.sonDoorAmount;
}
set sonDoorAmount(v: number) {
this.data.sonDoorAmount = v;
} }
clone(): PlatformData { clone(): PlatformData {

View File

@ -9,6 +9,7 @@ import {
calculateMirrorPoint, calculateMirrorPoint,
getRectangleCenter, getRectangleCenter,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { Station } from '../station/Station';
export interface IPlatformData extends GraphicData { export interface IPlatformData extends GraphicData {
get code(): string; // 编号 get code(): string; // 编号
@ -19,8 +20,10 @@ export interface IPlatformData extends GraphicData {
set direction(v: string); set direction(v: string);
get index(): number; get index(): number;
set index(v: number); set index(v: number);
get refStationIndex(): number; get refStation(): string; // 关联的车站
set refStationIndex(v: number); set refStation(v: string);
get sonDoorAmount(): number; //子屏蔽门的数量
set sonDoorAmount(v: number);
clone(): IPlatformData; clone(): IPlatformData;
copyFrom(data: IPlatformData): void; copyFrom(data: IPlatformData): void;
eq(other: IPlatformData): boolean; eq(other: IPlatformData): boolean;
@ -139,19 +142,23 @@ class smallDoorGraphic extends Container {
this.addChild(this.smallDoorGraphic); this.addChild(this.smallDoorGraphic);
this.addChild(this.labelGraphic); this.addChild(this.labelGraphic);
} }
draw(direction: string, stateData: IPlatformState, i: number): void { draw(data: IPlatformData, stateData: IPlatformState, i: number): void {
const sonDoorAmount = data?.sonDoorAmount || 30;
const start = const start =
-platformConsts.smallDoorWidth * 15 + platformConsts.smallDoorWidth * i; (-platformConsts.smallDoorWidth * sonDoorAmount) / 2 +
platformConsts.smallDoorWidth * i;
const smallDoorGraphic = this.smallDoorGraphic; const smallDoorGraphic = this.smallDoorGraphic;
const lineColor = PlatformColorEnum.doorGreen; const lineColor = PlatformColorEnum.doorGreen;
// if (stateData.psdCut) { // if (stateData.psdCut) {
// lineColor = PlatformColorEnum.doorRed; // lineColor = PlatformColorEnum.doorRed;
// } // }
smallDoorGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor)); const direction = data.direction;
smallDoorGraphic.moveTo(start, 0); smallDoorGraphic
smallDoorGraphic.lineTo(start + platformConsts.smallDoorWidth - 3, 0); .lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(start, 0)
.lineTo(start + platformConsts.smallDoorWidth - 3, 0);
if (direction == 'down') { if (direction == 'down') {
this.labelGraphic.text = 30 - i; this.labelGraphic.text = sonDoorAmount - i;
} else { } else {
this.labelGraphic.text = i + 1; this.labelGraphic.text = i + 1;
} }
@ -167,10 +174,11 @@ export class doorGraphic extends Container {
constructor() { constructor() {
super(); super();
} }
draw(direction: string, stateData: IPlatformState): void { draw(data: IPlatformData, stateData: IPlatformState): void {
for (let i = 0; i < 30; i++) { const sonDoorAmount = data?.sonDoorAmount || 30;
for (let i = 0; i < sonDoorAmount; i++) {
const smallDoor = new smallDoorGraphic(); const smallDoor = new smallDoorGraphic();
smallDoor.draw(direction, stateData, i); smallDoor.draw(data, stateData, i);
this.addChild(smallDoor); this.addChild(smallDoor);
} }
} }
@ -423,7 +431,7 @@ export class Platform extends JlGraphic {
doRepaint(): void { doRepaint(): void {
this.doorGraphic.clear(); this.doorGraphic.clear();
if (this.datas.hasdoor) { if (this.datas.hasdoor) {
this.doorGraphic.draw(this.datas.direction, this.states); this.doorGraphic.draw(this.datas, this.states);
} }
this.platformGraphic.draw(this.states); this.platformGraphic.draw(this.states);
this.emergClose.draw(); this.emergClose.draw();
@ -453,6 +461,32 @@ export class Platform extends JlGraphic {
} }
// this.changeState(); // this.changeState();
} }
buildRelation() {
const stationas = this.queryStore.queryByType<Station>(Station.Type);
for (let i = 0; i < stationas.length; i++) {
const sP = stationas[i].localBoundsToCanvasPoints();
if (this.x > sP[0].x && this.x < sP[1].x) {
this.relationManage.addRelation(this, stationas[i]);
break;
}
}
}
saveRelations() {
const refStation = this.relationManage
.getRelationsOfGraphicAndOtherType(this, Station.Type)
.map((relation) => relation.getOtherGraphic<Station>(this).datas.id);
if (refStation.length) {
this.datas.refStation = refStation[0];
}
}
loadRelations() {
if (this.datas.refStation) {
this.relationManage.addRelation(
this,
this.queryStore.queryById<Station>(this.datas.refStation)
);
}
}
// changeState(): void { // changeState(): void {
// this.doorGraphic.changeState(this.states); // this.doorGraphic.changeState(this.states);
// this.emergClose.changeState(this.id, this.states); // this.emergClose.changeState(this.id, this.states);

View File

@ -10,7 +10,7 @@ import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
export interface IRelayData extends GraphicData { export interface IRelayData extends GraphicData {
get code(): string; // 编号 get code(): string; // 编号
set code(v: string); set code(v: string);
get newModel(): relayCabinetGraphicData.Relay.ModelType; // 计轴、区段边界 get newModel(): relayCabinetGraphicData.Relay.ModelType; // 型号
set newModel(v: relayCabinetGraphicData.Relay.ModelType); set newModel(v: relayCabinetGraphicData.Relay.ModelType);
clone(): IRelayData; clone(): IRelayData;
copyFrom(data: IRelayData): void; copyFrom(data: IRelayData): void;

View File

@ -652,13 +652,17 @@ abstract class GraphicSceneBase
} }
private async load(): Promise<void> { private async load(): Promise<void> {
console.log(this._options.dataLoader, '=====');
if (this._options.dataLoader) { if (this._options.dataLoader) {
const storage = await this._options.dataLoader(); const storage = await this._options.dataLoader();
console.log(storage, 'storage');
if (storage.canvasProperty) { if (storage.canvasProperty) {
this.canvas.update(storage.canvasProperty); this.canvas.update(storage.canvasProperty);
console.log(this.canvas, 'canvas');
} }
if (storage.datas) { if (storage.datas) {
await this.loadGraphic(storage.datas); await this.loadGraphic(storage.datas);
console.log('load');
} }
} }
this._loaded = true; this._loaded = true;

View File

@ -2,26 +2,20 @@
<q-layout view="hHh LpR fFf"> <q-layout view="hHh LpR fFf">
<q-header reveal class="bg-primary text-white"> <q-header reveal class="bg-primary text-white">
<q-toolbar> <q-toolbar>
<q-btn-dropdown color="info" label="切换场景"> <q-select
<q-list> dark
<q-item dense
v-for="(item, index) in projectInfo.mapInfoLinks" label-color="grey-13"
:key="index" v-model="sceneInfo"
:disable="item.id == lineStore.mapId" @update:model-value="switchScene"
clickable :options="sceneOptions"
v-close-popup :option-label="(item) => item.name"
@click="switchScene(item)" label="切换场景"
> ></q-select>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<q-toolbar-title> {{ projectName }} </q-toolbar-title> <q-toolbar-title> {{ projectName }} </q-toolbar-title>
<q-btn <q-btn
color="info" color="red"
label="销毁仿真" label="结束"
class="q-mr-md" class="q-mr-md"
@click="destroySimAndBack" @click="destroySimAndBack"
/> />
@ -44,7 +38,7 @@
<div id="line-app-container" class="overflow-hidden"></div> <div id="line-app-container" class="overflow-hidden"></div>
</q-page-container> </q-page-container>
<q-dialog v-model="pslDialog"> <q-dialog v-model="pslDialog">
<q-page-container style="width: 510px; height: 650px; background: #fff"> <q-page-container style="width: 1920px; height: 950px">
<div id="psl-app-container" class="overflow-hidden"></div> <div id="psl-app-container" class="overflow-hidden"></div>
</q-page-container> </q-page-container>
</q-dialog> </q-dialog>
@ -62,7 +56,7 @@ import {
nextTick, nextTick,
} from 'vue'; } from 'vue';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { usePslStore } from 'src/stores/psl-store.ts'; import { usePslStore } from 'src/stores/psl-store';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { destroySimulation } from 'src/api/Simulation'; import { destroySimulation } from 'src/api/Simulation';
import StateProperties from 'src/components/line-app/StateProperties.vue'; import StateProperties from 'src/components/line-app/StateProperties.vue';
@ -90,6 +84,11 @@ const drawerRight = ref(false);
const projectName = computed(() => projectInfo.name); const projectName = computed(() => projectInfo.name);
const sceneOptions = computed(() => {
return projectInfo.mapInfoLinks || [];
});
const sceneInfo = ref();
function onResize() { function onResize() {
const clientWidth = document.documentElement.clientWidth; const clientWidth = document.documentElement.clientWidth;
const clientHeight = document.documentElement.clientHeight; const clientHeight = document.documentElement.clientHeight;
@ -131,6 +130,7 @@ onMounted(async () => {
return item.id == lineStore.mapId; return item.id == lineStore.mapId;
}); });
if (find) { if (find) {
sceneInfo.value = find;
sceneName = getSceneNameFn(find); sceneName = getSceneNameFn(find);
} }
lineStore.addAllScene(projectInfo.mapInfoLinks || []); lineStore.addAllScene(projectInfo.mapInfoLinks || []);
@ -197,39 +197,53 @@ watch(
} }
); );
function destroySimAndBack() { function destroySimAndBack() {
if (simulationId) { $q.dialog({
destroySimulation({ simulationId }); title: '确认',
} message: `确认结束项目 "${projectName.value}" 吗?`,
backConfirm(); cancel: true,
}).onOk(async () => {
try {
if (simulationId) {
await destroySimulation({ simulationId });
}
backConfirm();
} catch (err) {
const error = err as ApiError;
$q.notify({
type: 'negative',
message: error.title,
});
backConfirm();
}
});
} }
function switchScene(val: MapInfo) { function switchScene(val: MapInfo) {
if (val.id == lineStore.mapId) return; if (val.id == lineStore.mapId) return;
scene && scene.unbindDom();
lineStore.setMapId(val.id); lineStore.setMapId(val.id);
sceneName = getSceneNameFn(val); sceneName = getSceneNameFn(val);
lineStore.setSceneName(sceneName); lineStore.setSceneName(sceneName);
scene = lineApp.getScene(sceneName);
const dom = document.getElementById('line-app-container'); const dom = document.getElementById('line-app-container');
if (dom) { if (dom) {
scene.bindDom(dom); lineApp.switchScene(sceneName, dom);
scene = lineApp.getScene(sceneName);
scene.reload(); scene.reload();
} }
} }
function pslShow() { function pslShow() {
pslDialog.value = true; pslDialog.value = true;
const pslApp = usePslStore().initLineApp();
nextTick(() => { nextTick(() => {
const dom = document.getElementById('psl-app-container'); const dom = document.getElementById('psl-app-container');
if (dom) { if (dom) {
const pslApp = usePslStore().initLineApp(); usePslStore().addAllScene([{ type: 1, id: 146 }]);
usePslStore().addAllScene([{ type: 1, id: 145 }]); usePslStore().setMapId(146);
pslApp.bindDom(dom);
usePslStore().setMapId(145);
usePslStore().setSimulationId(simulationId); usePslStore().setSimulationId(simulationId);
sceneName = getSceneNameFn({ type: 1, id: 145 }); sceneName = getSceneNameFn({ type: 1, id: 146 });
usePslStore().setSceneName(sceneName); usePslStore().setSceneName(sceneName);
scene = pslApp.getScene(sceneName); scene = pslApp.getScene(sceneName);
scene.bindDom(dom);
scene.reload(); scene.reload();
dom.style.width = '500px'; dom.style.width = '500px';
dom.style.height = '600px'; dom.style.height = '600px';

View File

@ -1271,7 +1271,8 @@ export namespace graphicData {
hasdoor?: boolean; hasdoor?: boolean;
direction?: string; direction?: string;
index?: number; index?: number;
refStationIndex?: number; refStation?: string;
sonDoorAmount?: number;
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -1291,8 +1292,11 @@ export namespace graphicData {
if ("index" in data && data.index != undefined) { if ("index" in data && data.index != undefined) {
this.index = data.index; this.index = data.index;
} }
if ("refStationIndex" in data && data.refStationIndex != undefined) { if ("refStation" in data && data.refStation != undefined) {
this.refStationIndex = data.refStationIndex; this.refStation = data.refStation;
}
if ("sonDoorAmount" in data && data.sonDoorAmount != undefined) {
this.sonDoorAmount = data.sonDoorAmount;
} }
} }
} }
@ -1329,11 +1333,17 @@ export namespace graphicData {
set index(value: number) { set index(value: number) {
pb_1.Message.setField(this, 5, value); pb_1.Message.setField(this, 5, value);
} }
get refStationIndex() { get refStation() {
return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; return pb_1.Message.getFieldWithDefault(this, 8, "") as string;
} }
set refStationIndex(value: number) { set refStation(value: string) {
pb_1.Message.setField(this, 6, value); pb_1.Message.setField(this, 8, value);
}
get sonDoorAmount() {
return pb_1.Message.getFieldWithDefault(this, 9, 0) as number;
}
set sonDoorAmount(value: number) {
pb_1.Message.setField(this, 9, value);
} }
static fromObject(data: { static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof CommonInfo.prototype.toObject>;
@ -1341,7 +1351,8 @@ export namespace graphicData {
hasdoor?: boolean; hasdoor?: boolean;
direction?: string; direction?: string;
index?: number; index?: number;
refStationIndex?: number; refStation?: string;
sonDoorAmount?: number;
}): Platform { }): Platform {
const message = new Platform({}); const message = new Platform({});
if (data.common != null) { if (data.common != null) {
@ -1359,8 +1370,11 @@ export namespace graphicData {
if (data.index != null) { if (data.index != null) {
message.index = data.index; message.index = data.index;
} }
if (data.refStationIndex != null) { if (data.refStation != null) {
message.refStationIndex = data.refStationIndex; message.refStation = data.refStation;
}
if (data.sonDoorAmount != null) {
message.sonDoorAmount = data.sonDoorAmount;
} }
return message; return message;
} }
@ -1371,7 +1385,8 @@ export namespace graphicData {
hasdoor?: boolean; hasdoor?: boolean;
direction?: string; direction?: string;
index?: number; index?: number;
refStationIndex?: number; refStation?: string;
sonDoorAmount?: number;
} = {}; } = {};
if (this.common != null) { if (this.common != null) {
data.common = this.common.toObject(); data.common = this.common.toObject();
@ -1388,8 +1403,11 @@ export namespace graphicData {
if (this.index != null) { if (this.index != null) {
data.index = this.index; data.index = this.index;
} }
if (this.refStationIndex != null) { if (this.refStation != null) {
data.refStationIndex = this.refStationIndex; data.refStation = this.refStation;
}
if (this.sonDoorAmount != null) {
data.sonDoorAmount = this.sonDoorAmount;
} }
return data; return data;
} }
@ -1407,8 +1425,10 @@ export namespace graphicData {
writer.writeString(4, this.direction); writer.writeString(4, this.direction);
if (this.index != 0) if (this.index != 0)
writer.writeInt32(5, this.index); writer.writeInt32(5, this.index);
if (this.refStationIndex != 0) if (this.refStation.length)
writer.writeInt32(6, this.refStationIndex); writer.writeString(8, this.refStation);
if (this.sonDoorAmount != 0)
writer.writeInt32(9, this.sonDoorAmount);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -1433,8 +1453,11 @@ export namespace graphicData {
case 5: case 5:
message.index = reader.readInt32(); message.index = reader.readInt32();
break; break;
case 6: case 8:
message.refStationIndex = reader.readInt32(); message.refStation = reader.readString();
break;
case 9:
message.sonDoorAmount = reader.readInt32();
break; break;
default: reader.skipField(); default: reader.skipField();
} }