This commit is contained in:
fan 2024-02-05 15:01:42 +08:00
commit 98a128a4dd
24 changed files with 872 additions and 57 deletions

View File

@ -1,6 +1,6 @@
import { api } from 'src/boot/axios'; import { api } from 'src/boot/axios';
import { request } from 'src/protos/request'; import { request } from 'src/protos/request';
import { TrainConfigData } from './TrainModelApi' import { TrainConfigData } from './TrainModelApi';
const UriBase = '/api/v1/simulation'; const UriBase = '/api/v1/simulation';
@ -39,12 +39,16 @@ export interface TrainEnd {
* @param devicePort * @param devicePort
* @param headOffset A端为偏移原点 * @param headOffset A端为偏移原点
* @param trainLength * @param trainLength
* @param trainId
* @param trainSpeed
*/ */
export async function addTrain(data: { export async function addTrain(data: {
simulationId: string; simulationId: string;
mapId: number; mapId: number;
up: boolean; up: boolean;
id: number; id: number;
trainId: number;
trainSpeed: number;
devicePort?: string; devicePort?: string;
headOffset: number; headOffset: number;
trainLength?: number; trainLength?: number;
@ -87,6 +91,17 @@ export async function removeTrain(data: {
return response.data; return response.data;
} }
/**
*
*/
export async function removeAllTrain(data: {
simulationId: string;
mapId: number;
}) {
const response = await api.post(`${UriBase}/train/remove/all`, data);
return response.data;
}
export async function setAxleSectionState(data: { export async function setAxleSectionState(data: {
simulationId: string; simulationId: string;
mapId: number; mapId: number;
@ -113,8 +128,8 @@ export interface SignalOperationReq {
deviceId: number; deviceId: number;
operation: request.Signal.Operation; operation: request.Signal.Operation;
param: { param: {
force: request.Signal.Force, force: request.Signal.Force;
dsList: request.Signal.DS[] dsList: request.Signal.DS[];
}; };
} }
export async function setSignalState(data: SignalOperationReq) { export async function setSignalState(data: SignalOperationReq) {
@ -167,6 +182,21 @@ export async function ibpKeyOperation(params: IbpKeyOperationParams) {
return await api.post(`${UriBase}/ibp/key/operation`, params); 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 }) { export function checkMapData(data: { mapProto: string }) {
return api.post(`${UriBase}/check/data`, data); return api.post(`${UriBase}/check/data`, data);
} }
@ -359,21 +389,21 @@ export interface TrainConfig {
idlingA: number; idlingA: number;
idlingR: number; idlingR: number;
idlingD: number; idlingD: number;
}, };
trainEndsA: { trainEndsA: {
radarCheckSpeedDiff: number; radarCheckSpeedDiff: number;
radarCheckTime: number; radarCheckTime: number;
radarEnable: boolean; radarEnable: boolean;
speedSensorEnableA: boolean; speedSensorEnableA: boolean;
speedSensorEnableB: boolean; speedSensorEnableB: boolean;
}, };
trainEndsB: { trainEndsB: {
radarCheckSpeedDiff: number; radarCheckSpeedDiff: number;
radarCheckTime: number; radarCheckTime: number;
radarEnable: boolean; radarEnable: boolean;
speedSensorEnableA: boolean; speedSensorEnableA: boolean;
speedSensorEnableB: boolean; speedSensorEnableB: boolean;
}, };
} }
/** 列车参数修改 */ /** 列车参数修改 */
export async function updateTrainConfig(data: TrainConfig) { export async function updateTrainConfig(data: TrainConfig) {

View File

@ -16,6 +16,21 @@
:label="props.dev.type" :label="props.dev.type"
v-model="props.dev.id" v-model="props.dev.id"
/> />
<q-input
type="number"
outlined
label="列车编号"
v-model.number="trainId"
lazy-rules
/>
<q-input
type="number"
outlined
label="列车初始速度(km/h)"
:min="0"
v-model.number="trainSpeed"
lazy-rules
/>
<q-input <q-input
type="number" type="number"
outlined outlined
@ -113,6 +128,8 @@ const dirOptions = [
{ label: '上行', value: 1 }, { label: '上行', value: 1 },
{ label: '下行', value: 0 }, { label: '下行', value: 0 },
]; ];
const trainSpeed = ref(0);
const trainId = ref(1);
const showAddTrainOperation = ref(true); const showAddTrainOperation = ref(true);
@ -141,6 +158,8 @@ function onCreate() {
up: !!dir.value, up: !!dir.value,
id: props.dev.datas.id, id: props.dev.datas.id,
headOffset: offset.value, headOffset: offset.value,
trainId: trainId.value,
trainSpeed: trainSpeed.value,
wheelDiameter: wheelDiameter.value, wheelDiameter: wheelDiameter.value,
trainLength: trainConfig.value.total_length, trainLength: trainConfig.value.total_length,
configTrain: trainConfig.value.trainConfigData as TrainConfigData, configTrain: trainConfig.value.trainConfigData as TrainConfigData,

View File

@ -18,6 +18,14 @@
@update:model-value="onUpdate" @update:model-value="onUpdate"
label="关联站台" label="关联站台"
></q-select> ></q-select>
<q-select
outlined
class="q-mt-sm"
@blur="onUpdate"
v-model="esbButtonModel.refEsbButtonMapCode"
:options="pslNameList"
label="关联PSL地图"
/>
</q-form> </q-form>
</template> </template>
@ -25,8 +33,10 @@
import { EsbButtonData } from 'src/drawApp/graphics/EsbButtonInteraction'; import { EsbButtonData } from 'src/drawApp/graphics/EsbButtonInteraction';
import { useFormData } from 'src/components/DrawAppFormUtils'; import { useFormData } from 'src/components/DrawAppFormUtils';
import { useDrawStore } from 'src/stores/draw-store'; import { useDrawStore } from 'src/stores/draw-store';
import { onMounted, reactive } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { Platform } from 'src/graphics/platform/Platform'; import { Platform } from 'src/graphics/platform/Platform';
import { getPublishList } from 'src/api/PublishApi';
import { PictureType } from 'src/protos/picture';
const drawStore = useDrawStore(); const drawStore = useDrawStore();
const platformList: { label: string; value: number }[] = reactive([]); const platformList: { label: string; value: number }[] = reactive([]);
@ -35,8 +45,22 @@ const { data: esbButtonModel, onUpdate } = useFormData(
new EsbButtonData(), new EsbButtonData(),
drawStore.getDrawApp() drawStore.getDrawApp()
); );
const pslNameList = ref<string[]>([]);
onMounted(() => { onMounted(() => {
const list2: string[] = [];
getPublishList({
type: PictureType.Psl,
category: useDrawStore().categoryType,
}).then((pslMapList) => {
if (pslMapList && pslMapList.length) {
pslMapList.forEach((item) => {
list2.push(item.name);
});
}
pslNameList.value = list2;
});
const platforms = drawStore const platforms = drawStore
.getDrawApp() .getDrawApp()
.queryStore.queryByType<Platform>(Platform.Type); .queryStore.queryByType<Platform>(Platform.Type);

View File

@ -80,7 +80,10 @@
</template> </template>
</q-select> </q-select>
<q-select <q-select
v-if="gatedBoxSetProperty.refGatedBoxMapCode" v-if="
commonSetProperty.commonRefGatedBoxMapCode ||
commonSetProperty.oneDeviceTypeOfPSL
"
outlined outlined
bottom-slots bottom-slots
v-model="refGatedBoxMapCode" v-model="refGatedBoxMapCode"
@ -155,6 +158,10 @@ import {
findCommonElements, findCommonElements,
handleCentralizedStationsData, handleCentralizedStationsData,
} from 'src/graphics/concentrationDividingLine/ConcentrationDividingLineUtils'; } from 'src/graphics/concentrationDividingLine/ConcentrationDividingLineUtils';
import { EsbButton } from 'src/graphics/esbButton/EsbButton';
import { EsbButtonData } from 'src/drawApp/graphics/EsbButtonInteraction';
import { ZdwxEsb } from 'src/graphics/esbButton/ZdwxEsb';
import { ZdwxEsbData } from 'src/drawApp/graphics/ZdwxEsbInteraction';
const drawStore = useDrawStore(); const drawStore = useDrawStore();
const $q = useQuasar(); const $q = useQuasar();
@ -196,7 +203,17 @@ const transponderSetProperty = ref<{
const gatedBoxSetProperty = ref<{ const gatedBoxSetProperty = ref<{
[key: string]: boolean; [key: string]: boolean;
}>({ }>({
refGatedBoxMapCode: false, commonRefGatedBoxMapCode: false,
});
const esbButtonSetProperty = ref<{
[key: string]: boolean;
}>({
commonRefGatedBoxMapCode: false,
});
const ZdwxEsbSetProperty = ref<{
[key: string]: boolean;
}>({
commonRefGatedBoxMapCode: false,
}); });
const screenDoorSetProperty = ref<{ const screenDoorSetProperty = ref<{
[key: string]: boolean; [key: string]: boolean;
@ -215,6 +232,8 @@ const commonSetProperty = ref<{
oneDeviceTypeOfJZZ: false, // oneDeviceTypeOfJZZ: false, //
commonCodeEndings: false, commonCodeEndings: false,
oneDeviceTypeOfCCE: false, oneDeviceTypeOfCCE: false,
commonRefGatedBoxMapCode: false, //PSL
oneDeviceTypeOfPSL: false,
}); });
const allDeviceProperty = [ const allDeviceProperty = [
@ -226,6 +245,8 @@ const allDeviceProperty = [
{ type: AxleCounting.Type, setProperty: axleCountingSetProperty }, // { type: AxleCounting.Type, setProperty: axleCountingSetProperty }, //
{ type: Transponder.Type, setProperty: transponderSetProperty }, // { type: Transponder.Type, setProperty: transponderSetProperty }, //
{ type: GatedBox.Type, setProperty: gatedBoxSetProperty }, //PSLCode { type: GatedBox.Type, setProperty: gatedBoxSetProperty }, //PSLCode
{ type: EsbButton.Type, setProperty: esbButtonSetProperty }, //PSLCode
{ type: ZdwxEsb.Type, setProperty: ZdwxEsbSetProperty }, //PSLCode
{ type: ScreenDoor.Type, setProperty: screenDoorSetProperty }, // { type: ScreenDoor.Type, setProperty: screenDoorSetProperty }, //
{ type: Platform.Type, setProperty: platformSetProperty }, // { type: Platform.Type, setProperty: platformSetProperty }, //
]; ];
@ -452,15 +473,31 @@ const pslNameList = ref<string[]>([]);
function setGatedBoxPslName() { function setGatedBoxPslName() {
if (refGatedBoxMapCode.value) { if (refGatedBoxMapCode.value) {
$q.dialog({ $q.dialog({
message: `确定批量设置选中门控箱关联的PSL地图为【${refGatedBoxMapCode.value}】吗?`, message: `确定批量设置选中门控箱和紧急关闭按钮关联的PSL地图为【${refGatedBoxMapCode.value}】吗?`,
cancel: true, cancel: true,
}).onOk(() => { }).onOk(() => {
drawStore.selectedGraphics?.forEach((gatedBox) => { drawStore.selectedGraphics?.forEach((device) => {
const data = new GatedBoxData(); if (device instanceof GatedBox) {
data.copyFrom(gatedBox.saveData()); const data = new GatedBoxData();
if (data.refGatedBoxMapCode !== refIbpMapCode.value) { data.copyFrom(device.saveData());
data.refGatedBoxMapCode = refGatedBoxMapCode.value; if (data.refGatedBoxMapCode !== refIbpMapCode.value) {
gatedBox.updateData(data); data.refGatedBoxMapCode = refGatedBoxMapCode.value;
device.updateData(data);
}
} else if (device instanceof EsbButton) {
const data = new EsbButtonData();
data.copyFrom(device.saveData());
if (data.refEsbButtonMapCode !== refIbpMapCode.value) {
data.refEsbButtonMapCode = refGatedBoxMapCode.value;
device.updateData(data);
}
} else {
const data = new ZdwxEsbData();
data.copyFrom(device.saveData());
if (data.refEsbButtonMapCode !== refIbpMapCode.value) {
data.refEsbButtonMapCode = refGatedBoxMapCode.value;
device.updateData(data);
}
} }
}); });
refGatedBoxMapCode.value = ''; refGatedBoxMapCode.value = '';

View File

@ -468,7 +468,6 @@ watch(
function getTrainStates(train: Train) { function getTrainStates(train: Train) {
trainInfo.value = null; trainInfo.value = null;
const s = train.states as ITrainState; const s = train.states as ITrainState;
console.log(s, '=======');
trainInfo.value = s; trainInfo.value = s;
} }

View File

@ -115,6 +115,14 @@ const options = [
label: '重置报文', label: '重置报文',
value: TransponderOperation.ResetMessage, value: TransponderOperation.ResetMessage,
}, },
{
label: '停止发送报文',
value: TransponderOperation.ResetMessage,
},
{
label: '取消停止发送报文',
value: TransponderOperation.ResetMessage,
},
]; ];
const directionOptions = [ const directionOptions = [

View File

@ -10,6 +10,7 @@ function getHost(): string {
// return '192.168.3.15:9091'; // 张骞 // return '192.168.3.15:9091'; // 张骞
// return '192.168.3.93:9091'; // return '192.168.3.93:9091';
// return '192.168.3.37:9091'; //卫志宏 // return '192.168.3.37:9091'; //卫志宏
return 'test.joylink.club/bjrtsts-service'; // 测试
return '192.168.3.233:9091'; return '192.168.3.233:9091';
} }
@ -23,7 +24,8 @@ export function getHttpBase() {
export function getWebsocketUrl() { export function getWebsocketUrl() {
let protocol = 'ws'; let protocol = 'ws';
let host = '192.168.3.233'; // let host = '192.168.3.233';
let host = 'test.joylink.club';
let port = '8083'; let port = '8083';
let url = `${protocol}://${host}:${port}`; let url = `${protocol}://${host}:${port}`;
if (process.env.ENV_MODE == 'test') { if (process.env.ENV_MODE == 'test') {

View File

@ -53,6 +53,12 @@ export class EsbButtonData extends GraphicDataBase implements IEsbButtonData {
set refStand(v: number) { set refStand(v: number) {
this.data.refStand = v; this.data.refStand = v;
} }
get refEsbButtonMapCode(): string {
return this.data.refEsbButtonMapCode;
}
set refEsbButtonMapCode(v: string) {
this.data.refEsbButtonMapCode = v;
}
clone(): EsbButtonData { clone(): EsbButtonData {
return new EsbButtonData(this.data.cloneMessage()); return new EsbButtonData(this.data.cloneMessage());
} }
@ -66,7 +72,8 @@ export class EsbButtonData extends GraphicDataBase implements IEsbButtonData {
export class EsbButtonState export class EsbButtonState
extends GraphicStateBase extends GraphicStateBase
implements IEsbButtonState { implements IEsbButtonState
{
constructor(data?: state.ButtonState) { constructor(data?: state.ButtonState) {
let ibpButtonState; let ibpButtonState;
if (data) { if (data) {

View File

@ -7,13 +7,19 @@ import {
} from 'src/graphics/IBPButton/IBPButton'; } from 'src/graphics/IBPButton/IBPButton';
import { ibpGraphicData } from 'src/protos/ibpGraphics'; import { ibpGraphicData } from 'src/protos/ibpGraphics';
import { import {
ContextMenu,
GraphicInteractionPlugin, GraphicInteractionPlugin,
IGraphicScene, IGraphicScene,
JlGraphic, JlGraphic,
MenuItemOptions,
} from 'jl-graphic'; } from 'jl-graphic';
import { FederatedMouseEvent } from 'pixi.js'; import { FederatedMouseEvent } from 'pixi.js';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import { useIbpStore } from 'src/stores/ibp-store'; import { useIbpStore } from 'src/stores/ibp-store';
import { useLineStore } from 'src/stores/line-store';
import { bypassOperation } from 'src/api/Simulation';
import { request } from 'src/protos/request';
import { errorNotify } from 'src/utils/CommonNotify';
export class IBPButtonData extends GraphicDataBase implements IIBPButtonData { export class IBPButtonData extends GraphicDataBase implements IIBPButtonData {
constructor(data?: ibpGraphicData.IBPButton) { constructor(data?: ibpGraphicData.IBPButton) {
@ -67,7 +73,8 @@ export class IBPButtonData extends GraphicDataBase implements IIBPButtonData {
export class IbpButtonState export class IbpButtonState
extends GraphicStateBase extends GraphicStateBase
implements IIbpButtonState { implements IIbpButtonState
{
constructor(data?: state.ButtonState) { constructor(data?: state.ButtonState) {
let ibpButtonState; let ibpButtonState;
if (data) { if (data) {
@ -95,6 +102,12 @@ export class IbpButtonState
set active(v: boolean) { set active(v: boolean) {
this.states.active = v; this.states.active = v;
} }
get bypass(): boolean {
return this.states.bypass;
}
set bypass(v: boolean) {
this.states.bypass = v;
}
clone(): IbpButtonState { clone(): IbpButtonState {
return new IbpButtonState(this.states.cloneMessage()); return new IbpButtonState(this.states.cloneMessage());
} }
@ -106,11 +119,27 @@ export class IbpButtonState
} }
} }
const bypassConfig: MenuItemOptions = {
name: '旁路',
};
const bypassResetConfig: MenuItemOptions = {
name: '旁路复位',
};
const IbpButtonMenu: ContextMenu = ContextMenu.init({
name: 'ibp按钮编辑菜单',
groups: [
{
items: [bypassConfig, bypassResetConfig],
},
],
});
// IbpScene使用 // IbpScene使用
export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> { export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
static Name = 'ibp_button_operate_menu'; static Name = 'ibp_button_operate_menu';
constructor(app: IGraphicScene) { constructor(app: IGraphicScene) {
super(IbpButtonInteraction.Name, app); super(IbpButtonInteraction.Name, app);
app.registerMenu(IbpButtonMenu);
} }
static init(app: IGraphicScene) { static init(app: IGraphicScene) {
return new IbpButtonInteraction(app); return new IbpButtonInteraction(app);
@ -124,12 +153,14 @@ export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
g.on('mousedown', this.onMouseDown); g.on('mousedown', this.onMouseDown);
g.on('mouseup', this.onMouseUp); g.on('mouseup', this.onMouseUp);
g.on('mouseleave', this.onMouseLeave); g.on('mouseleave', this.onMouseLeave);
g.on('_rightclick', this.onContextMenu, this);
} }
unbind(g: IBPButton): void { unbind(g: IBPButton): void {
g.eventMode = 'none'; g.eventMode = 'none';
g.off('mousedown', this.onMouseDown); g.off('mousedown', this.onMouseDown);
g.off('mouseup', this.onMouseUp); g.off('mouseup', this.onMouseUp);
g.off('mouseleave', this.onMouseLeave); g.off('mouseleave', this.onMouseLeave);
g.off('_rightclick', this.onContextMenu, this);
} }
onMouseDown(e: FederatedMouseEvent) { onMouseDown(e: FederatedMouseEvent) {
const g = e.target as IBPButton; const g = e.target as IBPButton;
@ -154,4 +185,45 @@ export class IbpButtonInteraction extends GraphicInteractionPlugin<IBPButton> {
changeState(g.datas.id, false); changeState(g.datas.id, false);
} }
} }
onContextMenu(e: FederatedMouseEvent) {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const stationId = useIbpStore().stationId;
const ibpButton = e.target as IBPButton;
bypassConfig.handler = () => {
if (!simulationId || !mapId) {
return;
}
bypassOperation({
simulationId,
mapId,
deviceId: ibpButton.id,
deviceCode: ibpButton.datas.code,
stationId,
operation: request.BypassOperationReq.Operation.bypass,
btnType: request.BypassOperationReq.BtnType.ibp_btn,
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
};
bypassResetConfig.handler = () => {
bypassConfig.handler = () => {
if (!simulationId || !mapId) {
return;
}
bypassOperation({
simulationId,
mapId,
deviceId: ibpButton.id,
deviceCode: ibpButton.datas.code,
stationId,
operation: request.BypassOperationReq.Operation.bypass_reset,
btnType: request.BypassOperationReq.BtnType.ibp_btn,
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
};
};
IbpButtonMenu.open(e.global);
}
} }

View File

@ -4,12 +4,18 @@ import { ibpGraphicData } from 'src/protos/ibpGraphics';
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import { import {
ContextMenu,
GraphicInteractionPlugin, GraphicInteractionPlugin,
IGraphicScene, IGraphicScene,
JlGraphic, JlGraphic,
MenuItemOptions,
} from 'jl-graphic'; } from 'jl-graphic';
import { type FederatedMouseEvent } from 'pixi.js'; import { type FederatedMouseEvent } from 'pixi.js';
import { useIbpStore } from 'src/stores/ibp-store'; import { useIbpStore } from 'src/stores/ibp-store';
import { useLineStore } from 'src/stores/line-store';
import { bypassOperation } from 'src/api/Simulation';
import { request } from 'src/protos/request';
import { errorNotify } from 'src/utils/CommonNotify';
export class IbpKeyData extends GraphicDataBase implements IIbpKeyData { export class IbpKeyData extends GraphicDataBase implements IIbpKeyData {
constructor(data?: ibpGraphicData.IbpKey) { constructor(data?: ibpGraphicData.IbpKey) {
@ -67,6 +73,12 @@ export class IbpKeyState extends GraphicStateBase implements IIbpKeyState {
set gear(v: number) { set gear(v: number) {
this.states.gear = v; this.states.gear = v;
} }
get bypass(): boolean {
return this.states.bypass;
}
set bypass(v: boolean) {
this.states.bypass = v;
}
clone(): IbpKeyState { clone(): IbpKeyState {
return new IbpKeyState(this.states.cloneMessage()); return new IbpKeyState(this.states.cloneMessage());
} }
@ -78,10 +90,26 @@ export class IbpKeyState extends GraphicStateBase implements IIbpKeyState {
} }
} }
const bypassConfig: MenuItemOptions = {
name: '旁路',
};
const bypassResetConfig: MenuItemOptions = {
name: '旁路复位',
};
const IbpKeyMenu: ContextMenu = ContextMenu.init({
name: 'ibp钥匙编辑菜单',
groups: [
{
items: [bypassConfig, bypassResetConfig],
},
],
});
export class IbpKeyInteraction extends GraphicInteractionPlugin<IbpKey> { export class IbpKeyInteraction extends GraphicInteractionPlugin<IbpKey> {
static Name = 'IbpKeyInteraction'; static Name = 'IbpKeyInteraction';
constructor(app: IGraphicScene) { constructor(app: IGraphicScene) {
super(IbpKeyInteraction.Name, app); super(IbpKeyInteraction.Name, app);
app.registerMenu(IbpKeyMenu);
} }
static init(app: IGraphicScene) { static init(app: IGraphicScene) {
return new IbpKeyInteraction(app); return new IbpKeyInteraction(app);
@ -93,14 +121,57 @@ export class IbpKeyInteraction extends GraphicInteractionPlugin<IbpKey> {
g.eventMode = 'static'; g.eventMode = 'static';
g.cursor = 'pointer'; g.cursor = 'pointer';
g.on('_leftclick', this.onClick); g.on('_leftclick', this.onClick);
g.on('_rightclick', this.onContextMenu, this);
} }
unbind(g: IbpKey): void { unbind(g: IbpKey): void {
g.eventMode = 'none'; g.eventMode = 'none';
g.off('_leftclick', this.onClick); g.off('_leftclick', this.onClick);
g.off('_rightclick', this.onContextMenu, this);
} }
onClick(e: FederatedMouseEvent): void { onClick(e: FederatedMouseEvent): void {
const g = e.target as IbpKey; const g = e.target as IbpKey;
const changeState = useIbpStore().ibpKeyOperation; const changeState = useIbpStore().ibpKeyOperation;
changeState(g.datas.id, g.state.gear === 0 ? 1 : 0); changeState(g.datas.id, g.state.gear === 0 ? 1 : 0);
} }
onContextMenu(e: FederatedMouseEvent) {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const stationId = useIbpStore().stationId;
const ibpKey = e.target as IbpKey;
bypassConfig.handler = () => {
if (!simulationId || !mapId) {
return;
}
bypassOperation({
simulationId,
mapId,
deviceId: ibpKey.id,
deviceCode: ibpKey.datas.code,
stationId,
operation: request.BypassOperationReq.Operation.bypass,
btnType: request.BypassOperationReq.BtnType.ibp_key,
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
};
bypassResetConfig.handler = () => {
bypassConfig.handler = () => {
if (!simulationId || !mapId) {
return;
}
bypassOperation({
simulationId,
mapId,
deviceId: ibpKey.id,
deviceCode: ibpKey.datas.code,
stationId,
operation: request.BypassOperationReq.Operation.bypass_reset,
btnType: request.BypassOperationReq.BtnType.ibp_key,
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
};
};
IbpKeyMenu.open(e.global);
}
} }

View File

@ -5,18 +5,21 @@ import {
PslButton, PslButton,
} from 'src/graphics/pslButton/pslButton'; } from 'src/graphics/pslButton/pslButton';
import { import {
ContextMenu,
GraphicInteractionPlugin, GraphicInteractionPlugin,
IGraphicScene, IGraphicScene,
JlGraphic, JlGraphic,
MenuItemOptions,
} from 'jl-graphic'; } from 'jl-graphic';
import { pslGraphicData } from 'src/protos/pslGraphics'; import { pslGraphicData } from 'src/protos/pslGraphics';
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; 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 { useLineStore } from 'src/stores/line-store';
import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
import { errorNotify } from 'src/utils/CommonNotify'; import { errorNotify } from 'src/utils/CommonNotify';
import { usePslStore } from 'src/stores/psl-store'; import { usePslStore } from 'src/stores/psl-store';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import { request } from 'src/protos/request';
export class PslButtonData extends GraphicDataBase implements IPslButtonData { export class PslButtonData extends GraphicDataBase implements IPslButtonData {
constructor(data?: pslGraphicData.PslButton) { constructor(data?: pslGraphicData.PslButton) {
@ -65,7 +68,8 @@ export class PslButtonData extends GraphicDataBase implements IPslButtonData {
} }
export class PslButtonState export class PslButtonState
extends GraphicStateBase extends GraphicStateBase
implements IPslButtonState { implements IPslButtonState
{
constructor(proto?: state.ButtonState) { constructor(proto?: state.ButtonState) {
let states; let states;
if (proto) { if (proto) {
@ -84,6 +88,12 @@ export class PslButtonState
set down(v: boolean) { set down(v: boolean) {
this.states.down = v; this.states.down = v;
} }
get bypass(): boolean {
return this.states.bypass;
}
set bypass(v: boolean) {
this.states.bypass = v;
}
get states(): state.ButtonState { get states(): state.ButtonState {
return this.getState<state.ButtonState>(); return this.getState<state.ButtonState>();
} }
@ -98,10 +108,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> { export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslButton> {
static Name = 'psl_button_operate_menu'; static Name = 'psl_button_operate_menu';
constructor(app: IGraphicScene) { constructor(app: IGraphicScene) {
super(PslButtonOperateInteraction.Name, app); super(PslButtonOperateInteraction.Name, app);
app.registerMenu(PslButtonMenu);
} }
static init(app: IGraphicScene) { static init(app: IGraphicScene) {
return new PslButtonOperateInteraction(app); return new PslButtonOperateInteraction(app);
@ -117,6 +143,7 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
g.on('mousedown', this.onMouseDown, this); g.on('mousedown', this.onMouseDown, this);
g.on('mouseup', this.onMouseUp, this); g.on('mouseup', this.onMouseUp, this);
g.on('mouseout', this.onMouseOut, this); g.on('mouseout', this.onMouseOut, this);
g.on('_rightclick', this.onContextMenu, this);
} }
unbind(g: PslButton): void { unbind(g: PslButton): void {
@ -124,6 +151,7 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
g.off('mousedown', this.onMouseDown, this); g.off('mousedown', this.onMouseDown, this);
g.on('mouseup', this.onMouseUp, this); g.on('mouseup', this.onMouseUp, this);
g.on('mouseout', this.onMouseOut, this); g.on('mouseout', this.onMouseOut, this);
g.off('_rightclick', this.onContextMenu, this);
} }
onMouseOut(e: FederatedMouseEvent) { onMouseOut(e: FederatedMouseEvent) {
const target = e.target as DisplayObject; const target = e.target as DisplayObject;
@ -181,4 +209,47 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
errorNotify('操作失败', { message: err.origin.response.data.title }); 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);
}
} }

View File

@ -14,7 +14,7 @@ import { removeTrain } from 'src/api/Simulation';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { successNotify, errorNotify } from '../../utils/CommonNotify'; import { successNotify, errorNotify } from '../../utils/CommonNotify';
import { Dialog } from 'quasar'; import { Dialog } from 'quasar';
import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue' import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue';
export class TrainState extends GraphicStateBase implements ITrainState { export class TrainState extends GraphicStateBase implements ITrainState {
constructor(proto?: state.TrainMapState) { constructor(proto?: state.TrainMapState) {
let states; let states;
@ -609,8 +609,8 @@ export class TrainState extends GraphicStateBase implements ITrainState {
// name: '列车轮径调整', // name: '列车轮径调整',
// }; // };
const TrainParam: MenuItemOptions = { const TrainParam: MenuItemOptions = {
name: '设置参数' name: '设置参数',
} };
const removeTrainConfig: MenuItemOptions = { const removeTrainConfig: MenuItemOptions = {
name: '清除列车', name: '清除列车',
}; };
@ -673,17 +673,23 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
}); });
}; };
removeTrainConfig.handler = () => { removeTrainConfig.handler = () => {
removeTrain({ Dialog.create({
simulationId, title: '确认',
mapId, message: '确认清除所有列车吗?',
trainId: train.code, cancel: true,
}) }).onOk(async () => {
.then(() => { removeTrain({
successNotify('移除列车成功!'); simulationId,
mapId,
trainId: train.code,
}) })
.catch((err) => { .then(() => {
errorNotify('移除列车失败!', err); successNotify('移除列车成功!');
}); })
.catch((err) => {
errorNotify('移除列车失败!', err);
});
});
}; };
TrainOperateMenu.open(e.global); TrainOperateMenu.open(e.global);

View File

@ -19,7 +19,7 @@ import { FederatedMouseEvent, DisplayObject } from 'pixi.js';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { Dialog } from 'quasar'; import { Dialog } from 'quasar';
import MoveTranspondere from '../../components/draw-app/dialogs/MoveTransponder.vue'; import MoveTranspondere from '../../components/draw-app/dialogs/MoveTransponder.vue';
import UpdateMessageTransponder from '../../components/draw-app/dialogs/UpdateMessageTransponder.vue' import UpdateMessageTransponder from '../../components/draw-app/dialogs/UpdateMessageTransponder.vue';
import { import {
resetMessageTransponder, resetMessageTransponder,
resetPositionTransponder, resetPositionTransponder,
@ -29,7 +29,8 @@ import { state } from 'src/protos/device_state';
export class TransponderData export class TransponderData
extends GraphicDataBase extends GraphicDataBase
implements ITransponderData { implements ITransponderData
{
constructor(data?: graphicData.Transponder) { constructor(data?: graphicData.Transponder) {
let transponder; let transponder;
if (!data) { if (!data) {
@ -105,17 +106,28 @@ const movePosition: MenuItemOptions = { name: '移动应答器位置' };
const recoverPosition: MenuItemOptions = { name: '复位应答器' }; const recoverPosition: MenuItemOptions = { name: '复位应答器' };
const modifyMessage: MenuItemOptions = { name: '修改报文' }; const modifyMessage: MenuItemOptions = { name: '修改报文' };
const resetMessage: MenuItemOptions = { name: '重置报文' }; const resetMessage: MenuItemOptions = { name: '重置报文' };
// const sendMessage: MenuItemOptions = { name: '发送报文' }; const stopSendMessage: MenuItemOptions = { name: '停止发送报文' };
const cancelStopSendMessage: MenuItemOptions = { name: '取消停止发送报文' };
const TransponderOperationMenu: ContextMenu = ContextMenu.init({ const TransponderOperationMenu: ContextMenu = ContextMenu.init({
name: '应答器操作', name: '应答器操作',
groups: [ groups: [
{ items: [movePosition, recoverPosition, modifyMessage, resetMessage] }, {
items: [
movePosition,
recoverPosition,
modifyMessage,
resetMessage,
stopSendMessage,
cancelStopSendMessage,
],
},
], ],
}); });
export class TransponderState export class TransponderState
extends GraphicStateBase extends GraphicStateBase
implements ITransponderState { implements ITransponderState
{
constructor(proto?: state.BaliseState) { constructor(proto?: state.BaliseState) {
let states; let states;
if (proto) { if (proto) {
@ -138,10 +150,10 @@ export class TransponderState
return this.states.km return this.states.km
? this.states.km ? this.states.km
: new graphicData.KilometerSystem({ : new graphicData.KilometerSystem({
coordinateSystem: '', coordinateSystem: '',
kilometer: 0, kilometer: 0,
direction: 0, direction: 0,
}); });
} }
set km(v: graphicData.KilometerSystem) { set km(v: graphicData.KilometerSystem) {
this.states.km = new graphicData.KilometerSystem(v); this.states.km = new graphicData.KilometerSystem(v);
@ -234,7 +246,7 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin<Transpo
coordinateSystem: transponder.states.km?.coordinateSystem, coordinateSystem: transponder.states.km?.coordinateSystem,
kilometer: transponder.states.km?.kilometer, kilometer: transponder.states.km?.kilometer,
direction: transponder.states.km?.direction, direction: transponder.states.km?.direction,
id: transponder.datas.id id: transponder.datas.id,
}, },
cancel: true, cancel: true,
persistent: true, persistent: true,
@ -262,7 +274,7 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin<Transpo
id: transponder.datas.id, id: transponder.datas.id,
type: transponder.datas.type, type: transponder.datas.type,
variableTelegram: transponder.states.variableTelegram, variableTelegram: transponder.states.variableTelegram,
variableUserTelegram: transponder.states.variableUserTelegram variableUserTelegram: transponder.states.variableUserTelegram,
}, },
cancel: true, cancel: true,
persistent: true, persistent: true,

View File

@ -53,6 +53,12 @@ export class ZdwxEsbData extends GraphicDataBase implements IZdwxEsbData {
set refStand(v: number) { set refStand(v: number) {
this.data.refStand = v; this.data.refStand = v;
} }
get refEsbButtonMapCode(): string {
return this.data.refEsbButtonMapCode;
}
set refEsbButtonMapCode(v: string) {
this.data.refEsbButtonMapCode = v;
}
clone(): ZdwxEsbData { clone(): ZdwxEsbData {
return new ZdwxEsbData(this.data.cloneMessage()); return new ZdwxEsbData(this.data.cloneMessage());
} }

View File

@ -90,7 +90,7 @@ import {
} from './graphics/SectionLinkInteraction'; } from './graphics/SectionLinkInteraction';
import { AxleCountingSectionData } from './graphics/AxleCountingSectionInteraction'; import { AxleCountingSectionData } from './graphics/AxleCountingSectionInteraction';
import { LogicSectionData } from './graphics/LogicSectionInteraction'; import { LogicSectionData } from './graphics/LogicSectionInteraction';
import { Notify, QNotifyUpdateOptions } from 'quasar'; import { Notify, QNotifyUpdateOptions, Dialog } from 'quasar';
import { import {
StopPosition, StopPosition,
StopPositionTemplate, StopPositionTemplate,
@ -158,7 +158,9 @@ import {
AutoReturnBoxOperationInteraction, AutoReturnBoxOperationInteraction,
AutoReturnBoxState, AutoReturnBoxState,
} from './graphics/AutoReturnBoxInteraction'; } from './graphics/AutoReturnBoxInteraction';
import { errorNotify } from 'src/utils/CommonNotify'; import { errorNotify, successNotify } from 'src/utils/CommonNotify';
import { removeAllTrain } from 'src/api/Simulation';
import { ApiError } from 'src/boot/axios';
const showOptions: MenuItemOptions = { const showOptions: MenuItemOptions = {
name: '显示控制', name: '显示控制',
@ -167,17 +169,26 @@ const initTranspondersOptions: MenuItemOptions = {
name: '应答器一键恢复', name: '应答器一键恢复',
}; };
const searchDeviceOptions: MenuItemOptions = { const searchDeviceOptions: MenuItemOptions = {
name: '设备检索' name: '设备检索',
}; };
const searchTrainOptions: MenuItemOptions = { const searchTrainOptions: MenuItemOptions = {
name: '列车检索' name: '列车检索',
} };
const clearAllTrainOptions: MenuItemOptions = {
name: '清除所有列车',
};
const DefaultCanvasMenu = new ContextMenu({ const DefaultCanvasMenu = new ContextMenu({
name: '图层选择', name: '图层选择',
groups: [ groups: [
{ {
items: [showOptions, initTranspondersOptions, searchDeviceOptions, searchTrainOptions], items: [
showOptions,
initTranspondersOptions,
searchDeviceOptions,
searchTrainOptions,
clearAllTrainOptions,
],
}, },
], ],
}); });
@ -314,6 +325,27 @@ export function initLineScene(lineApp: IGraphicApp, sceneName: string) {
searchTrainOptions.handler = () => { searchTrainOptions.handler = () => {
lineStore.setShowTrainSearch(true); lineStore.setShowTrainSearch(true);
}; };
clearAllTrainOptions.handler = () => {
if (!lineStore.simulationId) {
return;
}
Dialog.create({
title: '确认',
message: '确认清除所有列车吗?',
cancel: true,
}).onOk(async () => {
try {
await removeAllTrain({
simulationId: lineStore.simulationId || '',
mapId: lineStore.mapId || 0,
});
successNotify('清除所有列车成功!');
} catch (err) {
const error = err as ApiError;
errorNotify('清除所有列车失败!', error.title);
}
});
};
DefaultCanvasMenu.open(e.global); DefaultCanvasMenu.open(e.global);
}); });
lineScene.on('postdataloaded', () => { lineScene.on('postdataloaded', () => {

View File

@ -3,11 +3,20 @@ import {
GraphicState, GraphicState,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
getRectangleCenter,
} from 'jl-graphic'; } from 'jl-graphic';
import { ibpGraphicData } from 'src/protos/ibpGraphics'; import { ibpGraphicData } from 'src/protos/ibpGraphics';
import IPBButtonAssets from './ibpButton.png'; import IPBButtonAssets from './ibpButton.png';
import IBPButtonJSON from './ibpButton.json'; import IBPButtonJSON from './ibpButton.json';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; import {
Assets,
Sprite,
Spritesheet,
Texture,
Rectangle,
Graphics,
Color,
} from 'pixi.js';
export interface IIBPButtonData extends GraphicData { export interface IIBPButtonData extends GraphicData {
get code(): string; get code(): string;
@ -26,12 +35,22 @@ export interface IIbpButtonState extends GraphicState {
set down(v: boolean); set down(v: boolean);
get active(): boolean; get active(): boolean;
set active(v: boolean); set active(v: boolean);
get bypass(): boolean;
set bypass(v: boolean);
} }
const ibpButtonConsts = {
width: 100,
height: 110,
lineWidth: 3,
redColor: '0xff0000',
};
export class IBPButton extends JlGraphic { export class IBPButton extends JlGraphic {
static Type = 'IBPButton'; static Type = 'IBPButton';
textures: IBPButtonTextures; textures: IBPButtonTextures;
sprite: Sprite; sprite: Sprite;
rectGraphic: Graphics;
constructor(textures: IBPButtonTextures) { constructor(textures: IBPButtonTextures) {
super(IBPButton.Type); super(IBPButton.Type);
@ -43,7 +62,10 @@ export class IBPButton extends JlGraphic {
false false
); );
this.sprite.anchor.set(0.5); this.sprite.anchor.set(0.5);
this.rectGraphic = new Graphics();
this.addChild(this.sprite); this.addChild(this.sprite);
this.addChild(this.rectGraphic);
this.drawRectBypass();
} }
get code(): string { get code(): string {
return this.datas.code; return this.datas.code;
@ -61,6 +83,16 @@ export class IBPButton extends JlGraphic {
this.state.down, this.state.down,
this.datas.hasLight && this.state.active this.datas.hasLight && this.state.active
); );
this.rectGraphic.visible = this.state.bypass ? true : false;
}
drawRectBypass() {
this.rectGraphic
.clear()
.lineStyle(ibpButtonConsts.lineWidth, new Color(ibpButtonConsts.redColor))
.drawRect(0, 0, ibpButtonConsts.width, ibpButtonConsts.height);
this.rectGraphic.pivot = getRectangleCenter(
new Rectangle(0, 0, ibpButtonConsts.width, ibpButtonConsts.height)
);
} }
} }

View File

@ -14,6 +14,8 @@ export interface IEsbButtonData extends GraphicData {
set flip(v: boolean); set flip(v: boolean);
get refStand(): number; get refStand(): number;
set refStand(v: number); set refStand(v: number);
get refEsbButtonMapCode(): string;
set refEsbButtonMapCode(v: string);
clone(): IEsbButtonData; clone(): IEsbButtonData;
copyFrom(data: IEsbButtonData): void; copyFrom(data: IEsbButtonData): void;
eq(other: IEsbButtonData): boolean; eq(other: IEsbButtonData): boolean;

View File

@ -14,6 +14,8 @@ export interface IZdwxEsbData extends GraphicData {
set flip(v: boolean); set flip(v: boolean);
get refStand(): number; get refStand(): number;
set refStand(v: number); set refStand(v: number);
get refEsbButtonMapCode(): string;
set refEsbButtonMapCode(v: string);
clone(): IZdwxEsbData; clone(): IZdwxEsbData;
copyFrom(data: IZdwxEsbData): void; copyFrom(data: IZdwxEsbData): void;
eq(other: IZdwxEsbData): boolean; eq(other: IZdwxEsbData): boolean;

View File

@ -3,11 +3,20 @@ import {
GraphicState, GraphicState,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
getRectangleCenter,
} from 'jl-graphic'; } from 'jl-graphic';
import Ibp_Key_Assets from './ibp-key-spritesheet.png'; import Ibp_Key_Assets from './ibp-key-spritesheet.png';
import Ibp_Key_JSON from './ibp-key-data.json'; import Ibp_Key_JSON from './ibp-key-data.json';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; import {
Assets,
Sprite,
Spritesheet,
Texture,
Rectangle,
Graphics,
Color,
} from 'pixi.js';
interface IbpKeyTextures { interface IbpKeyTextures {
ibpKey: Texture; ibpKey: Texture;
@ -21,12 +30,22 @@ export interface IIbpKeyData extends GraphicData {
export interface IIbpKeyState extends GraphicState { export interface IIbpKeyState extends GraphicState {
get gear(): number; get gear(): number;
set gear(v: number); set gear(v: number);
get bypass(): boolean;
set bypass(v: boolean);
} }
const ibpKeyConsts = {
width: 50,
height: 50,
lineWidth: 2,
redColor: '0xff0000',
};
export class IbpKey extends JlGraphic { export class IbpKey extends JlGraphic {
static Type = 'IbpKey'; static Type = 'IbpKey';
_ibpKey: Sprite; _ibpKey: Sprite;
ibpKeyTextures: IbpKeyTextures; ibpKeyTextures: IbpKeyTextures;
rectGraphic: Graphics;
__state = 0; __state = 0;
constructor(ibpKeyTextures: IbpKeyTextures) { constructor(ibpKeyTextures: IbpKeyTextures) {
@ -35,7 +54,10 @@ export class IbpKey extends JlGraphic {
this._ibpKey = new Sprite(); this._ibpKey = new Sprite();
this._ibpKey.texture = this.ibpKeyTextures.ibpKey; this._ibpKey.texture = this.ibpKeyTextures.ibpKey;
this._ibpKey.anchor.set(0.5); this._ibpKey.anchor.set(0.5);
this.rectGraphic = new Graphics();
this.addChild(this._ibpKey); this.addChild(this._ibpKey);
this.addChild(this.rectGraphic);
this.drawRectBypass();
} }
get code(): string { get code(): string {
return this.datas.code; return this.datas.code;
@ -49,6 +71,17 @@ export class IbpKey extends JlGraphic {
doRepaint(): void { doRepaint(): void {
this._ibpKey.rotation = (-Math.PI / 2) * this.state.gear; this._ibpKey.rotation = (-Math.PI / 2) * this.state.gear;
this._ibpKey.texture = this.ibpKeyTextures.ibpKey; this._ibpKey.texture = this.ibpKeyTextures.ibpKey;
this.rectGraphic.visible = this.state.bypass ? true : false;
}
drawRectBypass() {
this.rectGraphic
.clear()
.lineStyle(ibpKeyConsts.lineWidth, new Color(ibpKeyConsts.redColor))
.drawRect(0, 0, ibpKeyConsts.width, ibpKeyConsts.height);
this.rectGraphic.pivot = getRectangleCenter(
new Rectangle(0, 0, ibpKeyConsts.width, ibpKeyConsts.height)
);
this.rectGraphic.rotation = Math.PI / 4;
} }
} }

View File

@ -3,11 +3,20 @@ import {
GraphicState, GraphicState,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
getRectangleCenter,
} from 'jl-graphic'; } from 'jl-graphic';
import Psl_Button_Assets from './psl-button-spritesheet.png'; import Psl_Button_Assets from './psl-button-spritesheet.png';
import Psl_Button_JSON from './psl-button-data.json'; import Psl_Button_JSON from './psl-button-data.json';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; import {
Assets,
Sprite,
Spritesheet,
Texture,
Graphics,
Color,
Rectangle,
} from 'pixi.js';
import { pslGraphicData } from 'src/protos/pslGraphics'; import { pslGraphicData } from 'src/protos/pslGraphics';
interface PslButtonTextures { interface PslButtonTextures {
@ -31,12 +40,22 @@ export interface IPslButtonState extends GraphicState {
set code(v: string); set code(v: string);
get down(): boolean; get down(): boolean;
set down(v: boolean); set down(v: boolean);
get bypass(): boolean;
set bypass(v: boolean);
} }
const pslButtonConsts = {
width: 70,
height: 70,
lineWidth: 1,
redColor: '0xff0000',
};
export class PslButton extends JlGraphic { export class PslButton extends JlGraphic {
static Type = 'PslButton'; static Type = 'PslButton';
_pslButton: Sprite; _pslButton: Sprite;
pslButtonTextures: PslButtonTextures; pslButtonTextures: PslButtonTextures;
rectGraphic: Graphics;
__state = 0; __state = 0;
constructor(pslButtonTextures: PslButtonTextures) { constructor(pslButtonTextures: PslButtonTextures) {
@ -45,7 +64,10 @@ export class PslButton extends JlGraphic {
this._pslButton = new Sprite(); this._pslButton = new Sprite();
this._pslButton.texture = this.pslButtonTextures.redBtn; this._pslButton.texture = this.pslButtonTextures.redBtn;
this._pslButton.anchor.set(0.5); this._pslButton.anchor.set(0.5);
this.rectGraphic = new Graphics();
this.addChild(this._pslButton); this.addChild(this._pslButton);
this.addChild(this.rectGraphic);
this.drawRectBypass();
} }
get code(): string { get code(): string {
return this.datas.code; return this.datas.code;
@ -71,6 +93,16 @@ export class PslButton extends JlGraphic {
this._pslButton.texture = this.pslButtonTextures.redBtn; this._pslButton.texture = this.pslButtonTextures.redBtn;
} }
} }
this.rectGraphic.visible = this.states.bypass ? true : false;
}
drawRectBypass() {
this.rectGraphic
.clear()
.lineStyle(pslButtonConsts.lineWidth, new Color(pslButtonConsts.redColor))
.drawRect(0, 0, pslButtonConsts.width, pslButtonConsts.height);
this.rectGraphic.pivot = getRectangleCenter(
new Rectangle(0, 0, pslButtonConsts.width, pslButtonConsts.height)
);
} }
} }

View File

@ -151,7 +151,7 @@ export class TransponderCode extends Container {
this.addChild(this.codeText); this.addChild(this.codeText);
} }
setVectorFontSize(fontSize: number) { setVectorFontSize(fontSize: number) {
this.codeText.setVectorFontSize(fontSize) this.codeText.setVectorFontSize(fontSize);
} }
clear() { clear() {
@ -211,7 +211,16 @@ export class Transponder extends JlGraphic {
}); });
polygonGraphic.endFill; polygonGraphic.endFill;
this.labelGraphic.paint(this.datas); this.labelGraphic.paint(this.datas);
this.labelGraphic.codeText.style.fill = lineColor; let textColor = '#ff0000';
if (
this.states.km &&
this.states.km.kilometer === this.datas.kilometerSystem.kilometer &&
this.states.fixedTelegram === this.datas.fixedTelegram &&
this.states.fixedUserTelegram === this.datas.fixedUserTelegram
) {
textColor = '#ffffff';
}
this.labelGraphic.codeText.style.fill = textColor;
const codeTransform = this.datas?.childTransforms?.find( const codeTransform = this.datas?.childTransforms?.find(
(item) => item.name === 'transponderCode' (item) => item.name === 'transponderCode'
); );

View File

@ -5079,6 +5079,7 @@ export namespace state {
id?: number; id?: number;
down?: boolean; down?: boolean;
active?: boolean; active?: boolean;
bypass?: boolean;
}) { }) {
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);
@ -5092,6 +5093,9 @@ export namespace state {
if ("active" in data && data.active != undefined) { if ("active" in data && data.active != undefined) {
this.active = data.active; this.active = data.active;
} }
if ("bypass" in data && data.bypass != undefined) {
this.bypass = data.bypass;
}
} }
} }
get id() { get id() {
@ -5112,10 +5116,17 @@ export namespace state {
set active(value: boolean) { set active(value: boolean) {
pb_1.Message.setField(this, 3, value); 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: { static fromObject(data: {
id?: number; id?: number;
down?: boolean; down?: boolean;
active?: boolean; active?: boolean;
bypass?: boolean;
}): ButtonState { }): ButtonState {
const message = new ButtonState({}); const message = new ButtonState({});
if (data.id != null) { if (data.id != null) {
@ -5127,6 +5138,9 @@ export namespace state {
if (data.active != null) { if (data.active != null) {
message.active = data.active; message.active = data.active;
} }
if (data.bypass != null) {
message.bypass = data.bypass;
}
return message; return message;
} }
toObject() { toObject() {
@ -5134,6 +5148,7 @@ export namespace state {
id?: number; id?: number;
down?: boolean; down?: boolean;
active?: boolean; active?: boolean;
bypass?: boolean;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
@ -5144,6 +5159,9 @@ export namespace state {
if (this.active != null) { if (this.active != null) {
data.active = this.active; data.active = this.active;
} }
if (this.bypass != null) {
data.bypass = this.bypass;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -5156,6 +5174,8 @@ export namespace state {
writer.writeBool(2, this.down); writer.writeBool(2, this.down);
if (this.active != false) if (this.active != false)
writer.writeBool(3, this.active); writer.writeBool(3, this.active);
if (this.bypass != false)
writer.writeBool(4, this.bypass);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -5174,6 +5194,9 @@ export namespace state {
case 3: case 3:
message.active = reader.readBool(); message.active = reader.readBool();
break; break;
case 4:
message.bypass = reader.readBool();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }
@ -5669,6 +5692,7 @@ export namespace state {
constructor(data?: any[] | { constructor(data?: any[] | {
id?: number; id?: number;
gear?: number; gear?: number;
bypass?: boolean;
}) { }) {
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);
@ -5679,6 +5703,9 @@ export namespace state {
if ("gear" in data && data.gear != undefined) { if ("gear" in data && data.gear != undefined) {
this.gear = data.gear; this.gear = data.gear;
} }
if ("bypass" in data && data.bypass != undefined) {
this.bypass = data.bypass;
}
} }
} }
get id() { get id() {
@ -5693,9 +5720,16 @@ export namespace state {
set gear(value: number) { set gear(value: number) {
pb_1.Message.setField(this, 2, value); 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: { static fromObject(data: {
id?: number; id?: number;
gear?: number; gear?: number;
bypass?: boolean;
}): KeyState { }): KeyState {
const message = new KeyState({}); const message = new KeyState({});
if (data.id != null) { if (data.id != null) {
@ -5704,12 +5738,16 @@ export namespace state {
if (data.gear != null) { if (data.gear != null) {
message.gear = data.gear; message.gear = data.gear;
} }
if (data.bypass != null) {
message.bypass = data.bypass;
}
return message; return message;
} }
toObject() { toObject() {
const data: { const data: {
id?: number; id?: number;
gear?: number; gear?: number;
bypass?: boolean;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
@ -5717,6 +5755,9 @@ export namespace state {
if (this.gear != null) { if (this.gear != null) {
data.gear = this.gear; data.gear = this.gear;
} }
if (this.bypass != null) {
data.bypass = this.bypass;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -5727,6 +5768,8 @@ export namespace state {
writer.writeUint32(1, this.id); writer.writeUint32(1, this.id);
if (this.gear != 0) if (this.gear != 0)
writer.writeInt32(2, this.gear); writer.writeInt32(2, this.gear);
if (this.bypass != false)
writer.writeBool(3, this.bypass);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -5742,6 +5785,9 @@ export namespace state {
case 2: case 2:
message.gear = reader.readInt32(); message.gear = reader.readInt32();
break; break;
case 3:
message.bypass = reader.readBool();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }

View File

@ -5,6 +5,246 @@
* git: https://github.com/thesayyn/protoc-gen-ts */ * git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf"; import * as pb_1 from "google-protobuf";
export namespace request { 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 { export class Relay extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | {}) { constructor(data?: any[] | {}) {

View File

@ -6920,6 +6920,7 @@ export namespace graphicData {
flip?: boolean; flip?: boolean;
oldrefStand?: string; oldrefStand?: string;
refStand?: number; refStand?: number;
refEsbButtonMapCode?: 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);
@ -6939,6 +6940,9 @@ export namespace graphicData {
if ("refStand" in data && data.refStand != undefined) { if ("refStand" in data && data.refStand != undefined) {
this.refStand = data.refStand; this.refStand = data.refStand;
} }
if ("refEsbButtonMapCode" in data && data.refEsbButtonMapCode != undefined) {
this.refEsbButtonMapCode = data.refEsbButtonMapCode;
}
} }
} }
get common() { get common() {
@ -6974,12 +6978,19 @@ export namespace graphicData {
set refStand(value: number) { set refStand(value: number) {
pb_1.Message.setField(this, 7, value); pb_1.Message.setField(this, 7, value);
} }
get refEsbButtonMapCode() {
return pb_1.Message.getFieldWithDefault(this, 8, "") as string;
}
set refEsbButtonMapCode(value: string) {
pb_1.Message.setField(this, 8, value);
}
static fromObject(data: { static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string; code?: string;
flip?: boolean; flip?: boolean;
oldrefStand?: string; oldrefStand?: string;
refStand?: number; refStand?: number;
refEsbButtonMapCode?: string;
}): EsbButton { }): EsbButton {
const message = new EsbButton({}); const message = new EsbButton({});
if (data.common != null) { if (data.common != null) {
@ -6997,6 +7008,9 @@ export namespace graphicData {
if (data.refStand != null) { if (data.refStand != null) {
message.refStand = data.refStand; message.refStand = data.refStand;
} }
if (data.refEsbButtonMapCode != null) {
message.refEsbButtonMapCode = data.refEsbButtonMapCode;
}
return message; return message;
} }
toObject() { toObject() {
@ -7006,6 +7020,7 @@ export namespace graphicData {
flip?: boolean; flip?: boolean;
oldrefStand?: string; oldrefStand?: string;
refStand?: number; refStand?: number;
refEsbButtonMapCode?: string;
} = {}; } = {};
if (this.common != null) { if (this.common != null) {
data.common = this.common.toObject(); data.common = this.common.toObject();
@ -7022,6 +7037,9 @@ export namespace graphicData {
if (this.refStand != null) { if (this.refStand != null) {
data.refStand = this.refStand; data.refStand = this.refStand;
} }
if (this.refEsbButtonMapCode != null) {
data.refEsbButtonMapCode = this.refEsbButtonMapCode;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -7038,6 +7056,8 @@ export namespace graphicData {
writer.writeString(6, this.oldrefStand); writer.writeString(6, this.oldrefStand);
if (this.refStand != 0) if (this.refStand != 0)
writer.writeUint32(7, this.refStand); writer.writeUint32(7, this.refStand);
if (this.refEsbButtonMapCode.length)
writer.writeString(8, this.refEsbButtonMapCode);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -7062,6 +7082,9 @@ export namespace graphicData {
case 7: case 7:
message.refStand = reader.readUint32(); message.refStand = reader.readUint32();
break; break;
case 8:
message.refEsbButtonMapCode = reader.readString();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }