diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index 2a5b353..d9b95af 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -253,13 +253,17 @@ export default class LineConnection { this.config.output = this.config.output.slice(-15000) if (!this.isReady && canInputCommand(message)) { this.isReady = true + this.socketIO.emit('update_status_ready', { + stationId, + lineId: id, + isReady: true, + }) } this.socketIO.emit('line_output', { stationId, lineId: id, data: message, ports: this.config.ports, - isReady: this.isReady ? true : canInputCommand(message), }) setTimeout(() => { if (!this.config.inventory) { diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index 08decde..d2ff63a 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -605,7 +605,7 @@ export class WebSocketIo { socket.on('run_all_dpelp', async (data) => { try { - const lineIds = data.lineIds + const dataLines = data.lineIds || [] const stationName = data.stationName || '' const stationId = data.stationId || '' const scenarioName = data.scenarioName || '' @@ -613,9 +613,17 @@ export class WebSocketIo { // Check station is active const activeStation = await checkStationActive(stationId) if (!activeStation) return + // Filter line is not ready + let lineIds: number[] = [] + for (const lineId of dataLines) { + const line = this.lineMap.get(lineId) + if (line && line.isReady) { + lineIds.push(lineId) + } + } // Check station sendWiki flag console.log('[DPELP] Received run all dpelp', lineIds) - if (!station || !station?.send_wiki) return + if (!station || !station?.send_wiki || lineIds?.length < 1) return const results = await this.waitUntilAllReady(lineIds) const tableHTML = this.generateTable(results) diff --git a/FRONTEND/src/App.tsx b/FRONTEND/src/App.tsx index 6848cde..57ce4f3 100644 --- a/FRONTEND/src/App.tsx +++ b/FRONTEND/src/App.tsx @@ -257,6 +257,7 @@ function App() { output: "[CLEAR_TERMINAL_SCROLL_BACK]", listFeatureTested: [], latestScenario: undefined, + isReady: false, }, data?.stationId ) @@ -264,11 +265,11 @@ function App() { socket?.on("line_output", (data) => { const { lineId, data: text } = data; - updateValueLineStation( - data?.lineId, - { isReady: data.isReady }, - data?.stationId - ); + // updateValueLineStation( + // data?.lineId, + // { isReady: data.isReady }, + // data?.stationId + // ); const buf = lineBuffersRef.current.get(lineId) || ""; lineBuffersRef.current.set(lineId, buf + text); @@ -279,6 +280,15 @@ function App() { } }); + socket?.on("update_status_ready", (data) => { + const { isReady } = data; + updateValueLineStation( + data?.lineId, + { isReady: isReady }, + data?.stationId + ); + }); + socket?.on("line_error", (data) => { updateValueLineStation( data?.lineId,