This commit is contained in:
joylink_fanyuhong 2024-03-21 09:12:31 +08:00
commit d843e81fd4
16 changed files with 308 additions and 126 deletions

View File

@ -56,7 +56,8 @@ export interface TrainCreateParams {
total_length: number; total_length: number;
train_model: number; train_model: number;
train_sets: string; train_sets: string;
trainConfigData?: TrainConfigData trainConfigData?: TrainConfigData;
trainControlMapId: number;
} }
/** /**

View File

@ -163,6 +163,7 @@ function onCreate() {
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,
trainControlMapId: trainConfig.value.trainControlMapId,
trainEndsA: { trainEndsA: {
radarCheckSpeedDiff: 0, radarCheckSpeedDiff: 0,
radarCheckTime: 0, radarCheckTime: 0,
@ -208,6 +209,7 @@ const trainConfig = ref<TrainConfigItem | null>({
total_length: 0, total_length: 0,
train_model: 0, train_model: 0,
train_sets: '', train_sets: '',
trainControlMapId: 0,
}); });
function setConfigVal(val: TrainConfigItem | null) { function setConfigVal(val: TrainConfigItem | null) {
trainConfig.value = val || null; trainConfig.value = val || null;

View File

@ -190,6 +190,7 @@ import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue';
import { Dialog } from 'quasar'; import { Dialog } from 'quasar';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue'; import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue';
import { useTccStore } from 'src/stores/tcc-store';
interface KeyType { interface KeyType {
label: string; label: string;
@ -607,6 +608,10 @@ const options = [
label: '列车连接', label: '列车连接',
value: 2, value: 2,
}, },
{
label: '列车驾驶台',
value: 3,
},
]; ];
function doTrainOperation(option: { label: string; value: number }) { function doTrainOperation(option: { label: string; value: number }) {
@ -614,6 +619,8 @@ function doTrainOperation(option: { label: string; value: number }) {
setTrain(); setTrain();
} else if (option.value == 2) { } else if (option.value == 2) {
linkTrain(); linkTrain();
} else if (option.value == 3) {
openTccDialog();
} }
} }
@ -649,6 +656,14 @@ function setTrain() {
persistent: true, persistent: true,
}); });
} }
function openTccDialog() {
const trainId = trainInfo.value?.id ? +trainInfo.value?.id : 0;
useTccStore().setTccParam(
trainId,
trainInfo.value?.trainControlMapId as number
);
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.q-item { .q-item {

View File

@ -6,7 +6,11 @@ import { useLineStore } from 'src/stores/line-store';
import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
import { useTccStore } from 'src/stores/tcc-store'; import { useTccStore } from 'src/stores/tcc-store';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import { ITccButtonData, ITccButtonState, TccButton } from 'src/graphics/tccButton/TccButton'; import {
ITccButtonData,
ITccButtonState,
TccButton,
} from 'src/graphics/tccButton/TccButton';
export class TccButtonData extends GraphicDataBase implements ITccButtonData { export class TccButtonData extends GraphicDataBase implements ITccButtonData {
constructor(data?: tccGraphicData.TccButton) { constructor(data?: tccGraphicData.TccButton) {
@ -51,12 +55,12 @@ export class TccButtonState
extends GraphicStateBase extends GraphicStateBase
implements ITccButtonState implements ITccButtonState
{ {
constructor(proto?: state.ButtonState) { constructor(proto?: state.TrainControlState.EmergentButton) {
let states; let states;
if (proto) { if (proto) {
states = proto; states = proto;
} else { } else {
states = new state.ButtonState(); states = new state.TrainControlState.EmergentButton();
} }
super(states, TccButton.Type); super(states, TccButton.Type);
} }
@ -64,13 +68,13 @@ export class TccButtonState
return this.states.id + ''; return this.states.id + '';
} }
get down(): boolean { get down(): boolean {
return this.states.down; return this.states.passed;
} }
set down(v: boolean) { set down(v: boolean) {
this.states.down = v; this.states.passed = v;
} }
get states(): state.ButtonState { get states(): state.TrainControlState.EmergentButton {
return this.getState<state.ButtonState>(); return this.getState<state.TrainControlState.EmergentButton>();
} }
clone(): TccButtonState { clone(): TccButtonState {
return new TccButtonState(this.states.cloneMessage()); return new TccButtonState(this.states.cloneMessage());
@ -97,47 +101,22 @@ export class TccButtonOperateInteraction extends GraphicInteractionPlugin<TccBut
.map((g) => g as TccButton); .map((g) => g as TccButton);
} }
bind(g: TccButton): void { bind(g: TccButton): void {
g.eventMode = 'static'; g._tccButton.eventMode = 'static';
g.cursor = 'pointer'; g._tccButton.cursor = 'pointer';
g.on('mousedown', this.onMouseDown, this); g._tccButton.on('_leftclick', this.onClick);
g.on('mouseup', this.onMouseUp, this);
g.on('mouseout', this.onMouseOut, this);
} }
unbind(g: TccButton): void { unbind(g: TccButton): void {
g.eventMode = 'none'; g._tccButton.eventMode = 'none';
g.off('mousedown', this.onMouseDown, this); g._tccButton.off('_leftclick', this.onClick);
g.on('mouseup', this.onMouseUp, this);
g.on('mouseout', this.onMouseOut, this);
} }
onMouseOut(e: FederatedMouseEvent) {
onClick(e: FederatedMouseEvent): void {
const target = e.target as DisplayObject; const target = e.target as DisplayObject;
const tccButton = target.getGraphic() as TccButton; const tccButton = target.getGraphic<TccButton>();
if (tccButton.states.down && tccButton.datas.isSelfReset) { if (!tccButton) return;
tccButton.states.down = false; tccButton.states.down = !tccButton.states.down;
tccButton.doRepaint(); tccButton.doRepaint();
} console.log(tccButton.states.down);
}
onMouseDown(e: FederatedMouseEvent) {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const tccId = useTccStore().tccId;
const target = e.target as DisplayObject;
const tccButton = target.getGraphic() as TccButton;
if (!simulationId || !mapId) {
return;
}
console.log('按钮按下');
}
onMouseUp(e: FederatedMouseEvent) {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const tccId = useTccStore().tccId;
const target = e.target as DisplayObject;
const tccButton = target.getGraphic() as TccButton;
if (!simulationId || !mapId || !tccButton.datas.isSelfReset) {
return;
}
console.log('按钮弹起');
} }
} }

View File

@ -8,7 +8,7 @@ import { tccGraphicData } from 'src/protos/tccGraphics';
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 { GraphicInteractionPlugin, IGraphicScene, JlGraphic } from 'jl-graphic'; import { GraphicInteractionPlugin, IGraphicScene, JlGraphic } from 'jl-graphic';
import { type FederatedMouseEvent } from 'pixi.js'; import { type FederatedMouseEvent, DisplayObject } from 'pixi.js';
import { useTccStore } from 'src/stores/tcc-store'; import { useTccStore } from 'src/stores/tcc-store';
export class TccHandleData extends GraphicDataBase implements ITccHandleData { export class TccHandleData extends GraphicDataBase implements ITccHandleData {
@ -49,26 +49,26 @@ export class TccHandleState
extends GraphicStateBase extends GraphicStateBase
implements ITccHandleState implements ITccHandleState
{ {
constructor(data?: state.KeyState) { constructor(data?: state.TrainControlState.PushHandler) {
let tccHandleState; let tccHandleState;
if (data) { if (data) {
tccHandleState = data; tccHandleState = data;
} else { } else {
tccHandleState = new state.KeyState(); tccHandleState = new state.TrainControlState.PushHandler();
} }
super(tccHandleState, TccHandle.Type); super(tccHandleState, TccHandle.Type);
} }
get code(): string { get code(): string {
return this.states.id + ''; return this.states.id + '';
} }
get states(): state.KeyState { get states(): state.TrainControlState.PushHandler {
return this.getState<state.KeyState>(); return this.getState<state.TrainControlState.PushHandler>();
} }
get gear(): number { get gear(): number {
return this.states.gear; return this.states.val;
} }
set gear(v: number) { set gear(v: number) {
this.states.gear = v; this.states.val = v;
} }
clone(): TccHandleState { clone(): TccHandleState {
return new TccHandleState(this.states.cloneMessage()); return new TccHandleState(this.states.cloneMessage());
@ -96,37 +96,52 @@ export class TccHandleInteraction extends GraphicInteractionPlugin<TccHandle> {
return grahpics.filter((g): g is TccHandle => g instanceof TccHandle); return grahpics.filter((g): g is TccHandle => g instanceof TccHandle);
} }
bind(g: TccHandle): void { bind(g: TccHandle): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g._tccHandle.eventMode = 'static'; g._tccHandle.eventMode = 'static';
g._tccHandle.cursor = 'pointer'; g._tccHandle.cursor = 'Move';
g._tccHandle.on('mousedown', this.onMouseDown); g._tccHandle.onmousedown = (e) => {
g._tccHandle.on('mouseup', this.onMouseUp); this.onMouseDown(e);
};
g._tccHandle.onmouseup = () => {
this.isMouseDown = false;
};
g.onmousemove = (e) => { g.onmousemove = (e) => {
this.onMouseOver(e); this.onMouseMove(e);
};
g.onmouseleave = () => {
this.isMouseDown = false;
}; };
} }
unbind(g: TccHandle): void { unbind(g: TccHandle): void {
g.eventMode = 'none';
g._tccHandle.eventMode = 'none'; g._tccHandle.eventMode = 'none';
g._tccHandle.off('mousedown', this.onMouseDown); g._tccHandle.onmousedown = null;
g._tccHandle.off('mouseup', this.onMouseUp); g._tccHandle.onmouseup = null;
g.onmousemove = null; g.onmousemove = null;
g.onmouseleave = null;
} }
onMouseDown(e: FederatedMouseEvent) { onMouseDown(e: FederatedMouseEvent) {
const tccHandle = e.target as TccHandle; const target = e.target as DisplayObject;
const tccHandle = target.getGraphic<TccHandle>();
if (!tccHandle) return;
this.isMouseDown = true; this.isMouseDown = true;
this.mouseDownBeginPos = e.clientY; this.mouseDownBeginPos = e.clientY;
this.mouseDownTccHandleBeginPos = tccHandle._tccHandle.y; this.mouseDownTccHandleBeginPos = tccHandle._tccHandle.y;
} }
onMouseUp() { onMouseMove(e: FederatedMouseEvent) {
this.isMouseDown = false; const target = e.target as DisplayObject;
} const tccHandle = target.getGraphic<TccHandle>();
onMouseOver(e: FederatedMouseEvent) { if (!tccHandle) return;
const tccHandle = e.target as TccHandle; if (
if (this.isMouseDown) { this.isMouseDown &&
tccHandle._tccHandle.y > -145 &&
tccHandle._tccHandle.y < 145
) {
tccHandle._tccHandle.y = tccHandle._tccHandle.y =
this.mouseDownTccHandleBeginPos + e.clientY - this.mouseDownBeginPos; this.mouseDownTccHandleBeginPos + e.clientY - this.mouseDownBeginPos;
if (tccHandle._tccHandle.y >= 145) {
tccHandle._tccHandle.y = 144;
} else if (tccHandle._tccHandle.y <= -145) {
tccHandle._tccHandle.y = -144;
}
} }
} }
} }

View File

@ -4,7 +4,7 @@ import { tccGraphicData } from 'src/protos/tccGraphics';
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 { GraphicInteractionPlugin, IGraphicScene, JlGraphic } from 'jl-graphic'; import { GraphicInteractionPlugin, IGraphicScene, JlGraphic } from 'jl-graphic';
import { type FederatedMouseEvent } from 'pixi.js'; import { type FederatedMouseEvent, DisplayObject, Point } from 'pixi.js';
import { useTccStore } from 'src/stores/tcc-store'; import { useTccStore } from 'src/stores/tcc-store';
export class TccKeyData extends GraphicDataBase implements ITccKeyData { export class TccKeyData extends GraphicDataBase implements ITccKeyData {
@ -48,26 +48,26 @@ export class TccKeyData extends GraphicDataBase implements ITccKeyData {
} }
export class TccKeyState extends GraphicStateBase implements ITccKeyState { export class TccKeyState extends GraphicStateBase implements ITccKeyState {
constructor(data?: state.KeyState) { constructor(data?: state.TrainControlState.DirectionKeySwitch) {
let tccKeyState; let tccKeyState;
if (data) { if (data) {
tccKeyState = data; tccKeyState = data;
} else { } else {
tccKeyState = new state.KeyState(); tccKeyState = new state.TrainControlState.DirectionKeySwitch();
} }
super(tccKeyState, TccKey.Type); super(tccKeyState, TccKey.Type);
} }
get code(): string { get code(): string {
return this.states.id + ''; return this.states.id + '';
} }
get states(): state.KeyState { get states(): state.TrainControlState.DirectionKeySwitch {
return this.getState<state.KeyState>(); return this.getState<state.TrainControlState.DirectionKeySwitch>();
} }
get gear(): number { get position(): number {
return this.states.gear; return this.states.val;
} }
set gear(v: number) { set position(v: number) {
this.states.gear = v; this.states.val = v;
} }
clone(): TccKeyState { clone(): TccKeyState {
return new TccKeyState(this.states.cloneMessage()); return new TccKeyState(this.states.cloneMessage());
@ -82,6 +82,9 @@ export class TccKeyState extends GraphicStateBase implements ITccKeyState {
export class TccKeyInteraction extends GraphicInteractionPlugin<TccKey> { export class TccKeyInteraction extends GraphicInteractionPlugin<TccKey> {
static Name = 'TccKeyInteraction'; static Name = 'TccKeyInteraction';
isMouseDown = false;
changeOnce = false;
mouseDownBeginPos = new Point();
constructor(app: IGraphicScene) { constructor(app: IGraphicScene) {
super(TccKeyInteraction.Name, app); super(TccKeyInteraction.Name, app);
} }
@ -92,17 +95,115 @@ export class TccKeyInteraction extends GraphicInteractionPlugin<TccKey> {
return grahpics.filter((g): g is TccKey => g instanceof TccKey); return grahpics.filter((g): g is TccKey => g instanceof TccKey);
} }
bind(g: TccKey): void { bind(g: TccKey): void {
g.eventMode = 'static'; g._tccKey.eventMode = 'static';
g.cursor = 'pointer'; g._tccKey.cursor = 'pointer';
g.on('_leftclick', this.onClick); if (
g.datas.type ==
tccGraphicData.TccKey.TccKeyType.driverControllerActivationClint
) {
g._tccKey.on('_leftclick', this.onClick);
} else {
g._tccKey.onmousedown = (e) => {
this.onMouseDown(e);
};
g._tccKey.onmouseup = () => {
this.isMouseDown = false;
this.changeOnce = false;
};
g.onmousemove = (e) => {
this.onMousemove(e);
};
g.onmouseleave = () => {
this.isMouseDown = false;
this.changeOnce = false;
};
}
} }
unbind(g: TccKey): void { unbind(g: TccKey): void {
g.eventMode = 'none'; g._tccKey.eventMode = 'none';
g.off('_leftclick', this.onClick); if (
g.datas.type ==
tccGraphicData.TccKey.TccKeyType.driverControllerActivationClint
) {
g._tccKey.off('_leftclick', this.onClick);
} else {
g._tccKey.onmousedown = null;
g._tccKey.onmouseup = null;
g.onmousemove = null;
g.onmouseleave = null;
}
} }
onClick(e: FederatedMouseEvent): void { onClick(e: FederatedMouseEvent): void {
const g = e.target as TccKey; const target = e.target as DisplayObject;
/* const changeState = useTccStore().tccKeyOperation; const tccKey = target.getGraphic<TccKey>();
changeState(g.datas.id, g.state.gear === 0 ? 1 : 0); */ if (!tccKey) return;
tccKey.state.position = tccKey?.state.position == 0 ? 1 : 0;
tccKey.doRepaint();
}
onMouseDown(e: FederatedMouseEvent) {
const target = e.target as DisplayObject;
const tccKey = target.getGraphic<TccKey>();
if (!tccKey) return;
this.isMouseDown = true;
this.mouseDownBeginPos = tccKey
.getGraphicApp()
.getScene('tcc')
.toCanvasCoordinates(e.global);
}
onMousemove(e: FederatedMouseEvent) {
const target = e.target as DisplayObject;
const tccKey = target.getGraphic<TccKey>();
if (!tccKey) return;
if (this.isMouseDown) {
const mouseEndPos = tccKey
.getGraphicApp()
.getScene('tcc')
.toCanvasCoordinates(e.global);
const { angle, direction } = calculateAngleAndDirection(
this.mouseDownBeginPos,
tccKey.position,
mouseEndPos
);
if (
direction == 'ssz' &&
((angle > 45 && !this.changeOnce) || (angle > 90 && this.changeOnce)) &&
(tccKey._tccKey.rotation == -Math.PI / 4 ||
tccKey._tccKey.rotation == 0)
) {
this.changeOnce = true;
tccKey._tccKey.rotation += Math.PI / 4;
}
if (
direction == 'nsz' &&
((angle > 45 && !this.changeOnce) || (angle > 90 && this.changeOnce)) &&
(tccKey._tccKey.rotation == Math.PI / 4 || tccKey._tccKey.rotation == 0)
) {
this.changeOnce = true;
tccKey._tccKey.rotation -= Math.PI / 4;
}
}
} }
} }
function calculateAngleAndDirection(
pointA: Point,
pointO: Point,
pointB: Point
) {
const vectorAO = { x: pointA.x - pointO.x, y: pointA.y - pointO.y };
const vectorOB = { x: pointB.x - pointO.x, y: pointB.y - pointO.y };
const dotProduct = vectorAO.x * vectorOB.x + vectorAO.y * vectorOB.y;
const magnitudeAO = Math.sqrt(vectorAO.x ** 2 + vectorAO.y ** 2);
const magnitudeOB = Math.sqrt(vectorOB.x ** 2 + vectorOB.y ** 2);
const angle =
Math.acos(dotProduct / (magnitudeAO * magnitudeOB)) * (180 / Math.PI);
const crossProduct = vectorAO.x * vectorOB.y - vectorAO.y * vectorOB.x;
let rotationDirection = '';
if (crossProduct > 0) {
rotationDirection = 'ssz';
} else {
rotationDirection = 'nsz';
}
return { angle: angle, direction: rotationDirection };
}

