屏蔽门操作添加

This commit is contained in:
fan 2023-11-02 16:51:21 +08:00
parent bbb3c80b0b
commit 23bf0ee1a0
12 changed files with 550 additions and 38 deletions

@ -1 +1 @@
Subproject commit 2a14cd39d1e50848eff33df9cb163a453cde0668
Subproject commit 92c5696b7eb3b47b387f48e094f5c8644ddb7da8

@ -1 +1 @@
Subproject commit 6ac8af13ebb029b428cc45e5ca70f5da01f50029
Subproject commit 3fe8f895fa2458f7e7b93f24558fdc81a11c3f13

View File

@ -212,3 +212,14 @@ export async function pslOperate(data: {
}) {
return await api.post(`${UriBase}/psl/operation`, data);
}
/**
* ScreenDoor操作
*/
export async function screenDoorOperate(data: {
simulationId: string;
mapId: number;
deviceId: string;
operation: number;
}) {
return await api.post(`${UriBase}/psd/operation`, data);
}

View File

@ -18,8 +18,9 @@
<section-state
v-else-if="lineStore.selectedGraphicType === Section.Type"
/>
<relay-state
v-else-if="lineStore.selectedGraphicType === Relay.Type"
<relay-state v-else-if="lineStore.selectedGraphicType === Relay.Type" />
<screen-door-state
v-else-if="lineStore.selectedGraphicType === ScreenDoor.Type"
/>
</div>
</q-scroll-area>
@ -43,6 +44,8 @@ import SectionState from './states/SectionState.vue';
import { Section } from 'src/graphics/section/Section';
import RelayState from './states/RelayState.vue';
import { Relay } from 'src/graphics/relay/Relay';
import ScreenDoorState from './states/ScreenDoorState.vue';
import { ScreenDoor } from 'src/graphics/screenDoor/ScreenDoor';
const lineStore = useLineStore();
</script>

View File

@ -0,0 +1,188 @@
<template>
<q-card flat bordered>
<q-card-section class="flex justify-between">
<div class="text-h6">屏蔽门状态</div>
<q-btn-dropdown color="primary" label="操作">
<q-list>
<q-item
v-for="(item, index) in options"
:key="index"
clickable
v-close-popup
@click="doScreenDoorOperation(item)"
>
<q-item-section>
<q-item-label>{{ item.label }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</q-card-section>
<q-separator inset />
<q-card-section>
<q-input
outlined
readonly
v-model="screenDoorState.id"
label="id"
hint=""
/>
<q-input
outlined
readonly
v-model.number="screenDoorState.code"
label="名称"
/>
<q-input
outlined
readonly
style="margin-top: 10px"
v-model="screenDoorState.openAsdCodesString"
label="开启的滑动门的编号"
:disable="true"
type="textarea"
autogrow
/>
<q-checkbox
dense
style="margin-top: 10px"
v-model="screenDoorState.close"
outlined
label="屏蔽门整体的关闭(继电器)状态"
:disable="true"
/>
</q-card-section>
<!-- <q-card-actions align="center">
<q-btn label="修改" type="submit" color="primary" @click="submitState" />
<q-btn
label="重置"
type="reset"
color="primary"
flat
class="q-ml-sm"
@click="onReset"
/>
</q-card-actions> -->
</q-card>
</template>
<script setup lang="ts">
import { useLineStore } from 'src/stores/line-store';
import { ref, watch, onMounted } from 'vue';
import { ScreenDoor } from 'src/graphics/screenDoor/ScreenDoor';
import { request } from 'src/protos/request';
// import { state } from 'src/protos/device_state';
import { screenDoorOperate } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
const lineStore = useLineStore();
interface psdState {
id: string;
code: string;
openAsdCodes: number[];
close: boolean;
openAsdCodesString: string;
}
const psdStateData: psdState = {
id: '',
code: '',
openAsdCodes: [],
close: false,
openAsdCodesString: '',
};
const screenDoorState = ref(psdStateData);
const options = [
{
label: '四编组开门',
value: request.Psd.Operation.Km4,
},
{
label: '取消四编组开门',
value: request.Psd.Operation.CancelKm4,
},
{
label: '八编组开门',
value: request.Psd.Operation.Km8,
},
{
label: '取消八编组开门',
value: request.Psd.Operation.CancelKm8,
},
{
label: '关门',
value: request.Psd.Operation.Gm,
},
{
label: '取消关门',
value: request.Psd.Operation.CancelGm,
},
{
label: '强制四编组开门',
value: request.Psd.Operation.ForceKm4,
},
{
label: '强制八编组开门',
value: request.Psd.Operation.ForceKm8,
},
{
label: '强制关门',
value: request.Psd.Operation.Gm,
},
];
watch(
() => lineStore.selectedGraphics,
(val) => {
if (val?.length == 1 && val[0].type == ScreenDoor.Type) {
initScreenDoorState(val[0] as ScreenDoor);
} else {
screenDoorState.value = {
id: '',
code: '',
openAsdCodes: [],
close: false,
openAsdCodesString: '',
};
}
}
);
function initScreenDoorState(screenDoor: ScreenDoor) {
screenDoorState.value = {
id: screenDoor.datas.id,
code: screenDoor.datas.code,
openAsdCodes: screenDoor.states.openAsdCodes,
close: screenDoor.states.close,
openAsdCodesString: screenDoor.states.openAsdCodes.join('、'),
};
}
// function submitState() {
// if (lineStore.simulationId) {
// }
// }
// function onReset() {
// if (lineStore.selectedGraphics) {
// initScreenDoorState(lineStore.selectedGraphics[0] as ScreenDoor);
// }
// }
function doScreenDoorOperation(item: {
label: string;
value: request.Psd.Operation;
}) {
const simulationId = useLineStore().simulationId || '';
const mapId = useLineStore().mapId as number;
screenDoorOperate({
simulationId,
mapId,
deviceId: screenDoorState.value.id,
operation: item.value,
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
}
onMounted(() => {
if (lineStore.selectedGraphics) {
initScreenDoorState(lineStore.selectedGraphics[0] as ScreenDoor);
}
});
</script>

View File

@ -19,7 +19,7 @@
</q-btn-dropdown>
</q-card-section>
<q-separator inset />
<q-form>
<q-card-section>
<q-input outlined readonly v-model="signalState.id" label="id" hint="" />
<q-input
outlined
@ -34,8 +34,19 @@
v-model.number="signalState.code"
label="名称"
/>
</q-form>
<q-card-actions align="center">
<q-select
v-model="signalState.aspect"
style="margin-top: 10px"
label="灯亮状态"
outlined
:options="aspectOptions"
emitValue
mapOptions
:disable="true"
>
</q-select>
</q-card-section>
<!-- <q-card-actions align="center">
<q-btn label="修改" type="submit" color="primary" @click="submitState" />
<q-btn
label="重置"
@ -45,7 +56,7 @@
class="q-ml-sm"
@click="onReset"
/>
</q-card-actions>
</q-card-actions> -->
</q-card>
</template>
<script setup lang="ts">
@ -58,8 +69,18 @@ import { setSignalState } from 'src/api/Simulation';
import { errorNotify } from 'src/utils/CommonNotify';
const lineStore = useLineStore();
const signalState = ref({ id: '', index: 0, code: '' });
const signalState = ref({ id: '', index: 0, code: '', aspect: 0 });
const aspectOptions = [
{ label: '无用值', value: 0 },
{ label: '物理灭灯', value: 1 },
{ label: '绿灯亮', value: 2 },
{ label: '红灯亮', value: 3 },
{ label: '黄灯亮', value: 4 },
{ label: '红黄灯亮', value: 5 },
{ label: '白灯亮', value: 6 },
{ label: '蓝灯亮', value: 7 },
];
const options = [
{
label: '开红灯',
@ -150,6 +171,7 @@ watch(
id: '',
index: 0,
code: '',
aspect: 0,
};
}
}
@ -159,17 +181,18 @@ function initSignalState(signal: Signal) {
id: signal.datas.id,
index: signal.datas.index,
code: signal.datas.code,
aspect: signal.states.aspect,
};
}
function submitState() {
if (lineStore.simulationId) {
}
}
function onReset() {
if (lineStore.selectedGraphics) {
initSignalState(lineStore.selectedGraphics[0] as Signal);
}
}
// function submitState() {
// if (lineStore.simulationId) {
// }
// }
// function onReset() {
// if (lineStore.selectedGraphics) {
// initSignalState(lineStore.selectedGraphics[0] as Signal);
// }
// }
function doSignalOperation(item: {
label: string;
value: { aspect: state.Signal.Aspect; operation: request.Signal.Operation };

View File

@ -7,10 +7,10 @@ function getHost(): string {
// return '192.168.3.7:9091';
// return '192.168.3.47:9091';
// return '192.168.3.37:9091';
// return '192.168.3.15:9091';
return '192.168.3.15:9091';
// return '192.168.3.5:9091';
// return '192.168.3.37:9091'; //卫志宏
return '192.168.3.233:9091';
// return '192.168.3.233:9091';
}
export function getHttpBase() {

View File

@ -7,6 +7,12 @@ import {
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
import { state } from 'src/protos/device_state';
import { useLineStore } from 'src/stores/line-store';
import {
GraphicInteractionPlugin,
IGraphicScene,
JlGraphic,
} from 'src/jl-graphic';
export class ScreenDoorData extends GraphicDataBase implements IScreenDoorData {
constructor(data?: graphicData.ScreenDoor) {
@ -78,8 +84,17 @@ export class ScreenDoorState
get code(): string {
return this.states.id;
}
get openDoorCodes() {
return this.states.openDoorCodes;
get openAsdCodes() {
return this.states.openAsdCodes;
}
set openAsdCodes(v: number[]) {
this.states.openAsdCodes = v;
}
get close() {
return this.states.close;
}
set close(v: boolean) {
this.states.close = v;
}
get states(): state.PsdState {
return this.getState<state.PsdState>();
@ -94,3 +109,34 @@ export class ScreenDoorState
return pb_1.Message.equals(this._state, data._state);
}
}
export class ScreenDoorOperateInteraction extends GraphicInteractionPlugin<ScreenDoor> {
static Name = 'screen_door_operate_menu';
constructor(app: IGraphicScene) {
super(ScreenDoorOperateInteraction.Name, app);
// app.registerMenu();
}
static init(app: IGraphicScene) {
return new ScreenDoorOperateInteraction(app);
}
filter(...grahpics: JlGraphic[]): ScreenDoor[] | undefined {
return grahpics
.filter((g) => g.type === ScreenDoor.Type)
.map((g) => g as ScreenDoor);
}
bind(g: ScreenDoor): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.selectable = true;
g.on('_leftclick', this.onLeftClick, this);
}
unbind(g: ScreenDoor): void {
g.selectable = false;
g.eventMode = 'none';
g.off('_leftclick', this.onLeftClick, this);
}
onLeftClick() {
useLineStore().stateProCountIncrease();
}
}

View File

@ -24,6 +24,7 @@ import { PlatformTemplate, Platform } from 'src/graphics/platform/Platform';
import {
ScreenDoorData,
ScreenDoorState,
ScreenDoorOperateInteraction,
} from './graphics/ScreenDoorInteraction';
import {
ScreenDoor,
@ -245,6 +246,7 @@ export function initLineScene(lineApp: IGraphicApp, sceneName: string) {
];
lineScene.registerGraphicTemplates(...graphicTemplate);
SignalOperateInteraction.init(lineScene);
ScreenDoorOperateInteraction.init(lineScene);
PlatformOperateInteraction.init(lineScene);
StationOperateInteraction.init(lineScene);
SectionLinkOperateInteraction.init(lineScene);

View File

@ -25,7 +25,10 @@ export interface IScreenDoorData extends GraphicData {
}
export interface IScreenDoorState extends GraphicState {
get openDoorCodes(): number[]; //打开的屏蔽门的编号
get openAsdCodes(): number[]; //打开的屏蔽门的编号
set openAsdCodes(v: number[]);
get close(): boolean; //屏蔽门整体的关闭(继电器)状态
set close(v: boolean);
}
const screenDoorConsts = {
@ -94,7 +97,7 @@ export class ScreenDoor extends JlGraphic {
this.datas.sonDoorAmount = this.datas?.sonDoorAmount || 30;
for (let i = 0; i < this.datas.sonDoorAmount; i++) {
const smallDoor = new smallDoorGraphic();
smallDoor.draw(this.datas, i, this.states.openDoorCodes.includes(i + 1));
smallDoor.draw(this.datas, i, this.states.openAsdCodes.includes(i + 1));
doorGraphic.addChild(smallDoor);
}
}

View File

@ -920,6 +920,7 @@ export namespace state {
vobcState?: TrainVobcState;
trainKilometer?: number;
controlDelayTime?: number;
headDeviceUId?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -969,6 +970,9 @@ export namespace state {
if ("controlDelayTime" in data && data.controlDelayTime != undefined) {
this.controlDelayTime = data.controlDelayTime;
}
if ("headDeviceUId" in data && data.headDeviceUId != undefined) {
this.headDeviceUId = data.headDeviceUId;
}
}
}
get id() {
@ -1067,6 +1071,12 @@ export namespace state {
set controlDelayTime(value: number) {
pb_1.Message.setField(this, 15, value);
}
get headDeviceUId() {
return pb_1.Message.getFieldWithDefault(this, 16, "") as string;
}
set headDeviceUId(value: string) {
pb_1.Message.setField(this, 16, value);
}
static fromObject(data: {
id?: string;
up?: boolean;
@ -1083,6 +1093,7 @@ export namespace state {
vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>;
trainKilometer?: number;
controlDelayTime?: number;
headDeviceUId?: string;
}): TrainState {
const message = new TrainState({});
if (data.id != null) {
@ -1130,6 +1141,9 @@ export namespace state {
if (data.controlDelayTime != null) {
message.controlDelayTime = data.controlDelayTime;
}
if (data.headDeviceUId != null) {
message.headDeviceUId = data.headDeviceUId;
}
return message;
}
toObject() {
@ -1149,6 +1163,7 @@ export namespace state {
vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>;
trainKilometer?: number;
controlDelayTime?: number;
headDeviceUId?: string;
} = {};
if (this.id != null) {
data.id = this.id;
@ -1195,6 +1210,9 @@ export namespace state {
if (this.controlDelayTime != null) {
data.controlDelayTime = this.controlDelayTime;
}
if (this.headDeviceUId != null) {
data.headDeviceUId = this.headDeviceUId;
}
return data;
}
serialize(): Uint8Array;
@ -1231,6 +1249,8 @@ export namespace state {
writer.writeInt64(14, this.trainKilometer);
if (this.controlDelayTime != 0)
writer.writeInt64(15, this.controlDelayTime);
if (this.headDeviceUId.length)
writer.writeString(16, this.headDeviceUId);
if (!w)
return writer.getResultBuffer();
}
@ -1285,6 +1305,9 @@ export namespace state {
case 15:
message.controlDelayTime = reader.readInt64();
break;
case 16:
message.headDeviceUId = reader.readString();
break;
default: reader.skipField();
}
}
@ -2876,7 +2899,8 @@ export namespace state {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
id?: string;
openDoorCodes?: number[];
openAsdCodes?: number[];
close?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls);
@ -2884,8 +2908,11 @@ export namespace state {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("openDoorCodes" in data && data.openDoorCodes != undefined) {
this.openDoorCodes = data.openDoorCodes;
if ("openAsdCodes" in data && data.openAsdCodes != undefined) {
this.openAsdCodes = data.openAsdCodes;
}
if ("close" in data && data.close != undefined) {
this.close = data.close;
}
}
}
@ -2895,35 +2922,49 @@ export namespace state {
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get openDoorCodes() {
get openAsdCodes() {
return pb_1.Message.getFieldWithDefault(this, 2, []) as number[];
}
set openDoorCodes(value: number[]) {
set openAsdCodes(value: number[]) {
pb_1.Message.setField(this, 2, value);
}
get close() {
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
}
set close(value: boolean) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
id?: string;
openDoorCodes?: number[];
openAsdCodes?: number[];
close?: boolean;
}): PsdState {
const message = new PsdState({});
if (data.id != null) {
message.id = data.id;
}
if (data.openDoorCodes != null) {
message.openDoorCodes = data.openDoorCodes;
if (data.openAsdCodes != null) {
message.openAsdCodes = data.openAsdCodes;
}
if (data.close != null) {
message.close = data.close;
}
return message;
}
toObject() {
const data: {
id?: string;
openDoorCodes?: number[];
openAsdCodes?: number[];
close?: boolean;
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.openDoorCodes != null) {
data.openDoorCodes = this.openDoorCodes;
if (this.openAsdCodes != null) {
data.openAsdCodes = this.openAsdCodes;
}
if (this.close != null) {
data.close = this.close;
}
return data;
}
@ -2933,8 +2974,10 @@ export namespace state {
const writer = w || new pb_1.BinaryWriter();
if (this.id.length)
writer.writeString(1, this.id);
if (this.openDoorCodes.length)
writer.writePackedInt32(2, this.openDoorCodes);
if (this.openAsdCodes.length)
writer.writePackedInt32(2, this.openAsdCodes);
if (this.close != false)
writer.writeBool(3, this.close);
if (!w)
return writer.getResultBuffer();
}
@ -2948,7 +2991,10 @@ export namespace state {
message.id = reader.readString();
break;
case 2:
message.openDoorCodes = reader.readPackedInt32();
message.openAsdCodes = reader.readPackedInt32();
break;
case 3:
message.close = reader.readBool();
break;
default: reader.skipField();
}

View File

@ -303,4 +303,194 @@ export namespace request {
CancelFaultOcc = 5
}
}
export class Psd extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}): Psd {
const message = new Psd({});
return message;
}
toObject() {
const data: {} = {};
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 (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Psd {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Psd();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Psd {
return Psd.deserialize(bytes);
}
}
export namespace Psd {
export enum Operation {
Undefined = 0,
Km4 = 1,
CancelKm4 = 2,
Km8 = 3,
CancelKm8 = 4,
Gm = 5,
CancelGm = 6,
ForceKm4 = 7,
ForceKm8 = 8,
ForceGm = 9
}
}
export class PsdOperationReq extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
simulationId?: string;
mapId?: number;
deviceId?: string;
operation?: Psd.Operation;
}) {
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 ("operation" in data && data.operation != undefined) {
this.operation = data.operation;
}
}
}
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, "") as string;
}
set deviceId(value: string) {
pb_1.Message.setField(this, 3, value);
}
get operation() {
return pb_1.Message.getFieldWithDefault(this, 4, Psd.Operation.Undefined) as Psd.Operation;
}
set operation(value: Psd.Operation) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: {
simulationId?: string;
mapId?: number;
deviceId?: string;
operation?: Psd.Operation;
}): PsdOperationReq {
const message = new PsdOperationReq({});
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.operation != null) {
message.operation = data.operation;
}
return message;
}
toObject() {
const data: {
simulationId?: string;
mapId?: number;
deviceId?: string;
operation?: Psd.Operation;
} = {};
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.operation != null) {
data.operation = this.operation;
}
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.length)
writer.writeString(3, this.deviceId);
if (this.operation != Psd.Operation.Undefined)
writer.writeEnum(4, this.operation);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PsdOperationReq {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PsdOperationReq();
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.readString();
break;
case 4:
message.operation = reader.readEnum();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): PsdOperationReq {
return PsdOperationReq.deserialize(bytes);
}
}
}