psl旁路操作
This commit is contained in:
parent
fd2e8bd975
commit
949b173603
@ -169,6 +169,21 @@ export async function ibpKeyOperation(params: IbpKeyOperationParams) {
|
||||
return await api.post(`${UriBase}/ibp/key/operation`, params);
|
||||
}
|
||||
|
||||
export interface BypassOperationParams {
|
||||
simulationId: string;
|
||||
mapId: number;
|
||||
deviceId: number;
|
||||
deviceCode: string;
|
||||
stationId?: number;
|
||||
gateBoxId?: number;
|
||||
operation: request.BypassOperationReq.Operation;
|
||||
btnType: request.BypassOperationReq.BtnType;
|
||||
}
|
||||
|
||||
export async function bypassOperation(params: BypassOperationParams) {
|
||||
return await api.post(`${UriBase}/bypass/operation`, params);
|
||||
}
|
||||
|
||||
export function checkMapData(data: { mapProto: string }) {
|
||||
return api.post(`${UriBase}/check/data`, data);
|
||||
}
|
||||
|
@ -5,18 +5,21 @@ import {
|
||||
PslButton,
|
||||
} from 'src/graphics/pslButton/pslButton';
|
||||
import {
|
||||
ContextMenu,
|
||||
GraphicInteractionPlugin,
|
||||
IGraphicScene,
|
||||
JlGraphic,
|
||||
MenuItemOptions,
|
||||
} from 'jl-graphic';
|
||||
import { pslGraphicData } from 'src/protos/pslGraphics';
|
||||
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
|
||||
import { pslOperate } from 'src/api/Simulation';
|
||||
import { bypassOperation, pslOperate } from 'src/api/Simulation';
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
|
||||
import { errorNotify } from 'src/utils/CommonNotify';
|
||||
import { usePslStore } from 'src/stores/psl-store';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import { request } from 'src/protos/request';
|
||||
|
||||
export class PslButtonData extends GraphicDataBase implements IPslButtonData {
|
||||
constructor(data?: pslGraphicData.PslButton) {
|
||||
@ -65,7 +68,8 @@ export class PslButtonData extends GraphicDataBase implements IPslButtonData {
|
||||
}
|
||||
export class PslButtonState
|
||||
extends GraphicStateBase
|
||||
implements IPslButtonState {
|
||||
implements IPslButtonState
|
||||
{
|
||||
constructor(proto?: state.ButtonState) {
|
||||
let states;
|
||||
if (proto) {
|
||||
@ -98,10 +102,26 @@ export class PslButtonState
|
||||
}
|
||||
}
|
||||
|
||||
const bypassConfig: MenuItemOptions = {
|
||||
name: '旁路',
|
||||
};
|
||||
const bypassResetConfig: MenuItemOptions = {
|
||||
name: '旁路复位',
|
||||
};
|
||||
const PslButtonMenu: ContextMenu = ContextMenu.init({
|
||||
name: 'Psl按钮编辑菜单',
|
||||
groups: [
|
||||
{
|
||||
items: [bypassConfig, bypassResetConfig],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslButton> {
|
||||
static Name = 'psl_button_operate_menu';
|
||||
constructor(app: IGraphicScene) {
|
||||
super(PslButtonOperateInteraction.Name, app);
|
||||
app.registerMenu(PslButtonMenu);
|
||||
}
|
||||
static init(app: IGraphicScene) {
|
||||
return new PslButtonOperateInteraction(app);
|
||||
@ -117,6 +137,7 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
|
||||
g.on('mousedown', this.onMouseDown, this);
|
||||
g.on('mouseup', this.onMouseUp, this);
|
||||
g.on('mouseout', this.onMouseOut, this);
|
||||
g.on('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
|
||||
unbind(g: PslButton): void {
|
||||
@ -124,6 +145,7 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
|
||||
g.off('mousedown', this.onMouseDown, this);
|
||||
g.on('mouseup', this.onMouseUp, this);
|
||||
g.on('mouseout', this.onMouseOut, this);
|
||||
g.off('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
onMouseOut(e: FederatedMouseEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
@ -181,4 +203,47 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
}
|
||||
onContextMenu(e: FederatedMouseEvent) {
|
||||
const simulationId = useLineStore().simulationId;
|
||||
const mapId = useLineStore().mapId;
|
||||
const gateBoxId = usePslStore().gatedBoxId;
|
||||
const target = e.target as DisplayObject;
|
||||
const pslButton = target.getGraphic() as PslButton;
|
||||
this.app.updateSelected(pslButton);
|
||||
bypassConfig.handler = () => {
|
||||
if (!simulationId || !mapId) {
|
||||
return;
|
||||
}
|
||||
bypassOperation({
|
||||
simulationId,
|
||||
mapId,
|
||||
deviceId: pslButton.id,
|
||||
deviceCode: pslButton.datas.code,
|
||||
gateBoxId,
|
||||
operation: request.BypassOperationReq.Operation.bypass,
|
||||
btnType: request.BypassOperationReq.BtnType.pls_btn,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
};
|
||||
bypassResetConfig.handler = () => {
|
||||
bypassConfig.handler = () => {
|
||||
if (!simulationId || !mapId) {
|
||||
return;
|
||||
}
|
||||
bypassOperation({
|
||||
simulationId,
|
||||
mapId,
|
||||
deviceId: pslButton.id,
|
||||
deviceCode: pslButton.datas.code,
|
||||
gateBoxId,
|
||||
operation: request.BypassOperationReq.Operation.bypass_reset,
|
||||
btnType: request.BypassOperationReq.BtnType.pls_btn,
|
||||
}).catch((err) => {
|
||||
errorNotify('操作失败', { message: err.origin.response.data.title });
|
||||
});
|
||||
};
|
||||
};
|
||||
PslButtonMenu.open(e.global);
|
||||
}
|
||||
}
|
||||
|
@ -5079,6 +5079,7 @@ export namespace state {
|
||||
id?: number;
|
||||
down?: boolean;
|
||||
active?: boolean;
|
||||
bypass?: boolean;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@ -5092,6 +5093,9 @@ export namespace state {
|
||||
if ("active" in data && data.active != undefined) {
|
||||
this.active = data.active;
|
||||
}
|
||||
if ("bypass" in data && data.bypass != undefined) {
|
||||
this.bypass = data.bypass;
|
||||
}
|
||||
}
|
||||
}
|
||||
get id() {
|
||||
@ -5112,10 +5116,17 @@ export namespace state {
|
||||
set active(value: boolean) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get bypass() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean;
|
||||
}
|
||||
set bypass(value: boolean) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
id?: number;
|
||||
down?: boolean;
|
||||
active?: boolean;
|
||||
bypass?: boolean;
|
||||
}): ButtonState {
|
||||
const message = new ButtonState({});
|
||||
if (data.id != null) {
|
||||
@ -5127,6 +5138,9 @@ export namespace state {
|
||||
if (data.active != null) {
|
||||
message.active = data.active;
|
||||
}
|
||||
if (data.bypass != null) {
|
||||
message.bypass = data.bypass;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@ -5134,6 +5148,7 @@ export namespace state {
|
||||
id?: number;
|
||||
down?: boolean;
|
||||
active?: boolean;
|
||||
bypass?: boolean;
|
||||
} = {};
|
||||
if (this.id != null) {
|
||||
data.id = this.id;
|
||||
@ -5144,6 +5159,9 @@ export namespace state {
|
||||
if (this.active != null) {
|
||||
data.active = this.active;
|
||||
}
|
||||
if (this.bypass != null) {
|
||||
data.bypass = this.bypass;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -5156,6 +5174,8 @@ export namespace state {
|
||||
writer.writeBool(2, this.down);
|
||||
if (this.active != false)
|
||||
writer.writeBool(3, this.active);
|
||||
if (this.bypass != false)
|
||||
writer.writeBool(4, this.bypass);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -5174,6 +5194,9 @@ export namespace state {
|
||||
case 3:
|
||||
message.active = reader.readBool();
|
||||
break;
|
||||
case 4:
|
||||
message.bypass = reader.readBool();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@ -5669,6 +5692,7 @@ export namespace state {
|
||||
constructor(data?: any[] | {
|
||||
id?: number;
|
||||
gear?: number;
|
||||
bypass?: boolean;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@ -5679,6 +5703,9 @@ export namespace state {
|
||||
if ("gear" in data && data.gear != undefined) {
|
||||
this.gear = data.gear;
|
||||
}
|
||||
if ("bypass" in data && data.bypass != undefined) {
|
||||
this.bypass = data.bypass;
|
||||
}
|
||||
}
|
||||
}
|
||||
get id() {
|
||||
@ -5693,9 +5720,16 @@ export namespace state {
|
||||
set gear(value: number) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get bypass() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
|
||||
}
|
||||
set bypass(value: boolean) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
id?: number;
|
||||
gear?: number;
|
||||
bypass?: boolean;
|
||||
}): KeyState {
|
||||
const message = new KeyState({});
|
||||
if (data.id != null) {
|
||||
@ -5704,12 +5738,16 @@ export namespace state {
|
||||
if (data.gear != null) {
|
||||
message.gear = data.gear;
|
||||
}
|
||||
if (data.bypass != null) {
|
||||
message.bypass = data.bypass;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
id?: number;
|
||||
gear?: number;
|
||||
bypass?: boolean;
|
||||
} = {};
|
||||
if (this.id != null) {
|
||||
data.id = this.id;
|
||||
@ -5717,6 +5755,9 @@ export namespace state {
|
||||
if (this.gear != null) {
|
||||
data.gear = this.gear;
|
||||
}
|
||||
if (this.bypass != null) {
|
||||
data.bypass = this.bypass;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -5727,6 +5768,8 @@ export namespace state {
|
||||
writer.writeUint32(1, this.id);
|
||||
if (this.gear != 0)
|
||||
writer.writeInt32(2, this.gear);
|
||||
if (this.bypass != false)
|
||||
writer.writeBool(3, this.bypass);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -5742,6 +5785,9 @@ export namespace state {
|
||||
case 2:
|
||||
message.gear = reader.readInt32();
|
||||
break;
|
||||
case 3:
|
||||
message.bypass = reader.readBool();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,246 @@
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as pb_1 from "google-protobuf";
|
||||
export namespace request {
|
||||
export class BypassOperationReq extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
simulationId?: string;
|
||||
mapId?: number;
|
||||
deviceId?: number;
|
||||
deviceCode?: string;
|
||||
stationId?: number;
|
||||
gateBoxId?: number;
|
||||
operation?: BypassOperationReq.Operation;
|
||||
btnType?: BypassOperationReq.BtnType;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("simulationId" in data && data.simulationId != undefined) {
|
||||
this.simulationId = data.simulationId;
|
||||
}
|
||||
if ("mapId" in data && data.mapId != undefined) {
|
||||
this.mapId = data.mapId;
|
||||
}
|
||||
if ("deviceId" in data && data.deviceId != undefined) {
|
||||
this.deviceId = data.deviceId;
|
||||
}
|
||||
if ("deviceCode" in data && data.deviceCode != undefined) {
|
||||
this.deviceCode = data.deviceCode;
|
||||
}
|
||||
if ("stationId" in data && data.stationId != undefined) {
|
||||
this.stationId = data.stationId;
|
||||
}
|
||||
if ("gateBoxId" in data && data.gateBoxId != undefined) {
|
||||
this.gateBoxId = data.gateBoxId;
|
||||
}
|
||||
if ("operation" in data && data.operation != undefined) {
|
||||
this.operation = data.operation;
|
||||
}
|
||||
if ("btnType" in data && data.btnType != undefined) {
|
||||
this.btnType = data.btnType;
|
||||
}
|
||||
}
|
||||
}
|
||||
get simulationId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
|
||||
}
|
||||
set simulationId(value: string) {
|
||||
pb_1.Message.setField(this, 1, value);
|
||||
}
|
||||
get mapId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
|
||||
}
|
||||
set mapId(value: number) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get deviceId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
|
||||
}
|
||||
set deviceId(value: number) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get deviceCode() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||
}
|
||||
set deviceCode(value: string) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
get stationId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 6, 0) as number;
|
||||
}
|
||||
set stationId(value: number) {
|
||||
pb_1.Message.setField(this, 6, value);
|
||||
}
|
||||
get gateBoxId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 7, 0) as number;
|
||||
}
|
||||
set gateBoxId(value: number) {
|
||||
pb_1.Message.setField(this, 7, value);
|
||||
}
|
||||
get operation() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 8, BypassOperationReq.Operation.bypass) as BypassOperationReq.Operation;
|
||||
}
|
||||
set operation(value: BypassOperationReq.Operation) {
|
||||
pb_1.Message.setField(this, 8, value);
|
||||
}
|
||||
get btnType() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 9, BypassOperationReq.BtnType.esb_btn) as BypassOperationReq.BtnType;
|
||||
}
|
||||
set btnType(value: BypassOperationReq.BtnType) {
|
||||
pb_1.Message.setField(this, 9, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
simulationId?: string;
|
||||
mapId?: number;
|
||||
deviceId?: number;
|
||||
deviceCode?: string;
|
||||
stationId?: number;
|
||||
gateBoxId?: number;
|
||||
operation?: BypassOperationReq.Operation;
|
||||
btnType?: BypassOperationReq.BtnType;
|
||||
}): BypassOperationReq {
|
||||
const message = new BypassOperationReq({});
|
||||
if (data.simulationId != null) {
|
||||
message.simulationId = data.simulationId;
|
||||
}
|
||||
if (data.mapId != null) {
|
||||
message.mapId = data.mapId;
|
||||
}
|
||||
if (data.deviceId != null) {
|
||||
message.deviceId = data.deviceId;
|
||||
}
|
||||
if (data.deviceCode != null) {
|
||||
message.deviceCode = data.deviceCode;
|
||||
}
|
||||
if (data.stationId != null) {
|
||||
message.stationId = data.stationId;
|
||||
}
|
||||
if (data.gateBoxId != null) {
|
||||
message.gateBoxId = data.gateBoxId;
|
||||
}
|
||||
if (data.operation != null) {
|
||||
message.operation = data.operation;
|
||||
}
|
||||
if (data.btnType != null) {
|
||||
message.btnType = data.btnType;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
simulationId?: string;
|
||||
mapId?: number;
|
||||
deviceId?: number;
|
||||
deviceCode?: string;
|
||||
stationId?: number;
|
||||
gateBoxId?: number;
|
||||
operation?: BypassOperationReq.Operation;
|
||||
btnType?: BypassOperationReq.BtnType;
|
||||
} = {};
|
||||
if (this.simulationId != null) {
|
||||
data.simulationId = this.simulationId;
|
||||
}
|
||||
if (this.mapId != null) {
|
||||
data.mapId = this.mapId;
|
||||
}
|
||||
if (this.deviceId != null) {
|
||||
data.deviceId = this.deviceId;
|
||||
}
|
||||
if (this.deviceCode != null) {
|
||||
data.deviceCode = this.deviceCode;
|
||||
}
|
||||
if (this.stationId != null) {
|
||||
data.stationId = this.stationId;
|
||||
}
|
||||
if (this.gateBoxId != null) {
|
||||
data.gateBoxId = this.gateBoxId;
|
||||
}
|
||||
if (this.operation != null) {
|
||||
data.operation = this.operation;
|
||||
}
|
||||
if (this.btnType != null) {
|
||||
data.btnType = this.btnType;
|
||||
}
|
||||
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.simulationId.length)
|
||||
writer.writeString(1, this.simulationId);
|
||||
if (this.mapId != 0)
|
||||
writer.writeInt32(2, this.mapId);
|
||||
if (this.deviceId != 0)
|
||||
writer.writeUint32(3, this.deviceId);
|
||||
if (this.deviceCode.length)
|
||||
writer.writeString(5, this.deviceCode);
|
||||
if (this.stationId != 0)
|
||||
writer.writeUint32(6, this.stationId);
|
||||
if (this.gateBoxId != 0)
|
||||
writer.writeUint32(7, this.gateBoxId);
|
||||
if (this.operation != BypassOperationReq.Operation.bypass)
|
||||
writer.writeEnum(8, this.operation);
|
||||
if (this.btnType != BypassOperationReq.BtnType.esb_btn)
|
||||
writer.writeEnum(9, this.btnType);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BypassOperationReq {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BypassOperationReq();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
message.simulationId = reader.readString();
|
||||
break;
|
||||
case 2:
|
||||
message.mapId = reader.readInt32();
|
||||
break;
|
||||
case 3:
|
||||
message.deviceId = reader.readUint32();
|
||||
break;
|
||||
case 5:
|
||||
message.deviceCode = reader.readString();
|
||||
break;
|
||||
case 6:
|
||||
message.stationId = reader.readUint32();
|
||||
break;
|
||||
case 7:
|
||||
message.gateBoxId = reader.readUint32();
|
||||
break;
|
||||
case 8:
|
||||
message.operation = reader.readEnum();
|
||||
break;
|
||||
case 9:
|
||||
message.btnType = reader.readEnum();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): BypassOperationReq {
|
||||
return BypassOperationReq.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export namespace BypassOperationReq {
|
||||
export enum Operation {
|
||||
bypass = 0,
|
||||
bypass_reset = 1
|
||||
}
|
||||
export enum BtnType {
|
||||
esb_btn = 0,
|
||||
ibp_btn = 1,
|
||||
ibp_key = 2,
|
||||
pls_btn = 3
|
||||
}
|
||||
}
|
||||
export class Relay extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {}) {
|
||||
|
Loading…
Reference in New Issue
Block a user