diff --git a/src/api/Simulation.ts b/src/api/Simulation.ts index 259d381..7ba81c9 100644 --- a/src/api/Simulation.ts +++ b/src/api/Simulation.ts @@ -189,7 +189,7 @@ export interface TccOperationParams { trainId: string; deviceId: number; controlType: request.TrainControl.TrainControlType; - button?: object; + controlButton?: object; driverKey?: object; dirKey?: object; handler?: object; diff --git a/src/components/draw-app/TccDrawProperties.vue b/src/components/draw-app/TccDrawProperties.vue index d9d601d..bca34bd 100644 --- a/src/components/draw-app/TccDrawProperties.vue +++ b/src/components/draw-app/TccDrawProperties.vue @@ -27,6 +27,9 @@ + @@ -44,6 +47,8 @@ import { TccKey } from 'src/graphics/tccKey/TccKey'; import TccKeyProperty from './properties/TccKeyProperty.vue'; import { TccHandle } from 'src/graphics/tccHandle/TccHandle'; import TccHandleProperty from './properties/TccHandleProperty.vue'; +import { TccLight } from 'src/graphics/tccLight/TccLight'; +import TccLightProperty from './properties/TccLightProperty.vue'; const tccDrawStore = useTccDrawStore(); diff --git a/src/components/draw-app/properties/TccButtonProperty.vue b/src/components/draw-app/properties/TccButtonProperty.vue index 742074f..55f7975 100644 --- a/src/components/draw-app/properties/TccButtonProperty.vue +++ b/src/components/draw-app/properties/TccButtonProperty.vue @@ -5,7 +5,7 @@ outlined v-model="tccButtonModel.code" @blur="onUpdate" - label="紧急制动按钮" + label="Tcc按钮" lazy-rules /> + + + + + + + + + diff --git a/src/drawApp/graphics/TccButtonInteraction.ts b/src/drawApp/graphics/TccButtonInteraction.ts index 54ccd08..6d433cb 100644 --- a/src/drawApp/graphics/TccButtonInteraction.ts +++ b/src/drawApp/graphics/TccButtonInteraction.ts @@ -58,12 +58,12 @@ export class TccButtonState extends GraphicStateBase implements ITccButtonState { - constructor(proto?: state.TrainControlState.EmergentButton) { + constructor(proto?: state.TrainControlState.ControlButton) { let states; if (proto) { states = proto; } else { - states = new state.TrainControlState.EmergentButton(); + states = new state.TrainControlState.ControlButton(); } super(states, TccButton.Type); } @@ -76,8 +76,8 @@ export class TccButtonState set down(v: boolean) { this.states.passed = v; } - get states(): state.TrainControlState.EmergentButton { - return this.getState(); + get states(): state.TrainControlState.ControlButton { + return this.getState(); } clone(): TccButtonState { return new TccButtonState(this.states.cloneMessage()); @@ -125,7 +125,7 @@ export class TccButtonOperateInteraction extends GraphicInteractionPlugin { diff --git a/src/drawApp/graphics/TccLightInteraction.ts b/src/drawApp/graphics/TccLightInteraction.ts new file mode 100644 index 0000000..42e46c1 --- /dev/null +++ b/src/drawApp/graphics/TccLightInteraction.ts @@ -0,0 +1,88 @@ +import * as pb_1 from 'google-protobuf'; +import { + ItccLightData, + ItccLightState, + TccLight, +} from 'src/graphics/tccLight/TccLight'; +import { tccGraphicData } from 'src/protos/tccGraphics'; +import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; +import { state } from 'src/protos/device_state'; + +export class TccLightData extends GraphicDataBase implements ItccLightData { + constructor(data?: tccGraphicData.TccLight) { + let tccLight; + if (data) { + tccLight = data; + } else { + tccLight = new tccGraphicData.TccLight({ + common: GraphicDataBase.defaultCommonInfo(TccLight.Type), + }); + } + super(tccLight); + } + + public get data(): tccGraphicData.TccLight { + return this.getData(); + } + + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get lightColor(): tccGraphicData.TccElementColor { + return this.data.lightColor; + } + set lightColor(v: tccGraphicData.TccElementColor) { + this.data.lightColor = v; + } + get activeLevel(): boolean { + return this.data.activeLevel; + } + set activeLevel(v: boolean) { + this.data.activeLevel = v; + } + clone(): TccLightData { + return new TccLightData(this.data.cloneMessage()); + } + copyFrom(data: TccLightData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: TccLightData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} + +export class TccLightState extends GraphicStateBase implements ItccLightState { + constructor(proto?: state.TrainControlState.ControlButton) { + let states; + if (proto) { + states = proto; + } else { + states = new state.TrainControlState.ControlButton(); + } + super(states, TccLight.Type); + } + get code(): string { + return this.states.id + ''; + } + get active(): boolean { + return this.states.passed; + } + set active(v: boolean) { + this.states.passed = v; + } + get states(): state.TrainControlState.ControlButton { + return this.getState(); + } + clone(): TccLightState { + return new TccLightState(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); + } +} diff --git a/src/drawApp/lineScene.ts b/src/drawApp/lineScene.ts index 37d487e..9199b75 100644 --- a/src/drawApp/lineScene.ts +++ b/src/drawApp/lineScene.ts @@ -470,7 +470,6 @@ function handleSubscribe(lineScene: IGraphicScene) { states.push(new CarWashingState(item)); } }); - console.log(storage.allStatus.trainState, '===='); storage.allStatus.trainState.forEach((item) => { // 列车 if (!item.show) { diff --git a/src/drawApp/tccApp.ts b/src/drawApp/tccApp.ts index 5198803..617f9e4 100644 --- a/src/drawApp/tccApp.ts +++ b/src/drawApp/tccApp.ts @@ -32,6 +32,10 @@ import { TccKeyData, TccKeyState } from './graphics/TccKeyInteraction'; import { TccHandleDraw } from 'src/graphics/tccHandle/TccHandleDrawAssistant'; import { TccHandle, TccHandleTemplate } from 'src/graphics/tccHandle/TccHandle'; import { TccHandleData, TccHandleState } from './graphics/TccHandleInteraction'; +import { TccLightDraw } from 'src/graphics/tccLight/TccLightDrawAssistant'; +import { TccLightData, TccLightState } from './graphics/TccLightInteraction'; +import { TccLight, TccLightTemplate } from 'src/graphics/tccLight/TccLight'; + const UndoOptions: MenuItemOptions = { name: '撤销', @@ -87,6 +91,10 @@ export function initTccDrawApp(): IDrawApp { drawApp, new TccHandleTemplate(new TccHandleData(), new TccHandleState()) ); + new TccLightDraw( + app, + new TccLightTemplate(new TccLightData(), new TccLightState()) + ); // 画布右键菜单 app.registerMenu(DefaultCanvasMenu); @@ -181,6 +189,8 @@ export function saveTccDrawDatas(app: IDrawApp) { storage.tccKeys.push(g.saveData().data); } else if (g instanceof TccHandle) { storage.tccHandles.push(g.saveData().data); + } else if (g instanceof TccLight) { + storage.tccLights.push(g.saveData().data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -214,6 +224,9 @@ export async function loadTccDrawDatas(): Promise { storage.tccTexts.forEach((tccText) => { datas.push(new TccTextData(tccText)); }); + storage.tccLights.forEach((tccLight) => { + datas.push(new TccLightData(tccLight)); + }); return { canvasProperty: storage.canvas, datas: datas, diff --git a/src/drawApp/tccScene.ts b/src/drawApp/tccScene.ts index 5beeca6..66b59df 100644 --- a/src/drawApp/tccScene.ts +++ b/src/drawApp/tccScene.ts @@ -31,6 +31,8 @@ import { TccHandleInteraction, TccHandleState, } from './graphics/TccHandleInteraction'; +import { TccLightTemplate } from 'src/graphics/tccLight/TccLight'; +import { TccLightData, TccLightState } from './graphics/TccLightInteraction'; export function initTccScene(lineApp: IGraphicApp, sceneName: string) { const tccScene = lineApp.initScene(sceneName, { @@ -45,6 +47,7 @@ export function initTccScene(lineApp: IGraphicApp, sceneName: string) { new TextContentTemplate(new TccTextData()), new TccKeyTemplate(new TccKeyData(), new TccKeyState()), new TccHandleTemplate(new TccHandleData(), new TccHandleState()), + new TccLightTemplate(new TccLightData(), new TccLightState()), ]; TccButtonOperateInteraction.init(tccScene); TccKeyInteraction.init(tccScene); @@ -84,9 +87,9 @@ function handleSubscribe(tccScene: IGraphicScene) { messageConverter: (message: Uint8Array) => { const states: GraphicState[] = []; const storage = state.TrainControlState.deserialize(message); - if (storage.ebutton) { - states.push(new TccButtonState(storage.ebutton)); - } + storage.buttons.forEach((button) => { + states.push(new TccButtonState(button)); + }); if (storage.dirKey) { states.push(new TccKeyState(storage.dirKey)); } @@ -130,6 +133,9 @@ async function loadTccDatas(): Promise { storage.tccTexts.forEach((tccText) => { datas.push(new TccTextData(tccText)); }); + storage.tccLights.forEach((tccLight) => { + datas.push(new TccLightData(tccLight)); + }); return Promise.resolve({ canvasProperty: storage.canvas, datas: datas, diff --git a/src/graphics/tccButton/TccButton.ts b/src/graphics/tccButton/TccButton.ts index 9bb23c0..9b42c3c 100644 --- a/src/graphics/tccButton/TccButton.ts +++ b/src/graphics/tccButton/TccButton.ts @@ -8,7 +8,6 @@ import Tcc_Button_Assets from './tcc-button-spritesheet.png'; import Tcc_Button_JSON from './tcc-button-data.json'; import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; -import { tccGraphicData } from 'src/protos/tccGraphics'; interface TccButtonTextures { redBtn: Texture; diff --git a/src/graphics/tccButton/TccButtonDrawAssistant.ts b/src/graphics/tccButton/TccButtonDrawAssistant.ts index a2d26af..6e1562f 100644 --- a/src/graphics/tccButton/TccButtonDrawAssistant.ts +++ b/src/graphics/tccButton/TccButtonDrawAssistant.ts @@ -87,7 +87,7 @@ function buildAbsorbablePositions(tccButton: TccButton): AbsorbablePosition[] { } export class TccButtonInteraction extends GraphicInteractionPlugin { - static Name = 'tcc_light_transform'; + static Name = 'tcc_button_transform'; constructor(app: IDrawApp) { super(TccButtonInteraction.Name, app); } diff --git a/src/graphics/tccLight/TccLight.ts b/src/graphics/tccLight/TccLight.ts new file mode 100644 index 0000000..8943cee --- /dev/null +++ b/src/graphics/tccLight/TccLight.ts @@ -0,0 +1,99 @@ +import { + GraphicData, + GraphicState, + JlGraphic, + JlGraphicTemplate, +} from 'jl-graphic'; +import tcc_Light_Assets from './tcc-light-spritesheet.png'; +import tcc_Light_JSON from './tcc-light-data.json'; + +import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; +import { tccGraphicData } from 'src/protos/tccGraphics'; + +interface TccLightTextures { + redOn: Texture; + redOff: Texture; + greenOn: Texture; + greenOff: Texture; + blueOn: Texture; + blueOff: Texture; +} + +export interface ItccLightData extends GraphicData { + get code(): string; + set code(v: string); + get lightColor(): tccGraphicData.TccElementColor; + set lightColor(v: tccGraphicData.TccElementColor); + get activeLevel(): boolean; + set activeLevel(v: boolean); +} + +export interface ItccLightState extends GraphicState { + id?: number; + get active(): boolean; + set active(v: boolean); +} + +export class TccLight extends JlGraphic { + static Type = 'TccLight'; + _tccLight: Sprite; + tccLightTextures: TccLightTextures; + __state = 0; + + constructor(tccLightTextures: TccLightTextures) { + super(TccLight.Type); + this.tccLightTextures = tccLightTextures; + this._tccLight = new Sprite(); + this._tccLight.texture = this.tccLightTextures.greenOff; + this._tccLight.scale.set(0.25); + this._tccLight.anchor.set(0.5); + this.addChild(this._tccLight); + } + get code(): string { + return this.datas.code; + } + get datas(): ItccLightData { + return this.getDatas(); + } + get states(): ItccLightState { + return this.getStates(); + } + doRepaint(): void { + if (this.states.active == this.datas.activeLevel) { + this._tccLight.texture = this.tccLightTextures.greenOn; + } else { + this._tccLight.texture = this.tccLightTextures.greenOff; + } + } +} + +export class TccLightTemplate extends JlGraphicTemplate { + tccLightTextures?: TccLightTextures; + constructor(dataTemplate: ItccLightData, stateTemplate: ItccLightState) { + super(TccLight.Type, { dataTemplate, stateTemplate }); + this.loadAssets(); + } + new(): TccLight { + if (this.tccLightTextures) { + const g = new TccLight(this.tccLightTextures); + g.loadData(this.datas); + g.loadState(this.states); + return g; + } + throw new Error('资源未加载/加载失败'); + } + async loadAssets(): Promise { + const texture = await Assets.load(tcc_Light_Assets); + const tccLightSheet = new Spritesheet(texture, tcc_Light_JSON); + const result = await tccLightSheet.parse(); + this.tccLightTextures = { + redOff: result['red-off.png'], + redOn: result['red-on.png'], + blueOff: result['blue-off.png'], + blueOn: result['blue-on.png'], + greenOff: result['green-off.png'], + greenOn: result['green-on.png'], + }; + return this.tccLightTextures as TccLightTextures; + } +} diff --git a/src/graphics/tccLight/TccLightDrawAssistant.ts b/src/graphics/tccLight/TccLightDrawAssistant.ts new file mode 100644 index 0000000..045dae1 --- /dev/null +++ b/src/graphics/tccLight/TccLightDrawAssistant.ts @@ -0,0 +1,129 @@ +import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicInteractionPlugin, + GraphicTransformEvent, + IDrawApp, + JlGraphic, +} from 'jl-graphic'; +import { TccButton } from '../tccButton/TccButton'; +import { ItccLightData, TccLight, TccLightTemplate } from './TccLight'; + +export class TccLightDraw extends GraphicDrawAssistant< + TccLightTemplate, + ItccLightData +> { + _tccLight: TccLight | null = null; + constructor(app: IDrawApp, template: TccLightTemplate) { + super(app, template, 'sym_o_lightbulb', 'Tcc灯'); + TccLightInteraction.init(app); + } + + bind(): void { + super.bind(); + if (!this._tccLight) { + this._tccLight = this.graphicTemplate.new(); + this.container.addChild(this._tccLight); + } + } + + public get tccLight(): TccLight { + if (!this._tccLight) { + this._tccLight = this.graphicTemplate.new(); + this.container.addChild(this._tccLight); + } + return this._tccLight; + } + + redraw(cp: Point): void { + this.tccLight.position.copyFrom(cp); + } + onLeftUp(e: FederatedMouseEvent): void { + this.tccLight.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + prepareData(data: ItccLightData): boolean { + data.transform = this.tccLight.saveTransform(); + return true; + } + onEsc(): void { + this.finish(); + } +} + +/** + * 构建吸附线 + * @param tccLight + */ +function buildAbsorbablePositions(tccLight: TccLight): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const TccButtons = tccLight.queryStore.queryByType(TccButton.Type); + const tccLights = tccLight.queryStore.queryByType(TccLight.Type); + const canvas = tccLight.getCanvas(); + TccButtons.forEach((item) => { + 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) + ); + aps.push(ala); + aps.push(alb); + }); + tccLights.forEach((item) => { + if (item.id === tccLight.id) { + return; + } + 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) + ); + aps.push(ala); + aps.push(alb); + }); + + return aps; +} + +export class TccLightInteraction extends GraphicInteractionPlugin { + static Name = 'tcc_light_transform'; + constructor(app: IDrawApp) { + super(TccLightInteraction.Name, app); + } + static init(app: IDrawApp) { + return new TccLightInteraction(app); + } + filter(...grahpics: JlGraphic[]): TccLight[] | undefined { + return grahpics + .filter((g) => g.type === TccLight.Type) + .map((g) => g as TccLight); + } + bind(g: TccLight): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.on('transformstart', this.transformstart, this); + } + unbind(g: TccLight): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + g.off('transformstart', this.transformstart, this); + } + transformstart(e: GraphicTransformEvent) { + const target = e.target as DisplayObject; + const tccLight = target.getGraphic() as TccLight; + tccLight.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(tccLight), + }); + } +} diff --git a/src/graphics/tccLight/tcc-light-data.json b/src/graphics/tccLight/tcc-light-data.json new file mode 100644 index 0000000..225241a --- /dev/null +++ b/src/graphics/tccLight/tcc-light-data.json @@ -0,0 +1,29 @@ +{ + "frames": { + "green-off.png": { + "frame": { "x": 0, "y": 0, "w": 128, "h": 128 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 }, + "sourceSize": { "w": 128, "h": 128 }, + "anchor": { "x": 0.5, "y": 0.5 } + }, + "green-on.png": { + "frame": { "x": 128, "y": 0, "w": 128, "h": 128 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 }, + "sourceSize": { "w": 128, "h": 64 }, + "anchor": { "x": 0.5, "y": 0.5 } + } + }, + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "1.1", + "image": "tcc-light.png", + "format": "RGBA8888", + "size": { "w": 256, "h": 128 }, + "scale": "0.5", + "smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$" + } +} diff --git a/src/graphics/tccLight/tcc-light-spritesheet.png b/src/graphics/tccLight/tcc-light-spritesheet.png new file mode 100644 index 0000000..8f8ffc0 Binary files /dev/null and b/src/graphics/tccLight/tcc-light-spritesheet.png differ diff --git a/src/layouts/TrainControlCabDrawLayout.vue b/src/layouts/TrainControlCabDrawLayout.vue index b77dfc9..85f984f 100644 --- a/src/layouts/TrainControlCabDrawLayout.vue +++ b/src/layouts/TrainControlCabDrawLayout.vue @@ -122,6 +122,7 @@ import { TccButton } from 'src/graphics/tccButton/TccButton'; import { TextContent } from 'src/graphics/textContent/TextContent'; import { TccKey } from 'src/graphics/tccKey/TccKey'; import { TccHandle } from 'src/graphics/tccHandle/TccHandle'; +import { TccLight } from 'src/graphics/tccLight/TccLight'; const $q = useQuasar(); const route = useRoute(); @@ -207,6 +208,7 @@ onMounted(() => { TextContent.Type, TccKey.Type, TccHandle.Type, + TccLight.Type, ]; drawAssistantsTypes.forEach((type) => { const drawAssistant = getTccDrawApp()?.getDrawAssistant(type); diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index 25c3f30..f4ca2de 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -2955,6 +2955,7 @@ export namespace state { atoSendTrainBtn?: boolean; trainIntegrity?: boolean; atpOrAtoBypassState?: boolean; + trainTractionCuted?: boolean; obstacleCheckBtn?: boolean; driverActiveReportBtn?: boolean; brakeHeavyFault?: boolean; @@ -2995,6 +2996,7 @@ export namespace state { atoTractionCommand2?: boolean; atoTractionCommand3?: boolean; mockInfo?: number; + atpCutSwitch?: boolean; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -3098,6 +3100,9 @@ export namespace state { if ("atpOrAtoBypassState" in data && data.atpOrAtoBypassState != undefined) { this.atpOrAtoBypassState = data.atpOrAtoBypassState; } + if ("trainTractionCuted" in data && data.trainTractionCuted != undefined) { + this.trainTractionCuted = data.trainTractionCuted; + } if ("obstacleCheckBtn" in data && data.obstacleCheckBtn != undefined) { this.obstacleCheckBtn = data.obstacleCheckBtn; } @@ -3218,6 +3223,9 @@ export namespace state { if ("mockInfo" in data && data.mockInfo != undefined) { this.mockInfo = data.mockInfo; } + if ("atpCutSwitch" in data && data.atpCutSwitch != undefined) { + this.atpCutSwitch = data.atpCutSwitch; + } } } get lifeSignal() { @@ -3418,6 +3426,12 @@ export namespace state { set atpOrAtoBypassState(value: boolean) { pb_1.Message.setField(this, 33, value); } + get trainTractionCuted() { + return pb_1.Message.getFieldWithDefault(this, 34, false) as boolean; + } + set trainTractionCuted(value: boolean) { + pb_1.Message.setField(this, 34, value); + } get obstacleCheckBtn() { return pb_1.Message.getFieldWithDefault(this, 35, false) as boolean; } @@ -3658,6 +3672,12 @@ export namespace state { set mockInfo(value: number) { pb_1.Message.setField(this, 75, value); } + get atpCutSwitch() { + return pb_1.Message.getFieldWithDefault(this, 76, false) as boolean; + } + set atpCutSwitch(value: boolean) { + pb_1.Message.setField(this, 76, value); + } static fromObject(data: { lifeSignal?: number; tc1Active?: boolean; @@ -3692,6 +3712,7 @@ export namespace state { atoSendTrainBtn?: boolean; trainIntegrity?: boolean; atpOrAtoBypassState?: boolean; + trainTractionCuted?: boolean; obstacleCheckBtn?: boolean; driverActiveReportBtn?: boolean; brakeHeavyFault?: boolean; @@ -3732,6 +3753,7 @@ export namespace state { atoTractionCommand2?: boolean; atoTractionCommand3?: boolean; mockInfo?: number; + atpCutSwitch?: boolean; }): TrainVobcState { const message = new TrainVobcState({}); if (data.lifeSignal != null) { @@ -3833,6 +3855,9 @@ export namespace state { if (data.atpOrAtoBypassState != null) { message.atpOrAtoBypassState = data.atpOrAtoBypassState; } + if (data.trainTractionCuted != null) { + message.trainTractionCuted = data.trainTractionCuted; + } if (data.obstacleCheckBtn != null) { message.obstacleCheckBtn = data.obstacleCheckBtn; } @@ -3953,6 +3978,9 @@ export namespace state { if (data.mockInfo != null) { message.mockInfo = data.mockInfo; } + if (data.atpCutSwitch != null) { + message.atpCutSwitch = data.atpCutSwitch; + } return message; } toObject() { @@ -3990,6 +4018,7 @@ export namespace state { atoSendTrainBtn?: boolean; trainIntegrity?: boolean; atpOrAtoBypassState?: boolean; + trainTractionCuted?: boolean; obstacleCheckBtn?: boolean; driverActiveReportBtn?: boolean; brakeHeavyFault?: boolean; @@ -4030,6 +4059,7 @@ export namespace state { atoTractionCommand2?: boolean; atoTractionCommand3?: boolean; mockInfo?: number; + atpCutSwitch?: boolean; } = {}; if (this.lifeSignal != null) { data.lifeSignal = this.lifeSignal; @@ -4130,6 +4160,9 @@ export namespace state { if (this.atpOrAtoBypassState != null) { data.atpOrAtoBypassState = this.atpOrAtoBypassState; } + if (this.trainTractionCuted != null) { + data.trainTractionCuted = this.trainTractionCuted; + } if (this.obstacleCheckBtn != null) { data.obstacleCheckBtn = this.obstacleCheckBtn; } @@ -4250,6 +4283,9 @@ export namespace state { if (this.mockInfo != null) { data.mockInfo = this.mockInfo; } + if (this.atpCutSwitch != null) { + data.atpCutSwitch = this.atpCutSwitch; + } return data; } serialize(): Uint8Array; @@ -4322,6 +4358,8 @@ export namespace state { writer.writeBool(32, this.trainIntegrity); if (this.atpOrAtoBypassState != false) writer.writeBool(33, this.atpOrAtoBypassState); + if (this.trainTractionCuted != false) + writer.writeBool(34, this.trainTractionCuted); if (this.obstacleCheckBtn != false) writer.writeBool(35, this.obstacleCheckBtn); if (this.driverActiveReportBtn != false) @@ -4402,6 +4440,8 @@ export namespace state { writer.writeBool(74, this.atoTractionCommand3); if (this.mockInfo != 0) writer.writeUint32(75, this.mockInfo); + if (this.atpCutSwitch != false) + writer.writeBool(76, this.atpCutSwitch); if (!w) return writer.getResultBuffer(); } @@ -4510,6 +4550,9 @@ export namespace state { case 33: message.atpOrAtoBypassState = reader.readBool(); break; + case 34: + message.trainTractionCuted = reader.readBool(); + break; case 35: message.obstacleCheckBtn = reader.readBool(); break; @@ -4630,6 +4673,9 @@ export namespace state { case 75: message.mockInfo = reader.readUint32(); break; + case 76: + message.atpCutSwitch = reader.readBool(); + break; default: reader.skipField(); } } @@ -9994,16 +10040,16 @@ export namespace state { export class TrainControlState extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - ebutton?: TrainControlState.EmergentButton; + buttons?: TrainControlState.ControlButton[]; driverKey?: TrainControlState.DriverKeySwitch[]; dirKey?: TrainControlState.DirectionKeySwitch; pushHandler?: TrainControlState.PushHandler; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { - if ("ebutton" in data && data.ebutton != undefined) { - this.ebutton = data.ebutton; + if ("buttons" in data && data.buttons != undefined) { + this.buttons = data.buttons; } if ("driverKey" in data && data.driverKey != undefined) { this.driverKey = data.driverKey; @@ -10016,14 +10062,11 @@ export namespace state { } } } - get ebutton() { - return pb_1.Message.getWrapperField(this, TrainControlState.EmergentButton, 1) as TrainControlState.EmergentButton; + get buttons() { + return pb_1.Message.getRepeatedWrapperField(this, TrainControlState.ControlButton, 1) as TrainControlState.ControlButton[]; } - set ebutton(value: TrainControlState.EmergentButton) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_ebutton() { - return pb_1.Message.getField(this, 1) != null; + set buttons(value: TrainControlState.ControlButton[]) { + pb_1.Message.setRepeatedWrapperField(this, 1, value); } get driverKey() { return pb_1.Message.getRepeatedWrapperField(this, TrainControlState.DriverKeySwitch, 2) as TrainControlState.DriverKeySwitch[]; @@ -10050,14 +10093,14 @@ export namespace state { return pb_1.Message.getField(this, 4) != null; } static fromObject(data: { - ebutton?: ReturnType; + buttons?: ReturnType[]; driverKey?: ReturnType[]; dirKey?: ReturnType; pushHandler?: ReturnType; }): TrainControlState { const message = new TrainControlState({}); - if (data.ebutton != null) { - message.ebutton = TrainControlState.EmergentButton.fromObject(data.ebutton); + if (data.buttons != null) { + message.buttons = data.buttons.map(item => TrainControlState.ControlButton.fromObject(item)); } if (data.driverKey != null) { message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item)); @@ -10072,13 +10115,13 @@ export namespace state { } toObject() { const data: { - ebutton?: ReturnType; + buttons?: ReturnType[]; driverKey?: ReturnType[]; dirKey?: ReturnType; pushHandler?: ReturnType; } = {}; - if (this.ebutton != null) { - data.ebutton = this.ebutton.toObject(); + if (this.buttons != null) { + data.buttons = this.buttons.map((item: TrainControlState.ControlButton) => item.toObject()); } if (this.driverKey != null) { data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject()); @@ -10095,8 +10138,8 @@ export namespace state { serialize(w: pb_1.BinaryWriter): void; serialize(w?: pb_1.BinaryWriter): Uint8Array | void { const writer = w || new pb_1.BinaryWriter(); - if (this.has_ebutton) - writer.writeMessage(1, this.ebutton, () => this.ebutton.serialize(writer)); + if (this.buttons.length) + writer.writeRepeatedMessage(1, this.buttons, (item: TrainControlState.ControlButton) => item.serialize(writer)); if (this.driverKey.length) writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer)); if (this.has_dirKey) @@ -10113,7 +10156,7 @@ export namespace state { break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.ebutton, () => message.ebutton = TrainControlState.EmergentButton.deserialize(reader)); + reader.readMessage(message.buttons, () => pb_1.Message.addToRepeatedWrapperField(message, 1, TrainControlState.ControlButton.deserialize(reader), TrainControlState.ControlButton)); break; case 2: reader.readMessage(message.driverKey, () => pb_1.Message.addToRepeatedWrapperField(message, 2, TrainControlState.DriverKeySwitch.deserialize(reader), TrainControlState.DriverKeySwitch)); @@ -10137,7 +10180,7 @@ export namespace state { } } export namespace TrainControlState { - export class EmergentButton extends pb_1.Message { + export class ControlButton extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { id?: number; @@ -10169,8 +10212,8 @@ export namespace state { static fromObject(data: { id?: number; passed?: boolean; - }): EmergentButton { - const message = new EmergentButton({}); + }): ControlButton { + const message = new ControlButton({}); if (data.id != null) { message.id = data.id; } @@ -10203,8 +10246,8 @@ export namespace state { if (!w) return writer.getResultBuffer(); } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): EmergentButton { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new EmergentButton(); + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ControlButton { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ControlButton(); while (reader.nextField()) { if (reader.isEndGroup()) break; @@ -10223,8 +10266,8 @@ export namespace state { serializeBinary(): Uint8Array { return this.serialize(); } - static deserializeBinary(bytes: Uint8Array): EmergentButton { - return EmergentButton.deserialize(bytes); + static deserializeBinary(bytes: Uint8Array): ControlButton { + return ControlButton.deserialize(bytes); } } export class DriverKeySwitch extends pb_1.Message { diff --git a/src/protos/request.ts b/src/protos/request.ts index ebcb81b..c23e593 100644 --- a/src/protos/request.ts +++ b/src/protos/request.ts @@ -1421,7 +1421,7 @@ export namespace request { trainId?: string; deviceId?: number; controlType?: TrainControl.TrainControlType; - button?: TrainControl.EmergentButton; + controlButton?: TrainControl.ControlButton; driverKey?: TrainControl.DriverKeySwitch; dirKey?: TrainControl.DirectionKeySwitch; handler?: TrainControl.PushHandler; @@ -1441,8 +1441,8 @@ export namespace request { if ("controlType" in data && data.controlType != undefined) { this.controlType = data.controlType; } - if ("button" in data && data.button != undefined) { - this.button = data.button; + if ("controlButton" in data && data.controlButton != undefined) { + this.controlButton = data.controlButton; } if ("driverKey" in data && data.driverKey != undefined) { this.driverKey = data.driverKey; @@ -1479,13 +1479,13 @@ export namespace request { set controlType(value: TrainControl.TrainControlType) { pb_1.Message.setField(this, 4, value); } - get button() { - return pb_1.Message.getWrapperField(this, TrainControl.EmergentButton, 5) as TrainControl.EmergentButton; + get controlButton() { + return pb_1.Message.getWrapperField(this, TrainControl.ControlButton, 5) as TrainControl.ControlButton; } - set button(value: TrainControl.EmergentButton) { + set controlButton(value: TrainControl.ControlButton) { pb_1.Message.setWrapperField(this, 5, value); } - get has_button() { + get has_controlButton() { return pb_1.Message.getField(this, 5) != null; } get driverKey() { @@ -1520,7 +1520,7 @@ export namespace request { trainId?: string; deviceId?: number; controlType?: TrainControl.TrainControlType; - button?: ReturnType; + controlButton?: ReturnType; driverKey?: ReturnType; dirKey?: ReturnType; handler?: ReturnType; @@ -1538,8 +1538,8 @@ export namespace request { if (data.controlType != null) { message.controlType = data.controlType; } - if (data.button != null) { - message.button = TrainControl.EmergentButton.fromObject(data.button); + if (data.controlButton != null) { + message.controlButton = TrainControl.ControlButton.fromObject(data.controlButton); } if (data.driverKey != null) { message.driverKey = TrainControl.DriverKeySwitch.fromObject(data.driverKey); @@ -1558,7 +1558,7 @@ export namespace request { trainId?: string; deviceId?: number; controlType?: TrainControl.TrainControlType; - button?: ReturnType; + controlButton?: ReturnType; driverKey?: ReturnType; dirKey?: ReturnType; handler?: ReturnType; @@ -1575,8 +1575,8 @@ export namespace request { if (this.controlType != null) { data.controlType = this.controlType; } - if (this.button != null) { - data.button = this.button.toObject(); + if (this.controlButton != null) { + data.controlButton = this.controlButton.toObject(); } if (this.driverKey != null) { data.driverKey = this.driverKey.toObject(); @@ -1601,8 +1601,8 @@ export namespace request { writer.writeUint32(3, this.deviceId); if (this.controlType != TrainControl.TrainControlType.EMERGENT_BUTTON) writer.writeEnum(4, this.controlType); - if (this.has_button) - writer.writeMessage(5, this.button, () => this.button.serialize(writer)); + if (this.has_controlButton) + writer.writeMessage(5, this.controlButton, () => this.controlButton.serialize(writer)); if (this.has_driverKey) writer.writeMessage(6, this.driverKey, () => this.driverKey.serialize(writer)); if (this.has_dirKey) @@ -1631,7 +1631,7 @@ export namespace request { message.controlType = reader.readEnum(); break; case 5: - reader.readMessage(message.button, () => message.button = TrainControl.EmergentButton.deserialize(reader)); + reader.readMessage(message.controlButton, () => message.controlButton = TrainControl.ControlButton.deserialize(reader)); break; case 6: reader.readMessage(message.driverKey, () => message.driverKey = TrainControl.DriverKeySwitch.deserialize(reader)); @@ -1666,6 +1666,73 @@ export namespace request { FORWARD = 1, NEUTRALWARD = 2 } + export class ControlButton extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + active?: boolean; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("active" in data && data.active != undefined) { + this.active = data.active; + } + } + } + get active() { + return pb_1.Message.getFieldWithDefault(this, 1, false) as boolean; + } + set active(value: boolean) { + pb_1.Message.setField(this, 1, value); + } + static fromObject(data: { + active?: boolean; + }): ControlButton { + const message = new ControlButton({}); + if (data.active != null) { + message.active = data.active; + } + return message; + } + toObject() { + const data: { + active?: boolean; + } = {}; + if (this.active != null) { + data.active = this.active; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.active != false) + writer.writeBool(1, this.active); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ControlButton { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ControlButton(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.active = reader.readBool(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): ControlButton { + return ControlButton.deserialize(bytes); + } + } export class EmergentButton extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { diff --git a/src/protos/tccGraphics.ts b/src/protos/tccGraphics.ts index db13d88..158c176 100644 --- a/src/protos/tccGraphics.ts +++ b/src/protos/tccGraphics.ts @@ -6,6 +6,11 @@ import * as dependency_1 from "./stationLayoutGraphics"; import * as pb_1 from "google-protobuf"; export namespace tccGraphicData { + export enum TccElementColor { + green = 0, + red = 1, + blue = 2 + } export class TccGraphicStorage extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -14,9 +19,10 @@ export namespace tccGraphicData { tccTexts?: TccText[]; tccKeys?: TccKey[]; tccHandles?: TccHandle[]; + tccLights?: TccLight[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -33,6 +39,9 @@ export namespace tccGraphicData { if ("tccHandles" in data && data.tccHandles != undefined) { this.tccHandles = data.tccHandles; } + if ("tccLights" in data && data.tccLights != undefined) { + this.tccLights = data.tccLights; + } } } get canvas() { @@ -68,12 +77,19 @@ export namespace tccGraphicData { set tccHandles(value: TccHandle[]) { pb_1.Message.setRepeatedWrapperField(this, 5, value); } + get tccLights() { + return pb_1.Message.getRepeatedWrapperField(this, TccLight, 6) as TccLight[]; + } + set tccLights(value: TccLight[]) { + pb_1.Message.setRepeatedWrapperField(this, 6, value); + } static fromObject(data: { canvas?: ReturnType; tccButtons?: ReturnType[]; tccTexts?: ReturnType[]; tccKeys?: ReturnType[]; tccHandles?: ReturnType[]; + tccLights?: ReturnType[]; }): TccGraphicStorage { const message = new TccGraphicStorage({}); if (data.canvas != null) { @@ -91,6 +107,9 @@ export namespace tccGraphicData { if (data.tccHandles != null) { message.tccHandles = data.tccHandles.map(item => TccHandle.fromObject(item)); } + if (data.tccLights != null) { + message.tccLights = data.tccLights.map(item => TccLight.fromObject(item)); + } return message; } toObject() { @@ -100,6 +119,7 @@ export namespace tccGraphicData { tccTexts?: ReturnType[]; tccKeys?: ReturnType[]; tccHandles?: ReturnType[]; + tccLights?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -116,6 +136,9 @@ export namespace tccGraphicData { if (this.tccHandles != null) { data.tccHandles = this.tccHandles.map((item: TccHandle) => item.toObject()); } + if (this.tccLights != null) { + data.tccLights = this.tccLights.map((item: TccLight) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -132,6 +155,8 @@ export namespace tccGraphicData { writer.writeRepeatedMessage(4, this.tccKeys, (item: TccKey) => item.serialize(writer)); if (this.tccHandles.length) writer.writeRepeatedMessage(5, this.tccHandles, (item: TccHandle) => item.serialize(writer)); + if (this.tccLights.length) + writer.writeRepeatedMessage(6, this.tccLights, (item: TccLight) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -156,6 +181,9 @@ export namespace tccGraphicData { case 5: reader.readMessage(message.tccHandles, () => pb_1.Message.addToRepeatedWrapperField(message, 5, TccHandle.deserialize(reader), TccHandle)); break; + case 6: + reader.readMessage(message.tccLights, () => pb_1.Message.addToRepeatedWrapperField(message, 6, TccLight.deserialize(reader), TccLight)); + break; default: reader.skipField(); } } @@ -661,4 +689,143 @@ export namespace tccGraphicData { return TccHandle.deserialize(bytes); } } + export class TccLight extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: dependency_1.graphicData.CommonInfo; + code?: string; + lightColor?: TccElementColor; + activeLevel?: boolean; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("lightColor" in data && data.lightColor != undefined) { + this.lightColor = data.lightColor; + } + if ("activeLevel" in data && data.activeLevel != undefined) { + this.activeLevel = data.activeLevel; + } + } + } + get common() { + return pb_1.Message.getWrapperField(this, dependency_1.graphicData.CommonInfo, 1) as dependency_1.graphicData.CommonInfo; + } + set common(value: dependency_1.graphicData.CommonInfo) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_common() { + return pb_1.Message.getField(this, 1) != null; + } + get code() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set code(value: string) { + pb_1.Message.setField(this, 2, value); + } + get lightColor() { + return pb_1.Message.getFieldWithDefault(this, 3, TccElementColor.green) as TccElementColor; + } + set lightColor(value: TccElementColor) { + pb_1.Message.setField(this, 3, value); + } + get activeLevel() { + return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; + } + set activeLevel(value: boolean) { + pb_1.Message.setField(this, 4, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + lightColor?: TccElementColor; + activeLevel?: boolean; + }): TccLight { + const message = new TccLight({}); + if (data.common != null) { + message.common = dependency_1.graphicData.CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.lightColor != null) { + message.lightColor = data.lightColor; + } + if (data.activeLevel != null) { + message.activeLevel = data.activeLevel; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + lightColor?: TccElementColor; + activeLevel?: boolean; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.lightColor != null) { + data.lightColor = this.lightColor; + } + if (this.activeLevel != null) { + data.activeLevel = this.activeLevel; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_common) + writer.writeMessage(1, this.common, () => this.common.serialize(writer)); + if (this.code.length) + writer.writeString(2, this.code); + if (this.lightColor != TccElementColor.green) + writer.writeEnum(3, this.lightColor); + if (this.activeLevel != false) + writer.writeBool(4, this.activeLevel); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TccLight { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TccLight(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.common, () => message.common = dependency_1.graphicData.CommonInfo.deserialize(reader)); + break; + case 2: + message.code = reader.readString(); + break; + case 3: + message.lightColor = reader.readEnum(); + break; + case 4: + message.activeLevel = reader.readBool(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): TccLight { + return TccLight.deserialize(bytes); + } + } }