This commit is contained in:
fan 2023-10-20 11:04:09 +08:00
commit ae8bb593d4
8 changed files with 116 additions and 14 deletions

View File

@ -3,13 +3,22 @@
<q-input outlined readonly v-model="stationModel.id" label="id" /> <q-input outlined readonly v-model="stationModel.id" label="id" />
<q-input <q-input
outlined outlined
label="车站" label="车站名"
type="textarea" type="textarea"
@blur="onUpdate" @blur="onUpdate"
v-model="stationModel.code" v-model="stationModel.code"
lazy-rules lazy-rules
autogrow autogrow
/> />
<q-input
outlined
label="车站名"
type="textarea"
@blur="onUpdate"
v-model="stationModel.stationName"
lazy-rules
autogrow
/>
<q-input <q-input
outlined outlined
v-model.number="stationModel.index" v-model.number="stationModel.index"

View File

@ -17,7 +17,10 @@ import {
ScreenDoor, ScreenDoor,
ScreenDoorTemplate, ScreenDoorTemplate,
} from 'src/graphics/screenDoor/ScreenDoor'; } from 'src/graphics/screenDoor/ScreenDoor';
import { ScreenDoorData } from './graphics/ScreenDoorInteraction'; import {
ScreenDoorData,
ScreenDoorState,
} from './graphics/ScreenDoorInteraction';
import { ScreenDoorDraw } from 'src/graphics/screenDoor/ScreenDoorDrawAssistant'; import { ScreenDoorDraw } from 'src/graphics/screenDoor/ScreenDoorDrawAssistant';
import { Station, StationTemplate } from 'src/graphics/station/Station'; import { Station, StationTemplate } from 'src/graphics/station/Station';
import { StationDraw } from 'src/graphics/station/StationDrawAssistant'; import { StationDraw } from 'src/graphics/station/StationDrawAssistant';
@ -168,7 +171,10 @@ export function initCommonDrawApp(app: IDrawApp) {
app, app,
new PlatformTemplate(new PlatformData(), new PlatformState()) new PlatformTemplate(new PlatformData(), new PlatformState())
); );
new ScreenDoorDraw(app, new ScreenDoorTemplate(new ScreenDoorData())); new ScreenDoorDraw(
app,
new ScreenDoorTemplate(new ScreenDoorData(), new ScreenDoorState())
);
new StationDraw( new StationDraw(
app, app,
new StationTemplate(new StationData(), new StationState()) new StationTemplate(new StationData(), new StationState())

View File

@ -1,10 +1,12 @@
import * as pb_1 from 'google-protobuf'; import * as pb_1 from 'google-protobuf';
import { import {
IScreenDoorData, IScreenDoorData,
IScreenDoorState,
ScreenDoor, ScreenDoor,
} from 'src/graphics/screenDoor/ScreenDoor'; } from 'src/graphics/screenDoor/ScreenDoor';
import { graphicData } from 'src/protos/stationLayoutGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics';
import { GraphicDataBase } from './GraphicDataBase'; import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
import { state } from 'src/protos/device_state';
export class ScreenDoorData extends GraphicDataBase implements IScreenDoorData { export class ScreenDoorData extends GraphicDataBase implements IScreenDoorData {
constructor(data?: graphicData.ScreenDoor) { constructor(data?: graphicData.ScreenDoor) {
@ -59,3 +61,36 @@ export class ScreenDoorData extends GraphicDataBase implements IScreenDoorData {
return pb_1.Message.equals(this.data, other.data); return pb_1.Message.equals(this.data, other.data);
} }
} }
export class ScreenDoorState
extends GraphicStateBase
implements IScreenDoorState
{
constructor(proto?: state.PsdState) {
let states;
if (proto) {
states = proto;
} else {
states = new state.PsdState();
}
super(states, ScreenDoor.Type);
}
get code(): string {
return this.states.id;
}
get openDoorCodes() {
return this.states.openDoorCodes;
}
get states(): state.PsdState {
return this.getState<state.PsdState>();
}
clone(): ScreenDoorState {
return new ScreenDoorState(this.states.cloneMessage());
}
copyFrom(data: GraphicStateBase): void {
pb_1.Message.copyInto(data._state, this._state);
}
eq(data: GraphicStateBase): boolean {
return pb_1.Message.equals(this._state, data._state);
}
}

View File

@ -43,6 +43,12 @@ export class StationData extends GraphicDataBase implements IStationData {
set code(v: string) { set code(v: string) {
this.data.code = v; this.data.code = v;
} }
get stationName(): string {
return this.data.stationName;
}
set stationName(v: string) {
this.data.stationName = v;
}
get kilometerSystem(): KilometerSystem { get kilometerSystem(): KilometerSystem {
if (!this.data.kilometerSystem) { if (!this.data.kilometerSystem) {
this.data.kilometerSystem = new graphicData.KilometerSystem(); this.data.kilometerSystem = new graphicData.KilometerSystem();

View File

@ -21,7 +21,10 @@ import {
PlatformState, PlatformState,
} from './graphics/PlatformInteraction'; } from './graphics/PlatformInteraction';
import { PlatformTemplate, Platform } from 'src/graphics/platform/Platform'; import { PlatformTemplate, Platform } from 'src/graphics/platform/Platform';
import { ScreenDoorData } from './graphics/ScreenDoorInteraction'; import {
ScreenDoorData,
ScreenDoorState,
} from './graphics/ScreenDoorInteraction';
import { import {
ScreenDoor, ScreenDoor,
ScreenDoorTemplate, ScreenDoorTemplate,
@ -209,7 +212,7 @@ export function initLineScene(lineApp: IGraphicApp, sceneName: string) {
getTypeConsts(Signal.Type) getTypeConsts(Signal.Type)
), ),
new PlatformTemplate(new PlatformData(), new PlatformState()), new PlatformTemplate(new PlatformData(), new PlatformState()),
new ScreenDoorTemplate(new ScreenDoorData()), new ScreenDoorTemplate(new ScreenDoorData(), new ScreenDoorState()),
new StationTemplate(new StationData(), new StationState()), new StationTemplate(new StationData(), new StationState()),
new TurnoutTemplate(new TurnoutData(), new TurnoutStates()), new TurnoutTemplate(new TurnoutData(), new TurnoutStates()),
new SectionTemplate(new SectionData()), new SectionTemplate(new SectionData()),
@ -284,6 +287,11 @@ function handleSubscribe(lineScene: IGraphicScene) {
// states.push(new SectionState(item)); // states.push(new SectionState(item));
} }
}); });
storage.allStatus.psdState.forEach((item) => {
if (item.id) {
states.push(new ScreenDoorState(item));
}
});
storage.allStatus.switchState.forEach((item) => { storage.allStatus.switchState.forEach((item) => {
// 道岔 // 道岔
if (item.id) { if (item.id) {

View File

@ -1,6 +1,7 @@
import { Color, Container, Graphics } from 'pixi.js'; import { Color, Container, Graphics } from 'pixi.js';
import { import {
GraphicData, GraphicData,
GraphicState,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
VectorText, VectorText,
@ -23,11 +24,15 @@ export interface IScreenDoorData extends GraphicData {
eq(other: IScreenDoorData): boolean; eq(other: IScreenDoorData): boolean;
} }
export interface IScreenDoorState extends GraphicState {
get openDoorCodes(): number[]; //打开的屏蔽门的编号
}
const screenDoorConsts = { const screenDoorConsts = {
lineWidth: 3, lineWidth: 3,
smallDoorWidth: 10, smallDoorWidth: 10,
doorGreen: '0x00FF00', //屏蔽门的颜色 doorClose: '0x00FF00', //屏蔽门的颜色
doorRed: '0xff0000', doorOpen: '0xff0000',
}; };
class smallDoorGraphic extends Container { class smallDoorGraphic extends Container {
@ -42,12 +47,14 @@ class smallDoorGraphic extends Container {
this.addChild(this.smallDoorGraphic); this.addChild(this.smallDoorGraphic);
this.addChild(this.labelGraphic); this.addChild(this.labelGraphic);
} }
draw(data: IScreenDoorData, i: number): void { draw(data: IScreenDoorData, i: number, open: boolean): void {
const start = const start =
(-screenDoorConsts.smallDoorWidth * data.sonDoorAmount) / 2 + (-screenDoorConsts.smallDoorWidth * data.sonDoorAmount) / 2 +
screenDoorConsts.smallDoorWidth * i; screenDoorConsts.smallDoorWidth * i;
const smallDoorGraphic = this.smallDoorGraphic; const smallDoorGraphic = this.smallDoorGraphic;
const lineColor = screenDoorConsts.doorGreen; const lineColor = open
? screenDoorConsts.doorOpen
: screenDoorConsts.doorClose;
const direction = 'up'; const direction = 'up';
smallDoorGraphic smallDoorGraphic
.lineStyle(screenDoorConsts.lineWidth, new Color(lineColor)) .lineStyle(screenDoorConsts.lineWidth, new Color(lineColor))
@ -79,6 +86,10 @@ export class ScreenDoor extends JlGraphic {
return this.getDatas<IScreenDoorData>(); return this.getDatas<IScreenDoorData>();
} }
get states(): IScreenDoorState {
return this.getStates<IScreenDoorState>();
}
doRepaint(): void { doRepaint(): void {
const doorGraphic = this.doorGraphic; const doorGraphic = this.doorGraphic;
doorGraphic.children.forEach((g) => { doorGraphic.children.forEach((g) => {
@ -88,7 +99,7 @@ export class ScreenDoor extends JlGraphic {
this.datas.sonDoorAmount = this.datas?.sonDoorAmount || 30; this.datas.sonDoorAmount = this.datas?.sonDoorAmount || 30;
for (let i = 0; i < this.datas.sonDoorAmount; i++) { for (let i = 0; i < this.datas.sonDoorAmount; i++) {
const smallDoor = new smallDoorGraphic(); const smallDoor = new smallDoorGraphic();
smallDoor.draw(this.datas, i); smallDoor.draw(this.datas, i, this.states.openDoorCodes.includes(i));
doorGraphic.addChild(smallDoor); doorGraphic.addChild(smallDoor);
} }
} }
@ -130,14 +141,16 @@ export class ScreenDoor extends JlGraphic {
} }
export class ScreenDoorTemplate extends JlGraphicTemplate<ScreenDoor> { export class ScreenDoorTemplate extends JlGraphicTemplate<ScreenDoor> {
constructor(dataTemplate: IScreenDoorData) { constructor(dataTemplate: IScreenDoorData, stateTemplate?: IScreenDoorState) {
super(ScreenDoor.Type, { super(ScreenDoor.Type, {
dataTemplate, dataTemplate,
stateTemplate,
}); });
} }
new(): ScreenDoor { new(): ScreenDoor {
const screenDoor = new ScreenDoor(); const screenDoor = new ScreenDoor();
screenDoor.loadData(this.datas); screenDoor.loadData(this.datas);
screenDoor.loadState(this.states);
return screenDoor; return screenDoor;
} }
} }

View File

@ -8,8 +8,10 @@ import {
import { KilometerSystem } from '../signal/Signal'; import { KilometerSystem } from '../signal/Signal';
export interface IStationData extends GraphicData { export interface IStationData extends GraphicData {
get code(): string; // 编号 get code(): string; // 车站站名
set code(v: string); set code(v: string);
get stationName(): string; // 车站名
set stationName(v: string);
get kilometerSystem(): KilometerSystem; get kilometerSystem(): KilometerSystem;
set kilometerSystem(v: KilometerSystem); set kilometerSystem(v: KilometerSystem);
get concentrationStations(): boolean; //是否集中站 get concentrationStations(): boolean; //是否集中站
@ -36,7 +38,7 @@ const stationConsts = {
}; };
export class Station extends JlGraphic { export class Station extends JlGraphic {
static Type = 'station'; static Type = 'station';
codeGraph: VectorText = new VectorText(''); //车站 codeGraph: VectorText = new VectorText(''); //车站
kilometerGraph: VectorText = new VectorText(''); //公里标 kilometerGraph: VectorText = new VectorText(''); //公里标
constructor() { constructor() {
super(Station.Type); super(Station.Type);

View File

@ -1755,6 +1755,7 @@ export namespace graphicData {
kilometerSystem?: KilometerSystem; kilometerSystem?: KilometerSystem;
index?: number; index?: number;
refIbpMapCode?: string; refIbpMapCode?: string;
stationName?: string;
}) { }) {
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);
@ -1777,6 +1778,9 @@ export namespace graphicData {
if ("refIbpMapCode" in data && data.refIbpMapCode != undefined) { if ("refIbpMapCode" in data && data.refIbpMapCode != undefined) {
this.refIbpMapCode = data.refIbpMapCode; this.refIbpMapCode = data.refIbpMapCode;
} }
if ("stationName" in data && data.stationName != undefined) {
this.stationName = data.stationName;
}
} }
} }
get common() { get common() {
@ -1821,6 +1825,12 @@ export namespace graphicData {
set refIbpMapCode(value: string) { set refIbpMapCode(value: string) {
pb_1.Message.setField(this, 8, value); pb_1.Message.setField(this, 8, value);
} }
get stationName() {
return pb_1.Message.getFieldWithDefault(this, 9, "") as string;
}
set stationName(value: string) {
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>;
code?: string; code?: string;
@ -1828,6 +1838,7 @@ export namespace graphicData {
kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>; kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>;
index?: number; index?: number;
refIbpMapCode?: string; refIbpMapCode?: string;
stationName?: string;
}): Station { }): Station {
const message = new Station({}); const message = new Station({});
if (data.common != null) { if (data.common != null) {
@ -1848,6 +1859,9 @@ export namespace graphicData {
if (data.refIbpMapCode != null) { if (data.refIbpMapCode != null) {
message.refIbpMapCode = data.refIbpMapCode; message.refIbpMapCode = data.refIbpMapCode;
} }
if (data.stationName != null) {
message.stationName = data.stationName;
}
return message; return message;
} }
toObject() { toObject() {
@ -1858,6 +1872,7 @@ export namespace graphicData {
kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>; kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>;
index?: number; index?: number;
refIbpMapCode?: string; refIbpMapCode?: string;
stationName?: string;
} = {}; } = {};
if (this.common != null) { if (this.common != null) {
data.common = this.common.toObject(); data.common = this.common.toObject();
@ -1877,6 +1892,9 @@ export namespace graphicData {
if (this.refIbpMapCode != null) { if (this.refIbpMapCode != null) {
data.refIbpMapCode = this.refIbpMapCode; data.refIbpMapCode = this.refIbpMapCode;
} }
if (this.stationName != null) {
data.stationName = this.stationName;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -1895,6 +1913,8 @@ export namespace graphicData {
writer.writeInt32(7, this.index); writer.writeInt32(7, this.index);
if (this.refIbpMapCode.length) if (this.refIbpMapCode.length)
writer.writeString(8, this.refIbpMapCode); writer.writeString(8, this.refIbpMapCode);
if (this.stationName.length)
writer.writeString(9, this.stationName);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -1922,6 +1942,9 @@ export namespace graphicData {
case 8: case 8:
message.refIbpMapCode = reader.readString(); message.refIbpMapCode = reader.readString();
break; break;
case 9:
message.stationName = reader.readString();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }