仿真订阅和操作添加mapId
This commit is contained in:
parent
da66269b90
commit
41ec1a763f
@ -23,6 +23,7 @@ export async function destroySimulation(data: { simulationId: string }) {
|
||||
/**
|
||||
* 添加列车
|
||||
* @param simulationId 仿真id
|
||||
* @param mapId 发布图id
|
||||
* @param up 是否上行
|
||||
* @param id 区段或者道岔的索引
|
||||
* @param devicePort 道岔的端口
|
||||
@ -31,6 +32,7 @@ export async function destroySimulation(data: { simulationId: string }) {
|
||||
*/
|
||||
export async function addTrain(data: {
|
||||
simulationId: string;
|
||||
mapId: number;
|
||||
up: boolean;
|
||||
id: string;
|
||||
devicePort?: string;
|
||||
@ -47,6 +49,7 @@ export async function addTrain(data: {
|
||||
*/
|
||||
export async function removeTrain(data: {
|
||||
simulationId: string;
|
||||
mapId: number;
|
||||
trainId: string;
|
||||
}) {
|
||||
const response = await api.post(`${UriBase}/train/remove`, data);
|
||||
@ -55,6 +58,7 @@ export async function removeTrain(data: {
|
||||
|
||||
export async function setSwitchPosition(data: {
|
||||
simulationId: string;
|
||||
mapId: number;
|
||||
switchIndex: string;
|
||||
turnNormal: boolean;
|
||||
turnReverse: boolean;
|
||||
|
@ -83,6 +83,7 @@ function submitState() {
|
||||
if (lineStore.simulationId) {
|
||||
setSwitchPosition({
|
||||
simulationId: lineStore.simulationId,
|
||||
mapId: lineStore.mapId as number,
|
||||
switchIndex: turnoutState.value.index + '',
|
||||
turnNormal: turnoutState.value.normal,
|
||||
turnReverse: turnoutState.value.reverse,
|
||||
|
@ -170,6 +170,7 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin<Section>
|
||||
if (!section) return;
|
||||
this.app.updateSelected(section);
|
||||
const simulationId = useLineStore().simulationId || '';
|
||||
const mapId = useLineStore().mapId as number;
|
||||
addTrainConfig.handler = () => {
|
||||
const relations =
|
||||
section.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
@ -201,6 +202,7 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin<Section>
|
||||
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => {
|
||||
const params = {
|
||||
simulationId,
|
||||
mapId,
|
||||
up: !!data.dir,
|
||||
id: section.datas.index + '',
|
||||
headOffset: data.offset,
|
||||
|
@ -174,9 +174,11 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
|
||||
this.app.updateSelected(train);
|
||||
const lineStore = useLineStore();
|
||||
const simulationId = lineStore.simulationId || '';
|
||||
const mapId = lineStore.mapId as number;
|
||||
removeTrainConfig.handler = () => {
|
||||
removeTrain({
|
||||
simulationId,
|
||||
mapId,
|
||||
trainId: train.code,
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -92,9 +92,11 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
|
||||
if (!turnout) return;
|
||||
this.app.updateSelected(turnout);
|
||||
const simulationId = useLineStore().simulationId || '';
|
||||
const mapId = useLineStore().mapId as number;
|
||||
const setPosition = async (normal: boolean) => {
|
||||
setSwitchPosition({
|
||||
simulationId,
|
||||
mapId,
|
||||
switchIndex: turnout.datas.index + '',
|
||||
turnNormal: normal,
|
||||
turnReverse: !normal,
|
||||
@ -150,6 +152,7 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
|
||||
}).onOk((data: { offset: number; dir: 1 | 0 }) => {
|
||||
addTrain({
|
||||
simulationId,
|
||||
mapId,
|
||||
up: !!data.dir,
|
||||
id: turnout.datas.index + '',
|
||||
devicePort: port,
|
||||
|
@ -229,6 +229,7 @@ export function initLineScene(lineApp: IGraphicApp) {
|
||||
function handleSubscribe(lineScene: IGraphicScene, lineApp: IGraphicApp) {
|
||||
const lineStore = useLineStore();
|
||||
const simulationId = lineStore.simulationId;
|
||||
const mapId = lineStore.mapId;
|
||||
const app = lineScene;
|
||||
|
||||
lineApp?.enableWsMassaging({
|
||||
@ -238,7 +239,7 @@ function handleSubscribe(lineScene: IGraphicScene, lineApp: IGraphicApp) {
|
||||
});
|
||||
app.subscribe({
|
||||
// destination: `/simulation/${simulationId}/devices/status`,
|
||||
destination: `simulation-${simulationId}-devices-status`,
|
||||
destination: `simulation-${simulationId}_${mapId}-devices-status`,
|
||||
messageConverter: (message: Uint8Array) => {
|
||||
// console.log('收到消息', message);
|
||||
const states: GraphicState[] = [];
|
||||
|
Loading…
Reference in New Issue
Block a user