View File

@ -673,6 +673,9 @@ export class TrainState extends GraphicStateBase implements ITrainState {
set connType(v: state.TrainConnState.TrainConnType) { set connType(v: state.TrainConnState.TrainConnType) {
this.states.connState.connType = v; this.states.connState.connType = v;
} }
get trainControlMapId(): number {
return this.states.connState.TrainControlMapId;
}
clone(): TrainState { clone(): TrainState {
return new TrainState(this.states.cloneMessage()); return new TrainState(this.states.cloneMessage());
} }

View File

@ -60,7 +60,7 @@ function handleSubscribe(pslScene: IGraphicScene) {
const pslStore = usePslStore(); const pslStore = usePslStore();
const simulationId = lineStore.simulationId; const simulationId = lineStore.simulationId;
const mapId = lineStore.mapId; const mapId = lineStore.mapId;
const pslId = pslStore.gatedBoxId; const pslId = pslStore.pslId;
const app = pslScene; const app = pslScene;
app.subscribe({ app.subscribe({
destination: `/rtsts/simulation/${simulationId}/psl/${mapId}/${pslId}`, destination: `/rtsts/simulation/${simulationId}/psl/${mapId}/${pslId}`,

View File

@ -31,11 +31,7 @@ import { TccKey, TccKeyTemplate } from 'src/graphics/tccKey/TccKey';
import { TccKeyData, TccKeyState } from './graphics/TccKeyInteraction'; import { TccKeyData, TccKeyState } from './graphics/TccKeyInteraction';
import { TccHandleDraw } from 'src/graphics/tccHandle/TccHandleDrawAssistant'; import { TccHandleDraw } from 'src/graphics/tccHandle/TccHandleDrawAssistant';
import { TccHandle, TccHandleTemplate } from 'src/graphics/tccHandle/TccHandle'; import { TccHandle, TccHandleTemplate } from 'src/graphics/tccHandle/TccHandle';
import { import { TccHandleData, TccHandleState } from './graphics/TccHandleInteraction';
TccHandleData,
TccHandleInteraction,
TccHandleState,
} from './graphics/TccHandleInteraction';
const UndoOptions: MenuItemOptions = { const UndoOptions: MenuItemOptions = {
name: '撤销', name: '撤销',
@ -91,7 +87,6 @@ export function initTccDrawApp(): IDrawApp {
drawApp, drawApp,
new TccHandleTemplate(new TccHandleData(), new TccHandleState()) new TccHandleTemplate(new TccHandleData(), new TccHandleState())
); );
TccHandleInteraction.init(app);
// 画布右键菜单 // 画布右键菜单
app.registerMenu(DefaultCanvasMenu); app.registerMenu(DefaultCanvasMenu);

View File

@ -5,7 +5,7 @@ import {
IGraphicScene, IGraphicScene,
IGraphicStorage, IGraphicStorage,
} from 'jl-graphic'; } from 'jl-graphic';
import { getPublishMapInfoByName } from 'src/api/PublishApi'; import { getPublishMapInfoById } from 'src/api/PublishApi';
import { useTccStore } from 'src/stores/tcc-store'; import { useTccStore } from 'src/stores/tcc-store';
import { toUint8Array } from 'js-base64'; import { toUint8Array } from 'js-base64';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
@ -37,7 +37,6 @@ export function initTccScene(lineApp: IGraphicApp, sceneName: string) {
dataLoader: loadTccDatas, dataLoader: loadTccDatas,
mouseToolOptions: { mouseToolOptions: {
boxSelect: false, boxSelect: false,
viewportDrag: false,
wheelZoom: false, wheelZoom: false,
}, },
}); });
@ -54,13 +53,6 @@ export function initTccScene(lineApp: IGraphicApp, sceneName: string) {
tccScene.on('postdataloaded', () => { tccScene.on('postdataloaded', () => {
handleSubscribe(tccScene); handleSubscribe(tccScene);
}); });
tccScene.setOptions({
mouseToolOptions: {
boxSelect: false,
viewportDrag: false,
wheelZoom: false,
},
});
return tccScene; return tccScene;
} }
@ -68,34 +60,42 @@ function handleSubscribe(tccScene: IGraphicScene) {
const lineStore = useLineStore(); const lineStore = useLineStore();
const tccStore = useTccStore(); const tccStore = useTccStore();
const simulationId = lineStore.simulationId; const simulationId = lineStore.simulationId;
const mapId = lineStore.mapId;
const tccId = tccStore.tccId; const tccId = tccStore.tccId;
const app = tccScene; const app = tccScene;
app.subscribe({ app.subscribe({
destination: `/rtsts/simulation/${simulationId}/tcc/${mapId}/${tccId}`, destination: `/rtsts/simulation/${simulationId}/train/control/${tccId}`,
messageConverter: (message: Uint8Array) => { messageConverter: (message: Uint8Array) => {
// console.log('收到消息', message);
const states: GraphicState[] = []; const states: GraphicState[] = [];
const storage = state.PushedDevicesStatus.deserialize(message); const storage = state.TrainControlState.deserialize(message);
if (storage.all) { if (storage.ebutton) {
// storage.allStatus.buttonState.forEach((item) => { states.push(new TccButtonState(storage.ebutton));
// if (item.id) { }
// states.push(new TccButtonState(item)); if (storage.dirKey) {
// } states.push(new TccKeyState(storage.dirKey));
// }); }
storage?.driverKey.forEach((driverKey) => {
const data = new state.TrainControlState.DirectionKeySwitch({
id: driverKey.id,
val: driverKey.val ? 1 : 0,
});
states.push(new TccKeyState(data));
});
if (storage.pushHandler) {
states.push(new TccHandleState(storage.pushHandler));
} }
// console.log(states, 'states');
return states; return states;
}, },
graphicQueryer: (state, store) => {
return store.queryById(+state.code);
},
}); });
} }
async function loadTccDatas(): Promise<IGraphicStorage> { async function loadTccDatas(): Promise<IGraphicStorage> {
const tccStore = useTccStore(); const tccStore = useTccStore();
const { proto: base64 } = await getPublishMapInfoByName({ const { proto: base64 } = await getPublishMapInfoById(
name: tccStore.tccMapCode, tccStore.trainControlMapId
detail: true, );
});
if (base64) { if (base64) {
const storage = tccGraphicData.TccGraphicStorage.deserialize( const storage = tccGraphicData.TccGraphicStorage.deserialize(
toUint8Array(base64) toUint8Array(base64)

View File

@ -24,8 +24,8 @@ export interface ITccKeyData extends GraphicData {
} }
export interface ITccKeyState extends GraphicState { export interface ITccKeyState extends GraphicState {
get gear(): number; get position(): number;
set gear(v: number); set position(v: number);
} }
export class TccKey extends JlGraphic { export class TccKey extends JlGraphic {
@ -58,13 +58,13 @@ export class TccKey extends JlGraphic {
return this.getStates<ITccKeyState>(); return this.getStates<ITccKeyState>();
} }
doRepaint(): void { doRepaint(): void {
//this._tccKey.rotation = (-Math.PI / 2) * this.state.gear;
if ( if (
this.datas.type == this.datas.type ==
tccGraphicData.TccKey.TccKeyType.driverControllerActivationClint tccGraphicData.TccKey.TccKeyType.driverControllerActivationClint
) { ) {
this._tccKey.texture = this.tccKeyTextures.tccKey; this._tccKey.texture = this.tccKeyTextures.tccKey;
this._tccKey.rotation = Math.PI / 4; this._tccKey.rotation =
this.state.position == 0 ? Math.PI / 4 : -Math.PI / 4;
} else { } else {
this._tccKey.texture = this.tccKeyTextures.tccKnob; this._tccKey.texture = this.tccKeyTextures.tccKnob;
this._tccKey.scale.set(0.6); this._tccKey.scale.set(0.6);

View File

@ -240,6 +240,7 @@ export interface ITrainState extends GraphicState {
set conn(v: boolean); set conn(v: boolean);
get connType(): state.TrainConnState.TrainConnType; get connType(): state.TrainConnState.TrainConnType;
set connType(v: state.TrainConnState.TrainConnType); set connType(v: state.TrainConnState.TrainConnType);
get trainControlMapId(): number;
} }
interface bodyWH { interface bodyWH {
width: number; // 宽 width: number; // 宽

View File

@ -64,7 +64,7 @@
style="width: 500px; height: 600px" style="width: 500px; height: 600px"
></div> ></div>
</draggable-dialog> </draggable-dialog>
<DraggableDialog <draggable-dialog
:title="`${ibpStore.stationCode}IBP`" :title="`${ibpStore.stationCode}IBP`"
v-model="ibpStore.isIbpDialogOpen" v-model="ibpStore.isIbpDialogOpen"
:width="1250" :width="1250"
@ -76,7 +76,15 @@
class="overflow-hidden" class="overflow-hidden"
style="width: 1250px; height: 615px" style="width: 1250px; height: 615px"
/> />
</DraggableDialog> </draggable-dialog>
<draggable-dialog
v-model="tccStore.isTccDialogOpen"
:width="tccCanvasWidth"
:height="tccCanvasHeight"
@hide="tccHide"
>
<div id="tcc-app-container" class="overflow-hidden"></div>
</draggable-dialog>
</q-layout> </q-layout>
</template> </template>
@ -113,6 +121,7 @@ import { state } from 'src/protos/device_state';
import { PictureType } from 'src/protos/picture'; import { PictureType } from 'src/protos/picture';
import ConnectInfoDialog from 'src/components/line-app/dialogs/ConnectInfoDialog.vue'; import ConnectInfoDialog from 'src/components/line-app/dialogs/ConnectInfoDialog.vue';
import { updataOnChangeScene } from 'src/drawApp/relayScene'; import { updataOnChangeScene } from 'src/drawApp/relayScene';
import { useTccStore } from 'src/stores/tcc-store';
const $q = useQuasar(); const $q = useQuasar();
const canvasWidth = ref(0); const canvasWidth = ref(0);
@ -225,6 +234,7 @@ onMounted(async () => {
// drawerRight.value = false; // drawerRight.value = false;
}); });
//psl
const pslCanvasWidth = ref(500); const pslCanvasWidth = ref(500);
const pslCanvasHeight = ref(600); const pslCanvasHeight = ref(600);
watch( watch(
@ -252,6 +262,34 @@ function pslHide() {
pslStore.clearPslParam(); pslStore.clearPslParam();
lineApp.getScene('psl').unbindDom(); lineApp.getScene('psl').unbindDom();
} }
//Tcc
const tccStore = useTccStore();
const tccCanvasWidth = ref(1000);
const tccCanvasHeight = ref(600);
watch(
() => tccStore.isTccDialogOpen,
(val: boolean) => {
if (val === true) {
nextTick(async () => {
const container = document.getElementById('tcc-app-container');
if (!container) return;
const tccScene = tccStore.getTccScene();
tccScene?.bindDom(container);
await tccScene?.reload();
if (tccScene) {
container.style.width = tccCanvasWidth.value + 'px';
container.style.height = tccCanvasHeight.value + 'px';
}
});
}
}
);
function tccHide() {
tccStore.clearTccParam();
lineApp.getScene('tcc').unbindDom();
}
watch( watch(
() => lineStore.showTrainSearch, () => lineStore.showTrainSearch,
(val) => { (val) => {

View File

@ -423,6 +423,7 @@ const pictureTypeList: { label: string; value: PictureType }[] = [
{ label: '继电器柜布置图', value: PictureType.RelayCabinetLayout }, { label: '继电器柜布置图', value: PictureType.RelayCabinetLayout },
{ label: 'IBP盘', value: PictureType.IBP }, { label: 'IBP盘', value: PictureType.IBP },
{ label: '列车数据', value: PictureType.TrainData }, { label: '列车数据', value: PictureType.TrainData },
{ label: '列车驾驶台', value: PictureType.TrainControlCab },
]; ];
function getTypeName(val?: number) { function getTypeName(val?: number) {

View File

@ -156,6 +156,16 @@
hint="" hint=""
></q-input> ></q-input>
</div> </div>
<div class="col-4 q-px-sm">
<q-select
outlined
v-model="editInfo.trainControlMapId"
emitValue
mapOptions
:options="tccNameList"
label="关联驾驶台地图"
/>
</div>
<div class="col-12 q-px-sm" style="padding-bottom: 10px"> <div class="col-12 q-px-sm" style="padding-bottom: 10px">
<q-input <q-input
outlined outlined
@ -368,6 +378,8 @@ import {
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { graphicData } from 'src/protos/stationLayoutGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics';
import { computed, onMounted, reactive, ref } from 'vue'; import { computed, onMounted, reactive, ref } from 'vue';
import { getPublishList } from 'src/api/PublishApi';
import { PictureType } from 'src/protos/picture';
const $q = useQuasar(); const $q = useQuasar();
@ -381,10 +393,24 @@ const props = withDefaults(
const tableHeight = computed(() => { const tableHeight = computed(() => {
return props.sizeHeight - 32; return props.sizeHeight - 32;
}); });
const tccNameList = ref<{ label: string; value: number }[]>([]);
onMounted(() => { onMounted(() => {
getModelOption(); getModelOption();
tableRef.value.requestServerInteraction(); tableRef.value.requestServerInteraction();
getPublishList({
type: PictureType.TrainControlCab,
category: null,
}).then((tccMapList) => {
if (tccMapList && tccMapList.length) {
tccMapList.forEach((item) => {
tccNameList.value.push({
label: item.name,
value: item.id,
});
});
}
});
}); });
const columnDefs: QTableColumn[] = [ const columnDefs: QTableColumn[] = [
@ -502,6 +528,7 @@ function onCreate() {
// max_diameter: editInfo.max_diameter, // max_diameter: editInfo.max_diameter,
train_sets: editInfo.train_sets, train_sets: editInfo.train_sets,
trainConfigData: editInfo.trainConfigData, trainConfigData: editInfo.trainConfigData,
trainControlMapId: editInfo.trainControlMapId,
}; };
if (editInfo.id) { if (editInfo.id) {
await saveTrainData(+editInfo.id, params); await saveTrainData(+editInfo.id, params);
@ -534,6 +561,7 @@ function onReset() {
// editInfo.min_diameter = 0; // editInfo.min_diameter = 0;
// editInfo.max_diameter = 0; // editInfo.max_diameter = 0;
editInfo.train_sets = ''; editInfo.train_sets = '';
editInfo.trainControlMapId = 0;
editInfo.trainConfigData.davisParamA = 2.25; editInfo.trainConfigData.davisParamA = 2.25;
editInfo.trainConfigData.davisParamB = 0.019; editInfo.trainConfigData.davisParamB = 0.019;
editInfo.trainConfigData.davisParamC = 0.00032; editInfo.trainConfigData.davisParamC = 0.00032;
@ -588,6 +616,7 @@ interface EditCreateItem extends TrainCreateParams {
total_length: number; total_length: number;
train_model: number; train_model: number;
train_sets: string; train_sets: string;
trainControlMapId: number;
trainConfigData: { trainConfigData: {
davisParamA: number; davisParamA: number;
davisParamB: number; davisParamB: number;
@ -619,6 +648,7 @@ const editInfo = reactive<EditCreateItem>({
min_diameter: 0, min_diameter: 0,
max_diameter: 0, max_diameter: 0,
train_sets: '', train_sets: '',
trainControlMapId: 0,
trainConfigData: { trainConfigData: {
davisParamA: 2.25, davisParamA: 2.25,
davisParamB: 0.019, davisParamB: 0.019,
@ -651,6 +681,7 @@ function editData(row: TrainItem) {
// editInfo.min_diameter = res.min_diameter; // editInfo.min_diameter = res.min_diameter;
// editInfo.max_diameter = res.max_diameter; // editInfo.max_diameter = res.max_diameter;
editInfo.train_sets = res.train_sets; editInfo.train_sets = res.train_sets;
editInfo.trainControlMapId = res.trainControlMapId;
if (res.trainConfigData) { if (res.trainConfigData) {
editInfo.trainConfigData.davisParamA = res.trainConfigData.davisParamA; editInfo.trainConfigData.davisParamA = res.trainConfigData.davisParamA;
editInfo.trainConfigData.davisParamB = res.trainConfigData.davisParamB; editInfo.trainConfigData.davisParamB = res.trainConfigData.davisParamB;

View File

@ -4,7 +4,7 @@ import { getLineApp } from 'src/drawApp/lineApp';
export const useTccStore = defineStore('tcc', { export const useTccStore = defineStore('tcc', {
state: () => ({ state: () => ({
tccMapCode: '', trainControlMapId: 0,
tccId: 0, tccId: 0,
isTccDialogOpen: false, isTccDialogOpen: false,
}), }),
@ -19,14 +19,14 @@ export const useTccStore = defineStore('tcc', {
return tccScene; return tccScene;
} }
}, },
setTccParam(tccId: number, tccMapCode: string) { setTccParam(tccId: number, trainControlMapId: number) {
this.tccId = tccId; this.tccId = tccId;
this.tccMapCode = tccMapCode; this.trainControlMapId = trainControlMapId;
this.isTccDialogOpen = true; this.isTccDialogOpen = true;
}, },
clearTccParam() { clearTccParam() {
this.tccId = 0; this.tccId = 0;
this.tccMapCode = ''; this.trainControlMapId = 0;
this.isTccDialogOpen = false; this.isTccDialogOpen = false;
}, },
}, },